Add input checks, fix overflow/wrap related bugs

This commit is contained in:
2025-08-04 20:35:19 +03:00
parent deb4ec00f4
commit 4ce443f0d9
4 changed files with 137 additions and 113 deletions

View File

@@ -114,12 +114,12 @@ I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
=head2 BH_BitmapNew
BH_Bitmap *BH_BitmapNew(int width,
int height,
int format,
int flags,
void *data,
void *palette);
BH_Bitmap *BH_BitmapNew(uint32_t width,
uint32_t height,
int format,
int flags,
void *data,
void *palette);
Создает растровое изображение с указанной шириной, высотой и пиксельным
форматом.
@@ -155,8 +155,8 @@ I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
=head2 BH_BitmapColor
void BH_BitmapColor(const BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
BH_Color *value);
Считывает значение цвета пикселя в указанной позиции.
@@ -167,8 +167,8 @@ I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
=head2 BH_BitmapSetColor
void BH_BitmapSetColor(BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
const BH_Color *value);
Записывает значение цвета пикселя в указанной позиции.
@@ -179,8 +179,8 @@ I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
=head2 BH_BitmapIndex
uint8_t BH_BitmapIndex(const BH_Bitmap *bitmap,
int x,
int y);
uint32_t x,
uint32_t y);
Возвращает значение индекса в указанной позиции.
@@ -190,8 +190,8 @@ I<BH_BITMAP_INDEX4> и I<BH_BITMAP_INDEX8>.
=head2 BH_BitmapSetIndex
void BH_BitmapSetIndex(BH_Bitmap *bitmap,
int x,
int y,
uint32_t x,
uint32_t y,
uint8_t index);
Устанавливает значение индекса в указанной позиции.
@@ -202,10 +202,10 @@ void BH_BitmapSetIndex(BH_Bitmap *bitmap,
=head2 BH_BitmapCopy
BH_Bitmap *BH_BitmapCopy(BH_Bitmap *bitmap,
int x,
int y,
int width,
int height,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
int shallow);
Создает копию области растрового изображения с заданным положением и размером.
@@ -225,7 +225,7 @@ void BH_BitmapSetIndex(BH_Bitmap *bitmap,
=head2 BH_BitmapScanline
void *BH_BitmapScanline(const BH_Bitmap *bitmap,
int y);
uint32_t y);
Возвращает адрес строки сканирования в растровом изображении.
@@ -233,22 +233,22 @@ void BH_BitmapSetIndex(BH_Bitmap *bitmap,
=head2 BH_BitmapAt
void *BH_BitmapAt(const BH_Bitmap *bitmap,
int x,
int y);
uint32_t x,
uint32_t y);
Возвращает адрес пикселя в растровом изображении.
=head2 BH_BitmapWidth
int BH_BitmapWidth(BH_Bitmap *bitmap);
uint32_t BH_BitmapWidth(BH_Bitmap *bitmap);
Возвращает ширину растрового изображения.
=head2 BH_BitmapHeight
int BH_BitmapHeight(BH_Bitmap *bitmap);
uint32_t BH_BitmapHeight(BH_Bitmap *bitmap);
Возвращает высоту растрового изображения.