Testing framework for bmplib.
Requires sample files from J. Summers' BMP Suite.
Use the -f
command line option to specify a file which contains the
definitions of all tests to be run. (see --help
)
The test parser is very simplisitic, no quoting, escaping or even nesting. Leading and trailing white space around commands, options, and their values is ignored.
Every test consists of a series of commands. Tests are separated by blank lines.
Commands may be (but don't have to be) separated from each other with white space or semicolons.
Lines starting with '#' are comments. (Comment lines do not count as separators between tests.)
Example, defining two tests ("Load 8-bit indexed" and "Test HDR 64-bit"):
# simple test; load a BMP file and compare against a reference PNG
name{Load 8-bit indexed}
loadbmp{sample,g/pal8.bmp}; loadpng{ref,ref_8bit_252c.png}
compare{}
#
# more complicated test
#
name { Test HDR 64-bit }
#
# Load PNG and save as 64bit BMP with exposure +2
#
loadpng { ref, almdudler.png }
convertformat { float, 0 }
convertgamma { srgb, linear }
exposure { fstops: 2 }
savebmp { hdr-64bit.bmp, 64bit: yes }
#
# Reset exposure and convert to int8 and add alpha channel
#
exposure { fstops: -2 }
convertformat { int, 8 }
addalpha { }
#
# Load the 64bit BMP that we saved above
#
loadbmp { tmp, hdr-64bit.bmp, format: float, conv64: linear }
#
# Reset exposure and convert to int8, then compare with previous,
# allowing slight rounding differences with 'fuzz: 1'
#
exposure { fstops: -2 }
convertformat { int, 8 }
compare { fuzz: 1 }
Load a BMP image onto the image stack.
loadbmp{<dir>,<file>,...}
<dir>
must be one of the lables "sample", "ref", or "tmp". The actual path name is defined via command line options or environment variables (see--help
)<file>
the file name. May include subdirectories, e.g. "g/test.bmp".
line: whole|line
Whether to read the whole image at once, or line-by-line.rgb: rgb|index
Whether to load indexed images as RGB or index + palette.undef: alpha|leave
Whether to make undefined pixels in RLE images transparent. (adds an alpha channel to the loaded image)conv64: srgb|linear
How to convert (or not) 64bit gamma.format: int|float|s2.13
Specify number format for loaded image.insane: yes
Load images larger than bmplib's insanity limit.expect: <BMPRESULT>
Specify BMPRESULT error code to expect, e.g.expect: BMP_RESULT_PNG
huff-t4black: 0|1
Specify numerical value (index into color palette) that ITU-T T.4 "black" corresonds to.
Save the topmost image on the stack to a BMP file.
savebmp{<file>,...}
<file>
the file name. May include subdirectories, e.g. "abc/test.bmp".
format: int|float|s2.13
Number format used to supply image data to bmplib. Note: the image will be converted to the specified format before saving, and the converted image will be left on the stack. Use duplicate{}/delete{} to preserve the original. When specifyingformat:int
,bufferbits
must be set, as well.bufferbits: <n>
number of bits when specifyingformat:int
. Will otherwise be ignored.rle: auto|rle8|none
Which RLE compression to use.auto
selects one from RLE4, RLE8, RLE24, or Huffman-1D, depending on the supplied image data (and theallow
-option, see below).allow: huff|2bit|rle24
allow writing the respective compressions / pixel formats. Option may be repeated to allow more than one of the posibilites.huff-fgidx: 0|1
specify which color index in the image corresponds to the foreground color.outbits: r<n>g<n>b<n>a<n>
Specify the channel bit-depths for the BMP file. E.g.outbits: r10g10b10a0
to write a 32-bit BMP with RGBA channels 10-10-10 - 0.64bit:yes
write a 64bit BMP file.huff-t4black: 0|1
Specify numerical value (index into color palette) that ITU-T T.4 "black" corresonds to.
Load a PNG image onto the image stack.
loadpng{<dir>,<file>}
Compare the two topmost images on the stack. Test fails if images are not identical.
compare{fuzz: <n>}
fuzz: <n>
Allow a difference ofn
between pixel values.
Remove the top image from the stack.
delete{}
Swap the top two images on the stack.
swap{}
Duplicate the top image on the stack.
duplicate{}
Add an alpha channel (full opacity) to the top image on the stack.
addalpha{}
Convert the top image on the stack to the specified gamma curve.
convertgamma{<from>, <to>}
<from>
,<to>
may each be one ofsrgb
orlinear
Convert the top image on the stack to the specified number format.
convertformat{<format>, <bits>}
<format>
May be one ofint
,float
,s2.13
.<bits>
Only needed forint
format, otherwise ignored. Must be one of 8, 16, 32.
Convert the top image on the stack from indexed to 8-bit RGB.
flatten{}
Change the exposure (brightness) for the top image on the stack.
exposure{fstops: <f>}
fstops: <f>
Positive or negative floating point number.