summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile3
-rw-r--r--test/bmpsuite/g01bg.bmpbin0 -> 1086 bytes
-rw-r--r--test/bmpsuite/g01bw.bmpbin0 -> 1086 bytes
-rw-r--r--test/bmpsuite/g01p1.bmpbin0 -> 1082 bytes
-rw-r--r--test/bmpsuite/g01wb.bmpbin0 -> 1086 bytes
-rw-r--r--test/bmpsuite/g04.bmpbin0 -> 4214 bytes
-rw-r--r--test/bmpsuite/g04p4.bmpbin0 -> 4166 bytes
-rw-r--r--test/bmpsuite/g04rle.bmpbin0 -> 922 bytes
-rw-r--r--test/bmpsuite/g08.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08offs.bmpbin0 -> 9370 bytes
-rw-r--r--test/bmpsuite/g08os2.bmpbin0 -> 8986 bytes
-rw-r--r--test/bmpsuite/g08p256.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08p64.bmpbin0 -> 8502 bytes
-rw-r--r--test/bmpsuite/g08pi256.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08pi64.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08res11.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08res21.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08res22.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08rle.bmpbin0 -> 1820 bytes
-rw-r--r--test/bmpsuite/g08s0.bmpbin0 -> 9270 bytes
-rw-r--r--test/bmpsuite/g08w124.bmpbin0 -> 8642 bytes
-rw-r--r--test/bmpsuite/g08w125.bmpbin0 -> 9014 bytes
-rw-r--r--test/bmpsuite/g08w126.bmpbin0 -> 9142 bytes
-rw-r--r--test/bmpsuite/g16bf555.bmpbin0 -> 16450 bytes
-rw-r--r--test/bmpsuite/g16bf565.bmpbin0 -> 16450 bytes
-rw-r--r--test/bmpsuite/g16def555.bmpbin0 -> 16438 bytes
-rw-r--r--test/bmpsuite/g24.bmpbin0 -> 24630 bytes
-rw-r--r--test/bmpsuite/g32bf.bmpbin0 -> 32578 bytes
-rw-r--r--test/bmpsuite/g32def.bmpbin0 -> 32566 bytes
-rw-r--r--test/bmpsuite/png/01bg.pngbin0 -> 281 bytes
-rw-r--r--test/bmpsuite/png/01bw.pngbin0 -> 281 bytes
-rw-r--r--test/bmpsuite/png/01p1.pngbin0 -> 139 bytes
-rw-r--r--test/bmpsuite/png/04.pngbin0 -> 280 bytes
-rw-r--r--test/bmpsuite/png/04p4.pngbin0 -> 223 bytes
-rw-r--r--test/bmpsuite/png/08.pngbin0 -> 1447 bytes
-rw-r--r--test/bmpsuite/png/08p64.pngbin0 -> 694 bytes
-rw-r--r--test/bmpsuite/png/08w124.pngbin0 -> 1434 bytes
-rw-r--r--test/bmpsuite/png/08w125.pngbin0 -> 1450 bytes
-rw-r--r--test/bmpsuite/png/08w126.pngbin0 -> 1461 bytes
-rw-r--r--test/bmpsuite/png/16bf555.pngbin0 -> 525 bytes
-rw-r--r--test/bmpsuite/png/16bf565.pngbin0 -> 580 bytes
-rw-r--r--test/bmpsuite/png/24.pngbin0 -> 433 bytes
-rw-r--r--test/bmpsuite/png/reference.html54
-rw-r--r--test/bmpsuite/readme.txt38
-rw-r--r--test/bmpsuite/test.html54
-rw-r--r--test/decode_bmp.c192
-rw-r--r--test/decode_ico.c203
-rw-r--r--test/icons/monitor.icobin0 -> 102758 bytes
-rwxr-xr-xtest/runtest.sh26
49 files changed, 570 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..6c73a91
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,3 @@
+DIR_TEST_ITEMS := decode_bmp:decode_bmp.c decode_ico:decode_ico.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/test/bmpsuite/g01bg.bmp b/test/bmpsuite/g01bg.bmp
new file mode 100644
index 0000000..a720347
--- /dev/null
+++ b/test/bmpsuite/g01bg.bmp
Binary files differ
diff --git a/test/bmpsuite/g01bw.bmp b/test/bmpsuite/g01bw.bmp
new file mode 100644
index 0000000..06189a6
--- /dev/null
+++ b/test/bmpsuite/g01bw.bmp
Binary files differ
diff --git a/test/bmpsuite/g01p1.bmp b/test/bmpsuite/g01p1.bmp
new file mode 100644
index 0000000..706b4a1
--- /dev/null
+++ b/test/bmpsuite/g01p1.bmp
Binary files differ
diff --git a/test/bmpsuite/g01wb.bmp b/test/bmpsuite/g01wb.bmp
new file mode 100644
index 0000000..2f05b43
--- /dev/null
+++ b/test/bmpsuite/g01wb.bmp
Binary files differ
diff --git a/test/bmpsuite/g04.bmp b/test/bmpsuite/g04.bmp
new file mode 100644
index 0000000..a064f66
--- /dev/null
+++ b/test/bmpsuite/g04.bmp
Binary files differ
diff --git a/test/bmpsuite/g04p4.bmp b/test/bmpsuite/g04p4.bmp
new file mode 100644
index 0000000..4c1096b
--- /dev/null
+++ b/test/bmpsuite/g04p4.bmp
Binary files differ
diff --git a/test/bmpsuite/g04rle.bmp b/test/bmpsuite/g04rle.bmp
new file mode 100644
index 0000000..7239fa6
--- /dev/null
+++ b/test/bmpsuite/g04rle.bmp
Binary files differ
diff --git a/test/bmpsuite/g08.bmp b/test/bmpsuite/g08.bmp
new file mode 100644
index 0000000..3be9a20
--- /dev/null
+++ b/test/bmpsuite/g08.bmp
Binary files differ
diff --git a/test/bmpsuite/g08offs.bmp b/test/bmpsuite/g08offs.bmp
new file mode 100644
index 0000000..71def41
--- /dev/null
+++ b/test/bmpsuite/g08offs.bmp
Binary files differ
diff --git a/test/bmpsuite/g08os2.bmp b/test/bmpsuite/g08os2.bmp
new file mode 100644
index 0000000..f7f9f57
--- /dev/null
+++ b/test/bmpsuite/g08os2.bmp
Binary files differ
diff --git a/test/bmpsuite/g08p256.bmp b/test/bmpsuite/g08p256.bmp
new file mode 100644
index 0000000..a129bbc
--- /dev/null
+++ b/test/bmpsuite/g08p256.bmp
Binary files differ
diff --git a/test/bmpsuite/g08p64.bmp b/test/bmpsuite/g08p64.bmp
new file mode 100644
index 0000000..9d3affd
--- /dev/null
+++ b/test/bmpsuite/g08p64.bmp
Binary files differ
diff --git a/test/bmpsuite/g08pi256.bmp b/test/bmpsuite/g08pi256.bmp
new file mode 100644
index 0000000..45df3f8
--- /dev/null
+++ b/test/bmpsuite/g08pi256.bmp
Binary files differ
diff --git a/test/bmpsuite/g08pi64.bmp b/test/bmpsuite/g08pi64.bmp
new file mode 100644
index 0000000..52baf91
--- /dev/null
+++ b/test/bmpsuite/g08pi64.bmp
Binary files differ
diff --git a/test/bmpsuite/g08res11.bmp b/test/bmpsuite/g08res11.bmp
new file mode 100644
index 0000000..f03d0f3
--- /dev/null
+++ b/test/bmpsuite/g08res11.bmp
Binary files differ
diff --git a/test/bmpsuite/g08res21.bmp b/test/bmpsuite/g08res21.bmp
new file mode 100644
index 0000000..61198e5
--- /dev/null
+++ b/test/bmpsuite/g08res21.bmp
Binary files differ
diff --git a/test/bmpsuite/g08res22.bmp b/test/bmpsuite/g08res22.bmp
new file mode 100644
index 0000000..1af0ecc
--- /dev/null
+++ b/test/bmpsuite/g08res22.bmp
Binary files differ
diff --git a/test/bmpsuite/g08rle.bmp b/test/bmpsuite/g08rle.bmp
new file mode 100644
index 0000000..082f7f4
--- /dev/null
+++ b/test/bmpsuite/g08rle.bmp
Binary files differ
diff --git a/test/bmpsuite/g08s0.bmp b/test/bmpsuite/g08s0.bmp
new file mode 100644
index 0000000..4b2c521
--- /dev/null
+++ b/test/bmpsuite/g08s0.bmp
Binary files differ
diff --git a/test/bmpsuite/g08w124.bmp b/test/bmpsuite/g08w124.bmp
new file mode 100644
index 0000000..1896035
--- /dev/null
+++ b/test/bmpsuite/g08w124.bmp
Binary files differ
diff --git a/test/bmpsuite/g08w125.bmp b/test/bmpsuite/g08w125.bmp
new file mode 100644
index 0000000..b348a7c
--- /dev/null
+++ b/test/bmpsuite/g08w125.bmp
Binary files differ
diff --git a/test/bmpsuite/g08w126.bmp b/test/bmpsuite/g08w126.bmp
new file mode 100644
index 0000000..3628d66
--- /dev/null
+++ b/test/bmpsuite/g08w126.bmp
Binary files differ
diff --git a/test/bmpsuite/g16bf555.bmp b/test/bmpsuite/g16bf555.bmp
new file mode 100644
index 0000000..639a57f
--- /dev/null
+++ b/test/bmpsuite/g16bf555.bmp
Binary files differ
diff --git a/test/bmpsuite/g16bf565.bmp b/test/bmpsuite/g16bf565.bmp
new file mode 100644
index 0000000..cb0ea24
--- /dev/null
+++ b/test/bmpsuite/g16bf565.bmp
Binary files differ
diff --git a/test/bmpsuite/g16def555.bmp b/test/bmpsuite/g16def555.bmp
new file mode 100644
index 0000000..a5a3195
--- /dev/null
+++ b/test/bmpsuite/g16def555.bmp
Binary files differ
diff --git a/test/bmpsuite/g24.bmp b/test/bmpsuite/g24.bmp
new file mode 100644
index 0000000..d6d9e6a
--- /dev/null
+++ b/test/bmpsuite/g24.bmp
Binary files differ
diff --git a/test/bmpsuite/g32bf.bmp b/test/bmpsuite/g32bf.bmp
new file mode 100644
index 0000000..0f41534
--- /dev/null
+++ b/test/bmpsuite/g32bf.bmp
Binary files differ
diff --git a/test/bmpsuite/g32def.bmp b/test/bmpsuite/g32def.bmp
new file mode 100644
index 0000000..9524f76
--- /dev/null
+++ b/test/bmpsuite/g32def.bmp
Binary files differ
diff --git a/test/bmpsuite/png/01bg.png b/test/bmpsuite/png/01bg.png
new file mode 100644
index 0000000..0b9cf9a
--- /dev/null
+++ b/test/bmpsuite/png/01bg.png
Binary files differ
diff --git a/test/bmpsuite/png/01bw.png b/test/bmpsuite/png/01bw.png
new file mode 100644
index 0000000..9f2e57a
--- /dev/null
+++ b/test/bmpsuite/png/01bw.png
Binary files differ
diff --git a/test/bmpsuite/png/01p1.png b/test/bmpsuite/png/01p1.png
new file mode 100644
index 0000000..0103e79
--- /dev/null
+++ b/test/bmpsuite/png/01p1.png
Binary files differ
diff --git a/test/bmpsuite/png/04.png b/test/bmpsuite/png/04.png
new file mode 100644
index 0000000..14beb91
--- /dev/null
+++ b/test/bmpsuite/png/04.png
Binary files differ
diff --git a/test/bmpsuite/png/04p4.png b/test/bmpsuite/png/04p4.png
new file mode 100644
index 0000000..8dbcafa
--- /dev/null
+++ b/test/bmpsuite/png/04p4.png
Binary files differ
diff --git a/test/bmpsuite/png/08.png b/test/bmpsuite/png/08.png
new file mode 100644
index 0000000..06545a0
--- /dev/null
+++ b/test/bmpsuite/png/08.png
Binary files differ
diff --git a/test/bmpsuite/png/08p64.png b/test/bmpsuite/png/08p64.png
new file mode 100644
index 0000000..49f0802
--- /dev/null
+++ b/test/bmpsuite/png/08p64.png
Binary files differ
diff --git a/test/bmpsuite/png/08w124.png b/test/bmpsuite/png/08w124.png
new file mode 100644
index 0000000..8da58fb
--- /dev/null
+++ b/test/bmpsuite/png/08w124.png
Binary files differ
diff --git a/test/bmpsuite/png/08w125.png b/test/bmpsuite/png/08w125.png
new file mode 100644
index 0000000..6ebb4f8
--- /dev/null
+++ b/test/bmpsuite/png/08w125.png
Binary files differ
diff --git a/test/bmpsuite/png/08w126.png b/test/bmpsuite/png/08w126.png
new file mode 100644
index 0000000..ca9c9b9
--- /dev/null
+++ b/test/bmpsuite/png/08w126.png
Binary files differ
diff --git a/test/bmpsuite/png/16bf555.png b/test/bmpsuite/png/16bf555.png
new file mode 100644
index 0000000..aaa0dff
--- /dev/null
+++ b/test/bmpsuite/png/16bf555.png
Binary files differ
diff --git a/test/bmpsuite/png/16bf565.png b/test/bmpsuite/png/16bf565.png
new file mode 100644
index 0000000..52d90e3
--- /dev/null
+++ b/test/bmpsuite/png/16bf565.png
Binary files differ
diff --git a/test/bmpsuite/png/24.png b/test/bmpsuite/png/24.png
new file mode 100644
index 0000000..e9fc4db
--- /dev/null
+++ b/test/bmpsuite/png/24.png
Binary files differ
diff --git a/test/bmpsuite/png/reference.html b/test/bmpsuite/png/reference.html
new file mode 100644
index 0000000..7117b6c
--- /dev/null
+++ b/test/bmpsuite/png/reference.html
@@ -0,0 +1,54 @@
+<html>
+
+<head>
+<title>BMP Suite Reference Images</title>
+</head>
+
+<body>
+<h1>BMP Suite Reference Images</h1>
+
+<table border=1>
+<tr><th>File</th><th>bpp</th><th>Comments</th><th>Reference</th></tr>
+
+<tr><td>g01bw.bmp</td><td>1</td><td>black and white palette (#000000,#FFFFFF)</td><td><img src=01bw.png></td></tr>
+<tr><td>g01wb.bmp</td><td>1</td><td>white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.</td><td><img src=01bw.png></td></tr>
+<tr><td>g01bg.bmp</td><td>1</td><td>blue and green palette (#4040FF,#40FF40)</td><td><img src=01bg.png></td></tr>
+<tr><td>g01p1.bmp</td><td>1</td><td>1-color (blue) palette (#4040FF)</td><td><img src=01p1.png></td></tr>
+
+<tr><td>g04.bmp</td><td>4</td><td>basic 4bpp (16 color) image</td><td><img src=04.png></td></tr>
+<tr><td>g04rle.bmp</td><td>4</td><td>RLE compressed.</td><td><img src=04.png></td></tr>
+<tr><td>g04p4.bmp</td><td>4</td><td>4-color grayscale palette</td><td><img src=04p4.png></td></tr>
+
+<tr><td>g08.bmp</td><td>8</td><td>basic 8bpp (256 color) image</td><td><img src=08.png></td></tr>
+<tr><td>g08p256.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=0 [=256]</td><td><img src=08.png></td></tr>
+<tr><td>g08pi256.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=256</td><td><img src=08.png></td></tr>
+<tr><td>g08pi64.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=64. It's barely possible that some sophisticated viewers may display this image in grayscale, if there are a limited number of colors available.</td><td><img src=08.png></td></tr>
+<tr><td>g08rle.bmp</td><td>8</td><td>RLE compressed.</td><td><img src=08.png></td></tr>
+<tr><td>g08os2.bmp</td><td>8</td><td>OS/2-style bitmap. This is an obsolete variety of BMP that is still encountered sometimes. It has 3-byte palette entries (instead of 4), and 16-bit width/height fields (instead of 32).</td><td><img src=08.png></td></tr>
+<tr><td>g08res22.bmp</td><td>8</td><td>resolution 7874x7874 pixels/meter (200x200 dpi)</td><td><img src=08.png></td></tr>
+<tr><td>g08res11.bmp</td><td>8</td><td>resolution 3937x3937 pixels/meter (100x100 dpi)</td><td><img src=08.png></td></tr>
+<tr><td>g08res21.bmp</td><td>8</td><td>resolution 7874x3937 pixels/meter (200x100 dpi). Some programs (e.g. Imaging for Windows) may display this image stretched vertically, which is the optimal thing to do if the program is primarily a viewer, rather than an editor.</td><td><img src=08.png></td></tr>
+<tr><td>g08s0.bmp</td><td>8</td><td>bits size not given (set to 0). This is legal for uncompressed bitmaps.</td><td><img src=08.png></td></tr>
+<tr><td>g08offs.bmp</td><td>8</td><td>bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.</td><td><img src=08.png></td></tr>
+<tr><td>g08w126.bmp</td><td>8</td><td>size 126x63 (right and bottom slightly clipped)</td><td><img src=08w126.png></td></tr>
+<tr><td>g08w125.bmp</td><td>8</td><td>size 125x62</td><td><img src=08w125.png></td></tr>
+<tr><td>g08w124.bmp</td><td>8</td><td>size 124x61</td><td><img src=08w124.png></td></tr>
+<tr><td>g08p64.bmp</td><td>8</td><td>64-color grayscale palette</td><td><img src=08p64.png></td></tr>
+
+<tr><td>g16def555.bmp</td><td>16</td><td>15-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)</td><td><img src=16bf555.png></td></tr>
+<tr><td>g16bf555.bmp</td><td>16</td><td>15-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)</td><td><img src=16bf555.png></td></tr>
+<tr><td>g16bf565.bmp</td><td>16</td><td>16-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)</td><td><img src=16bf565.png></td></tr>
+
+<tr><td>g24.bmp</td><td>24</td><td>24-bit color (BGR)</td><td><img src=24.png></td></tr>
+<tr><td>g32def.bmp</td><td>32</td><td>24-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)</td><td><img src=24.png></td></tr>
+<tr><td>g32bf.bmp</td><td>32</td><td>24-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)</td><td><img src=24.png></td></tr>
+
+
+</table>
+
+<hr>
+<p><small><i>By <a href="http://pobox.com/%7Ejason1/">Jason Summers</a>,
+4/2001</i></small></p>
+
+</body>
+</html>
diff --git a/test/bmpsuite/readme.txt b/test/bmpsuite/readme.txt
new file mode 100644
index 0000000..347aded
--- /dev/null
+++ b/test/bmpsuite/readme.txt
@@ -0,0 +1,38 @@
+BMP Suite - sample BMP image files
+By Jason Summers <jason1@pobox.com>
+
+Version: 2001.04.27
+
+For more information: http://pobox.com/~jason1/bmpsuite/
+
+Contents
+--------
+
+g01bw.bmp
+g01wb.bmp
+g01bg.bmp
+g01p1.bmp
+g04.bmp
+g04p4.bmp
+g08.bmp
+g08offs.bmp
+g08os2.bmp
+g08w126.bmp
+g08w125.bmp
+g08w124.bmp
+g08p256.bmp
+g08pi256.bmp
+g08pi64.bmp
+g08res22.bmp
+g08res21.bmp
+g08res11.bmp
+g08p64.bmp
+g08s0.bmp
+g16def555.bmp
+g16bf555.bmp
+g16bf565.bmp
+g024.bmp
+g32def.bmp
+g32bf.bmp
+
+-- end --
diff --git a/test/bmpsuite/test.html b/test/bmpsuite/test.html
new file mode 100644
index 0000000..8abb614
--- /dev/null
+++ b/test/bmpsuite/test.html
@@ -0,0 +1,54 @@
+<html>
+
+<head>
+<title>BMP Suite Images</title>
+</head>
+
+<body>
+<h1>BMP Suite Images</h1>
+
+<table border=1>
+<tr><th>File</th><th>bpp</th><th>Comments</th><th>Image</th></tr>
+
+<tr><td>g01bw.bmp</td><td>1</td><td>black and white palette (#000000,#FFFFFF)</td><td><img src=g01bw.bmp></td></tr>
+<tr><td>g01wb.bmp</td><td>1</td><td>white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.</td><td><img src=g01wb.bmp></td></tr>
+<tr><td>g01bg.bmp</td><td>1</td><td>blue and green palette (#4040FF,#40FF40)</td><td><img src=g01bg.bmp></td></tr>
+<tr><td>g01p1.bmp</td><td>1</td><td>1-color (blue) palette (#4040FF)</td><td><img src=g01p1.bmp></td></tr>
+
+<tr><td>g04.bmp</td><td>4</td><td>basic 4bpp (16 color) image</td><td><img src=g04.bmp></td></tr>
+<tr><td>g04rle.bmp</td><td>4</td><td>RLE compressed.</td><td><img src=g04rle.bmp></td></tr>
+<tr><td>g04p4.bmp</td><td>4</td><td>4-color grayscale palette</td><td><img src=g04p4.bmp></td></tr>
+
+<tr><td>g08.bmp</td><td>8</td><td>basic 8bpp (256 color) image</td><td><img src=g08.bmp></td></tr>
+<tr><td>g08p256.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=0 [=256]</td><td><img src=g08p256.bmp></td></tr>
+<tr><td>g08pi256.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=256</td><td><img src=g08pi256.bmp></td></tr>
+<tr><td>g08pi64.bmp</td><td>8</td><td>biClrUsed=256, biClrImportant=64. It's barely possible that some sophisticated viewers may display this image in grayscale, if there are a limited number of colors available.</td><td><img src=g08pi64.bmp></td></tr>
+<tr><td>g08rle.bmp</td><td>8</td><td>RLE compressed.</td><td><img src=g08rle.bmp></td></tr>
+<tr><td>g08os2.bmp</td><td>8</td><td>OS/2-style bitmap. This is an obsolete variety of BMP that is still encountered sometimes. It has 3-byte palette entries (instead of 4), and 16-bit width/height fields (instead of 32).</td><td><img src=g08os2.bmp></td></tr>
+<tr><td>g08res22.bmp</td><td>8</td><td>resolution 7874x7874 pixels/meter (200x200 dpi)</td><td><img src=g08res22.bmp></td></tr>
+<tr><td>g08res11.bmp</td><td>8</td><td>resolution 3937x3937 pixels/meter (100x100 dpi)</td><td><img src=g08res11.bmp></td></tr>
+<tr><td>g08res21.bmp</td><td>8</td><td>resolution 7874x3937 pixels/meter (200x100 dpi). Some programs (e.g. Imaging for Windows) may display this image stretched vertically, which is the optimal thing to do if the program is primarily a viewer, rather than an editor.</td><td><img src=g08res21.bmp></td></tr>
+<tr><td>g08s0.bmp</td><td>8</td><td>bits size not given (set to 0). This is legal for uncompressed bitmaps.</td><td><img src=g08s0.bmp></td></tr>
+<tr><td>g08offs.bmp</td><td>8</td><td>bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.</td><td><img src=g08offs.bmp></td></tr>
+<tr><td>g08w126.bmp</td><td>8</td><td>size 126x63 (right and bottom slightly clipped)</td><td><img src=g08w126.bmp></td></tr>
+<tr><td>g08w125.bmp</td><td>8</td><td>size 125x62</td><td><img src=g08w125.bmp></td></tr>
+<tr><td>g08w124.bmp</td><td>8</td><td>size 124x61</td><td><img src=g08w124.bmp></td></tr>
+<tr><td>g08p64.bmp</td><td>8</td><td>64-color grayscale palette</td><td><img src=g08p64.bmp></td></tr>
+
+<tr><td>g16def555.bmp</td><td>16</td><td>15-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)</td><td><img src=g16def555.bmp></td></tr>
+<tr><td>g16bf555.bmp</td><td>16</td><td>15-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)</td><td><img src=g16bf555.bmp></td></tr>
+<tr><td>g16bf565.bmp</td><td>16</td><td>16-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)</td><td><img src=g16bf565.bmp></td></tr>
+
+<tr><td>g24.bmp</td><td>24</td><td>24-bit color (BGR)</td><td><img src=g24.bmp></td></tr>
+<tr><td>g32def.bmp</td><td>32</td><td>24-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)</td><td><img src=g32def.bmp></tr>
+<tr><td>g32bf.bmp</td><td>32</td><td>24-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)</td><td><img src=g32bf.bmp></tr>
+
+
+</table>
+
+<hr>
+<p><small><i>By <a href="http://pobox.com/%7Ejason1/">Jason Summers</a>,
+4/2001</i></small></p>
+
+</body>
+</html>
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
new file mode 100644
index 0000000..e5dc572
--- /dev/null
+++ b/test/decode_bmp.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2008 Sean Fox <dyntryx@gmail.com>
+ * Copyright 2008 James Bursa <james@netsurf-browser.org>
+ *
+ * This file is part of NetSurf's libnsbmp, http://www.netsurf-browser.org/
+ * Licenced under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include "../include/libnsbmp.h"
+
+#define BYTES_PER_PIXEL 4
+#define TRANSPARENT_COLOR 0xffffffff
+
+unsigned char *load_file(const char *path, size_t *data_size);
+void warning(const char *context, bmp_result code);
+void *bitmap_create(int width, int height, unsigned int state);
+unsigned char *bitmap_get_buffer(void *bitmap);
+size_t bitmap_get_bpp(void *bitmap);
+void bitmap_destroy(void *bitmap);
+
+
+int main(int argc, char *argv[])
+{
+ bmp_bitmap_callback_vt bitmap_callbacks = {
+ bitmap_create,
+ bitmap_destroy,
+ bitmap_get_buffer,
+ bitmap_get_bpp
+ };
+ bmp_result code;
+ bmp_image bmp;
+ size_t size;
+ unsigned short res = 0;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s image.bmp\n", argv[0]);
+ return 1;
+ }
+
+ /* create our bmp image */
+ bmp_create(&bmp, &bitmap_callbacks);
+
+ /* load file into memory */
+ unsigned char *data = load_file(argv[1], &size);
+
+ /* analyse the BMP */
+ code = bmp_analyse(&bmp, size, data);
+ if (code != BMP_OK) {
+ warning("bmp_analyse", code);
+ res = 1;
+ goto cleanup;
+ }
+
+ /* decode the image */
+ code = bmp_decode(&bmp);
+ /* code = bmp_decode_trans(&bmp, TRANSPARENT_COLOR); */
+ if (code != BMP_OK) {
+ warning("bmp_decode", code);
+ /* allow partially decoded images */
+ if (code != BMP_INSUFFICIENT_DATA) {
+ res = 1;
+ goto cleanup;
+ }
+ }
+
+ printf("P3\n");
+ printf("# %s\n", argv[1]);
+ printf("# width %u \n", bmp.width);
+ printf("# height %u \n", bmp.height);
+ printf("%u %u 256\n", bmp.width, bmp.height);
+
+ {
+ uint16_t row, col;
+ uint8_t *image;
+ image = (uint8_t *) bmp.bitmap;
+ for (row = 0; row != bmp.height; row++) {
+ for (col = 0; col != bmp.width; col++) {
+ size_t z = (row * bmp.width + col) * BYTES_PER_PIXEL;
+ printf("%u %u %u ", image[z],
+ image[z + 1],
+ image[z + 2]);
+ }
+ printf("\n");
+ }
+ }
+
+cleanup:
+ /* clean up */
+ bmp_finalise(&bmp);
+ free(data);
+
+ return res;
+}
+
+
+unsigned char *load_file(const char *path, size_t *data_size)
+{
+ FILE *fd;
+ struct stat sb;
+ unsigned char *buffer;
+ size_t size;
+ size_t n;
+
+ fd = fopen(path, "rb");
+ if (!fd) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ if (stat(path, &sb)) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+ size = sb.st_size;
+
+ buffer = malloc(size);
+ if (!buffer) {
+ fprintf(stderr, "Unable to allocate %lld bytes\n",
+ (long long) size);
+ exit(EXIT_FAILURE);
+ }
+
+ n = fread(buffer, 1, size, fd);
+ if (n != size) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fd);
+
+ *data_size = size;
+ return buffer;
+}
+
+
+void warning(const char *context, bmp_result code)
+{
+ fprintf(stderr, "%s failed: ", context);
+ switch (code) {
+ case BMP_INSUFFICIENT_MEMORY:
+ fprintf(stderr, "BMP_INSUFFICIENT_MEMORY");
+ break;
+ case BMP_INSUFFICIENT_DATA:
+ fprintf(stderr, "BMP_INSUFFICIENT_DATA");
+ break;
+ case BMP_DATA_ERROR:
+ fprintf(stderr, "BMP_DATA_ERROR");
+ break;
+ default:
+ fprintf(stderr, "unknown code %i", code);
+ break;
+ }
+ fprintf(stderr, "\n");
+}
+
+
+void *bitmap_create(int width, int height, unsigned int state)
+{
+ (void) state; /* unused */
+ return calloc(width * height, BYTES_PER_PIXEL);
+}
+
+
+unsigned char *bitmap_get_buffer(void *bitmap)
+{
+ assert(bitmap);
+ return bitmap;
+}
+
+
+size_t bitmap_get_bpp(void *bitmap)
+{
+ (void) bitmap; /* unused */
+ return BYTES_PER_PIXEL;
+}
+
+
+void bitmap_destroy(void *bitmap)
+{
+ assert(bitmap);
+ free(bitmap);
+}
+
diff --git a/test/decode_ico.c b/test/decode_ico.c
new file mode 100644
index 0000000..935001c
--- /dev/null
+++ b/test/decode_ico.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2008 Sean Fox <dyntryx@gmail.com>
+ * Copyright 2008 James Bursa <james@netsurf-browser.org>
+ *
+ * This file is part of NetSurf's libnsbmp, http://www.netsurf-browser.org/
+ * Licenced under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include "../include/libnsbmp.h"
+
+/* Currently the library returns the data in RGBA format,
+ * so there are 4 bytes per pixel */
+#define BYTES_PER_PIXEL 4
+
+/* White with alpha masking. */
+#define TRANSPARENT_COLOR 0xffffffff
+
+unsigned char *load_file(const char *path, size_t *data_size);
+void warning(const char *context, bmp_result code);
+void *bitmap_create(int width, int height, unsigned int state);
+unsigned char *bitmap_get_buffer(void *bitmap);
+size_t bitmap_get_bpp(void *bitmap);
+void bitmap_destroy(void *bitmap);
+
+
+int main(int argc, char *argv[])
+{
+ bmp_bitmap_callback_vt bitmap_callbacks = {
+ bitmap_create,
+ bitmap_destroy,
+ bitmap_get_buffer,
+ bitmap_get_bpp
+ };
+ uint16_t width, height;
+ ico_collection ico;
+ bmp_result code;
+ struct bmp_image *bmp;
+ size_t size;
+ unsigned short res = 0;
+
+ if ((argc < 2) || (argc > 4)) {
+ fprintf(stderr, "Usage: %s collection.ico [width=255] [height=255]\n", argv[0]);
+ return 1;
+ }
+ width = (argc >= 3) ? atoi(argv[2]) : 255;
+ height = (argc == 4) ? atoi(argv[3]) : 255;
+
+ /* create our bmp image */
+ ico_collection_create(&ico, &bitmap_callbacks);
+
+ /* load file into memory */
+ unsigned char *data = load_file(argv[1], &size);
+
+ /* analyse the BMP */
+ code = ico_analyse(&ico, size, data);
+ if (code != BMP_OK) {
+ warning("ico_analyse", code);
+ res = 1;
+ goto cleanup;
+ }
+
+ /* decode the image */
+ bmp = ico_find(&ico, width, height);
+ assert(bmp);
+
+ code = bmp_decode(bmp);
+ /* code = bmp_decode_trans(bmp, TRANSPARENT_COLOR); */
+ if (code != BMP_OK) {
+ warning("bmp_decode", code);
+ /* allow partially decoded images */
+ if (code != BMP_INSUFFICIENT_DATA) {
+ res = 1;
+ goto cleanup;
+ }
+ }
+
+ printf("P3\n");
+ printf("# %s\n", argv[1]);
+ printf("# width %u \n", bmp->width);
+ printf("# height %u \n", bmp->height);
+ printf("%u %u 256\n", bmp->width, bmp->height);
+
+ {
+ uint16_t row, col;
+ uint8_t *image;
+ image = (uint8_t *) bmp->bitmap;
+ for (row = 0; row != bmp->height; row++) {
+ for (col = 0; col != bmp->width; col++) {
+ size_t z = (row * bmp->width + col) * BYTES_PER_PIXEL;
+ printf("%u %u %u ", image[z],
+ image[z + 1],
+ image[z + 2]);
+ }
+ printf("\n");
+ }
+ }
+
+cleanup:
+ /* clean up */
+ ico_finalise(&ico);
+ free(data);
+
+ return res;
+}
+
+
+unsigned char *load_file(const char *path, size_t *data_size)
+{
+ FILE *fd;
+ struct stat sb;
+ unsigned char *buffer;
+ size_t size;
+ size_t n;
+
+ fd = fopen(path, "rb");
+ if (!fd) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ if (stat(path, &sb)) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+ size = sb.st_size;
+
+ buffer = malloc(size);
+ if (!buffer) {
+ fprintf(stderr, "Unable to allocate %lld bytes\n",
+ (long long) size);
+ exit(EXIT_FAILURE);
+ }
+
+ n = fread(buffer, 1, size, fd);
+ if (n != size) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fd);
+
+ *data_size = size;
+ return buffer;
+}
+
+
+void warning(const char *context, bmp_result code)
+{
+ fprintf(stderr, "%s failed: ", context);
+ switch (code) {
+ case BMP_INSUFFICIENT_MEMORY:
+ fprintf(stderr, "BMP_INSUFFICIENT_MEMORY");
+ break;
+ case BMP_INSUFFICIENT_DATA:
+ fprintf(stderr, "BMP_INSUFFICIENT_DATA");
+ break;
+ case BMP_DATA_ERROR:
+ fprintf(stderr, "BMP_DATA_ERROR");
+ break;
+ default:
+ fprintf(stderr, "unknown code %i", code);
+ break;
+ }
+ fprintf(stderr, "\n");
+}
+
+
+void *bitmap_create(int width, int height, unsigned int state)
+{
+ (void) state; /* unused */
+ return calloc(width * height, BYTES_PER_PIXEL);
+}
+
+
+unsigned char *bitmap_get_buffer(void *bitmap)
+{
+ assert(bitmap);
+ return bitmap;
+}
+
+
+size_t bitmap_get_bpp(void *bitmap)
+{
+ (void) bitmap; /* unused */
+ return BYTES_PER_PIXEL;
+}
+
+
+void bitmap_destroy(void *bitmap)
+{
+ assert(bitmap);
+ free(bitmap);
+}
+
diff --git a/test/icons/monitor.ico b/test/icons/monitor.ico
new file mode 100644
index 0000000..2997dc3
--- /dev/null
+++ b/test/icons/monitor.ico
Binary files differ
diff --git a/test/runtest.sh b/test/runtest.sh
new file mode 100755
index 0000000..65d7f45
--- /dev/null
+++ b/test/runtest.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+TEST_PATH=$1
+TEST_OUT=${TEST_PATH}/ppm
+
+mkdir -p ${TEST_OUT}
+
+bmpdecode()
+{
+ OUTF=$(basename ${1} .bmp)
+ ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm
+}
+
+icodecode()
+{
+ OUTF=$(basename ${1} .ico)
+ ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm
+}
+
+for BMP in $(ls test/bmpsuite/*.bmp);do
+ bmpdecode ${BMP}
+done
+
+#for ICO in $(ls test/icons/*.ico);do
+# icodecode ${BMP}
+#done