From 515f8e111ee6b12275fec93b4a05410868e6ae60 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 24 Mar 2022 12:00:21 +0000 Subject: Tests: Update for new API. --- test/decode_bmp.c | 14 +++----------- test/decode_ico.c | 10 +--------- 2 files changed, 4 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/decode_bmp.c b/test/decode_bmp.c index 68de542..a0b02e8 100644 --- a/test/decode_bmp.c +++ b/test/decode_bmp.c @@ -17,7 +17,7 @@ #include #include "../include/libnsbmp.h" -#define BYTES_PER_PIXEL 4 +#define BYTES_PER_PIXEL sizeof(uint32_t) #define MAX_IMAGE_BYTES (48 * 1024 * 1024) #define TRANSPARENT_COLOR 0xffffffff @@ -25,8 +25,8 @@ static void *bitmap_create(int width, int height, unsigned int state) { (void) state; /* unused */ - /* ensure a stupidly large (>50Megs or so) bitmap is not created */ - if (((long long)width * (long long)height) > (MAX_IMAGE_BYTES/BYTES_PER_PIXEL)) { + /* Ensure a stupidly large bitmap is not created */ + if (width > 4096 || height > 4096) { return NULL; } return calloc(width * height, BYTES_PER_PIXEL); @@ -40,13 +40,6 @@ static unsigned char *bitmap_get_buffer(void *bitmap) } -static size_t bitmap_get_bpp(void *bitmap) -{ - (void) bitmap; /* unused */ - return BYTES_PER_PIXEL; -} - - static void bitmap_destroy(void *bitmap) { assert(bitmap); @@ -144,7 +137,6 @@ int main(int argc, char *argv[]) bitmap_create, bitmap_destroy, bitmap_get_buffer, - bitmap_get_bpp }; bmp_result code; bmp_image bmp; diff --git a/test/decode_ico.c b/test/decode_ico.c index 5dbc7a5..94db57e 100644 --- a/test/decode_ico.c +++ b/test/decode_ico.c @@ -24,7 +24,7 @@ /* Currently the library returns the data in RGBA format, * so there are 4 bytes per pixel */ -#define BYTES_PER_PIXEL 4 +#define BYTES_PER_PIXEL sizeof(uint32_t) /* White with alpha masking. */ #define TRANSPARENT_COLOR 0xffffffff @@ -43,13 +43,6 @@ static unsigned char *bitmap_get_buffer(void *bitmap) } -static size_t bitmap_get_bpp(void *bitmap) -{ - (void) bitmap; /* unused */ - return BYTES_PER_PIXEL; -} - - static void bitmap_destroy(void *bitmap) { assert(bitmap); @@ -175,7 +168,6 @@ int main(int argc, char *argv[]) bitmap_create, bitmap_destroy, bitmap_get_buffer, - bitmap_get_bpp }; uint16_t width, height; ico_collection ico; -- cgit v1.2.3