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
iccprofile: loadonly
Load an embedded ICC profile. (loadonly
is currently the only option, might addapply
in the future.)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.iccprofile: embed
Embeds the ICC profile into the BMP file. (profile must have been loaded using theiccprofile
option withloadbmp
.)intent: NONE|BUSINESS|GRAPHICS|IMAGES|ABS
Specify the rendering intent. (BUSINESS
=saturation,GRAPHICS
=relative colorimetric,IMAGES
=perceptive,ABS
=absolute colorimetric)loadraw
Immediately after writing, do aloadraw
of the written image.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.
loadraw { <dir>, <file> }
Load a raw file to make rawcompare
comparisons with known values. Raw files
are not pushed onto the image stack. There can only be one raw file loaded at a
time.
Alternatively, as a shortcut, loadraw
can be specified as an argument to savebmp
(s.a.). The result is the same as explicitly loading it with loadraw{}
.
rawcompare { <offset>, <size>, <bytes> }
Compare portions of the last file loaded with loadraw
against the specified
values. offset
and size
specify where in the file and how many bytes are to
be compared. bytes
is a string of hexadecimal numbers, e.g.:
rawcompare { 0, 2, 424d }
N.B.: No endianess conversion or interpretation of bytes in the raw file takes place. Bytes must be listed in the order which they have in the file.
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.