summaryrefslogtreecommitdiff
path: root/image/bitmap.h
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-07-09 21:11:06 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-07-09 21:11:06 +0000
commite51ea4e0ee3ec45de0c661abd8eb04d433cdbfdf (patch)
tree2310b4eec68b67bfe028864e5b6881c4122ad3c2 /image/bitmap.h
parent1510bbd3ad9b1d39ab09e37d507399fb808fc83a (diff)
downloadnetsurf-e51ea4e0ee3ec45de0c661abd8eb04d433cdbfdf.tar.gz
netsurf-e51ea4e0ee3ec45de0c661abd8eb04d433cdbfdf.tar.bz2
Document the bitmap format properly.
svn path=/trunk/netsurf/; revision=10623
Diffstat (limited to 'image/bitmap.h')
-rw-r--r--image/bitmap.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/image/bitmap.h b/image/bitmap.h
index 4a99de17e..ee837f5d7 100644
--- a/image/bitmap.h
+++ b/image/bitmap.h
@@ -22,7 +22,32 @@
* This interface wraps the native platform-specific image format, so that
* portable image convertors can be written.
*
- * The bitmap format is ABGR.
+ * Bitmaps are required to be 32bpp with components in the order RR GG BB AA.
+ *
+ * For example, an opaque 1x1 pixel image would yield the following bitmap
+ * data:
+ *
+ * Red : 0xff 0x00 0x00 0x00
+ * Green: 0x00 0xff 0x00 0x00
+ * Blue : 0x00 0x00 0xff 0x00
+ *
+ * Any attempt to read pixels by casting bitmap data to uint32_t or similar
+ * will need to cater for the order of bytes in a word being different on
+ * big and little endian systems. To avoid confusion, it is recommended
+ * that pixel data is loaded as follows:
+ *
+ * uint32_t read_pixel(const uint8_t *bmp)
+ * {
+ * // red green blue alpha
+ * return bmp[0] | (bmp[1] << 8) | (bmp[2] << 16) | (bmp[3] << 24);
+ * }
+ *
+ * and *not* as follows:
+ *
+ * uint32_t read_pixel(const uint8_t *bmp)
+ * {
+ * return *((uint32_t *) bmp);
+ * }
*/
#ifndef _NETSURF_IMAGE_BITMAP_H_