Refactor bitmap, add extra accessor for color data

This commit is contained in:
2025-08-07 22:05:12 +03:00
parent 4ce443f0d9
commit d05efc5f85
6 changed files with 463 additions and 718 deletions

View File

@@ -27,15 +27,27 @@ Currently, the following pixel formats are supported:
=item B<BH_BITMAP_INDEX1>
1-bit indexed/paletted
1-bit indexed/paletted (bits are packed with most significant bit first)
=item B<BH_BITMAP_INDEX1_LSB>
1-bit index/paletted with (bits are packed with least significant bit first)
=item B<BH_BITMAP_INDEX2>
2-bit indexed/paletted
2-bit indexed/paletted (bits are packed with most significant bit first)
=item B<BH_BITMAP_INDEX2_LSB>
2-bit indexed/paletted (bits are packed with least significant bit first)
=item B<BH_BITMAP_INDEX4>
4-bit indexed/paletted
4-bit indexed/paletted (bits are packed with most significant bit first)
=item B<BH_BITMAP_INDEX4_LSB>
4-bit indexed/paletted (bits are packed with least significant bit first)
=item B<BH_BITMAP_INDEX8>
@@ -58,27 +70,27 @@ Currently, the following pixel formats are supported:
64-bit RGB with alpha represented in uint64_t value. The layout is:
0xAAAARRRRGGGGBBBB
=item B<BH_BITMAP_RGB565>
=item B<BH_BITMAP_RGB565>, B<BH_BITMAP_BGR565>
16-bit RGB
=item B<BH_BITMAP_RGB888>
=item B<BH_BITMAP_RGB888>, B<BH_BITMAP_BGR888>
24-bit RGB
=item B<BH_BITMAP_RGBA8888>
=item B<BH_BITMAP_RGBA8888>, B<BH_BITMAP_BGRA8888>, B<BH_BITMAP_ARGB8888>, B<BH_BITMAP_ABGR8888>
32-bit RGB with alpha
=item B<BH_BITMAP_RGB161616>
=item B<BH_BITMAP_RGB161616>, B<BH_BITMAP_BGR161616>
48-bit RGB
=item B<BH_BITMAP_RGBA16161616>
=item B<BH_BITMAP_RGBA16161616>, B<BH_BITMAP_BGRA16161616>, B<BH_BITMAP_ARGB16161616>, B<BH_BITMAP_ABGR16161616>
64-bit RGB with alpha
=item B<BH_BITMAP_RGBA1010102>
=item B<BH_BITMAP_RGBA1010102>, B<BH_BITMAP_BGRA1010102>, B<BH_BITMAP_ARGB1010102>, B<BH_BITMAP_ABGR1010102>
32-bit RGB with alpha
@@ -86,17 +98,6 @@ Currently, the following pixel formats are supported:
All pixel formats use the current machine endianness.
The flag I<BH_BITMAP_BGR> can be used to change the order of the color channels
(RGB -> BGR). The flag has no effect on the following pixel formats:
I<BH_BITMAP_INDEX1>, I<BH_BITMAP_INDEX2>, I<BH_BITMAP_INDEX4>,
I<BH_BITMAP_INDEX8>, I<BH_BITMAP_GRAY8>, I<BH_BITMAP_GRAY16>,
I<BH_BITMAP_RGBA32> and I<BH_BITMAP_RGBA64>.
The flag I<BH_BITMAP_LSB> can be used to change the start of the bit order for
indexed images. This flag only affects the following pixel formats:
I<BH_BITMAP_INDEX1>, I<BH_BITMAP_INDEX2>, I<BH_BITMAP_INDEX4> and
I<BH_BITMAP_INDEX8>.
The flag I<BH_BITMAP_NOALPHA> can be used to indicate that the alpha channel is
not used and should always be set to the maximum value (255 for 8-bit and 65535
for 16-bit).
@@ -104,9 +105,6 @@ for 16-bit).
The flag I<BH_BITMAP_PREMULT> can be used to indicate that color values are in
premultiplied form.
The color palette is assumed to contain exactly 256 colors and is stored in the
I<BH_BITMAP_RGBA32> pixel format.
=head1 API CALLS
@@ -118,7 +116,7 @@ I<BH_BITMAP_RGBA32> pixel format.
int format,
int flags,
void *data,
void *palette);
BH_Color *palette);
Creates the bitmap with the specified I<width>, I<height> and pixel I<format>.
@@ -303,10 +301,10 @@ Bitmap doesn't own palette data
void BH_BitmapConvertRow(void *src,
int srcFormat,
void *srcPalette,
const BH_Color *srcPalette,
void *dest,
int destFormat,
void *destPalette,
const BH_Color *destPalette,
size_t count);
Converts a row of source data from one pixel format to another pixel format.