makepngs.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/sh
  2. #
  3. # Make a set of test PNG files, MAKEPNG is the name of the makepng executable
  4. # built from contrib/libtests/makepng.c
  5. # Copyright (c) 2015 John Cunningham Bowler
  6. # Last changed in libpng 1.6.20 [December 3, 2015]
  7. # This code is released under the libpng license.
  8. # For conditions of distribution and use, see the disclaimer
  9. # and license in png.h
  10. # The arguments say whether to build all the files or whether just to build the
  11. # ones that extend the code-coverage of libpng from the existing test files in
  12. # contrib/pngsuite.
  13. test -n "$MAKEPNG" || MAKEPNG=./makepng
  14. opts=
  15. mp(){
  16. ${MAKEPNG} $opts $1 "$3" "$4" "$3-$4$2.png"
  17. }
  18. mpg(){
  19. if test "$1" = "none"
  20. then
  21. mp "" "" "$2" "$3"
  22. else
  23. mp "--$1" "-$1" "$2" "$3"
  24. fi
  25. }
  26. mptrans(){
  27. if test "$1" = "none"
  28. then
  29. mp "--tRNS" "-tRNS" "$2" "$3"
  30. else
  31. mp "--tRNS --$1" "-$1-tRNS" "$2" "$3"
  32. fi
  33. }
  34. case "$1" in
  35. --small)
  36. opts="--small";;&
  37. --all|--small)
  38. for g in none sRGB linear 1.8
  39. do
  40. for c in gray palette
  41. do
  42. for b in 1 2 4
  43. do
  44. mpg "$g" "$c" "$b"
  45. mptrans "$g" "$c" "$b"
  46. done
  47. done
  48. mpg "$g" palette 8
  49. mptrans "$g" palette 8
  50. for b in 8 16
  51. do
  52. for c in gray gray-alpha rgb rgb-alpha
  53. do
  54. mpg "$g" "$c" "$b"
  55. done
  56. for c in gray rgb
  57. do
  58. mptrans "$g" "$c" "$b"
  59. done
  60. done
  61. done;;
  62. --coverage)
  63. # Comments below indicate cases known to be required and not duplicated
  64. # in other (required) cases; the aim is to get a minimal set that gives
  65. # the maximum code coverage.
  66. mpg none gray-alpha 8 # required: code coverage, sRGB opaque component
  67. mpg none palette 8 # required: basic palette read
  68. mpg 1.8 gray 2 # required: tests gamma threshold code
  69. mpg 1.8 palette 2 # required: code coverage
  70. mpg 1.8 palette 4 # required: code coverage
  71. mpg 1.8 palette 8 # error limits only
  72. mpg linear palette 8 # error limits only
  73. mpg linear rgb-alpha 16 # error limits only
  74. mpg sRGB palette 1 # required: code coverage
  75. mpg sRGB rgb-alpha 16 # required: code coverage: pngread.c:2422 untested
  76. :;;
  77. *)
  78. echo "$0 $1: unknown argument, usage:" >&2
  79. echo " $0 [--all|--coverage|--small]" >&2
  80. exit 1
  81. esac