Gitweb links:
...log
http://git.netsurf-browser.org/libnsbmp.git/shortlog/515f8e111ee6b12275fec93b4a05410868e6ae60
...commit
http://git.netsurf-browser.org/libnsbmp.git/commit/515f8e111ee6b12275fec93b4a05410868e6ae60
...tree
http://git.netsurf-browser.org/libnsbmp.git/tree/515f8e111ee6b12275fec93b4a05410868e6ae60
The branch, master has been updated
via 515f8e111ee6b12275fec93b4a05410868e6ae60 (commit)
via df9cc4e3d70afe522ca0a4e94d7b892bb9f65393 (commit)
from 3155a7e9db2d7d7c2349a12bc892fa9ff68c2338 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=515f8e111ee6b12275fec93b4a05410868e6ae60
commit 515f8e111ee6b12275fec93b4a05410868e6ae60
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Tests: Update for new API.
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 <sys/stat.h>
#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;
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=df9cc4e3d70afe522ca0a4e94d7b892bb9f65393
commit df9cc4e3d70afe522ca0a4e94d7b892bb9f65393
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
API: Remove get_bpp bitmap callback.
We only support 32bpp output pixel format.
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;
-----------------------------------------------------------------------
Summary of changes:
include/libnsbmp.h | 2 --
src/libnsbmp.c | 14 +++++++-------
test/decode_bmp.c | 14 +++-----------
test/decode_ico.c | 10 +---------
4 files changed, 11 insertions(+), 29 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;
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 <sys/stat.h>
#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;
--
NetSurf BMP Decoder
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]