From df9cc4e3d70afe522ca0a4e94d7b892bb9f65393 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 24 Mar 2022 11:59:22 +0000 Subject: API: Remove get_bpp bitmap callback. We only support 32bpp output pixel format. --- include/libnsbmp.h | 2 -- src/libnsbmp.c | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/libnsbmp.h b/include/libnsbmp.h index 7e90b4a..ad683f0 100644 --- a/include/libnsbmp.h +++ b/include/libnsbmp.h @@ -62,8 +62,6 @@ typedef struct bmp_bitmap_callback_vt_s { bmp_bitmap_cb_destroy bitmap_destroy; /** Return a pointer to the pixel data in a bitmap. */ bmp_bitmap_cb_get_buffer bitmap_get_buffer; - /** Find the width of a pixel row in bytes. */ - bmp_bitmap_cb_get_bpp bitmap_get_bpp; } bmp_bitmap_callback_vt; /** diff --git a/src/libnsbmp.c b/src/libnsbmp.c index f6ebd6c..b4da553 100644 --- a/src/libnsbmp.c +++ b/src/libnsbmp.c @@ -530,7 +530,7 @@ static bmp_result bmp_decode_rgb32(bmp_image *bmp, uint8_t **start, int bytes) assert(bmp->bpp == 32); data = *start; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; @@ -612,7 +612,7 @@ static bmp_result bmp_decode_rgb24(bmp_image *bmp, uint8_t **start, int bytes) assert(bmp->bpp == 24); data = *start; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) { return BMP_INSUFFICIENT_MEMORY; @@ -683,7 +683,7 @@ static bmp_result bmp_decode_rgb16(bmp_image *bmp, uint8_t **start, int bytes) uint16_t word; data = *start; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; @@ -777,7 +777,7 @@ static bmp_result bmp_decode_rgb(bmp_image *bmp, uint8_t **start, int bytes) bit_shifts[i] = 8 - ((i + 1) * bmp->bpp); data = *start; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; @@ -842,7 +842,7 @@ static bmp_result bmp_decode_mask(bmp_image *bmp, uint8_t *data, int bytes) uint32_t x, y, swidth; uint32_t cur_byte = 0; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; @@ -897,7 +897,7 @@ bmp_decode_rle8(bmp_image *bmp, uint8_t *data, int bytes) if (bmp->ico) return BMP_DATA_ERROR; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; @@ -1051,7 +1051,7 @@ bmp_decode_rle4(bmp_image *bmp, uint8_t *data, int bytes) if (bmp->ico) return BMP_DATA_ERROR; - swidth = bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bitmap) * bmp->width; + swidth = sizeof(uint32_t) * bmp->width; top = bmp->bitmap_callbacks.bitmap_get_buffer(bmp->bitmap); if (!top) return BMP_INSUFFICIENT_MEMORY; -- cgit v1.2.1