1 #define __OOP_NOATTRBASES__
3 #include <hidd/graphics.h>
4 #include <proto/graphics.h>
11 static OOP_AttrBase HiddBitMapAttrBase
;
14 #define SRC_PIXFMT vHidd_StdPixFmt_ARGB32
15 #define DST_PIXFMT vHidd_StdPixFmt_RGB15
17 #define SRC_PIXFMT vHidd_StdPixFmt_BGRA32
18 #define DST_PIXFMT vHidd_StdPixFmt_RGB15_LE
21 static ULONG argb
[8] =
32 static UWORD rgb15
[8];
33 static ULONG argb_inv
[8];
35 static void ConvertPixels(APTR srcPixels
, ULONG srcMod
, HIDDT_StdPixFmt srcPixFmt
,
36 APTR dstPixels
, ULONG dstMod
, HIDDT_StdPixFmt dstPixFmt
,
37 ULONG width
, ULONG height
, OOP_Object
*bm
)
39 OOP_Object
*gfxhidd
= NULL
;
40 OOP_Object
*srcpf
, *dstpf
;
44 OOP_GetAttr(bm
, aHidd_BitMap_GfxHidd
, (IPTR
*)&gfxhidd
);
47 printf("ConvertPixels(): Failed to obtain graphics driver\n");
51 srcpf
= HIDD_Gfx_GetPixFmt(gfxhidd
, srcPixFmt
);
52 dstpf
= HIDD_Gfx_GetPixFmt(gfxhidd
, dstPixFmt
);
56 printf("ConvertPixels(): Bad source (%ld) or dest (%ld) pixfmt!\n", srcPixFmt
, dstPixFmt
);
60 HIDD_BM_ConvertPixels(bm
, &src
, (HIDDT_PixelFormat
*)srcpf
, srcMod
,
61 &dst
, (HIDDT_PixelFormat
*)dstpf
, dstMod
,
67 struct BitMap
*bitmap
;
69 HiddBitMapAttrBase
= OOP_ObtainAttrBase(IID_Hidd_BitMap
);
70 if (!HiddBitMapAttrBase
) {
71 printf("Failed to obtain IID_Hidd_BitMap\n");
75 bitmap
= AllocBitMap(1, 1, 16, 0, NULL
);
77 printf("Failed to allocate a placeholder bitmap!\n");
78 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
82 ConvertPixels(argb
, 0, SRC_PIXFMT
, rgb15
, 0, DST_PIXFMT
, 8, 1, HIDD_BM_OBJ(bitmap
));
83 ConvertPixels(rgb15
, 0, DST_PIXFMT
, argb_inv
, 0, SRC_PIXFMT
, 8, 1, HIDD_BM_OBJ(bitmap
));
88 for(i
= 0; i
< 8; i
++)
90 printf("ARGB32 %08x = RGB15 %04x (%02x %02x %02x) (%3d%% %3d%% %3d%%) [%08x]\n",
91 (unsigned int)argb
[i
], rgb15
[i
],
92 (rgb15
[i
] & 0x7C00) >> 10,
93 (rgb15
[i
] & 0x03E0) >> 5,
95 ((rgb15
[i
] & 0x7C00) >> 10) * 100 / 31,
96 ((rgb15
[i
] & 0x03E0) >> 5) * 100 / 31,
97 (rgb15
[i
] & 0x001F) * 100 / 31,
98 (unsigned int)argb_inv
[i
]
103 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);