2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <cybergraphx/cybergraphics.h>
12 #include <proto/oop.h>
13 #include <proto/utility.h>
15 #include "cybergraphics_intern.h"
16 #include "gfxfuncsupport.h"
18 /*****************************************************************************
21 #include <proto/cybergraphics.h>
23 AROS_LH2(APTR
, LockBitMapTagList
,
26 AROS_LHA(APTR
, bitmap
, A0
),
27 AROS_LHA(struct TagItem
*, tags
, A1
),
30 struct Library
*, CyberGfxBase
, 28, Cybergraphics
)
33 Obtains exclusive access to a bitmap in preparation for direct access
34 to its pixel data. Direct access to a bitmap should only be done in
35 exceptional cases, and the locking period should be limited to at most
38 A taglist is passed in that contains pointers to variables in which to
39 store the information necessary to directly access the bitmap. The
40 tags used are as follows:
41 LBMI_WIDTH (ULONG *) - the bitmap's width.
42 LBMI_HEIGHT (ULONG *) - the bitmap's height.
43 LBMI_DEPTH (ULONG *) - the bitmap's depth.
44 LBMI_PIXFMT (ULONG *) - the bitmap's pixel format.
45 LBMI_BYTESPERPIX (ULONG *) - the number of bytes per pixel.
46 LBMI_BYTESPERROW (ULONG *) - the number of bytes per row.
47 LBMI_BASEADDRESS (APTR *) - the start address of the pixel data.
49 The value returned for LBMI_PIXFMT will be one of the following
51 PIXFMT_RGB24 - 3 bytes per pixel: 1 byte per component, in
52 the order red, green, blue.
53 PIXFMT_RGBA32 - 4 bytes per pixel: 1 byte per component, in
54 the order red, green, blue, alpha.
55 PIXFMT_ARGB32 - 4 bytes per pixel: 1 byte per component, in
56 the order alpha, red, green, blue.
57 PIXFMT_LUT8 - 1 byte per pixel: each byte is a pen number
58 rather than a direct colour value.
59 PIXFMT_RGB15 - 2 bytes per pixel: one unused bit, then 5 bits
60 per component, in the order red, green, blue.
61 PIXFMT_BGR15 - 2 bytes per pixel: 1 unused bit, then 5 bits
62 per component, in the order blue, green, red.
63 PIXFMT_RGB15PC - 2 bytes per pixel, accessed as a little
64 endian value: 1 unused bit, then 5 bits per component, in
65 the order red, green, blue.
66 PIXFMT_BGR15PC - 2 bytes per pixel, accessed as a little
67 endian value: 1 unused bit, then 5 bits per component, in
68 the order blue, green, red.
69 PIXFMT_RGB16 - 2 bytes per pixel: 5 bits for red, then 6 bits
70 for green, then 5 bits for blue.
71 PIXFMT_BGR16 - 2 bytes per pixel: 5 bits for blue, then 6 bits
72 for green, then 5 bits for red.
73 PIXFMT_RGB16PC - 2 bytes per pixel, accessed as a little
74 endian value: 5 bits for red, then 6 bits for green, then
76 PIXFMT_BGR16PC - 2 bytes per pixel, accessed as a little
77 endian value: 5 bits for blue, then 6 bits for green, then
79 PIXFMT_BGR24 - 3 bytes per pixel: 1 byte per component, in
80 the order blue, green, red.
81 PIXFMT_BGRA32 - 4 bytes per pixel: 1 byte per component, in
82 the order blue, green, red, alpha.
83 PIXFMT_ABGR32 - 4 bytes per pixel: 1 byte per component, in
84 the order alpha, blue, green, red (AROS extension).
85 PIXFMT_0RGB32 - 4 bytes per pixel: 1 unused byte, then 1 byte
86 per component, in the order red, green, blue (AROS
88 PIXFMT_BGR032 - 4 bytes per pixel: 1 byte per component, in
89 the order blue, green, red, followed by 1 unused byte
91 PIXFMT_RGB032 - 4 bytes per pixel: 1 byte per component, in
92 the order red, green, blue, followed by 1 unused byte
94 PIXFMT_0BGR32 - 4 bytes per pixel: 1 unused byte, then 1 byte
95 per component, in the order blue, green, red (AROS
99 bitmap - the bitmap to lock.
100 tags - a taglist that will be filled with information necessary to
101 directly access the bitmap.
104 handle - a handle to be passed to UnLockBitMap() or
105 UnLockBitMapTagList(), or NULL for failure.
108 While the bitmap is locked, no cybergraphics.library or
109 graphics.library related functions should be called (except to unlock
117 UnLockBitMap(), UnLockBitMapTagList()
121 *****************************************************************************/
125 struct BitMap
*bm
= bitmap
;
128 ULONG width
, height
, banksize
, memsize
;
134 D(bug("!!! TRYING TO CALL LockBitMapTagList() ON NON-HIDD BM !!!\n"));
138 OOP_GetAttr(HIDD_BM_OBJ(bm
), aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
139 OOP_GetAttr(pf
, aHidd_PixFmt_CgxPixFmt
, &cpf
);
142 D(bug("!!! TRYING TO CALL LockBitMapTagList() ON NON-CYBER PIXFMT BITMAP !!!\n"));
146 /* Get some info from the bitmap object */
147 if (!HIDD_BM_ObtainDirectAccess(HIDD_BM_OBJ(bm
), &baseaddress
, &width
, &height
, &banksize
, &memsize
)) {
148 D(bug("!!! CAN'T HIDD_BM_ObtainDirectAccess() on the object\n"));
152 while ((tag
= NextTagItem(&tags
)))
156 case LBMI_BASEADDRESS
:
157 *((IPTR
**)tag
->ti_Data
) = (IPTR
*)baseaddress
;
160 case LBMI_BYTESPERROW
:
161 OOP_GetAttr(HIDD_BM_OBJ(bm
), aHidd_BitMap_BytesPerRow
, (IPTR
*)tag
->ti_Data
);
164 case LBMI_BYTESPERPIX
:
165 OOP_GetAttr(pf
, aHidd_PixFmt_BytesPerPixel
, (IPTR
*)tag
->ti_Data
);
169 *((IPTR
*)tag
->ti_Data
) = (IPTR
)cpf
;
173 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, (IPTR
*)tag
->ti_Data
);
177 OOP_GetAttr(HIDD_BM_OBJ(bm
), aHidd_BitMap_Width
, (IPTR
*)tag
->ti_Data
);
181 OOP_GetAttr(HIDD_BM_OBJ(bm
), aHidd_BitMap_Height
, (IPTR
*)tag
->ti_Data
);
185 D(bug("!!! UNKNOWN TAG PASSED TO LockBitMapTagList() !!!\n"));
193 } /* LockBitMapTagList */