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, enclosed in a test { ... } block. A test description can be added in parentheses between the
test keyword and the opening curly brace, e.g.: test (Load a RGB24 file) { ... }
Commands may be (but don't have to be) separated from each other with any amount and type of white space.
Comments can be added with #.
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
test (Load 8-bit indexed) {
loadbmp {sample, g/pal8.bmp}
loadpng {ref, ref_8bit_252c.png}
compare {}
}
#
# more complicated test
#
test ( 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 } # results in values beyong [0..1] range
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|lineWhether to read the whole image at once, or line-by-line. -
rgb: rgb|indexWhether to load indexed images as RGB or index + palette. -
undef: alpha|leaveWhether to make undefined pixels in RLE images transparent. (alphaadds an alpha channel to the loaded image) -
conv64: srgb|linearHow to convert (or not) 64bit gamma. -
format: int|float|s2.13Specify number format for loaded image. -
insane: yesLoad images larger than bmplib's insanity limit. Must also specifyexpect: loadinfo=BMP_RESULT_INSANE. -
expect: <name>=<value>Specify result to expect from any of the bmplib calls made while loading a bmp file.namespecfies the call/operation,valueis the expected result. For the following calls,valuespecifies any of the BMPRESULT return codes:loadinfoarrayinfoloadiccset64bitsetformatloadpaletteloadimage
For these two,
valueis an integer value:numcolorsarraynum
E.g.:
expect: loadinfo=BMP_RESULT_INSANEorexpect: arraynum=3 -
iccprofile: loadonlyLoad an embedded ICC profile. (loadonlyis currently the only option, might addapplyin the future.) -
huff-t4black: 0|1Specify 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.
All files are witten to the directory specified by the --tmp command line
option or the BMPLIBTEST_TMPDIR environment variable.
savebmp { <file>, ... }
<file>the file name. May include subdirectories, e.g. "abc/test.bmp".
format: int|float|s2.13Number 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,bufferbitsmust be set, as well.bufferbits: <n>number of bits when specifyingformat:int. Will otherwise be ignored.rle: auto|rle8|noneWhich RLE compression to use.autoselects one from RLE4, RLE8, RLE24, or Huffman-1D, depending on the supplied image data (and theallow-option, see below).allow: huff|2bit|rle24allow writing the respective compressions / pixel formats. Option may be repeated to allow more than one of the posibilites.huff-fgidx: 0|1specify 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: r10g10b10a0to write a 32-bit BMP with RGBA channels 10-10-10 - 0.64bit:yeswrite a 64bit BMP file.iccprofile: embedEmbeds the ICC profile into the BMP file. (profile must have been loaded using theiccprofileoption withloadbmp.)intent: NONE|BUSINESS|GRAPHICS|IMAGES|ABSSpecify the rendering intent. (BUSINESS=saturation,GRAPHICS=relative colorimetric,IMAGES=perceptive,ABS=absolute colorimetric)loadrawImmediately after writing, do aloadrawof the written image.huff-t4black: 0|1Specify 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> }
<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.
Compare the two topmost images on the stack. Test fails if images are not identical.
compare { fuzz: <n> }
fuzz: <n>Allow a difference ofnbetween 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: <offset>, size: <size>, bytes: <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 { offset: 0, size: 2, bytes: 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: <gamma>, to: <gamma> }
from: <gamma>One ofsrgborlinearto: <gamma>One ofsrgborlinear
Convert the top image on the stack to the specified number format.
convertformat { format: <format>, bits: <bits> }
format: <format>May be one ofint,float,s2.13.bits: <bits>Only needed forintformat, 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.