Refactor bitmap, add new formats

Small refactoring of the bitmap module and added more indexed formats.
This commit is contained in:
2025-08-04 12:33:44 +03:00
parent 9c593932a3
commit 0da77c00d6
4 changed files with 583 additions and 203 deletions

View File

@@ -25,6 +25,18 @@ Currently, the following pixel formats are supported:
=over
=item B<BH_BITMAP_INDEX1>
1-bit indexed/paletted
=item B<BH_BITMAP_INDEX2>
2-bit indexed/paletted
=item B<BH_BITMAP_INDEX4>
4-bit indexed/paletted
=item B<BH_BITMAP_INDEX8>
8-bit indexed/paletted
@@ -74,11 +86,17 @@ 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
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).
@@ -152,6 +170,29 @@ Writes color value of the pixel at specified position.
The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapIndex
uint8_t BH_BitmapIndex(const BH_Bitmap *bitmap,
int x,
int y);
Returns the index value at the specified position.
The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapSetIndex
void BH_BitmapSetIndex(BH_Bitmap *bitmap,
int x,
int y,
uint8_t index);
Sets the index value at the specified position.
The I<x> and I<y> parameters specify a position on the bitmap.
=head2 BH_BitmapCopy
BH_Bitmap *BH_BitmapCopy(BH_Bitmap *bitmap,

View File

@@ -25,6 +25,18 @@ BH_Bitmap - доступ к растровому изображению/карт
=over
=item B<BH_BITMAP_INDEX1>
1-разрядный индексированный/палитрированный
=item B<BH_BITMAP_INDEX2>
2-разрядный индексированный/палитрированный
=item B<BH_BITMAP_INDEX4>
4-разрядный индексированный/палитрированный
=item B<BH_BITMAP_INDEX8>
8-разрядный индексированный/палитрированный
@@ -77,9 +89,15 @@ BH_Bitmap - доступ к растровому изображению/карт
Флаг I<BH_BITMAP_BGR> может использоваться для изменения порядка цветовых
каналов (RGB -> BGR). Этот флаг не влияет на следующие пиксельные форматы:
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> и I<BH_BITMAP_RGBA64>.
Флаг I<BH_BITMAP_LSB> может использоваться для изменения начала отсчета порядка
бит для индексированных изображений. Этот флаг влияет только на следующие
пиксельные форматы: I<BH_BITMAP_INDEX1>, I<BH_BITMAP_INDEX2>,
I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
Флаг I<BH_BITMAP_NOALPHA> может использоваться для указания того,
что альфа-канал не используется и всегда должен быть установлен в максимальное
значение (255 для 8-разрядных и 65535 для 16-разрядных).
@@ -155,7 +173,30 @@ I<BH_BITMAP_RGBA32> и I<BH_BITMAP_RGBA64>.
Записывает значение цвета пикселя в указанной позиции.
Параметры I<x> и I<y> определяют положение на растровой карте.
Параметры I<x> и I<y> определяют положение на растровом изображении.
=head2 BH_BitmapIndex
uint8_t BH_BitmapIndex(const BH_Bitmap *bitmap,
int x,
int y);
Возвращает значение индекса в указанной позиции.
Параметры I<x> и I<y> определяют положение на растровом изображении.
=head2 BH_BitmapSetIndex
void BH_BitmapSetIndex(BH_Bitmap *bitmap,
int x,
int y,
uint8_t index);
Устанавливает значение индекса в указанной позиции.
Параметры I<x> и I<y> определяют положение на растровом изображении.
=head2 BH_BitmapCopy