From f2d8f433391919bc13041fe850aefb502fa6f348 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 1 Sep 2015 15:05:27 +0100 Subject: add decode test suite --- Makefile | 6 ++ bmp_display | 3 - examples/bmp_display | 3 + examples/bmpsuite/g01bg.bmp | Bin 1086 -> 0 bytes examples/bmpsuite/g01bw.bmp | Bin 1086 -> 0 bytes examples/bmpsuite/g01p1.bmp | Bin 1082 -> 0 bytes examples/bmpsuite/g01wb.bmp | Bin 1086 -> 0 bytes examples/bmpsuite/g04.bmp | Bin 4214 -> 0 bytes examples/bmpsuite/g04p4.bmp | Bin 4166 -> 0 bytes examples/bmpsuite/g04rle.bmp | Bin 922 -> 0 bytes examples/bmpsuite/g08.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08offs.bmp | Bin 9370 -> 0 bytes examples/bmpsuite/g08os2.bmp | Bin 8986 -> 0 bytes examples/bmpsuite/g08p256.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08p64.bmp | Bin 8502 -> 0 bytes examples/bmpsuite/g08pi256.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08pi64.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08res11.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08res21.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08res22.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08rle.bmp | Bin 1820 -> 0 bytes examples/bmpsuite/g08s0.bmp | Bin 9270 -> 0 bytes examples/bmpsuite/g08w124.bmp | Bin 8642 -> 0 bytes examples/bmpsuite/g08w125.bmp | Bin 9014 -> 0 bytes examples/bmpsuite/g08w126.bmp | Bin 9142 -> 0 bytes examples/bmpsuite/g16bf555.bmp | Bin 16450 -> 0 bytes examples/bmpsuite/g16bf565.bmp | Bin 16450 -> 0 bytes examples/bmpsuite/g16def555.bmp | Bin 16438 -> 0 bytes examples/bmpsuite/g24.bmp | Bin 24630 -> 0 bytes examples/bmpsuite/g32bf.bmp | Bin 32578 -> 0 bytes examples/bmpsuite/g32def.bmp | Bin 32566 -> 0 bytes examples/bmpsuite/png/01bg.png | Bin 281 -> 0 bytes examples/bmpsuite/png/01bw.png | Bin 281 -> 0 bytes examples/bmpsuite/png/01p1.png | Bin 139 -> 0 bytes examples/bmpsuite/png/04.png | Bin 280 -> 0 bytes examples/bmpsuite/png/04p4.png | Bin 223 -> 0 bytes examples/bmpsuite/png/08.png | Bin 1447 -> 0 bytes examples/bmpsuite/png/08p64.png | Bin 694 -> 0 bytes examples/bmpsuite/png/08w124.png | Bin 1434 -> 0 bytes examples/bmpsuite/png/08w125.png | Bin 1450 -> 0 bytes examples/bmpsuite/png/08w126.png | Bin 1461 -> 0 bytes examples/bmpsuite/png/16bf555.png | Bin 525 -> 0 bytes examples/bmpsuite/png/16bf565.png | Bin 580 -> 0 bytes examples/bmpsuite/png/24.png | Bin 433 -> 0 bytes examples/bmpsuite/png/reference.html | 54 ---------- examples/bmpsuite/readme.txt | 38 ------- examples/bmpsuite/test.html | 54 ---------- examples/decode_bmp.c | 192 --------------------------------- examples/decode_ico.c | 203 ----------------------------------- examples/ico_display | 3 + examples/monitor.ico | Bin 102758 -> 0 bytes ico_display | 3 - test/Makefile | 3 + test/bmpsuite/g01bg.bmp | Bin 0 -> 1086 bytes test/bmpsuite/g01bw.bmp | Bin 0 -> 1086 bytes test/bmpsuite/g01p1.bmp | Bin 0 -> 1082 bytes test/bmpsuite/g01wb.bmp | Bin 0 -> 1086 bytes test/bmpsuite/g04.bmp | Bin 0 -> 4214 bytes test/bmpsuite/g04p4.bmp | Bin 0 -> 4166 bytes test/bmpsuite/g04rle.bmp | Bin 0 -> 922 bytes test/bmpsuite/g08.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08offs.bmp | Bin 0 -> 9370 bytes test/bmpsuite/g08os2.bmp | Bin 0 -> 8986 bytes test/bmpsuite/g08p256.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08p64.bmp | Bin 0 -> 8502 bytes test/bmpsuite/g08pi256.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08pi64.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08res11.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08res21.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08res22.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08rle.bmp | Bin 0 -> 1820 bytes test/bmpsuite/g08s0.bmp | Bin 0 -> 9270 bytes test/bmpsuite/g08w124.bmp | Bin 0 -> 8642 bytes test/bmpsuite/g08w125.bmp | Bin 0 -> 9014 bytes test/bmpsuite/g08w126.bmp | Bin 0 -> 9142 bytes test/bmpsuite/g16bf555.bmp | Bin 0 -> 16450 bytes test/bmpsuite/g16bf565.bmp | Bin 0 -> 16450 bytes test/bmpsuite/g16def555.bmp | Bin 0 -> 16438 bytes test/bmpsuite/g24.bmp | Bin 0 -> 24630 bytes test/bmpsuite/g32bf.bmp | Bin 0 -> 32578 bytes test/bmpsuite/g32def.bmp | Bin 0 -> 32566 bytes test/bmpsuite/png/01bg.png | Bin 0 -> 281 bytes test/bmpsuite/png/01bw.png | Bin 0 -> 281 bytes test/bmpsuite/png/01p1.png | Bin 0 -> 139 bytes test/bmpsuite/png/04.png | Bin 0 -> 280 bytes test/bmpsuite/png/04p4.png | Bin 0 -> 223 bytes test/bmpsuite/png/08.png | Bin 0 -> 1447 bytes test/bmpsuite/png/08p64.png | Bin 0 -> 694 bytes test/bmpsuite/png/08w124.png | Bin 0 -> 1434 bytes test/bmpsuite/png/08w125.png | Bin 0 -> 1450 bytes test/bmpsuite/png/08w126.png | Bin 0 -> 1461 bytes test/bmpsuite/png/16bf555.png | Bin 0 -> 525 bytes test/bmpsuite/png/16bf565.png | Bin 0 -> 580 bytes test/bmpsuite/png/24.png | Bin 0 -> 433 bytes test/bmpsuite/png/reference.html | 54 ++++++++++ test/bmpsuite/readme.txt | 38 +++++++ test/bmpsuite/test.html | 54 ++++++++++ test/decode_bmp.c | 192 +++++++++++++++++++++++++++++++++ test/decode_ico.c | 203 +++++++++++++++++++++++++++++++++++ test/icons/monitor.ico | Bin 0 -> 102758 bytes test/runtest.sh | 26 +++++ 101 files changed, 582 insertions(+), 547 deletions(-) delete mode 100755 bmp_display create mode 100755 examples/bmp_display delete mode 100644 examples/bmpsuite/g01bg.bmp delete mode 100644 examples/bmpsuite/g01bw.bmp delete mode 100644 examples/bmpsuite/g01p1.bmp delete mode 100644 examples/bmpsuite/g01wb.bmp delete mode 100644 examples/bmpsuite/g04.bmp delete mode 100644 examples/bmpsuite/g04p4.bmp delete mode 100644 examples/bmpsuite/g04rle.bmp delete mode 100644 examples/bmpsuite/g08.bmp delete mode 100644 examples/bmpsuite/g08offs.bmp delete mode 100644 examples/bmpsuite/g08os2.bmp delete mode 100644 examples/bmpsuite/g08p256.bmp delete mode 100644 examples/bmpsuite/g08p64.bmp delete mode 100644 examples/bmpsuite/g08pi256.bmp delete mode 100644 examples/bmpsuite/g08pi64.bmp delete mode 100644 examples/bmpsuite/g08res11.bmp delete mode 100644 examples/bmpsuite/g08res21.bmp delete mode 100644 examples/bmpsuite/g08res22.bmp delete mode 100644 examples/bmpsuite/g08rle.bmp delete mode 100644 examples/bmpsuite/g08s0.bmp delete mode 100644 examples/bmpsuite/g08w124.bmp delete mode 100644 examples/bmpsuite/g08w125.bmp delete mode 100644 examples/bmpsuite/g08w126.bmp delete mode 100644 examples/bmpsuite/g16bf555.bmp delete mode 100644 examples/bmpsuite/g16bf565.bmp delete mode 100644 examples/bmpsuite/g16def555.bmp delete mode 100644 examples/bmpsuite/g24.bmp delete mode 100644 examples/bmpsuite/g32bf.bmp delete mode 100644 examples/bmpsuite/g32def.bmp delete mode 100644 examples/bmpsuite/png/01bg.png delete mode 100644 examples/bmpsuite/png/01bw.png delete mode 100644 examples/bmpsuite/png/01p1.png delete mode 100644 examples/bmpsuite/png/04.png delete mode 100644 examples/bmpsuite/png/04p4.png delete mode 100644 examples/bmpsuite/png/08.png delete mode 100644 examples/bmpsuite/png/08p64.png delete mode 100644 examples/bmpsuite/png/08w124.png delete mode 100644 examples/bmpsuite/png/08w125.png delete mode 100644 examples/bmpsuite/png/08w126.png delete mode 100644 examples/bmpsuite/png/16bf555.png delete mode 100644 examples/bmpsuite/png/16bf565.png delete mode 100644 examples/bmpsuite/png/24.png delete mode 100644 examples/bmpsuite/png/reference.html delete mode 100644 examples/bmpsuite/readme.txt delete mode 100644 examples/bmpsuite/test.html delete mode 100644 examples/decode_bmp.c delete mode 100644 examples/decode_ico.c create mode 100755 examples/ico_display delete mode 100644 examples/monitor.ico delete mode 100755 ico_display create mode 100644 test/Makefile create mode 100644 test/bmpsuite/g01bg.bmp create mode 100644 test/bmpsuite/g01bw.bmp create mode 100644 test/bmpsuite/g01p1.bmp create mode 100644 test/bmpsuite/g01wb.bmp create mode 100644 test/bmpsuite/g04.bmp create mode 100644 test/bmpsuite/g04p4.bmp create mode 100644 test/bmpsuite/g04rle.bmp create mode 100644 test/bmpsuite/g08.bmp create mode 100644 test/bmpsuite/g08offs.bmp create mode 100644 test/bmpsuite/g08os2.bmp create mode 100644 test/bmpsuite/g08p256.bmp create mode 100644 test/bmpsuite/g08p64.bmp create mode 100644 test/bmpsuite/g08pi256.bmp create mode 100644 test/bmpsuite/g08pi64.bmp create mode 100644 test/bmpsuite/g08res11.bmp create mode 100644 test/bmpsuite/g08res21.bmp create mode 100644 test/bmpsuite/g08res22.bmp create mode 100644 test/bmpsuite/g08rle.bmp create mode 100644 test/bmpsuite/g08s0.bmp create mode 100644 test/bmpsuite/g08w124.bmp create mode 100644 test/bmpsuite/g08w125.bmp create mode 100644 test/bmpsuite/g08w126.bmp create mode 100644 test/bmpsuite/g16bf555.bmp create mode 100644 test/bmpsuite/g16bf565.bmp create mode 100644 test/bmpsuite/g16def555.bmp create mode 100644 test/bmpsuite/g24.bmp create mode 100644 test/bmpsuite/g32bf.bmp create mode 100644 test/bmpsuite/g32def.bmp create mode 100644 test/bmpsuite/png/01bg.png create mode 100644 test/bmpsuite/png/01bw.png create mode 100644 test/bmpsuite/png/01p1.png create mode 100644 test/bmpsuite/png/04.png create mode 100644 test/bmpsuite/png/04p4.png create mode 100644 test/bmpsuite/png/08.png create mode 100644 test/bmpsuite/png/08p64.png create mode 100644 test/bmpsuite/png/08w124.png create mode 100644 test/bmpsuite/png/08w125.png create mode 100644 test/bmpsuite/png/08w126.png create mode 100644 test/bmpsuite/png/16bf555.png create mode 100644 test/bmpsuite/png/16bf565.png create mode 100644 test/bmpsuite/png/24.png create mode 100644 test/bmpsuite/png/reference.html create mode 100644 test/bmpsuite/readme.txt create mode 100644 test/bmpsuite/test.html create mode 100644 test/decode_bmp.c create mode 100644 test/decode_ico.c create mode 100644 test/icons/monitor.ico create mode 100755 test/runtest.sh diff --git a/Makefile b/Makefile index 5837e5d..3250af7 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ PREFIX ?= /opt/netsurf NSSHARED ?= $(PREFIX)/share/netsurf-buildsystem include $(NSSHARED)/makefiles/Makefile.tools +# Reevaluate when used, as BUILDDIR won't be defined yet +TESTRUNNER = test/runtest.sh $(BUILDDIR) $(EXEEXT) + # Toolchain flags WARNFLAGS := -Wall -W -Wundef -Wpointer-arith -Wcast-align \ -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ @@ -34,6 +37,9 @@ else CFLAGS := $(CFLAGS) -Dinline="__inline__" endif +TESTCFLAGS := -g -O2 +TESTLDFLAGS := -lm -l$(COMPONENT) $(TESTLDFLAGS) + include $(NSBUILD)/Makefile.top # Extra installation rules diff --git a/bmp_display b/bmp_display deleted file mode 100755 index dd0458c..0000000 --- a/bmp_display +++ /dev/null @@ -1,3 +0,0 @@ -set -e -make -bin/decode_bmp $1 | display diff --git a/examples/bmp_display b/examples/bmp_display new file mode 100755 index 0000000..dd0458c --- /dev/null +++ b/examples/bmp_display @@ -0,0 +1,3 @@ +set -e +make +bin/decode_bmp $1 | display diff --git a/examples/bmpsuite/g01bg.bmp b/examples/bmpsuite/g01bg.bmp deleted file mode 100644 index a720347..0000000 Binary files a/examples/bmpsuite/g01bg.bmp and /dev/null differ diff --git a/examples/bmpsuite/g01bw.bmp b/examples/bmpsuite/g01bw.bmp deleted file mode 100644 index 06189a6..0000000 Binary files a/examples/bmpsuite/g01bw.bmp and /dev/null differ diff --git a/examples/bmpsuite/g01p1.bmp b/examples/bmpsuite/g01p1.bmp deleted file mode 100644 index 706b4a1..0000000 Binary files a/examples/bmpsuite/g01p1.bmp and /dev/null differ diff --git a/examples/bmpsuite/g01wb.bmp b/examples/bmpsuite/g01wb.bmp deleted file mode 100644 index 2f05b43..0000000 Binary files a/examples/bmpsuite/g01wb.bmp and /dev/null differ diff --git a/examples/bmpsuite/g04.bmp b/examples/bmpsuite/g04.bmp deleted file mode 100644 index a064f66..0000000 Binary files a/examples/bmpsuite/g04.bmp and /dev/null differ diff --git a/examples/bmpsuite/g04p4.bmp b/examples/bmpsuite/g04p4.bmp deleted file mode 100644 index 4c1096b..0000000 Binary files a/examples/bmpsuite/g04p4.bmp and /dev/null differ diff --git a/examples/bmpsuite/g04rle.bmp b/examples/bmpsuite/g04rle.bmp deleted file mode 100644 index 7239fa6..0000000 Binary files a/examples/bmpsuite/g04rle.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08.bmp b/examples/bmpsuite/g08.bmp deleted file mode 100644 index 3be9a20..0000000 Binary files a/examples/bmpsuite/g08.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08offs.bmp b/examples/bmpsuite/g08offs.bmp deleted file mode 100644 index 71def41..0000000 Binary files a/examples/bmpsuite/g08offs.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08os2.bmp b/examples/bmpsuite/g08os2.bmp deleted file mode 100644 index f7f9f57..0000000 Binary files a/examples/bmpsuite/g08os2.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08p256.bmp b/examples/bmpsuite/g08p256.bmp deleted file mode 100644 index a129bbc..0000000 Binary files a/examples/bmpsuite/g08p256.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08p64.bmp b/examples/bmpsuite/g08p64.bmp deleted file mode 100644 index 9d3affd..0000000 Binary files a/examples/bmpsuite/g08p64.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08pi256.bmp b/examples/bmpsuite/g08pi256.bmp deleted file mode 100644 index 45df3f8..0000000 Binary files a/examples/bmpsuite/g08pi256.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08pi64.bmp b/examples/bmpsuite/g08pi64.bmp deleted file mode 100644 index 52baf91..0000000 Binary files a/examples/bmpsuite/g08pi64.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08res11.bmp b/examples/bmpsuite/g08res11.bmp deleted file mode 100644 index f03d0f3..0000000 Binary files a/examples/bmpsuite/g08res11.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08res21.bmp b/examples/bmpsuite/g08res21.bmp deleted file mode 100644 index 61198e5..0000000 Binary files a/examples/bmpsuite/g08res21.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08res22.bmp b/examples/bmpsuite/g08res22.bmp deleted file mode 100644 index 1af0ecc..0000000 Binary files a/examples/bmpsuite/g08res22.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08rle.bmp b/examples/bmpsuite/g08rle.bmp deleted file mode 100644 index 082f7f4..0000000 Binary files a/examples/bmpsuite/g08rle.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08s0.bmp b/examples/bmpsuite/g08s0.bmp deleted file mode 100644 index 4b2c521..0000000 Binary files a/examples/bmpsuite/g08s0.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08w124.bmp b/examples/bmpsuite/g08w124.bmp deleted file mode 100644 index 1896035..0000000 Binary files a/examples/bmpsuite/g08w124.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08w125.bmp b/examples/bmpsuite/g08w125.bmp deleted file mode 100644 index b348a7c..0000000 Binary files a/examples/bmpsuite/g08w125.bmp and /dev/null differ diff --git a/examples/bmpsuite/g08w126.bmp b/examples/bmpsuite/g08w126.bmp deleted file mode 100644 index 3628d66..0000000 Binary files a/examples/bmpsuite/g08w126.bmp and /dev/null differ diff --git a/examples/bmpsuite/g16bf555.bmp b/examples/bmpsuite/g16bf555.bmp deleted file mode 100644 index 639a57f..0000000 Binary files a/examples/bmpsuite/g16bf555.bmp and /dev/null differ diff --git a/examples/bmpsuite/g16bf565.bmp b/examples/bmpsuite/g16bf565.bmp deleted file mode 100644 index cb0ea24..0000000 Binary files a/examples/bmpsuite/g16bf565.bmp and /dev/null differ diff --git a/examples/bmpsuite/g16def555.bmp b/examples/bmpsuite/g16def555.bmp deleted file mode 100644 index a5a3195..0000000 Binary files a/examples/bmpsuite/g16def555.bmp and /dev/null differ diff --git a/examples/bmpsuite/g24.bmp b/examples/bmpsuite/g24.bmp deleted file mode 100644 index d6d9e6a..0000000 Binary files a/examples/bmpsuite/g24.bmp and /dev/null differ diff --git a/examples/bmpsuite/g32bf.bmp b/examples/bmpsuite/g32bf.bmp deleted file mode 100644 index 0f41534..0000000 Binary files a/examples/bmpsuite/g32bf.bmp and /dev/null differ diff --git a/examples/bmpsuite/g32def.bmp b/examples/bmpsuite/g32def.bmp deleted file mode 100644 index 9524f76..0000000 Binary files a/examples/bmpsuite/g32def.bmp and /dev/null differ diff --git a/examples/bmpsuite/png/01bg.png b/examples/bmpsuite/png/01bg.png deleted file mode 100644 index 0b9cf9a..0000000 Binary files a/examples/bmpsuite/png/01bg.png and /dev/null differ diff --git a/examples/bmpsuite/png/01bw.png b/examples/bmpsuite/png/01bw.png deleted file mode 100644 index 9f2e57a..0000000 Binary files a/examples/bmpsuite/png/01bw.png and /dev/null differ diff --git a/examples/bmpsuite/png/01p1.png b/examples/bmpsuite/png/01p1.png deleted file mode 100644 index 0103e79..0000000 Binary files a/examples/bmpsuite/png/01p1.png and /dev/null differ diff --git a/examples/bmpsuite/png/04.png b/examples/bmpsuite/png/04.png deleted file mode 100644 index 14beb91..0000000 Binary files a/examples/bmpsuite/png/04.png and /dev/null differ diff --git a/examples/bmpsuite/png/04p4.png b/examples/bmpsuite/png/04p4.png deleted file mode 100644 index 8dbcafa..0000000 Binary files a/examples/bmpsuite/png/04p4.png and /dev/null differ diff --git a/examples/bmpsuite/png/08.png b/examples/bmpsuite/png/08.png deleted file mode 100644 index 06545a0..0000000 Binary files a/examples/bmpsuite/png/08.png and /dev/null differ diff --git a/examples/bmpsuite/png/08p64.png b/examples/bmpsuite/png/08p64.png deleted file mode 100644 index 49f0802..0000000 Binary files a/examples/bmpsuite/png/08p64.png and /dev/null differ diff --git a/examples/bmpsuite/png/08w124.png b/examples/bmpsuite/png/08w124.png deleted file mode 100644 index 8da58fb..0000000 Binary files a/examples/bmpsuite/png/08w124.png and /dev/null differ diff --git a/examples/bmpsuite/png/08w125.png b/examples/bmpsuite/png/08w125.png deleted file mode 100644 index 6ebb4f8..0000000 Binary files a/examples/bmpsuite/png/08w125.png and /dev/null differ diff --git a/examples/bmpsuite/png/08w126.png b/examples/bmpsuite/png/08w126.png deleted file mode 100644 index ca9c9b9..0000000 Binary files a/examples/bmpsuite/png/08w126.png and /dev/null differ diff --git a/examples/bmpsuite/png/16bf555.png b/examples/bmpsuite/png/16bf555.png deleted file mode 100644 index aaa0dff..0000000 Binary files a/examples/bmpsuite/png/16bf555.png and /dev/null differ diff --git a/examples/bmpsuite/png/16bf565.png b/examples/bmpsuite/png/16bf565.png deleted file mode 100644 index 52d90e3..0000000 Binary files a/examples/bmpsuite/png/16bf565.png and /dev/null differ diff --git a/examples/bmpsuite/png/24.png b/examples/bmpsuite/png/24.png deleted file mode 100644 index e9fc4db..0000000 Binary files a/examples/bmpsuite/png/24.png and /dev/null differ diff --git a/examples/bmpsuite/png/reference.html b/examples/bmpsuite/png/reference.html deleted file mode 100644 index 7117b6c..0000000 --- a/examples/bmpsuite/png/reference.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -BMP Suite Reference Images - - - -

BMP Suite Reference Images

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilebppCommentsReference
g01bw.bmp1black and white palette (#000000,#FFFFFF)
g01wb.bmp1white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.
g01bg.bmp1blue and green palette (#4040FF,#40FF40)
g01p1.bmp11-color (blue) palette (#4040FF)
g04.bmp4basic 4bpp (16 color) image
g04rle.bmp4RLE compressed.
g04p4.bmp44-color grayscale palette
g08.bmp8basic 8bpp (256 color) image
g08p256.bmp8biClrUsed=256, biClrImportant=0 [=256]
g08pi256.bmp8biClrUsed=256, biClrImportant=256
g08pi64.bmp8biClrUsed=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.
g08rle.bmp8RLE compressed.
g08os2.bmp8OS/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).
g08res22.bmp8resolution 7874x7874 pixels/meter (200x200 dpi)
g08res11.bmp8resolution 3937x3937 pixels/meter (100x100 dpi)
g08res21.bmp8resolution 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.
g08s0.bmp8bits size not given (set to 0). This is legal for uncompressed bitmaps.
g08offs.bmp8bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.
g08w126.bmp8size 126x63 (right and bottom slightly clipped)
g08w125.bmp8size 125x62
g08w124.bmp8size 124x61
g08p64.bmp864-color grayscale palette
g16def555.bmp1615-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)
g16bf555.bmp1615-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)
g16bf565.bmp1616-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)
g24.bmp2424-bit color (BGR)
g32def.bmp3224-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)
g32bf.bmp3224-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)
- -
-

By Jason Summers, -4/2001

- - - diff --git a/examples/bmpsuite/readme.txt b/examples/bmpsuite/readme.txt deleted file mode 100644 index 347aded..0000000 --- a/examples/bmpsuite/readme.txt +++ /dev/null @@ -1,38 +0,0 @@ -BMP Suite - sample BMP image files -By Jason Summers - -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/examples/bmpsuite/test.html b/examples/bmpsuite/test.html deleted file mode 100644 index 8abb614..0000000 --- a/examples/bmpsuite/test.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -BMP Suite Images - - - -

BMP Suite Images

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilebppCommentsImage
g01bw.bmp1black and white palette (#000000,#FFFFFF)
g01wb.bmp1white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.
g01bg.bmp1blue and green palette (#4040FF,#40FF40)
g01p1.bmp11-color (blue) palette (#4040FF)
g04.bmp4basic 4bpp (16 color) image
g04rle.bmp4RLE compressed.
g04p4.bmp44-color grayscale palette
g08.bmp8basic 8bpp (256 color) image
g08p256.bmp8biClrUsed=256, biClrImportant=0 [=256]
g08pi256.bmp8biClrUsed=256, biClrImportant=256
g08pi64.bmp8biClrUsed=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.
g08rle.bmp8RLE compressed.
g08os2.bmp8OS/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).
g08res22.bmp8resolution 7874x7874 pixels/meter (200x200 dpi)
g08res11.bmp8resolution 3937x3937 pixels/meter (100x100 dpi)
g08res21.bmp8resolution 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.
g08s0.bmp8bits size not given (set to 0). This is legal for uncompressed bitmaps.
g08offs.bmp8bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.
g08w126.bmp8size 126x63 (right and bottom slightly clipped)
g08w125.bmp8size 125x62
g08w124.bmp8size 124x61
g08p64.bmp864-color grayscale palette
g16def555.bmp1615-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)
g16bf555.bmp1615-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)
g16bf565.bmp1616-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)
g24.bmp2424-bit color (BGR)
g32def.bmp3224-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)
g32bf.bmp3224-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)
- -
-

By Jason Summers, -4/2001

- - - diff --git a/examples/decode_bmp.c b/examples/decode_bmp.c deleted file mode 100644 index e5dc572..0000000 --- a/examples/decode_bmp.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2008 Sean Fox - * Copyright 2008 James Bursa - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#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/examples/decode_ico.c b/examples/decode_ico.c deleted file mode 100644 index 935001c..0000000 --- a/examples/decode_ico.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2008 Sean Fox - * Copyright 2008 James Bursa - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#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/examples/ico_display b/examples/ico_display new file mode 100755 index 0000000..ff5cd3c --- /dev/null +++ b/examples/ico_display @@ -0,0 +1,3 @@ +set -e +make +bin/decode_ico $1 | display diff --git a/examples/monitor.ico b/examples/monitor.ico deleted file mode 100644 index 2997dc3..0000000 Binary files a/examples/monitor.ico and /dev/null differ diff --git a/ico_display b/ico_display deleted file mode 100755 index ff5cd3c..0000000 --- a/ico_display +++ /dev/null @@ -1,3 +0,0 @@ -set -e -make -bin/decode_ico $1 | display 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 Binary files /dev/null and b/test/bmpsuite/g01bg.bmp differ diff --git a/test/bmpsuite/g01bw.bmp b/test/bmpsuite/g01bw.bmp new file mode 100644 index 0000000..06189a6 Binary files /dev/null and b/test/bmpsuite/g01bw.bmp differ diff --git a/test/bmpsuite/g01p1.bmp b/test/bmpsuite/g01p1.bmp new file mode 100644 index 0000000..706b4a1 Binary files /dev/null and b/test/bmpsuite/g01p1.bmp differ diff --git a/test/bmpsuite/g01wb.bmp b/test/bmpsuite/g01wb.bmp new file mode 100644 index 0000000..2f05b43 Binary files /dev/null and b/test/bmpsuite/g01wb.bmp differ diff --git a/test/bmpsuite/g04.bmp b/test/bmpsuite/g04.bmp new file mode 100644 index 0000000..a064f66 Binary files /dev/null and b/test/bmpsuite/g04.bmp differ diff --git a/test/bmpsuite/g04p4.bmp b/test/bmpsuite/g04p4.bmp new file mode 100644 index 0000000..4c1096b Binary files /dev/null and b/test/bmpsuite/g04p4.bmp differ diff --git a/test/bmpsuite/g04rle.bmp b/test/bmpsuite/g04rle.bmp new file mode 100644 index 0000000..7239fa6 Binary files /dev/null and b/test/bmpsuite/g04rle.bmp differ diff --git a/test/bmpsuite/g08.bmp b/test/bmpsuite/g08.bmp new file mode 100644 index 0000000..3be9a20 Binary files /dev/null and b/test/bmpsuite/g08.bmp differ diff --git a/test/bmpsuite/g08offs.bmp b/test/bmpsuite/g08offs.bmp new file mode 100644 index 0000000..71def41 Binary files /dev/null and b/test/bmpsuite/g08offs.bmp differ diff --git a/test/bmpsuite/g08os2.bmp b/test/bmpsuite/g08os2.bmp new file mode 100644 index 0000000..f7f9f57 Binary files /dev/null and b/test/bmpsuite/g08os2.bmp differ diff --git a/test/bmpsuite/g08p256.bmp b/test/bmpsuite/g08p256.bmp new file mode 100644 index 0000000..a129bbc Binary files /dev/null and b/test/bmpsuite/g08p256.bmp differ diff --git a/test/bmpsuite/g08p64.bmp b/test/bmpsuite/g08p64.bmp new file mode 100644 index 0000000..9d3affd Binary files /dev/null and b/test/bmpsuite/g08p64.bmp differ diff --git a/test/bmpsuite/g08pi256.bmp b/test/bmpsuite/g08pi256.bmp new file mode 100644 index 0000000..45df3f8 Binary files /dev/null and b/test/bmpsuite/g08pi256.bmp differ diff --git a/test/bmpsuite/g08pi64.bmp b/test/bmpsuite/g08pi64.bmp new file mode 100644 index 0000000..52baf91 Binary files /dev/null and b/test/bmpsuite/g08pi64.bmp differ diff --git a/test/bmpsuite/g08res11.bmp b/test/bmpsuite/g08res11.bmp new file mode 100644 index 0000000..f03d0f3 Binary files /dev/null and b/test/bmpsuite/g08res11.bmp differ diff --git a/test/bmpsuite/g08res21.bmp b/test/bmpsuite/g08res21.bmp new file mode 100644 index 0000000..61198e5 Binary files /dev/null and b/test/bmpsuite/g08res21.bmp differ diff --git a/test/bmpsuite/g08res22.bmp b/test/bmpsuite/g08res22.bmp new file mode 100644 index 0000000..1af0ecc Binary files /dev/null and b/test/bmpsuite/g08res22.bmp differ diff --git a/test/bmpsuite/g08rle.bmp b/test/bmpsuite/g08rle.bmp new file mode 100644 index 0000000..082f7f4 Binary files /dev/null and b/test/bmpsuite/g08rle.bmp differ diff --git a/test/bmpsuite/g08s0.bmp b/test/bmpsuite/g08s0.bmp new file mode 100644 index 0000000..4b2c521 Binary files /dev/null and b/test/bmpsuite/g08s0.bmp differ diff --git a/test/bmpsuite/g08w124.bmp b/test/bmpsuite/g08w124.bmp new file mode 100644 index 0000000..1896035 Binary files /dev/null and b/test/bmpsuite/g08w124.bmp differ diff --git a/test/bmpsuite/g08w125.bmp b/test/bmpsuite/g08w125.bmp new file mode 100644 index 0000000..b348a7c Binary files /dev/null and b/test/bmpsuite/g08w125.bmp differ diff --git a/test/bmpsuite/g08w126.bmp b/test/bmpsuite/g08w126.bmp new file mode 100644 index 0000000..3628d66 Binary files /dev/null and b/test/bmpsuite/g08w126.bmp differ diff --git a/test/bmpsuite/g16bf555.bmp b/test/bmpsuite/g16bf555.bmp new file mode 100644 index 0000000..639a57f Binary files /dev/null and b/test/bmpsuite/g16bf555.bmp differ diff --git a/test/bmpsuite/g16bf565.bmp b/test/bmpsuite/g16bf565.bmp new file mode 100644 index 0000000..cb0ea24 Binary files /dev/null and b/test/bmpsuite/g16bf565.bmp differ diff --git a/test/bmpsuite/g16def555.bmp b/test/bmpsuite/g16def555.bmp new file mode 100644 index 0000000..a5a3195 Binary files /dev/null and b/test/bmpsuite/g16def555.bmp differ diff --git a/test/bmpsuite/g24.bmp b/test/bmpsuite/g24.bmp new file mode 100644 index 0000000..d6d9e6a Binary files /dev/null and b/test/bmpsuite/g24.bmp differ diff --git a/test/bmpsuite/g32bf.bmp b/test/bmpsuite/g32bf.bmp new file mode 100644 index 0000000..0f41534 Binary files /dev/null and b/test/bmpsuite/g32bf.bmp differ diff --git a/test/bmpsuite/g32def.bmp b/test/bmpsuite/g32def.bmp new file mode 100644 index 0000000..9524f76 Binary files /dev/null and b/test/bmpsuite/g32def.bmp differ diff --git a/test/bmpsuite/png/01bg.png b/test/bmpsuite/png/01bg.png new file mode 100644 index 0000000..0b9cf9a Binary files /dev/null and b/test/bmpsuite/png/01bg.png differ diff --git a/test/bmpsuite/png/01bw.png b/test/bmpsuite/png/01bw.png new file mode 100644 index 0000000..9f2e57a Binary files /dev/null and b/test/bmpsuite/png/01bw.png differ diff --git a/test/bmpsuite/png/01p1.png b/test/bmpsuite/png/01p1.png new file mode 100644 index 0000000..0103e79 Binary files /dev/null and b/test/bmpsuite/png/01p1.png differ diff --git a/test/bmpsuite/png/04.png b/test/bmpsuite/png/04.png new file mode 100644 index 0000000..14beb91 Binary files /dev/null and b/test/bmpsuite/png/04.png differ diff --git a/test/bmpsuite/png/04p4.png b/test/bmpsuite/png/04p4.png new file mode 100644 index 0000000..8dbcafa Binary files /dev/null and b/test/bmpsuite/png/04p4.png differ diff --git a/test/bmpsuite/png/08.png b/test/bmpsuite/png/08.png new file mode 100644 index 0000000..06545a0 Binary files /dev/null and b/test/bmpsuite/png/08.png differ diff --git a/test/bmpsuite/png/08p64.png b/test/bmpsuite/png/08p64.png new file mode 100644 index 0000000..49f0802 Binary files /dev/null and b/test/bmpsuite/png/08p64.png differ diff --git a/test/bmpsuite/png/08w124.png b/test/bmpsuite/png/08w124.png new file mode 100644 index 0000000..8da58fb Binary files /dev/null and b/test/bmpsuite/png/08w124.png differ diff --git a/test/bmpsuite/png/08w125.png b/test/bmpsuite/png/08w125.png new file mode 100644 index 0000000..6ebb4f8 Binary files /dev/null and b/test/bmpsuite/png/08w125.png differ diff --git a/test/bmpsuite/png/08w126.png b/test/bmpsuite/png/08w126.png new file mode 100644 index 0000000..ca9c9b9 Binary files /dev/null and b/test/bmpsuite/png/08w126.png differ diff --git a/test/bmpsuite/png/16bf555.png b/test/bmpsuite/png/16bf555.png new file mode 100644 index 0000000..aaa0dff Binary files /dev/null and b/test/bmpsuite/png/16bf555.png differ diff --git a/test/bmpsuite/png/16bf565.png b/test/bmpsuite/png/16bf565.png new file mode 100644 index 0000000..52d90e3 Binary files /dev/null and b/test/bmpsuite/png/16bf565.png differ diff --git a/test/bmpsuite/png/24.png b/test/bmpsuite/png/24.png new file mode 100644 index 0000000..e9fc4db Binary files /dev/null and b/test/bmpsuite/png/24.png 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 @@ + + + +BMP Suite Reference Images + + + +

BMP Suite Reference Images

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilebppCommentsReference
g01bw.bmp1black and white palette (#000000,#FFFFFF)
g01wb.bmp1white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.
g01bg.bmp1blue and green palette (#4040FF,#40FF40)
g01p1.bmp11-color (blue) palette (#4040FF)
g04.bmp4basic 4bpp (16 color) image
g04rle.bmp4RLE compressed.
g04p4.bmp44-color grayscale palette
g08.bmp8basic 8bpp (256 color) image
g08p256.bmp8biClrUsed=256, biClrImportant=0 [=256]
g08pi256.bmp8biClrUsed=256, biClrImportant=256
g08pi64.bmp8biClrUsed=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.
g08rle.bmp8RLE compressed.
g08os2.bmp8OS/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).
g08res22.bmp8resolution 7874x7874 pixels/meter (200x200 dpi)
g08res11.bmp8resolution 3937x3937 pixels/meter (100x100 dpi)
g08res21.bmp8resolution 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.
g08s0.bmp8bits size not given (set to 0). This is legal for uncompressed bitmaps.
g08offs.bmp8bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.
g08w126.bmp8size 126x63 (right and bottom slightly clipped)
g08w125.bmp8size 125x62
g08w124.bmp8size 124x61
g08p64.bmp864-color grayscale palette
g16def555.bmp1615-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)
g16bf555.bmp1615-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)
g16bf565.bmp1616-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)
g24.bmp2424-bit color (BGR)
g32def.bmp3224-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)
g32bf.bmp3224-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)
+ +
+

By Jason Summers, +4/2001

+ + + 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 + +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 @@ + + + +BMP Suite Images + + + +

BMP Suite Images

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilebppCommentsImage
g01bw.bmp1black and white palette (#000000,#FFFFFF)
g01wb.bmp1white and black palette (#FFFFFF,#000000). Should look the same as g01bw, not inverted.
g01bg.bmp1blue and green palette (#4040FF,#40FF40)
g01p1.bmp11-color (blue) palette (#4040FF)
g04.bmp4basic 4bpp (16 color) image
g04rle.bmp4RLE compressed.
g04p4.bmp44-color grayscale palette
g08.bmp8basic 8bpp (256 color) image
g08p256.bmp8biClrUsed=256, biClrImportant=0 [=256]
g08pi256.bmp8biClrUsed=256, biClrImportant=256
g08pi64.bmp8biClrUsed=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.
g08rle.bmp8RLE compressed.
g08os2.bmp8OS/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).
g08res22.bmp8resolution 7874x7874 pixels/meter (200x200 dpi)
g08res11.bmp8resolution 3937x3937 pixels/meter (100x100 dpi)
g08res21.bmp8resolution 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.
g08s0.bmp8bits size not given (set to 0). This is legal for uncompressed bitmaps.
g08offs.bmp8bfOffBits in header not set to the usual value. There are 100 extra unused bytes between palette and bits.
g08w126.bmp8size 126x63 (right and bottom slightly clipped)
g08w125.bmp8size 125x62
g08w124.bmp8size 124x61
g08p64.bmp864-color grayscale palette
g16def555.bmp1615-bit color (1 bit wasted), biCompression=BI_RGB (no bitfields, defaults to 5-5-5)
g16bf555.bmp1615-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-5-5)
g16bf565.bmp1616-bit color, biCompression=BI_BITFIELDS (bitfields indicate 5-6-5)
g24.bmp2424-bit color (BGR)
g32def.bmp3224-bit color (8 bits wasted), biCompression=BI_RGB (no bitfields, defaults to BGRx)
g32bf.bmp3224-bit color (8 bits wasted), biCompression=BI_BITFIELDS (bitfields indicate BGRx)
+ +
+

By Jason Summers, +4/2001

+ + + 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 + * Copyright 2008 James Bursa + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#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 + * Copyright 2008 James Bursa + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#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 Binary files /dev/null and b/test/icons/monitor.ico 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 -- cgit v1.2.3