2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #define __OOP_NOATTRBASES__
8 #include <hidd/graphics.h>
9 #include <proto/graphics.h>
10 #include <proto/oop.h>
16 static OOP_AttrBase HiddBitMapAttrBase
;
19 #define SRC_PIXFMT vHidd_StdPixFmt_ARGB32
20 #define DST_PIXFMT vHidd_StdPixFmt_RGB15
22 #define SRC_PIXFMT vHidd_StdPixFmt_BGRA32
23 #define DST_PIXFMT vHidd_StdPixFmt_RGB15_LE
26 static ULONG argb
[8] =
37 static UWORD rgb15
[8];
38 static ULONG argb_inv
[8];
40 static void ConvertPixels(APTR srcPixels
, ULONG srcMod
, HIDDT_StdPixFmt srcPixFmt
,
41 APTR dstPixels
, ULONG dstMod
, HIDDT_StdPixFmt dstPixFmt
,
42 ULONG width
, ULONG height
, OOP_Object
*bm
)
44 OOP_Object
*gfxhidd
= NULL
;
45 OOP_Object
*srcpf
, *dstpf
;
49 OOP_GetAttr(bm
, aHidd_BitMap_GfxHidd
, (IPTR
*)&gfxhidd
);
52 printf("ConvertPixels(): Failed to obtain graphics driver\n");
56 srcpf
= HIDD_Gfx_GetPixFmt(gfxhidd
, srcPixFmt
);
57 dstpf
= HIDD_Gfx_GetPixFmt(gfxhidd
, dstPixFmt
);
61 printf("ConvertPixels(): Bad source (%ld) or dest (%ld) pixfmt!\n", srcPixFmt
, dstPixFmt
);
65 HIDD_BM_ConvertPixels(bm
, &src
, (HIDDT_PixelFormat
*)srcpf
, srcMod
,
66 &dst
, (HIDDT_PixelFormat
*)dstpf
, dstMod
,
72 struct BitMap
*bitmap
;
74 HiddBitMapAttrBase
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
75 if (!HiddBitMapAttrBase
) {
76 printf("Failed to obtain IID_Hidd_BitMap\n");
80 bitmap
= AllocBitMap(1, 1, 16, 0, NULL
);
82 printf("Failed to allocate a placeholder bitmap!\n");
83 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
87 ConvertPixels(argb
, 0, SRC_PIXFMT
, rgb15
, 0, DST_PIXFMT
, 8, 1, HIDD_BM_OBJ(bitmap
));
88 ConvertPixels(rgb15
, 0, DST_PIXFMT
, argb_inv
, 0, SRC_PIXFMT
, 8, 1, HIDD_BM_OBJ(bitmap
));
93 for(i
= 0; i
< 8; i
++)
95 printf("ARGB32 %08x = RGB15 %04x (%02x %02x %02x) (%3d%% %3d%% %3d%%) [%08x]\n",
96 (unsigned int)argb
[i
], rgb15
[i
],
97 (rgb15
[i
] & 0x7C00) >> 10,
98 (rgb15
[i
] & 0x03E0) >> 5,
100 ((rgb15
[i
] & 0x7C00) >> 10) * 100 / 31,
101 ((rgb15
[i
] & 0x03E0) >> 5) * 100 / 31,
102 (rgb15
[i
] & 0x001F) * 100 / 31,
103 (unsigned int)argb_inv
[i
]
108 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);