APTR handle = hw_LockBitMap(APTR bmap, ULONG flags, struct hwos_LockBitMapStruct *bmlock, struct hwTagList *tags);
struct hwos_LockBitMapStruct
which will be filled with all the information you need by hw_LockBitMap()
.
struct hwos_LockBitMapStruct
looks like this:
struct hwos_LockBitMapStruct { APTR Data; // [out] int Modulo; // [out] int PixelFormat; // [out] int BytesPerPixel; // [out] int Width; // [out] int Height; // [out] }; |
hw_LockBitMap()
will write the following values to the structure members:
Data:
PixelFormat
member. Please note that
even if a 32-bit pixel format is used, Data
will never contain any alpha channel
information because Hollywood always stores the alpha channel separately in order to
be compatible with 15-bit and 16-bit screenmodes. See Bitmap information for details.
Modulo:
Width
because Hollywood
might choose to allocate some padding bytes for optimized blitting. Please note
that the value in Modulo
is returned in pixels for RGB bitmaps and in bytes
for mask, CLUT and alpha channel bitmaps.
PixelFormat:
Data
member. See Pixel format information for details.
BytesPerPixel:
Data
array. If the bitmap is a monochrome mask, this member will be set
to 1 although in reality only 1 bit is needed for a single pixel in case of a
monochrome mask. For CLUT bitmaps this will always be 1, even if the bit depth
is less than 8 bits.
Width:
Height:
The following tags can be passed in tag list parameter:
HWLBMAPTAG_READONLY:
iData
member of this tag item to True
, the bitmap will be locked
for read-only access. This might be faster with some bitmap backends. By
default, the bitmap is locked for read and write access.
Do not hold bitmap locks longer than necessary. In particular, do not return control to the script while holding a bitmap lock because the script might try to modify the bitmap then and this will lead to trouble in case the bitmap is still locked. You should call hw_UnLockBitMap() as soon as possible.
Note that hw_LockBitMap()
can only be used with software bitmaps. It is not possible
to access the raw pixels of hardware bitmaps.
If you only need to read a bitmap's raw pixel data, it might be more convenient to use the hw_BitMapToARGB() function instead. This will give you the pixels as readily formatted 32-bit ARGB values as it also takes potential mask and alpha channel bitmaps into account. The downside is that hw_BitMapToARGB() is slower because it needs to copy and convert the pixels first. See hw_BitMapToARGB for details.
struct hwos_LockBitMapStruct
that is to be filled
by this functionNULL
NULL
on error