summaryrefslogtreecommitdiff
path: root/libnsbmp.h
diff options
context:
space:
mode:
Diffstat (limited to 'libnsbmp.h')
-rw-r--r--libnsbmp.h45
1 files changed, 26 insertions, 19 deletions
diff --git a/libnsbmp.h b/libnsbmp.h
index ac5f77b..c11a047 100644
--- a/libnsbmp.h
+++ b/libnsbmp.h
@@ -25,10 +25,11 @@
#define _NETSURF_IMAGE_BMPREAD_H_
#include <stdbool.h>
+#include <stdint.h>
/* bmp flags */
-#define BMP_NEW 0
-#define BMP_OPAQUE (1 << 0) /** image is opaque */
+#define BMP_NEW 0
+#define BMP_OPAQUE (1 << 0) /** image is opaque (as opposed to having an alpha mask) */
#define BMP_CLEAR_MEMORY (1 << 1) /** memory should be wiped */
/* error return values */
@@ -68,23 +69,28 @@ typedef struct bmp_bitmap_callback_vt_s {
typedef struct bmp_image {
bmp_bitmap_callback_vt bitmap_callbacks; /**< callbacks for bitmap functions */
- unsigned int width; /** width of BMP (valid after _analyse) */
- unsigned int height; /** heigth of BMP (valid after _analyse) */
+ uint16_t width; /** width of BMP (valid after _analyse) */
+ uint16_t height; /** heigth of BMP (valid after _analyse) */
bool decoded; /** whether the image has been decoded */
void *bitmap; /** decoded image */
+ uint8_t *bmp_data; /** pointer to BMP data */
/** Internal members are listed below
*/
- unsigned char *bmp_data; /** pointer to BMP data */
- unsigned int buffer_size; /** total number of bytes of BMP data available */
+ uint32_t buffer_size; /** total number of bytes of BMP data available */
bmp_encoding encoding; /** pixel encoding type */
- unsigned int bitmap_offset; /** offset of bitmap data */
- unsigned int bpp; /** bits per pixel */
- unsigned int colours; /** number of colours */
- unsigned int *colour_table; /** colour table */
+ uint32_t bitmap_offset; /** offset of bitmap data */
+ uint16_t bpp; /** bits per pixel */
+ uint32_t colours; /** number of colours */
+ uint32_t *colour_table; /** colour table */
+ bool limited_trans; /** whether to use bmp's limited transparency */
+ uint32_t trans_colour; /** colour to display for "transparent" pixels when
+ * using limited transparency */
bool reversed; /** scanlines are top to bottom */
bool ico; /** image is part of an ICO, mask follows */
- unsigned int mask[4]; /** four bitwise mask */
- int shift[4]; /** four bitwise shifts */
+ bool opaque; /** true if the bitmap does not contain an alpha channel */
+ uint32_t mask[4]; /** four bitwise mask */
+ int32_t shift[4]; /** four bitwise shifts */
+ uint32_t transparent_index; /** colour representing "transparency" in the bitmap */
} bmp_image;
typedef struct ico_image {
@@ -94,23 +100,24 @@ typedef struct ico_image {
typedef struct ico_collection {
bmp_bitmap_callback_vt bitmap_callbacks; /**< callbacks for bitmap functions */
- unsigned int width; /** width of largest BMP */
- unsigned int height; /** heigth of largest BMP */
+ uint16_t width; /** width of largest BMP */
+ uint16_t height; /** heigth of largest BMP */
/** Internal members are listed below
*/
- unsigned char *ico_data; /** pointer to ICO data */
- unsigned int buffer_size; /** total number of bytes of ICO data available */
+ uint8_t *ico_data; /** pointer to ICO data */
+ uint32_t buffer_size; /** total number of bytes of ICO data available */
ico_image *first;
} ico_collection;
void bmp_create(bmp_image *gif, bmp_bitmap_callback_vt *bitmap_callbacks);
void ico_collection_create(ico_collection *ico, bmp_bitmap_callback_vt *bitmap_callbacks);
-bmp_result bmp_analyse(bmp_image *bmp, size_t size, unsigned char *data);
+bmp_result bmp_analyse(bmp_image *bmp, size_t size, uint8_t *data);
bmp_result bmp_decode(bmp_image *bmp);
+bmp_result bmp_decode_trans(bmp_image *bmp, uint32_t transparent_colour);
void bmp_finalise(bmp_image *bmp);
-bmp_result ico_analyse(ico_collection *ico, size_t size, unsigned char *data);
-bmp_image *ico_find(ico_collection *ico, int width, int height);
+bmp_result ico_analyse(ico_collection *ico, size_t size, uint8_t *data);
+bmp_image *ico_find(ico_collection *ico, uint16_t width, uint16_t height);
void ico_finalise(ico_collection *ico);
#endif