1 # Copyright © 2013, 2021 Nick Bowler
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 AT_BANNER([Image format tests])
18 m4_divert_push([PREPARE_TESTS])dnl
19 # Read the header from a PAM image (from standard input) and set declared
20 # parameters in shell variables. For example, if the PAM header specifies
21 # DEPTH 2, the shell variable pam_DEPTH will be set to 2.
23 # Returns a nonzero status if the header could not be parsed.
26 pam_p7_seen=false pam_endhdr_seen=false
31 $pam_p7_seen && break # duplicated header
39 IFS=$pam_save_IFS read b c <<EOF
43 AS_VAR_SET([pam_$b], [$c])
49 $pam_p7_seen && $pam_endhdr_seen
55 AS_UNSET([pam_$pam_arg])
58 pam_read_header || return
62 AS_VAR_SET_IF([pam_$pam_arg],
63 [AS_VAR_COPY([pam_val], [pam_$pam_arg])],
64 [AS_UNSET([pam_val])])
65 AS_ECHO(["$pam_arg${pam_val+ = }${pam_val- unset}"])
68 m4_divert_pop([PREPARE_TESTS])
70 AT_SETUP([Empty image])
72 AT_CHECK([lbximg -F pbm -dnf "$testdata/image-0x0" && cat out.000.pbm], [0],
79 AT_SETUP([PAM output format (no palette)])
81 # image-1x1 (no palette)
82 AT_CHECK([lbximg -F pam -dnf "$testdata/image-1x1"])
83 AT_CHECK([pam_check_header WIDTH HEIGHT DEPTH TUPLTYPE <out.000.pam], [0],
92 AT_SETUP([PAM output format (no palette + transparency)])
94 # image-1x1 (no palette)
95 AT_CHECK([lbximg -F pam -dnf "$testdata/image-1x1-mt"])
96 AT_CHECK([pam_check_header WIDTH HEIGHT DEPTH TUPLTYPE <out.000.pam], [0],
100 TUPLTYPE = GRAYSCALE_ALPHA
105 AT_SETUP([PAM output format (palette)])
107 # image-1x1 (no palette)
108 AT_CHECK([lbximg -F pam -df "$testdata/image-1x1" \
109 -p "$testdata/palette-ramp"])
110 AT_CHECK([pam_check_header WIDTH HEIGHT DEPTH TUPLTYPE <out.000.pam], [0],
119 AT_SETUP([PAM output format (palette + transparency)])
121 # image-1x1 (no palette)
122 AT_CHECK([lbximg -F pam -df "$testdata/image-1x1-mt" \
123 -p "$testdata/palette-ramp"])
124 AT_CHECK([pam_check_header WIDTH HEIGHT DEPTH TUPLTYPE <out.000.pam], [0],