|
Packit |
78deda |
#! /bin/bash
|
|
Packit |
78deda |
# This script tests: ppmtorgb3 rgb3toppm
|
|
Packit |
78deda |
# Also requires: pgmtopbm pgmtopgm ppmtopgm
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Break an image into three monochrome planes, reassemble the
|
|
Packit |
78deda |
# image from them and check whether the resulting output is
|
|
Packit |
78deda |
# identical to the original input.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
tmpdir=${tmpdir:-/tmp}
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Test 1. PPM (color) input
|
|
Packit |
78deda |
testimg_ppm=${tmpdir}/testimg.ppm
|
|
Packit |
78deda |
testimg_red=${tmpdir}/testimg.red
|
|
Packit |
78deda |
testimg_grn=${tmpdir}/testimg.grn
|
|
Packit |
78deda |
testimg_blu=${tmpdir}/testimg.blu
|
|
Packit |
78deda |
|
|
Packit |
78deda |
cp testimg.ppm ${tmpdir} &&
|
|
Packit |
78deda |
ppmtorgb3 ${testimg_ppm} &&
|
|
Packit |
78deda |
rgb3toppm ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum
|
|
Packit |
78deda |
|
|
Packit |
78deda |
cat ${testimg_red} ${testimg_grn} ${testimg_blu} | cksum
|
|
Packit |
78deda |
|
|
Packit |
78deda |
rm ${testimg_ppm} ${testimg_red} ${testimg_grn} ${testimg_blu}
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Test 2. PBM (monochrome) input
|
|
Packit |
78deda |
testgrid_pbm=${tmpdir}/testgrid.pbm
|
|
Packit |
78deda |
testgrid_red=${tmpdir}/testgrid.red
|
|
Packit |
78deda |
testgrid_grn=${tmpdir}/testgrid.grn
|
|
Packit |
78deda |
testgrid_blu=${tmpdir}/testgrid.blu
|
|
Packit |
78deda |
|
|
Packit |
78deda |
cp testgrid.pbm ${tmpdir} &&
|
|
Packit |
78deda |
ppmtorgb3 ${testgrid_pbm} &&
|
|
Packit |
78deda |
rgb3toppm ${testgrid_red} ${testgrid_grn} ${testgrid_blu} | \
|
|
Packit |
78deda |
ppmtopgm | pgmtopbm -th -val=0.5 | cksum
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Test 3.
|
|
Packit |
78deda |
# With PGM or PBM input, the three monochrome planes should be
|
|
Packit |
78deda |
# identical. Test for this.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
cmp -s ${testgrid_red} ${testgrid_grn} ; echo $?
|
|
Packit |
78deda |
cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $?
|
|
Packit |
78deda |
pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red}
|
|
Packit |
78deda |
echo $?
|
|
Packit |
78deda |
|
|
Packit |
78deda |
rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu}
|