about summary refs log tree commit diff
path: root/test/rgb3-roundtrip.test
blob: 9cc4549977c57ccb0d0e3c4b384ca6102c37f293 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /bin/bash
# This script tests: ppmtorgb3 rgb3toppm
# Also requires: pgmtopbm pgmtopgm ppmtopgm

# Break an image into three monochrome planes, reassemble the
# image from them and check whether the resulting output is
# identical to the original input.

cp testimg.ppm ${tmpdir} &&
${PBM_TESTPREFIX}ppmtorgb3 ${tmpdir}/testimg.ppm &&
${PBM_TESTPREFIX}rgb3toppm ${tmpdir}/testimg.red ${tmpdir}/testimg.grn \
  ${tmpdir}/testimg.blu | cksum

rm ${tmpdir}/testimg.{ppm,red,grn,blu}

cp testgrid.pbm ${tmpdir} &&
${PBM_TESTPREFIX}ppmtorgb3 ${tmpdir}/testgrid.pbm &&
${PBM_TESTPREFIX}rgb3toppm ${tmpdir}/testgrid.red ${tmpdir}/testgrid.grn \
  ${tmpdir}/testgrid.blu | \
  ${PBM_BINPREFIX}ppmtopgm | ${PBM_BINPREFIX}pgmtopbm -th -val=0.5 | cksum


# With PGM or PBM input, the three monochrome planes should be
# identical.  Test for this.

diff ${tmpdir}/testgrid.red ${tmpdir}/testgrid.grn ; echo $?
diff ${tmpdir}/testgrid.grn ${tmpdir}/testgrid.blu ; echo $?
${PBM_BINPREFIX}pgmtopgm < testgrid.pbm | diff - ${tmpdir}/testgrid.red;
  echo $?

rm ${tmpdir}/testgrid.{pbm,red,grn,blu}