summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/shellcheck.yml21
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml9
-rw-r--r--CHANGELOG.md164
-rw-r--r--CMakeLists.txt185
-rw-r--r--CODE_OF_CONDUCT.md46
-rw-r--r--CONTRIBUTING.md77
-rw-r--r--CONTRIBUTORS5
-rw-r--r--COPYING5
-rw-r--r--Makefile.am2
-rw-r--r--README.md15
-rw-r--r--VMS/CONFIGURE.COM1342
-rw-r--r--VMS/README.VMS71
-rw-r--r--appveyor.yml414
-rwxr-xr-xbootstrap.sh8
-rwxr-xr-xcmake/distclean.sh2
-rw-r--r--cmake/modules/AC_HEADER_STDC.cmake5
-rw-r--r--cmake/modules/CMakeParseArguments.cmake156
-rw-r--r--cmake/modules/CheckDIRSymbolExists.cmake16
-rw-r--r--cmake/modules/CheckPrototypeExists.cmake7
-rw-r--r--cmake/modules/FindFontConfig.cmake8
-rw-r--r--cmake/modules/FindFreetype.cmake128
-rw-r--r--cmake/modules/FindHEIF.cmake82
-rw-r--r--cmake/modules/FindICONV.cmake46
-rw-r--r--cmake/modules/FindLIQ.cmake38
-rw-r--r--cmake/modules/FindPNG.cmake93
-rw-r--r--cmake/modules/FindPTHREAD.cmake182
-rw-r--r--cmake/modules/FindPackageHandleStandardArgs.cmake317
-rw-r--r--cmake/modules/FindRAQM.cmake (renamed from cmake/modules/FindJPEG.cmake)67
-rw-r--r--cmake/modules/FindWEBP.cmake11
-rw-r--r--cmake/modules/FindXPM.cmake10
-rw-r--r--cmake/modules/TestForHighBitCharacters.c2
-rw-r--r--cmake/modules/TestForHighBitCharacters.cmake4
-rw-r--r--cmake/modules/gd.cmake7
-rw-r--r--config/Makefile.am2
-rw-r--r--config/gdlib.pc.cmake13
-rw-r--r--config/gdlib.pc.in4
-rwxr-xr-xconfig/getlib.sh42
-rwxr-xr-xconfig/getver.pl45
-rwxr-xr-xconfig/getver.sh48
-rw-r--r--configure.ac104
-rw-r--r--docs/ChangeLog.historic (renamed from ChangeLog)0
-rw-r--r--docs/INSTALL1
-rw-r--r--docs/NEWS.historic (renamed from NEWS)12
-rw-r--r--docs/README.CMAKE5
-rw-r--r--docs/README.JPN53
-rw-r--r--docs/README.TESTING10
-rw-r--r--docs/README.TXT2
-rw-r--r--docs/naturaldocs/nobgd.pl1
-rw-r--r--docs/naturaldocs/preamble.txt8
-rw-r--r--docs/naturaldocs/project/Menu.txt24
-rwxr-xr-xdocs/naturaldocs/run_docs.sh30
-rw-r--r--examples/CMakeLists.txt28
-rw-r--r--examples/arc.c5
-rw-r--r--examples/avif2jpeg.c55
-rw-r--r--examples/copyrotated.c5
-rw-r--r--examples/crop.c11
-rw-r--r--examples/flip.c1
-rw-r--r--examples/gif.c2
-rw-r--r--examples/jpeg2avif.c57
-rw-r--r--examples/jpeg2avifex.c98
-rw-r--r--examples/nnquant.c11
-rw-r--r--examples/png2avif.c58
-rw-r--r--examples/resize.c2
-rw-r--r--examples/tgaread.c7
-rw-r--r--examples/tiffread.c1
-rw-r--r--examples/windows.c1
-rw-r--r--m4/ax_append_flag.m433
-rw-r--r--m4/ax_cflags_warn_all.m46
-rw-r--r--m4/ax_pthread.m46
-rw-r--r--m4/ax_require_defined.m44
-rw-r--r--netware/Makefile.netware553
-rw-r--r--netware/get_exp.awk37
-rw-r--r--netware/get_ver.awk28
-rw-r--r--netware/keepscreen.c27
-rw-r--r--netware/nwlibc.c290
-rw-r--r--netware/tests/Makefile.netware285
-rw-r--r--src/CMakeLists.txt48
-rw-r--r--src/COPYING53
-rw-r--r--src/Makefile.am23
-rw-r--r--src/annotate.c46
-rwxr-xr-xsrc/bdftogd15
-rw-r--r--src/bmp.h11
-rw-r--r--src/circletexttest.c5
-rw-r--r--src/config.h.cmake24
-rw-r--r--src/entities.html26
-rw-r--r--src/fontconfigtest.c4
-rw-r--r--src/fontsizetest.c13
-rw-r--r--src/fontwheeltest.c6
-rw-r--r--src/gd.c95
-rw-r--r--src/gd.h172
-rw-r--r--src/gd2copypal.c1
-rw-r--r--src/gd2togif.c1
-rw-r--r--src/gd2topng.c5
-rw-r--r--src/gd_avif.c688
-rw-r--r--src/gd_bmp.c101
-rw-r--r--src/gd_color.c5
-rw-r--r--src/gd_color_match.c5
-rw-r--r--src/gd_crop.c140
-rw-r--r--src/gd_filename.c43
-rw-r--r--src/gd_filter.c28
-rw-r--r--src/gd_gd.c76
-rw-r--r--src/gd_gd2.c60
-rw-r--r--src/gd_gif_in.c35
-rw-r--r--src/gd_gif_out.c54
-rw-r--r--src/gd_heif.c584
-rw-r--r--src/gd_intern.h12
-rw-r--r--src/gd_interpolation.c188
-rw-r--r--src/gd_io.c20
-rw-r--r--src/gd_io.h25
-rw-r--r--src/gd_io_dp.c26
-rw-r--r--src/gd_io_stream.cxx15
-rw-r--r--src/gd_io_stream.h5
-rw-r--r--src/gd_jpeg.c93
-rw-r--r--src/gd_matrix.c5
-rw-r--r--src/gd_nnquant.c34
-rw-r--r--src/gd_nnquant.h3
-rw-r--r--src/gd_png.c108
-rw-r--r--src/gd_rotate.c179
-rw-r--r--src/gd_tga.c17
-rw-r--r--src/gd_tiff.c165
-rw-r--r--src/gd_topal.c17
-rw-r--r--src/gd_transform.c2
-rw-r--r--src/gd_wbmp.c23
-rw-r--r--src/gd_webp.c136
-rw-r--r--src/gd_xbm.c36
-rw-r--r--src/gdcache.c15
-rw-r--r--src/gdcache.h4
-rw-r--r--src/gdcmpgif.c2
-rw-r--r--src/gddemo.c5
-rw-r--r--src/gdfontg.c2
-rw-r--r--src/gdfontl.c2
-rw-r--r--src/gdfontmb.c2
-rw-r--r--src/gdfontt.c2
-rw-r--r--src/gdft.c119
-rw-r--r--src/gdfx.c5
-rw-r--r--src/gdfx.h11
-rw-r--r--src/gdhelpers.c2
-rw-r--r--src/gdhelpers.h10
-rw-r--r--src/gdkanji.c24
-rw-r--r--src/gdparttopng.c5
-rw-r--r--src/gdpp.cxx85
-rw-r--r--src/gdpp.h22
-rw-r--r--src/gdtables.c1
-rw-r--r--src/gdtest.c26
-rw-r--r--src/gdtestft.c18
-rw-r--r--src/gdtopng.c5
-rw-r--r--src/getopt.c129
-rw-r--r--src/gifanimtest.c1
-rw-r--r--src/giftogd2.c1
-rw-r--r--src/jisx0208.h8
-rw-r--r--src/msinttypes/inttypes.h18
-rw-r--r--src/msinttypes/stdint.h18
-rw-r--r--src/pngtogd.c4
-rw-r--r--src/pngtogd2.c6
-rw-r--r--src/snprintf.c25
-rw-r--r--src/testac.c9
-rw-r--r--src/testtr.c14
-rw-r--r--src/wbmp.c3
-rw-r--r--src/wbmp.h12
-rw-r--r--src/webpng.c12
-rw-r--r--tests/CMakeLists.txt18
-rw-r--r--tests/Makefile.am19
-rw-r--r--tests/avif/.gitignore5
-rw-r--r--tests/avif/CMakeLists.txt17
-rw-r--r--tests/avif/Makemodule.am24
-rw-r--r--tests/avif/avif_im2im.c67
-rw-r--r--tests/avif/avif_null.c23
-rw-r--r--tests/avif/avif_ptr_double_free.c34
-rw-r--r--tests/avif/baboon.avifbin0 -> 16521 bytes
-rw-r--r--tests/avif/baboon.pngbin0 -> 49030 bytes
-rw-r--r--tests/avif/bad_input.c57
-rw-r--r--tests/avif/compare_avif_to_png.c92
-rw-r--r--tests/avif/dice_with_alpha.avifbin0 -> 6248 bytes
-rw-r--r--tests/avif/dice_with_alpha.pngbin0 -> 48210 bytes
-rw-r--r--tests/avif/plum_blossom_12bit.avifbin0 -> 5202 bytes
-rw-r--r--tests/avif/plum_blossom_12bit.pngbin0 -> 10185 bytes
-rw-r--r--tests/avif/sunset.avifbin0 -> 1174 bytes
-rw-r--r--tests/avif/sunset.pngbin0 -> 47803 bytes
-rw-r--r--tests/bmp/.gitignore1
-rw-r--r--tests/bmp/CMakeLists.txt3
-rw-r--r--tests/bmp/Makemodule.am8
-rw-r--r--tests/bmp/bug00275.c4
-rw-r--r--tests/bmp/bug00276.c2
-rw-r--r--tests/bmp/bug00450.bmpbin0 -> 102 bytes
-rw-r--r--tests/bmp/bug00450.c40
-rw-r--r--tests/fontconfig/CMakeLists.txt6
-rw-r--r--tests/freetype/CMakeLists.txt2
-rw-r--r--tests/freetype/Makemodule.am2
-rw-r--r--tests/freetype/bug00132.c3
-rw-r--r--tests/gd/.gitignore1
-rw-r--r--tests/gd/CMakeLists.txt10
-rw-r--r--tests/gd/Makemodule.am8
-rw-r--r--tests/gd/bug00383.c32
-rw-r--r--tests/gd/bug00383.gdbin0 -> 1101 bytes
-rw-r--r--tests/gd2/.gitignore6
-rw-r--r--tests/gd2/CMakeLists.txt21
-rw-r--r--tests/gd2/Makemodule.am25
-rw-r--r--tests/gd2/bug00209.c26
-rw-r--r--tests/gd2/bug00209.gd2bin0 -> 1050 bytes
-rw-r--r--tests/gd2/bug00354.c30
-rw-r--r--tests/gd2/bug00354a.gd2bin0 -> 92 bytes
-rw-r--r--tests/gd2/bug00354b.gd2bin0 -> 18 bytes
-rw-r--r--tests/gd2/bug00383.c32
-rw-r--r--tests/gd2/bug00383.gd2bin0 -> 1113 bytes
-rw-r--r--tests/gd2/bug_289.c2
-rw-r--r--tests/gd2/createimagefromgd2part.c35
-rw-r--r--tests/gd2/createimagefromgd2partptr.c59
-rw-r--r--tests/gd2/gd2_read.c3
-rw-r--r--tests/gd2/php_bug_72339.c2
-rw-r--r--tests/gd2/too_few_image_data.c22
-rw-r--r--tests/gd2/too_few_image_data.gd2bin0 -> 1050 bytes
-rw-r--r--tests/gdimagearc/CMakeLists.txt2
-rw-r--r--tests/gdimagebrightness/CMakeLists.txt2
-rw-r--r--tests/gdimagebrightness/basic.c78
-rw-r--r--tests/gdimageclone/.gitignore1
-rw-r--r--tests/gdimageclone/CMakeLists.txt1
-rw-r--r--tests/gdimageclone/Makemodule.am3
-rw-r--r--tests/gdimageclone/style.c30
-rw-r--r--tests/gdimagecolor/CMakeLists.txt2
-rw-r--r--tests/gdimagecolor/basic.c56
-rw-r--r--tests/gdimagecolorclosest/Makemodule.am2
-rw-r--r--tests/gdimagecolorclosesthwb/.gitignore1
-rw-r--r--tests/gdimagecolorclosesthwb/CMakeLists.txt7
-rw-r--r--tests/gdimagecolorclosesthwb/Makemodule.am7
-rw-r--r--tests/gdimagecolorclosesthwb/gdImageColorClosestHWB.c26
-rw-r--r--tests/gdimagecolorexact/Makemodule.am2
-rw-r--r--tests/gdimagecolormatch/.gitignore2
-rw-r--r--tests/gdimagecolormatch/CMakeLists.txt6
-rw-r--r--tests/gdimagecolormatch/Makemodule.am6
-rw-r--r--tests/gdimagecolormatch/cve_2019_6977.c25
-rw-r--r--tests/gdimagecolormatch/gdimagecolormatch.c32
-rw-r--r--tests/gdimagecolorreplace/Makemodule.am2
-rw-r--r--tests/gdimagecolorresolve/Makemodule.am2
-rwxr-xr-xtests/gdimagecompare/.gitignore1
-rw-r--r--tests/gdimagecompare/CMakeLists.txt4
-rw-r--r--tests/gdimagecompare/Makemodule.am5
-rw-r--r--tests/gdimagecompare/gdimagecompare.c56
-rw-r--r--tests/gdimagecontrast/CMakeLists.txt2
-rw-r--r--tests/gdimagecontrast/basic.c78
-rw-r--r--tests/gdimageconvolution/.gitignore1
-rw-r--r--tests/gdimageconvolution/CMakeLists.txt4
-rw-r--r--tests/gdimageconvolution/Makemodule.am3
-rw-r--r--tests/gdimageconvolution/basic.c117
-rw-r--r--tests/gdimageconvolution/bug00369.c28
-rw-r--r--tests/gdimagecopy/CMakeLists.txt5
-rw-r--r--tests/gdimagecopymerge/.gitignore1
-rw-r--r--tests/gdimagecopymerge/CMakeLists.txt7
-rw-r--r--tests/gdimagecopymerge/Makemodule.am8
-rw-r--r--tests/gdimagecopymerge/gdimagecopymerge.c38
-rw-r--r--tests/gdimagecopymerge/gdimagecopymerge_exp.pngbin0 -> 124 bytes
-rw-r--r--tests/gdimagecopymergegray/.gitignore1
-rw-r--r--tests/gdimagecopymergegray/CMakeLists.txt7
-rw-r--r--tests/gdimagecopymergegray/Makemodule.am8
-rw-r--r--tests/gdimagecopymergegray/gdimagecopymergegray.c38
-rw-r--r--tests/gdimagecopymergegray/gdimagecopymergegray_exp.pngbin0 -> 124 bytes
-rw-r--r--tests/gdimagecopyresampled/CMakeLists.txt6
-rw-r--r--tests/gdimagecopyresampled/Makemodule.am4
-rw-r--r--tests/gdimagecopyresampled/bug00201.c8
-rw-r--r--tests/gdimagecopyresized/.gitignore1
-rw-r--r--tests/gdimagecopyresized/CMakeLists.txt7
-rw-r--r--tests/gdimagecopyresized/Makemodule.am8
-rw-r--r--tests/gdimagecopyresized/gdimagecopyresized.c35
-rw-r--r--tests/gdimagecopyresized/gdimagecopyresized_exp.pngbin0 -> 129 bytes
-rw-r--r--tests/gdimagecopyrotated/CMakeLists.txt2
-rw-r--r--tests/gdimagecreate/.gitignore1
-rw-r--r--tests/gdimagecreate/CMakeLists.txt5
-rw-r--r--tests/gdimagecreate/Makemodule.am5
-rw-r--r--tests/gdimagecreate/bug00340.c29
-rw-r--r--tests/gdimagecrop/.gitignore4
-rw-r--r--tests/gdimagecrop/CMakeLists.txt6
-rw-r--r--tests/gdimagecrop/Makemodule.am4
-rw-r--r--tests/gdimagecrop/bug00432.c45
-rw-r--r--tests/gdimagecrop/bug00485_auto.c52
-rw-r--r--tests/gdimagecrop/bug00485_threshold.c48
-rw-r--r--tests/gdimagecrop/bug00486.c48
-rw-r--r--tests/gdimageellipse/.gitignore1
-rw-r--r--tests/gdimageellipse/CMakeLists.txt7
-rw-r--r--tests/gdimageellipse/Makemodule.am8
-rw-r--r--tests/gdimageellipse/bug00169.c22
-rw-r--r--tests/gdimageellipse/bug00169_exp.pngbin0 -> 24802 bytes
-rw-r--r--tests/gdimagefile/CMakeLists.txt6
-rw-r--r--tests/gdimagefile/Makemodule.am6
-rw-r--r--tests/gdimagefile/gdnametest.c237
-rw-r--r--tests/gdimagefill/CMakeLists.txt2
-rw-r--r--tests/gdimagefill/bug00002_1.c1
-rw-r--r--tests/gdimagefill/bug00002_2.c1
-rw-r--r--tests/gdimagefill/bug00002_3.c1
-rw-r--r--tests/gdimagefill/bug00104_1.c10
-rw-r--r--tests/gdimagefilledarc/.gitignore1
-rw-r--r--tests/gdimagefilledarc/CMakeLists.txt3
-rw-r--r--tests/gdimagefilledarc/Makemodule.am2
-rw-r--r--tests/gdimagefilledarc/bug00351.c30
-rw-r--r--tests/gdimagefilledarc/bug00351_exp.pngbin0 -> 2652 bytes
-rw-r--r--tests/gdimagefilledellipse/.gitignore1
-rw-r--r--tests/gdimagefilledellipse/CMakeLists.txt3
-rw-r--r--tests/gdimagefilledellipse/Makemodule.am2
-rw-r--r--tests/gdimagefilledellipse/bug00169.c22
-rw-r--r--tests/gdimagefilledellipse/bug00169_exp.pngbin0 -> 27696 bytes
-rw-r--r--tests/gdimagefilledellipse/github_bug_00238.c2
-rw-r--r--tests/gdimagefilledpolygon/CMakeLists.txt2
-rw-r--r--tests/gdimagefilledpolygon/self_intersecting.c60
-rw-r--r--tests/gdimagefilledrectangle/bug00004.c1
-rw-r--r--tests/gdimagefilledrectangle/bug00078.c1
-rw-r--r--tests/gdimagefilledrectangle/bug00106_gdimagefilledrectangle.c1
-rw-r--r--tests/gdimagefilltoborder/Makemodule.am2
-rw-r--r--tests/gdimagefilltoborder/bug00037.c1
-rw-r--r--tests/gdimagefilter/gdCopyBlurred.c2
-rw-r--r--tests/gdimageflip/CMakeLists.txt2
-rw-r--r--tests/gdimageflip/gdimageflip.c71
-rw-r--r--tests/gdimagegrayscale/.gitignore1
-rw-r--r--tests/gdimagegrayscale/CMakeLists.txt3
-rw-r--r--tests/gdimagegrayscale/Makemodule.am6
-rw-r--r--tests/gdimagegrayscale/basic.c56
-rw-r--r--tests/gdimagegrayscale/bug00386.c53
-rw-r--r--tests/gdimagegrayscale/bug00386.pngbin0 -> 2436 bytes
-rw-r--r--tests/gdimageline/CMakeLists.txt14
-rw-r--r--tests/gdimageline/bug00315.c76
-rw-r--r--tests/gdimageline/gdimageline_bug5.c6
-rw-r--r--tests/gdimagenegate/CMakeLists.txt2
-rw-r--r--tests/gdimagenegate/basic.c56
-rw-r--r--tests/gdimageopenpolygon/CMakeLists.txt2
-rw-r--r--tests/gdimagepolygon/CMakeLists.txt2
-rw-r--r--tests/gdimagerectangle/CMakeLists.txt7
-rw-r--r--tests/gdimagerectangle/Makemodule.am6
-rw-r--r--tests/gdimagerotate/CMakeLists.txt2
-rw-r--r--tests/gdimagerotate/Makemodule.am6
-rw-r--r--tests/gdimagerotate/php_bug_65070.c68
-rw-r--r--tests/gdimagerotate/php_bug_65070_exp.pngbin32722 -> 32699 bytes
-rw-r--r--tests/gdimagescale/.gitignore2
-rw-r--r--tests/gdimagescale/CMakeLists.txt2
-rw-r--r--tests/gdimagescale/Makemodule.am3
-rw-r--r--tests/gdimagescale/bug00329.c50
-rw-r--r--tests/gdimagescale/bug00330.c30
-rw-r--r--tests/gdimagescale/bug_overflow_large_new_size.c3
-rw-r--r--tests/gdimagescatterex/CMakeLists.txt2
-rw-r--r--tests/gdimagesetinterpolationmethod/.gitignore1
-rw-r--r--tests/gdimagesetinterpolationmethod/CMakeLists.txt5
-rw-r--r--tests/gdimagesetinterpolationmethod/Makemodule.am5
-rw-r--r--tests/gdimagesetinterpolationmethod/github_bug_00584.c31
-rw-r--r--tests/gdimagesetpixel/CMakeLists.txt7
-rw-r--r--tests/gdimagesetpixel/Makemodule.am6
-rw-r--r--tests/gdimagesetpixel/alpha_blending.c106
-rw-r--r--tests/gdimagesquaretocircle/.gitignore1
-rw-r--r--tests/gdimagesquaretocircle/CMakeLists.txt7
-rw-r--r--tests/gdimagesquaretocircle/Makemodule.am8
-rw-r--r--tests/gdimagesquaretocircle/gdimagesquaretocircle.c32
-rw-r--r--tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.pngbin0 -> 1414 bytes
-rw-r--r--tests/gdimagestring/.gitignore1
-rw-r--r--tests/gdimagestring/CMakeLists.txt7
-rw-r--r--tests/gdimagestring/Makemodule.am8
-rw-r--r--tests/gdimagestring/gdimagestring.c34
-rw-r--r--tests/gdimagestring/gdimagestring_exp.pngbin0 -> 179 bytes
-rw-r--r--tests/gdimagestring16/.gitignore1
-rw-r--r--tests/gdimagestring16/CMakeLists.txt7
-rw-r--r--tests/gdimagestring16/Makemodule.am8
-rw-r--r--tests/gdimagestring16/gdimagestring16.c30
-rw-r--r--tests/gdimagestring16/gdimagestring16_exp.pngbin0 -> 118 bytes
-rw-r--r--tests/gdimagestringft/.gitignore1
-rw-r--r--tests/gdimagestringft/CMakeLists.txt1
-rw-r--r--tests/gdimagestringft/Makemodule.am1
-rw-r--r--tests/gdimagestringft/bug00615.c25
-rw-r--r--tests/gdimagestringft/gdimagestringft_bbox.c37
-rw-r--r--tests/gdimagestringup/.gitignore1
-rw-r--r--tests/gdimagestringup/CMakeLists.txt7
-rw-r--r--tests/gdimagestringup/Makemodule.am8
-rw-r--r--tests/gdimagestringup/gdimagestringup.c34
-rw-r--r--tests/gdimagestringup/gdimagestringup_exp.pngbin0 -> 180 bytes
-rw-r--r--tests/gdimagestringup16/.gitignore1
-rw-r--r--tests/gdimagestringup16/CMakeLists.txt7
-rw-r--r--tests/gdimagestringup16/Makemodule.am8
-rw-r--r--tests/gdimagestringup16/gdimagestringup16.c29
-rw-r--r--tests/gdimagestringup16/gdimagestringup16_exp.pngbin0 -> 117 bytes
-rw-r--r--tests/gdimagetruecolortopalette/CMakeLists.txt2
-rw-r--r--tests/gdimagetruecolortopalette/Makemodule.am1
-rw-r--r--tests/gdimagetruecolortopalette/bug00307.c2
-rw-r--r--tests/gdtest/CMakeLists.txt6
-rw-r--r--tests/gdtest/gdtest.c34
-rw-r--r--tests/gdtest/gdtest.h2
-rw-r--r--tests/gdtiled/CMakeLists.txt4
-rw-r--r--tests/gdtiled/bug00032.c1
-rw-r--r--tests/gdtransformaffineboundingbox/Makemodule.am1
-rw-r--r--tests/gdtransformaffineboundingbox/github_bug_00221.c4
-rw-r--r--tests/gdtransformaffinecopy/.gitignore4
-rw-r--r--tests/gdtransformaffinecopy/CMakeLists.txt8
-rw-r--r--tests/gdtransformaffinecopy/Makemodule.am8
-rw-r--r--tests/gdtransformaffinecopy/github_bug_00583.c30
-rw-r--r--tests/gdtransformaffinecopy/github_bug_00585.c33
-rw-r--r--tests/gdtransformaffinecopy/github_bug_00586.c26
-rw-r--r--tests/gdtransformaffinecopy/github_bug_00596.c42
-rw-r--r--tests/gif/.gitignore5
-rw-r--r--tests/gif/CMakeLists.txt20
-rw-r--r--tests/gif/Makemodule.am21
-rw-r--r--tests/gif/bug00006.c5
-rw-r--r--tests/gif/bug00181.c1
-rw-r--r--tests/gif/bug00227.c2
-rw-r--r--tests/gif/bug00499.c51
-rw-r--r--tests/gif/gif_nocolormaps.c25
-rw-r--r--tests/gif/gif_nocolormaps.gifbin0 -> 37 bytes
-rw-r--r--tests/gif/ossfuzz5700.c13
-rw-r--r--tests/gif/ossfuzz5700.gifbin0 -> 30 bytes
-rw-r--r--tests/gif/php_bug_75571.c28
-rw-r--r--tests/gif/php_bug_75571.gifbin0 -> 1731 bytes
-rw-r--r--tests/gif/uninitialized_memory_read.c42
-rw-r--r--tests/gif/unitialized_memory_read.gifbin0 -> 11464 bytes
-rw-r--r--tests/heif/CMakeLists.txt11
-rw-r--r--tests/heif/Makemodule.am12
-rw-r--r--tests/heif/avif_ptr_double_free.c31
-rw-r--r--tests/heif/heif_im2im.c57
-rw-r--r--tests/heif/heif_null.c20
-rw-r--r--tests/heif/heif_ptr_double_free.c31
-rw-r--r--tests/heif/heif_read.c28
-rw-r--r--tests/heif/label.avifbin0 -> 602 bytes
-rw-r--r--tests/heif/label.heicbin0 -> 1170 bytes
-rw-r--r--tests/jpeg/.gitignore2
-rw-r--r--tests/jpeg/CMakeLists.txt11
-rw-r--r--tests/jpeg/Makemodule.am10
-rw-r--r--tests/jpeg/bug00338.c46
-rw-r--r--tests/jpeg/jpeg_ptr_double_free.c31
-rw-r--r--tests/png/.gitignore3
-rw-r--r--tests/png/CMakeLists.txt8
-rw-r--r--tests/png/Makemodule.am8
-rw-r--r--tests/png/bug00338.c44
-rw-r--r--tests/png/bug00381_1.c31
-rw-r--r--tests/png/bug00381_2.c35
-rw-r--r--tests/png/bug00381_2.gdbin0 -> 10008 bytes
-rw-r--r--tests/png/png_resolution.c2
-rw-r--r--tests/source/README.md3
-rwxr-xr-xtests/source/run.sh46
-rwxr-xr-xtests/source/whitespace.py52
-rw-r--r--tests/tga/.gitignore1
-rw-r--r--tests/tga/CMakeLists.txt8
-rw-r--r--tests/tga/Makemodule.am9
-rw-r--r--tests/tga/heap_overflow.c59
-rw-r--r--tests/tga/heap_overflow.tgabin0 -> 605 bytes
-rw-r--r--tests/tga/heap_overflow_1.tgabin0 -> 605 bytes
-rw-r--r--tests/tga/heap_overflow_2.tgabin0 -> 8746 bytes
-rw-r--r--tests/tiff/.gitignore2
-rw-r--r--tests/tiff/CMakeLists.txt7
-rw-r--r--tests/tiff/Makemodule.am13
-rw-r--r--tests/tiff/tiff_dpi.c14
-rw-r--r--tests/tiff/tiff_im2im.c9
-rw-r--r--tests/tiff/tiff_invalid_read.c61
-rw-r--r--tests/tiff/tiff_invalid_read_1.tiffbin0 -> 3304 bytes
-rw-r--r--tests/tiff/tiff_invalid_read_2.tiffbin0 -> 429 bytes
-rw-r--r--tests/tiff/tiff_invalid_read_3.tiffbin0 -> 428 bytes
-rw-r--r--tests/tiff/tiff_null.c9
-rw-r--r--tests/tiff/tiff_read_bw.c25
-rw-r--r--tests/tiff/tiff_read_bw.tiffbin0 -> 606 bytes
-rw-r--r--tests/tiff/tiff_read_bw_exp.pngbin0 -> 330 bytes
-rw-r--r--tests/wbmp/CMakeLists.txt2
-rw-r--r--tests/wbmp/Makemodule.am6
-rw-r--r--tests/webp/.gitignore2
-rw-r--r--tests/webp/CMakeLists.txt6
-rw-r--r--tests/webp/Makemodule.am8
-rw-r--r--tests/webp/bug_double_free.c29
-rw-r--r--tests/webp/bug_double_free.jpgbin0 -> 576 bytes
-rw-r--r--tests/webp/gdImageWebpEx.c26
-rw-r--r--tests/xbm/.gitignore3
-rw-r--r--tests/xbm/CMakeLists.txt8
-rw-r--r--tests/xbm/Makemodule.am14
-rw-r--r--tests/xbm/github_bug_109.c33
-rw-r--r--tests/xbm/github_bug_109.xbm5
-rw-r--r--tests/xbm/github_bug_109_exp.pngbin0 -> 111 bytes
-rw-r--r--tests/xbm/github_bug_170.c2
-rw-r--r--tests/xbm/github_bug_501.c39
-rw-r--r--tests/xbm/github_bug_501.xbm4
-rw-r--r--tests/xbm/x10_basic_read.c30
-rw-r--r--tests/xbm/x10_basic_read.xbm4
-rw-r--r--tests/xbm/x10_basic_read_exp.pngbin0 -> 112 bytes
-rw-r--r--travis/lib.sh4
-rwxr-xr-xtravis/main.sh103
-rw-r--r--windows/Makefile.vc76
-rw-r--r--windows/Makefiletest.vc5
-rw-r--r--windows/gentest.bat10
-rwxr-xr-xwindows/libgd.rc4
-rw-r--r--windows/msys/Makefile23
-rw-r--r--windows/msys/README.MSYS.md13
-rwxr-xr-xwindows/msys/run_tests.sh74
-rw-r--r--windows/readme.md60
-rw-r--r--windows/run_tests.bat25
481 files changed, 8470 insertions, 6173 deletions
diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml
new file mode 100644
index 0000000..8b8a593
--- /dev/null
+++ b/.github/workflows/shellcheck.yml
@@ -0,0 +1,21 @@
+# GitHub actions workflow.
+# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
+
+name: Shellcheck
+
+on:
+ push:
+ branches: [master, GD-*]
+ pull_request:
+ types: [opened]
+
+jobs:
+ shellcheck:
+ name: Shellcheck
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Run ShellCheck
+ uses: ludeeus/action-shellcheck@master
+ env:
+ SHELLCHECK_OPTS: -x
diff --git a/.gitignore b/.gitignore
index 890c1fc..4447849 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ syntax: glob
*.dir
[Bb]in
win32
+.vscode
Makefile
CMakeCache.txt
@@ -96,6 +97,7 @@ Testing
/docs/naturaldocs/html/
/docs/naturaldocs/project/Data/
+# AppVeyor build artifacts.
gd-dotnet-bindings-generator
build_msvc12_x86
build_msvc12_x64
diff --git a/.travis.yml b/.travis.yml
index 61306a4..fcfd2d1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,7 +13,7 @@ env:
# COVERITY_SCAN_TOKEN
- secure: "h7NGklk0xX2iuY5PgxijE7FFEgd95hxbhSwofs+hzYIiW6FR2kk8gSwEqRH5dYGnvazGT3a7fjxuYAr0y5BQCfV7yyQISl19rYZPJbP9bTxGxijTGlItyQqVTXCaucuXzgJbAOgC1W3ja4lYODflCyFzHhPggJLkXEAw1FF3+5M="
-sudo: false
+dist: xenial
# Order here matters; see compiler comment above.
os:
@@ -42,3 +42,10 @@ addons:
- autoconf
- libtool
- html2text
+ homebrew:
+ packages:
+ - gettext
+ - freetype
+ - fontconfig
+ - webp
+ - xz
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..75e72db
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,164 @@
+# Change Log
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [2.3.2] - 2021-03-06
+
+### Fixed
+
+- gif: allow decodin when both Global and Local Colormaps (#494)
+
+### Added
+
+- avif: Support for AVIF images via libavif (#557)
+- heif: Support for HEIF/AVIF images via libheif (#395) (#557)
+- webp: Drop ../deps/ search when building with cmake
+- Windows: Remove unused snprintf fallback
+
+## [2.3.1] - 2021-01-30
+
+### Fixed
+
+- Fix potential integer overflow detected by oss-fuzz
+- Fix #615 using libraqm
+- Fix #303: gdlib.pc: use Requires instead of Libs (#537)
+- Fixed #472: Adjusting CMakeLists.txt (#582)
+- Fix #615: gdImageStringFT() fails for empty strings as of libgd 2.3.0 (#633)
+- Fix typo but preserve BC
+- Compute average in gdGuessBackgroundColorFromCorners properly (#483)
+- CMakeLists.txt: zlib is enabled implicitly
+- src/config.h.cmake: replace #cmakedefine01 with #define in macro ENABLE_GD_FOORMATS (#622)
+- gdlib.pc: use prefixes for pkgconfig file
+- cmake: remove required host includes (#617)
+- Move initial declaration out of `for` loop
+- distribute getlib script
+- Make gd_nnquant.c less likely to introduce duplicate definitions (#601)
+- webp: support pkg-config file
+- gd_io: replace internal Putchar with gdPutC
+- gd_io: trim unused Putword function
+
+### Added
+
+- Add REQUIRED to FIND_PACKAGE(ZLIB)
+- README: add some libraries info (#631)
+- VMS/README.VMS: Add dropping support information (#614)
+
+## [2.3.0] - 2020-03-22
+
+### Security
+
+- Potential double-free in gdImage*Ptr(). (CVE-2019-6978)
+- gdImageColorMatch() out of bounds write on heap. (CVE-2019-6977)
+- Uninitialized read in gdImageCreateFromXbm(). (CVE-2019-11038)
+- Double-free in gdImageBmp. (CVE-2018-1000222)
+- Potential NULL pointer dereference in gdImageClone(). (CVE-2018-14553)
+- Potential infinite loop in gdImageCreateFromGifCtx(). (CVE-2018-5711)
+
+### Fixed
+
+* Fix #597: add codecov support
+
+- Fix #596: gdTransformAffineCopy run error
+
+- Fix #589: Install dependencies move to .travis.yml
+
+- Fix #586: gdTransformAffineCopy() segfaults on palette images
+- Fix #585: gdTransformAffineCopy() changes interpolation method
+- Fix #584: gdImageSetInterpolationMethod(im, GD_DEFAULT) inconsistent
+- Fix #583: gdTransformAffineCopy() may use unitialized values
+- Fix #533: Remove cmake modules
+- Fix #539: Add RAQM support for cmake
+- Fix #499: gdImageGifAnimAddPtr: heap corruption with 2 identical images
+- Fix #486: gdImageCropAuto(…, GD_CROP_SIDES) crops left but not right
+- Fix #485: auto cropping has insufficient precision
+- Fix #479: Provide a suitable malloc function to liq
+- Fix #474: libtiff link returns 404 HTTP code
+- Fix #450: Failed to open 1 bit per pixel bitmap
+- Fix #440: new_width & new_height exception handling
+- Fix #432: gdImageCrop neglecting transparency
+- Fix #420: Potential infinite loop in gdImageCreateFromGifCtx
+- Fix #411: gd_gd.c format documentation appears to be incorrect
+- Fix #369: Fix new_a init error in gdImageConvolution()
+- Fix #351: gdImageFilledArc() doesn't properly draw pies
+- Fix #338: Fatal and normal libjpeg/libpng errors not distinguishable
+- Fix #169: Update var type to hold bigger w&h for ellipse
+- Fix #164: update doc files install directory in CMakeLists.txt
+- Correct some test depend errors
+- Update cmake min version to 3.7
+- Delete libimagequant source code download action in CMakeLists.txt
+- Improve msys support
+- Fix some logic error in CMakeLists.txt
+- Remove the following macro: HAVE_STDLIB_H, HAVE_STRING_H, HAVE_STDDEF_H, HAVE_LIMITS_H, HAVE_ERRNO_H, AC_C_CONST
+
+### Added
+
+- test cases for following API: gdImageCopyResized(), gdImageWebpEx(), gdImageCreateFromGd2PartPtr(), gdImageCloneMatch(), gdImageColorClosestHWB(), gdImageColorMatch(), gdImageStringUp(), gdImageStringUp16(), gdImageString(), gdImageString16(), gdImageCopyMergeGray(), gdImageCopyMerge()
+
+## [2.2.5] - 2017-08-30
+
+### Security
+- Double-free in gdImagePngPtr(). (CVE-2017-6362)
+- Buffer over-read into uninitialized memory. (CVE-2017-7890)
+
+### Fixed
+- Fix #109: XBM reading fails with printed error
+- Fix #338: Fatal and normal libjpeg/ibpng errors not distinguishable
+- Fix #357: 2.2.4: Segfault in test suite
+- Fix #386: gdImageGrayScale() may produce colors
+- Fix #406: webpng -i removes the transparent color
+- Fix Coverity #155475: Failure to restore alphaBlendingFlag
+- Fix Coverity #155476: potential resource leak
+- Fix several build issues and test failures
+- Fix and reenable optimized support for reading 1 bps TIFFs
+
+### Added
+- The native MSVC buildchain now supports libtiff and most executables
+
+## [2.2.4] - 2017-01-18
+
+### Security
+- gdImageCreate() doesn't check for oversized images and as such is
+ prone to DoS vulnerabilities. (CVE-2016-9317)
+- double-free in gdImageWebPtr() (CVE-2016-6912)
+- potential unsigned underflow in gd_interpolation.c
+- DOS vulnerability in gdImageCreateFromGd2Ctx()
+
+### Fixed
+- Fix #354: Signed Integer Overflow gd_io.c
+- Fix #340: System frozen
+- Fix OOB reads of the TGA decompression buffer
+- Fix DOS vulnerability in gdImageCreateFromGd2Ctx()
+- Fix potential unsigned underflow
+- Fix double-free in gdImageWebPtr()
+- Fix invalid read in gdImageCreateFromTiffPtr()
+- Fix OOB reads of the TGA decompression buffer
+- Fix #68: gif: buffer underflow reported by AddressSanitizer
+- Avoid potentially dangerous signed to unsigned conversion
+- Fix #304: test suite failure in gif/bug00006 [2.2.3]
+- Fix #329: GD_BILINEAR_FIXED gdImageScale() can cause black border
+- Fix #330: Integer overflow in gdImageScaleBilinearPalette()
+- Fix 321: Null pointer dereferences in gdImageRotateInterpolated
+- Fix whitespace and add missing comment block
+- Fix #319: gdImageRotateInterpolated can have wrong background color
+- Fix color quantization documentation
+- Fix #309: gdImageGd2() writes wrong chunk sizes on boundaries
+- Fix #307: GD_QUANT_NEUQUANT fails to unset trueColor flag
+- Fix #300: gdImageClone() assigns res_y = res_x
+- Fix #299: Regression regarding gdImageRectangle() with gdImageSetThickness()
+- Replace GNU old-style field designators with C89 compatible initializers
+- Fix #297: gdImageCrop() converts palette image to truecolor image
+- Fix #290: TGA RLE decoding is broken
+- Fix unnecessary non NULL checks
+- Fix #289: Passing unrecognized formats to gdImageGd2 results in corrupted files
+- Fix #280: gdImageWebpEx() `quantization` parameter is a misnomer
+- Publish all gdImageCreateFromWebp*() functions and gdImageWebpCtx()
+- Fix issue #276: Sometimes pixels are missing when storing images as BMPs
+- Fix issue #275: gdImageBmpCtx() may segfault for non-seekable contexts
+- Fix copy&paste error in gdImageScaleBicubicFixed()
+
+### Added
+- More documentation
+- Documentation on GD and GD2 formats
+- More tests
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56260b8..377d397 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,16 +1,15 @@
-# $Id$
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.7 FATAL_ERROR)
SET(PACKAGE GD)
SET(PACKAGE_NAME GD)
-CMAKE_POLICY(SET CMP0017 OLD)
PROJECT(GD)
SET(CMAKE_MODULE_PATH "${GD_SOURCE_DIR}/cmake/modules")
include(gd)
+OPTION(ENABLE_GD_FORMATS "Enable GD image formats" 0)
OPTION(ENABLE_PNG "Enable PNG support" 0)
OPTION(ENABLE_LIQ "Enable libimagequant support" 0)
OPTION(ENABLE_JPEG "Enable JPEG support" 0)
@@ -20,6 +19,9 @@ OPTION(ENABLE_XPM "Enable XPM support" 0)
OPTION(ENABLE_FREETYPE "Enable Freetype2 support" 0)
OPTION(ENABLE_FONTCONFIG "Enable FontConfig support" 0)
OPTION(ENABLE_WEBP "Enable WebP support" 0)
+OPTION(ENABLE_HEIF "Enable HEIF support" 0)
+OPTION(ENABLE_AVIF "Enable AVIF support" 0)
+OPTION(ENABLE_RAQM "Enable RAQM support" 0)
if (BUILD_TEST)
ENABLE_TESTING()
@@ -31,26 +33,28 @@ endif(BUILD_TEST)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -O0") # will be added to CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
ENDIF(CMAKE_COMPILER_IS_GNUCC)
-SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
- ${PROJECT_BINARY_DIR}/Bin
- CACHE PATH
- "Single Directory for all Libraries"
+SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/Bin
+ CACHE PATH
+ "Single Directory for all Libraries"
)
-# --------- Setup the Executable output Directory -------------
-SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
- ${PROJECT_BINARY_DIR}/Bin
- CACHE PATH
- "Single Directory for all Executables."
+# --------- Setup the Executable output Directory -------------
+SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/Bin
+ CACHE PATH
+ "Single Directory for all Executables."
)
-# --------- Setup the Executable output Directory -------------
-SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
- ${PROJECT_BINARY_DIR}/Bin
- CACHE PATH
- "Single Directory for all static libraries."
+# --------- Setup the Executable output Directory -------------
+SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/Bin
+ CACHE PATH
+ "Single Directory for all static libraries."
)
+SET(PKG_REQUIRES_PRIVATES "")
+
if (USE_EXT_GD)
message("Using GD at: ${USE_EXT_GD}")
INCLUDE_DIRECTORIES(BEFORE ${GD_INCLUDE_DIR})
@@ -69,16 +73,30 @@ if (USE_EXT_GD)
endif (GD_FOUND)
else (USE_EXT_GD)
- SET(GD_VERSION_MAJOR "2")
- SET(GD_VERSION_MINOR "2")
- SET(GD_VERSION_PATCH "0")
- SET(GD_VERSION_EXTRA "-dev")
- SET(GD_VERSION "${GD_VERSION_MAJOR}.${GD_VERSION_MINOR}.${GD_VERSION_PATCH}${GD_VERSION_EXTRA}")
- SET(GD_VERSION_STRING "${GD_VERSION}")
-
- SET(GD_VERSION_INT "20101")
-
- SET(CMAKE_REQUIRED_INCLUDES "/usr/include" "/usr/local/include")
+ MACRO(GV VER VAR)
+ execute_process(
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.sh ${VER}
+ OUTPUT_VARIABLE ${VAR}
+ )
+ ENDMACRO(GV)
+
+ GV(MAJOR GDLIB_MAJOR)
+ GV(MINOR GDLIB_MINOR)
+ GV(RELEASE GDLIB_REVISION)
+ GV(EXTRA GDLIB_EXTRA)
+ SET(GDLIB_VERSION "${GDLIB_MAJOR}.${GDLIB_MINOR}.${GDLIB_REVISION}${GDLIB_EXTRA}")
+ MESSAGE(STATUS "gd version ${GDLIB_VERSION}")
+
+ MACRO(GV_LT VER VAR)
+ execute_process(
+ COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/config/getlib.sh ${VER}
+ OUTPUT_VARIABLE ${VAR}
+ )
+ ENDMACRO(GV_LT)
+
+ GV_LT(SONAME GDLIB_LIB_SOVERSION)
+ GV_LT(VERSION GDLIB_LIB_VERSION)
+ MESSAGE(STATUS "gd shared lib version ${GDLIB_LIB_SOVERSION} (${GDLIB_LIB_VERSION})")
include(CheckIncludeFiles)
include(CheckIncludeFile)
@@ -86,22 +104,36 @@ else (USE_EXT_GD)
include(AC_HEADER_STDC)
include(CheckPrototypeExists)
+ if (ENABLE_GD_FORMATS)
+ FIND_PACKAGE(ZLIB REQUIRED)
+ endif (ENABLE_GD_FORMATS)
+
if (ENABLE_PNG)
+ FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
endif (ENABLE_PNG)
-
+
if (ENABLE_ICONV)
FIND_PACKAGE(ICONV REQUIRED)
endif (ENABLE_ICONV)
- FIND_PACKAGE(ZLIB)
-
IF (ENABLE_WEBP)
- FIND_PACKAGE(WEBP)
+ FIND_PACKAGE(WEBP REQUIRED)
ENDIF (ENABLE_WEBP)
+ IF (ENABLE_HEIF)
+ FIND_PACKAGE(HEIF REQUIRED)
+ ENDIF (ENABLE_HEIF)
+
+ IF (ENABLE_AVIF)
+ FIND_PACKAGE(libavif 0.8.2 REQUIRED CONFIG)
+ SET(HAVE_LIBAVIF 1)
+ SET(AVIF_LIBRARIES avif)
+ SET(AVIF_FOUND 1)
+ ENDIF (ENABLE_AVIF)
+
IF (ENABLE_LIQ)
- FIND_PACKAGE(LIQ)
+ FIND_PACKAGE(LIQ REQUIRED)
ENDIF (ENABLE_LIQ)
IF (NOT WIN32)
@@ -109,34 +141,42 @@ else (USE_EXT_GD)
ENDIF (NOT WIN32)
if (ENABLE_JPEG)
- FIND_PACKAGE(JPEG)
+ FIND_PACKAGE(JPEG REQUIRED)
endif (ENABLE_JPEG)
if (ENABLE_TIFF)
- FIND_PACKAGE(TIFF)
+ FIND_PACKAGE(TIFF REQUIRED)
endif (ENABLE_TIFF)
if (ENABLE_FREETYPE)
- FIND_PACKAGE(Freetype)
+ FIND_PACKAGE(Freetype REQUIRED)
endif (ENABLE_FREETYPE)
if (ENABLE_XPM)
- FIND_PACKAGE(XPM)
+ FIND_PACKAGE(XPM REQUIRED)
endif (ENABLE_XPM)
if (ENABLE_FONTCONFIG)
- FIND_PACKAGE(FontConfig)
+ FIND_PACKAGE(FontConfig REQUIRED)
endif (ENABLE_FONTCONFIG)
+ if (ENABLE_RAQM)
+ FIND_PACKAGE(RAQM REQUIRED)
+ endif (ENABLE_RAQM)
+
+ SET(ENABLE_GD_FORMATS ${ENABLE_GD_FORMATS})
+
if (FREETYPE_FOUND)
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
SET(HAVE_FT2BUILD_H 1)
SET(HAVE_LIBFREETYPE 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES freetype2)
ENDIF(FREETYPE_FOUND)
IF(ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
SET(HAVE_LIBZ 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES zlib)
ENDIF(ZLIB_FOUND)
IF(WEBP_FOUND)
@@ -144,11 +184,17 @@ else (USE_EXT_GD)
SET(HAVE_LIBWEBP 1)
ENDIF(WEBP_FOUND)
+ IF(HEIF_FOUND)
+ INCLUDE_DIRECTORIES(${HEIF_INCLUDE_DIR})
+ SET(HAVE_LIBHEIF 1)
+ ENDIF(HEIF_FOUND)
+
IF(PNG_FOUND)
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
SET(HAVE_LIBPNG 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES libpng)
ENDIF(PNG_FOUND)
-
+
IF(ICONV_FOUND)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
SET(HAVE_ICONV 1)
@@ -163,27 +209,38 @@ else (USE_EXT_GD)
IF(XPM_FOUND)
INCLUDE_DIRECTORIES(${XPM_INCLUDE_DIR})
SET(HAVE_LIBXPM 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES xpm)
ENDIF(XPM_FOUND)
IF(JPEG_FOUND)
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
SET(HAVE_LIBJPEG 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES libjpeg)
ENDIF(JPEG_FOUND)
IF(TIFF_FOUND)
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
SET(HAVE_LIBTIFF 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES libtiff-4)
ENDIF(TIFF_FOUND)
IF(FONTCONFIG_FOUND)
INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR})
SET(HAVE_LIBFONTCONFIG 1)
+ LIST(APPEND PKG_REQUIRES_PRIVATES fontconfig)
ELSE (FONTCONFIG_FOUND)
SET(FONTCONFIG_LIBRARY "")
SET(FONTCONFIG_INCLUDE_DIR "")
SET(FONTCONFIG_LIB_DIR "")
ENDIF(FONTCONFIG_FOUND)
+ IF(RAQM_FOUND)
+ INCLUDE_DIRECTORIES(${RAQM_INCLUDE_DIR})
+ SET(HAVE_RAQM 1)
+ LIST(APPEND PKG_REQUIRES_PRIVAES raqm)
+ ENDIF(RAQM_FOUND)
+
+ string(REPLACE ";" ", " PKG_REQUIRES_PRIVATES "${PKG_REQUIRES_PRIVATES}")
SET(HAVE_CONFIG_H 1)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
@@ -230,10 +287,10 @@ add_custom_target(distclean ${GD_SOURCE_DIR}/cmake/distclean.sh)
SET(CPACK_PACKAGE_NAME "libgd")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libGD, powerful and easy to use graphic library")
-SET(CPACK_PACKAGE_VENDOR "http://www.libgd.org")
-SET(CPACK_PACKAGE_VERSION_MAJOR "2")
-SET(CPACK_PACKAGE_VERSION_MINOR "1")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
+SET(CPACK_PACKAGE_VENDOR "https://www.libgd.org")
+SET(CPACK_PACKAGE_VERSION_MAJOR ${GDLIB_MAJOR})
+SET(CPACK_PACKAGE_VERSION_MINOR ${GDLIB_MINOR})
+SET(CPACK_PACKAGE_VERSION_PATCH ${GDLIB_REVISION}${GDLIB_EXTRA})
if(WIN32)
set(CPACK_GENERATOR ZIP)
@@ -241,33 +298,28 @@ else(WIN32)
set(CPACK_GENERATOR TGZ)
endif(WIN32)
-IF (ENABLE_LIQ AND LIQ_BUILD)
- ADD_DEPENDENCIES(${GD_LIB} libimagequant)
- ADD_DEPENDENCIES(${GD_LIB_STATIC} libimagequant)
-ENDIF(ENABLE_LIQ AND LIQ_BUILD)
-
-INSTALL(FILES docs/INSTALL DESTINATION share/docs)
-INSTALL(FILES docs/README.JPN DESTINATION share/docs)
-INSTALL(FILES docs/README.CMAKE DESTINATION share/docs)
-INSTALL(FILES docs/README.TESTING DESTINATION share/docs)
-INSTALL(FILES docs/README.TXT DESTINATION share/docs)
+INSTALL(FILES docs/INSTALL DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES docs/README.JPN DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES docs/README.CMAKE DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES docs/README.TESTING DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES docs/README.TXT DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
-INSTALL(FILES examples/arc.c DESTINATION share/docs)
-INSTALL(FILES examples/copyrotated.c DESTINATION share/docs)
-INSTALL(FILES examples/crop.c DESTINATION share/docs)
-INSTALL(FILES examples/flip.c DESTINATION share/docs)
-INSTALL(FILES examples/gif.c DESTINATION share/docs)
-INSTALL(FILES examples/nnquant.c DESTINATION share/docs)
-INSTALL(FILES examples/noIcon.pic DESTINATION share/docs)
-INSTALL(FILES examples/noIcon.sgi DESTINATION share/docs)
-INSTALL(FILES examples/noIcon.tga DESTINATION share/docs)
-INSTALL(FILES examples/noIconAlpha.tga DESTINATION share/docs)
-INSTALL(FILES examples/test_crop_threshold.png DESTINATION share/docs)
-INSTALL(FILES examples/tgaread.c DESTINATION share/docs)
-INSTALL(FILES examples/tiffread.c DESTINATION share/docs)
-INSTALL(FILES examples/windows.c DESTINATION share/docs)
+INSTALL(FILES examples/arc.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/copyrotated.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/crop.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/flip.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/gif.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/nnquant.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/noIcon.pic DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/noIcon.sgi DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/noIcon.tga DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/noIconAlpha.tga DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/test_crop_threshold.png DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/tgaread.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/tiffread.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
+INSTALL(FILES examples/windows.c DESTINATION share/doc/gd-${GDLIB_MAJOR}.${GDLIB_MINOR})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
@@ -283,4 +335,3 @@ set(CPACK_SOURCE_IGNORE_FILES
)
install(FILES ${top_level_DOCFILES} DESTINATION ${DOC_DIR})
INCLUDE(CPack)
-
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..c7d7eeb
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [atom@github.com](mailto:atom@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 48b608f..ca95eb4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -18,7 +18,7 @@
* [Git Commit Messages](#git-commit-messages)
* [Coding standard](#coding-standard)
* [Documentation Styleguide](#documentation-styleguide)
-
+
## What should I know before I get started?
### Code of Conduct
@@ -49,7 +49,7 @@ Before creating bug reports, please check [this list](#before-submitting-a-bug-r
#### How Do I Submit A (Good) Bug Report?
-For security related bugs, github does not support private issues, that's why we have to handle security issues outside the issues tracker for now. Please drop a mail to [security@libg.org](mailto:security@libgd.org).
+For security related bugs, github does not support private issues, that's why we have to handle security issues outside the issues tracker for now. Please drop a mail to [security@libg.org](mailto:security@libgd.org).
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined [which repository](#repositories) your bug is related to, create an issue on that repository and provide the following information.
@@ -64,4 +64,75 @@ Explain the problem and include additional details to help maintainers reproduce
* **If you're reporting that libGD crashed**, include a crash report with a stack trace from the operating system. Include the crash report in the issue in a [code block](https://help.github.com/articles/markdown-basics/#multiple-lines), a [file attachment](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/), or put it in a [gist](https://gist.github.com/) and provide link to that gist.
-This text has been largely inspired by the Atom contributing notes, which amazingly complete
+This text has been largely inspired by the Atom contributing notes, which are amazingly complete.
+
+
+## Styleguides
+
+These sections tend to bore people. But if you don't follow them, it slows
+down reviews from developers (and tends to tire/annoy them). Please give it
+a look over and feel free to ask questions.
+
+### Git Commit Messages
+
+Rather than duplicate a ton of great explanations, please read this site:
+http://chris.beams.io/posts/git-commit/
+
+Yes, it's long, but once you read and understand it once, it applies to
+every git project out there, not just GD.
+
+In case that site is broken, here is an archived link:
+http://web.archive.org/web/20160706012209/http://chris.beams.io/posts/git-commit/
+
+### Coding standard
+
+#### Style
+
+First, coding style should be consistent. If you're modifying a file that
+might not follow this section, stick with that file's style. If we want to
+fix the style later, we can.
+
+As for the rest, TBD!
+
+#### Practices
+
+Check for invalid settings (where reasonable) and return an error directly.
+Do not use `assert` and do not require the user to follow the documented API.
+e.g. Check for `NULL` pointers, and check enum values are within range. The
+GD library is used in a lot of hostile environments (like websites) and is
+given hostile (user controlled) data. When GD mishandles memory, that can be
+used to attack servers. When GD crashes (or calls `assert`), that can take
+out a web session.
+
+#### Testing
+
+We love unit tests. Every bugfix, new API, etc... should include a test update
+to make sure future work doesn't break things or regress. We want to fix bugs
+just once, not over and over again.
+
+Note that we say "should". While we really like tests, we understand that not
+all changes are trivial to verify.
+
+Some general guidelines:
+
+* Tests should be standalone: One test should test one thing only.
+* Tests should be reproducible: Avoid relying on system settings like /etc.
+* Tests must be fast: A good guideline is that they should take <1 second,
+ and must take <5 seconds.
+* Tests must be documented: Just add a comment block to the top of the file
+ with a short description and any existing bugs/URLs.
+
+### Documentation Styleguide
+
+Do everything in markdown. It's readable even in plain text, and converts
+well into other formats (e.g. HTML). The question is which flavor!
+
+For files that end in `.md`, use
+[GitHub markdown](https://guides.github.com/features/mastering-markdown/).
+
+For API documentation (embedded in the code), we use
+[Natural Docs](http://www.naturaldocs.org/). You can find more info about
+it under the [docs/naturaldocs/](docs/naturaldocs/) subdirectory.
+
+Try to keep the file linewrapped to 80 cols. Sometimes you won't be able to
+because of long strings (like links), and that's OK.
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index fc4cf12..cdb066a 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1,4 +1,6 @@
+Ben Morss (morsssss)
chapg
+Chen Pingping (Wilson)
Chris Reuter
Christoph M. Becker
Colin Watson
@@ -10,9 +12,10 @@ Kornel Lesiński
kshepherd
lhecking
Marcin Wojdyr
+Martin Reboredo (YakoYakoYokuYoku)
mattias
Mike Frysinger
-mloskot
+Mateusz Loskot (mloskot)
Nathanael Jones
nlopess
Ondřej Surý
diff --git a/COPYING b/COPYING
index 725d1b5..babeccc 100644
--- a/COPYING
+++ b/COPYING
@@ -25,8 +25,8 @@ pleased to correct them.
* Portions relating to gdft.c copyright 2001, 2002, 2003, 2004 John
Ellson (ellson@graphviz.org).
-* Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
- Pierre-Alain Joye (pierre@libgd.org).
+* Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008 Pierre-Alain Joye (pierre@libgd.org).
* Portions relating to JPEG and to color quantization copyright
2000, 2001, 2002, 2003, 2004, Doug Becker and copyright (C) 1994,
@@ -70,4 +70,3 @@ documentation.
Although their code does not appear in the current release, the
authors wish to thank David Koblas, David Rowley, and Hutchison
Avenue Software Corporation for their prior contributions.
-
diff --git a/Makefile.am b/Makefile.am
index c4ccbd4..b47226c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src config tests
-EXTRA_DIST = test docs examples windows VMS cmake netware bootstrap.sh CMakeLists.txt CONTRIBUTORS README.md
+EXTRA_DIST = test docs examples windows cmake bootstrap.sh CMakeLists.txt CONTRIBUTORS README.md CHANGELOG.md CONTRIBUTING.md
clean-local:
$(srcdir)/cmake/distclean.sh --automake
diff --git a/README.md b/README.md
index 681750a..aa8fa3f 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
[![Build Status](https://travis-ci.org/libgd/libgd.svg?branch=master)](https://travis-ci.org/libgd/libgd)
[![Build Status](https://scan.coverity.com/projects/3810/badge.svg)](https://scan.coverity.com/projects/libgd)
[![Chat](https://badges.gitter.im/libgd/libgd.svg)](https://gitter.im/libgd/libgd)
+[![codecov.io](https://codecov.io/github/libgd/libgd/coverage.svg?branch=master)](https://codecov.io/github/libgd/libgd/)
GD is an open source code library for the dynamic creation of images by
programmers.
@@ -38,9 +39,21 @@ GD has builtin support for:
It also has optional support for more formats via external libraries:
+* [AVIF](https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF)) via [libavif](https://github.com/AOMediaCodec/libavif)
+* [HEIF](https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format) via [libheif](https://github.com/strukturag/libheif/)
+ * This includes [AVIF](https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_%28AVIF%29) read support if your system's `libheif` has AV1 decoding.
* [JPEG](https://en.wikipedia.org/wiki/JPEG) via [IJG/libjpeg](http://www.ijg.org/) or [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/)
* Does not include [JPEG 2000](https://en.wikipedia.org/wiki/JPEG_2000)
* [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics) via [libpng](http://www.libpng.org/)
-* [TIFF](https://en.wikipedia.org/wiki/Tagged_Image_File_Format) via [libtiff](http://www.remotesensing.org/libtiff/)
+* [TIFF](https://en.wikipedia.org/wiki/Tagged_Image_File_Format) via [libtiff](http://www.libtiff.org/)
* [WebP](https://en.wikipedia.org/wiki/WebP) via [libwebp](https://developers.google.com/speed/webp/)
* [XPM](https://en.wikipedia.org/wiki/X_PixMap) via [libXpm](http://xorg.freedesktop.org/)
+
+Besides that, GD depends on some external libraries, which are all optional
+and disabled by default:
+
+* [FreeType](https://freetype.org) for rendering fonts
+* [Fontconfig](https://fontconfig.org) for configuring and customizing font access
+* [libraqm](https://github.com/HOST-Oman/libraqm) for complex text layout
+* [libimagequant](https://pngquant.org/lib) for conversion of RGBA images to 8-bit indexed-color images
+ * **NOTE** libimagequant is dual-licensed: GPLv3 and commercial license
diff --git a/VMS/CONFIGURE.COM b/VMS/CONFIGURE.COM
deleted file mode 100644
index f7b92f6..0000000
--- a/VMS/CONFIGURE.COM
+++ /dev/null
@@ -1,1342 +0,0 @@
-$! (c) Alexey Chupahin 18-APR-2006, 15-DEC-2007
-$! OpenVMS 8.2 Alpha DEC 2000 model 300
-$! OpenVMS 8.3 Itanium rx1620
-$! GNU
-$!
-$!
-$DEF SYS$ERROR _NL0:
-$ SET NOON
-$WRITE SYS$OUTPUT " "
-$WRITE SYS$OUTPUT "Configuring GD library for OpenVMS"
-$WRITE SYS$OUTPUT "(c) Alexey Chupahin "
-$! Checking architecture
-$! Checking architecture
-$ IF F$GETSYI("ARCH_TYPE").EQ.1 THEN CPU = "VAX"
-$ IF F$GETSYI("ARCH_TYPE").EQ.2 THEN CPU = "Alpha"
-$ IF F$GETSYI("ARCH_TYPE").EQ.3 THEN CPU = "I64"
-$ OS = F$GETSYI("VERSION")
-$WRITE SYS$OUTPUT "Checking architecture ... ", CPU
-$WRITE SYS$OUTPUT "Checking OS ... OpenVMS ",OS
-$SHARED=0
-$IF ( (CPU.EQS."Alpha").OR.(CPU.EQS."I64") )
-$ THEN
-$ SHARED=64
-$ ELSE
-$ SHARED=32
-$ENDIF
-$DECC = F$SEARCH("SYS$SYSTEM:DECC$COMPILER.EXE") .NES. ""
-$IF (DECC) THEN $WRITE SYS$OUTPUT "Compiler ... DEC C"
-$IF (.NOT. DECC) THEN $WRITE SYS$OUTPUT "BAD compiler" GOTO EXIT
-$MMS = F$SEARCH("SYS$SYSTEM:MMS.EXE") .NES. ""
-$MMK = F$TYPE(MMK)
-$IF (MMS .OR. MMK.NES."") THEN GOTO TEST_LIBRARIES
-$WRITE SYS$OUTPUT "Please install MMS from DECSET or MMK"
-$! I cant find any make tool
-$GOTO EXIT
-$!
-$!
-$TEST_LIBRARIES:
-$! Setting as MAKE utility one of MMS or MMK. I prefer MMS.
-$IF (MMK.NES."") THEN MAKE="MMK/IGN=WAR"
-$IF (MMS) THEN MAKE="MMS/IGN=WAR"
-$WRITE SYS$OUTPUT "Checking build utility ... ''MAKE'"
-$WRITE SYS$OUTPUT " "
-$!
-$IF (P1.EQS."STATIC") .OR. (P1.EQS."static")
-$ THEN
-$ WRITE SYS$OUTPUT "Configuring for static only"
-$ SHARED=0
-$ENDIF
-$!
-$! Is it package root directory? If no, go to [-]
-$ IF (F$SEARCH("[]VMS.DIR").EQS."") .AND. (F$SEARCH("[]vms.dir").EQS."")
-$ THEN
-$ SET DEF [-]
-$ ENDIF
-$!
-$!Checking for iconv
-$!
-$ DEFINE SYS$OUTPUT _NLA0:
-$ CC/OBJECT=TEST.OBJ SYS$INPUT
- #include <iconv.h>
- int main()
- {
- iconv_t cd;
- cd = iconv_open ((const char *)0, (const char *)0);
- }
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_ICONV=0
-$ENDIF
-$DEFINE SYS$OUTPUT _NLA0:
-$LINK/EXE=TEST TEST
-$TMP = $STATUS
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10000001)
-$ THEN
-$ HAVE_ICONV=0
-$ ELSE
-$ HAVE_ICONV=1
-$ENDIF
-$DEAS SYS$OUTPUT
-$IF (HAVE_ICONV.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for system iconv library... Yes"
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for system iconv library... No"
-$ENDIF
-$!
-$!"Checking for correct zlib library "
-$ ZLIB_STATIC=0
-$ DEFINE SYS$OUTPUT _NLA0:
-$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT
- #include <stdlib.h>
- #include <stdio.h>
- #include <zlib.h>
- int main()
- {
- printf("checking version zlib: %s\n",zlibVersion());
- }
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_ZLIB=0
-$ GOTO NEXT1
-$ENDIF
-$DEFINE SYS$OUTPUT _NLA0:
-$!Testing for shared ZLIB
-$COPY SYS$INPUT [.SRC]OPT.OPT
-SYS$SHARE:LIBZSHR/SHARE
-$LINK/EXE=TEST TEST,[.SRC]OPT/OPT
-$TMP = $STATUS
-$DEL [.SRC]OPT.OPT;*
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10000001)
-$ THEN
-$ LINK/EXE=TEST TEST,ZLIB:LIBZ/LIB
-$ TMP = $STATUS
-$ IF (TMP .NE. %X10000001)
-$ THEN
-$ HAVE_ZLIB=0
-$ ELSE
-$ HAVE_ZLIB=1
-$ ZLIB_STATIC=1
-$ ENDIF
-$ ELSE
-$ HAVE_ZLIB=1
-$ENDIF
-$NEXT1:
-$DEAS SYS$OUTPUT
-$IF (HAVE_ZLIB.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for correct zlib library ... Yes"
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for correct zlib library ... No"
-$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html"
-$ GOTO EXIT
-$ENDIF
-$RUN TEST
-$!
-$!
-$FREETYPE_STATIC=0
-$!"Checking for correct Freetype2 library"
-$ DEFINE SYS$OUTPUT _NLA0:
-$ CC/OBJECT=TEST.OBJ/INCLUDE=(FREETYPE2) SYS$INPUT
-#include <ft2build.h>
-#include <freetype/freetype.h>
-int main(int argc, char *argv[])
-{
-
-#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR <= 1
- printf("This version is too old. Please get newest\n");
- printf("From fafner.dyndns.org/~alexey/libsdl/required.html\n");
- exit(2);
-#endif
- printf("checking version FreeType : %d.%d.%d\n",
- FREETYPE_MAJOR,
- FREETYPE_MINOR,
- FREETYPE_PATCH);
- return(0);
-}
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_FREETYPE=0
-$ GOTO NEXT0
-$ENDIF
-$DEAS SYS$OUTPUT
-$DEFINE SYS$OUTPUT _NLA0:
-$LINK/EXE=TEST TEST,FREETYPE2:FREETYPE/OPT
-$TMP = $STATUS
-$IF (TMP .NE. %X10000001)
-$ THEN
-$ LINK/EXE=TEST TEST,FREETYPE2:FREETYPE/LIB,ZLIB:LIBZ/LIB
-$ TMP = $STATUS
-$ IF (TMP .NE. %X10000001)
-$ THEN
-$ TMP = $STATUS
-$ HAVE_FREETYPE=0
-$ GOTO NEXT0
-$ ELSE
-$ FREETYPE_STATIC=1
-$ ENDIF
-$ENDIF
-$!
-$RUN TEST
-$IF ($STATUS .NE. %X00000001)
-$ THEN
-$ HAVE_FREETYPE=0
-$ GOTO NEXT0
-$ ELSE
-$ HAVE_FREETYPE=1
-$ENDIF
-$NEXT0:
-$DEAS SYS$OUTPUT
-$IF (HAVE_FREETYPE.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for correct FreeType ... Yes"
-$ RUN TEST
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for correct FreeType ... No"
-$ WRITE SYS$OUTPUT "This is required library "
-$ WRITE SYS$OUTPUT "install it first from fafner.dyndns.org/~alexey/libsdl/required.html"
-$ GOTO EXIT
-$ENDIF
-$!
-$!
-$HAVE_TIFF=0
-$!"Checking for libPNG "
-$ DEFINE SYS$OUTPUT _NLA0:
-$ CC/OBJECT=TEST.OBJ/INCLUDE=(PNG,ZLIB) SYS$INPUT
- #include <stdlib.h>
- #include <png.h>
- int main()
- {
- png_uint_32 n,n1,n2,n3;
- n=png_access_version_number();
- n3=n%100; n=n/100;
- n2=n%100; n=n/100;
- n1=n%100;
- if ( (n1<=1)&&(n2<2) )
- { printf("checking version libPNG: %d.%d.%d\n",n1,n2,n3);
- printf("This version is too old. Please get newest\n");
- printf("From fafner.dyndns.org/~alexey/libsdl/public.html\n");
- exit(2);
- }
- printf("checking version libPNG: %d.%d.%d\n",n1,n2,n3);
- }
-$!
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_LIBPNG=0
-$ GOTO NEXT2
-$ENDIF
-$DEFINE SYS$OUTPUT _NLA0:
-$LINK/EXE=TEST TEST,PNG:LIBPNG$SHR/OPT,ZLIB:LIBZ/LIB
-$TMP = $STATUS
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10000001)
-$ THEN
-$! Trying for static libpng
-$ LINK/EXE=TEST TEST,PNG:LIBPNG/LIB,ZLIB:LIBZ/LIB
-$ TMP = $STATUS
-$ IF (TMP .NE. %X10000001)
-$ THEN
-$ LIBPNG_STATIC=0
-$ HAVE_LIBPNG=0
-$ GOTO NEXT2
-$ ELSE
-$ HAVE_LIBPNG=1
-$ LIBPNG_STATIC=1
-$ ENDIF
-$ ELSE
-$ HAVE_LIBPNG=1
-$ LIBPNG_STATIC=0
-$ENDIF
-$!
-$RUN TEST
-$IF ($STATUS .NE. %X00000001)
-$ THEN
-$ HAVE_LIBPNG=0
-$ ELSE
-$ HAVE_LIBPNG=1
-$ENDIF
-$NEXT2:
-$DEAS SYS$OUTPUT
-$IF (HAVE_LIBPNG.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for correct libPNG ... Yes"
-$ RUN TEST
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for correct libPNG ... No"
-$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html"
-$ GOTO EXIT
-$ENDIF
-$!
-$!
-$!
-$! Checking for JPEG ...
-$ DEFINE SYS$OUTPUT _NLA0:
-$ CC/OBJECT=TEST.OBJ/INCLUDE=(JPEG) SYS$INPUT
- #include <stdlib.h>
- #include <stdio.h>
- #include <jpeglib.h>
- #include <jversion.h>
- int main()
- {
- printf("checking version jpeg: %s\n",JVERSION);
- jpeg_quality_scaling(0);
- return 0;
- }
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_JPEG=0
-$ GOTO NEXT3
-$ENDIF
-$DEFINE SYS$OUTPUT _NLA0:
-$LINK/EXE=TEST TEST,JPEG:LIBJPEG$SHR/OPT
-$TMP = $STATUS
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10000001)
-$ THEN
-$ LINK/EXE=TEST TEST,JPEG:LIBJPEG/OPT
-$ TMP = $STATUS
-$ IF (TMP .NE. %X10000001)
-$ THEN
-$ HAVE_JPEG=0
-$ JPEG_STATIC=0
-$ GOTO NEXT3
-$ ELSE
-$ HAVE_JPEG=1
-$ JPEG_STATIC=1
-$ ENDIF
-$ ELSE
-$ HAVE_JPEG=1
-$ JPEG_STATIC=0
-$ENDIF
-$!
-$NEXT3:
-$DEAS SYS$OUTPUT
-$IF (HAVE_JPEG.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for correct jpeg library ... Yes"
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for correct jpeg library ... No"
-$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html"
-$ GOTO EXIT
-$ENDIF
-$RUN TEST
-$!
-$!
-$!Checking for libTIFF
-$ DEFINE SYS$OUTPUT _NLA0:
-$ DEL TEST.*;*
-$ CC/OBJECT=TEST.OBJ/INCLUDE=(TIFF) SYS$INPUT
- #include <stdlib.h>
- #include <stdio.h>
- #include <tiffio.h>
- int main()
- {
- printf("checking libTIFF version:\t%s\n\n", TIFFGetVersion());
- return 0;
- }
-$!
-$TMP = $STATUS
-$DEAS SYS$OUTPUT
-$IF (TMP .NE. %X10B90001)
-$ THEN
-$ HAVE_TIFF=0
-$ GOTO NEXT4
-$ENDIF
-$DEFINE SYS$OUTPUT _NLA0:
-$LINK TEST, TIFF:LIBTIFF/OPT, ZLIB:LIBZ/LIB
-$TMP = $STATUS
-$!WRITE SYS$OUTPUT TMP
-$IF (TMP .NE. %X10000001)
-$ THEN
-$ HAVE_TIFF=0
-$ ELSE
-$ HAVE_TIFF=1
-$ENDIF
-$NEXT4:
-$DEAS SYS$OUTPUT
-$IF (HAVE_TIFF.EQ.1)
-$ THEN
-$ WRITE SYS$OUTPUT "Checking for TIFF library ... Yes"
-$ TIFF_LIBRARY_PATH="TIFF:LIBTIFF/OPT"
-$ RUN TEST
-$ ELSE
-$ WRITE SYS$OUTPUT "Checking for TIFF library ... No"
-$ WRITE SYS$OUTPUT "No TIFF library installed. This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html"
-$ GOTO EXIT
-$ENDIF
-$!
-$!
-$!WRITING BUILD FILES
-$!
-$IF (SHARED.EQ.64)
-$ THEN
-$ COPY SYS$INPUT [.SRC]LIBGD$DEF.OPT
-SYMBOL_VECTOR= (-
-gdAlphaBlend=PROCEDURE,-
-gdImageCreate=PROCEDURE,-
-gdImageCreateTrueColor=PROCEDURE,-
-gdImageCreateFromPng=PROCEDURE,-
-gdImageCreateFromPngCtx=PROCEDURE,-
-gdImageCreateFromPngPtr=PROCEDURE,-
-gdImageCreateFromGif=PROCEDURE,-
-gdImageCreateFromGifCtx=PROCEDURE,-
-gdImageCreateFromGifPtr=PROCEDURE,-
-gdImageCreateFromWBMP=PROCEDURE,-
-gdImageCreateFromWBMPCtx=PROCEDURE,-
-gdImageCreateFromWBMPPtr=PROCEDURE,-
-gdImageCreateFromJpeg=PROCEDURE,-
-gdImageCreateFromJpegCtx=PROCEDURE,-
-gdImageCreateFromJpegPtr=PROCEDURE,-
-gdImageCreateFromPngSource=PROCEDURE,-
-gdImageCreateFromGd=PROCEDURE,-
-gdImageCreateFromGdCtx=PROCEDURE,-
-gdImageCreateFromGdPtr=PROCEDURE,-
-gdImageCreateFromGd2=PROCEDURE,-
-gdImageCreateFromGd2Ctx=PROCEDURE,-
-gdImageCreateFromGd2Ptr=PROCEDURE,-
-gdImageCreateFromGd2Part=PROCEDURE,-
-gdImageCreateFromGd2PartCtx=PROCEDURE,-
-gdImageCreateFromGd2PartPtr=PROCEDURE,-
-gdImageCreateFromXbm=PROCEDURE,-
-gdImageCreateFromXpm=PROCEDURE,-
-gdImageStringFTCircle=PROCEDURE,-
-gdImageDestroy=PROCEDURE,-
-gdImageSetPixel=PROCEDURE,-
-gdImageGetPixel=PROCEDURE,-
-gdImageGetTrueColorPixel=PROCEDURE,-
-gdImageAABlend=PROCEDURE,-
-gdImageLine=PROCEDURE,-
-gdImageDashedLine=PROCEDURE,-
-gdImageRectangle=PROCEDURE,-
-gdImageFilledRectangle=PROCEDURE,-
-gdImageSetClip=PROCEDURE,-
-gdImageGetClip=PROCEDURE,-
-gdImageBoundsSafe=PROCEDURE,-
-gdImageChar=PROCEDURE,-
-gdImageCharUp=PROCEDURE,-
-gdImageString=PROCEDURE,-
-gdImageStringUp=PROCEDURE,-
-gdImageString16=PROCEDURE,-
-gdImageStringUp16=PROCEDURE,-
-gdFontCacheSetup=PROCEDURE,-
-gdFontCacheShutdown=PROCEDURE,-
-gdFreeFontCache=PROCEDURE,-
-gdImageStringTTF=PROCEDURE,-
-gdImageStringFT=PROCEDURE,-
-gdFTUseFontConfig=PROCEDURE,-
-gdImageStringFTEx=PROCEDURE,-
-gdImagePolygon=PROCEDURE,-
-gdImageOpenPolygon=PROCEDURE,-
-gdImageFilledPolygon=PROCEDURE,-
-gdImageColorAllocate=PROCEDURE,-
-gdImageColorAllocateAlpha=PROCEDURE,-
-gdImageColorClosest=PROCEDURE,-
-gdImageColorClosestAlpha=PROCEDURE,-
-gdImageColorClosestHWB=PROCEDURE,-
-gdImageColorExact=PROCEDURE,-
-gdImageColorExactAlpha=PROCEDURE,-
-gdImageColorResolve=PROCEDURE,-
-gdImageColorResolveAlpha=PROCEDURE,-
-gdImageColorDeallocate=PROCEDURE,-
-gdImageCreatePaletteFromTrueCol=PROCEDURE,-
-gdImageTrueColorToPalette=PROCEDURE,-
-gdImageColorTransparent=PROCEDURE,-
-gdImagePaletteCopy=PROCEDURE,-
-gdImageGif=PROCEDURE,-
-gdImagePng=PROCEDURE,-
-gdImagePngCtx=PROCEDURE,-
-gdImageGifCtx=PROCEDURE,-
-gdImagePngEx=PROCEDURE,-
-gdImagePngCtxEx=PROCEDURE,-
-gdImageWBMP=PROCEDURE,-
-gdImageWBMPCtx=PROCEDURE,-
-gdFree=PROCEDURE,-
-gdImageWBMPPtr=PROCEDURE,-
-gdImageJpeg=PROCEDURE,-
-gdImageJpegCtx=PROCEDURE,-
-gdImageJpegPtr=PROCEDURE,-
-gdImageGifAnimBegin=PROCEDURE,-
-gdImageGifAnimAdd=PROCEDURE,-
-gdImageGifAnimEnd=PROCEDURE,-
-gdImageGifAnimBeginCtx=PROCEDURE,-
-gdImageGifAnimAddCtx=PROCEDURE,-
-gdImageGifAnimEndCtx=PROCEDURE,-
-gdImageGifAnimBeginPtr=PROCEDURE,-
-gdImageGifAnimAddPtr=PROCEDURE,-
-gdImageGifAnimEndPtr=PROCEDURE,-
-gdImagePngToSink=PROCEDURE,-
-gdImageGd=PROCEDURE,-
-gdImageGd2=PROCEDURE,-
-gdImageGifPtr=PROCEDURE,-
-gdImagePngPtr=PROCEDURE,-
-gdImagePngPtrEx=PROCEDURE,-
-gdImageGdPtr=PROCEDURE,-
-gdImageGd2Ptr=PROCEDURE,-
-gdImageFilledArc=PROCEDURE,-
-gdImageArc=PROCEDURE,-
-gdImageFilledEllipse=PROCEDURE,-
-gdImageFillToBorder=PROCEDURE,-
-gdImageFill=PROCEDURE,-
-gdImageCopy=PROCEDURE,-
-gdImageCopyMerge=PROCEDURE,-
-gdImageCopyMergeGray=PROCEDURE,-
-gdImageCopyResized=PROCEDURE,-
-gdImageCopyResampled=PROCEDURE,-
-gdImageCopyRotated=PROCEDURE,-
-gdImageSetBrush=PROCEDURE,-
-gdImageSetTile=PROCEDURE,-
-gdImageSetAntiAliased=PROCEDURE,-
-gdImageSetAntiAliasedDontBlend=PROCEDURE,-
-gdImageSetStyle=PROCEDURE,-
-gdImageSetThickness=PROCEDURE,-
-gdImageInterlace=PROCEDURE,-
-gdImageAlphaBlending=PROCEDURE,-
-gdImageSaveAlpha=PROCEDURE,-
-gdNewFileCtx=PROCEDURE,-
-gdNewDynamicCtx=PROCEDURE,-
-gdNewDynamicCtxEx=PROCEDURE,-
-gdNewSSCtx=PROCEDURE,-
-gdDPExtractData=PROCEDURE,-
-gdFontGetGiant=PROCEDURE,-
-gdFontGetLarge=PROCEDURE,-
-gdFontGetMediumBold=PROCEDURE,-
-gdFontGetSmall=PROCEDURE,-
-gdFontGetTiny=PROCEDURE,-
-gdImageCompare=PROCEDURE,-
-gdImageCreateFromTiff=PROCEDURE,-
-gdImageCreateFromTiffCtx=PROCEDURE,-
-gdImageCreateFromTiffPtr=PROCEDURE,-
-gdImageCreateFromTga=PROCEDURE,-
-gdImageCreateFromTgaCtx=PROCEDURE,-
-gdImageCreateFromTgaPtr=PROCEDURE,-
-gdImageTiff=PROCEDURE,-
-gdImageTiffPtr=PROCEDURE,-
-gdImageTiffCtx=PROCEDURE,-
-gdImageCrop=PROCEDURE,-
-gdImageAutoCrop=PROCEDURE,-
-gdImageThresholdCrop=PROCEDURE,-
-gdFontGiant=DATA,-
-GDFONTLARGE=DATA,-
-GDFONTMEDIUMBOLD=DATA,-
-GDFONTSMALL=DATA,-
-GDFONTTINY=DATA-
-)
-$ENDIF
-$!
-$IF (SHARED.EQ.32)
-$ THEN
-$ COPY SYS$INPUT [.SRC]LIBGD$DEF.OPT
-UNIVERSAL=gdAlphaBlend
-UNIVERSAL=gdImageCreate
-UNIVERSAL=gdImageCreateTrueColor
-UNIVERSAL=gdImageCreateFromPng
-UNIVERSAL=gdImageCreateFromPngCtx
-UNIVERSAL=gdImageCreateFromPngPtr
-UNIVERSAL=gdImageCreateFromGif
-UNIVERSAL=gdImageCreateFromGifCtx
-UNIVERSAL=gdImageCreateFromGifPtr
-UNIVERSAL=gdImageCreateFromWBMP
-UNIVERSAL=gdImageCreateFromWBMPCtx
-UNIVERSAL=gdImageCreateFromWBMPPtr
-UNIVERSAL=gdImageCreateFromJpeg
-UNIVERSAL=gdImageStringFTCircle
-UNIVERSAL=gdImageCreateFromJpegCtx
-UNIVERSAL=gdImageCreateFromJpegPtr
-UNIVERSAL=gdImageCreateFromPngSource
-UNIVERSAL=gdImageCreateFromGd
-UNIVERSAL=gdImageCreateFromGdCtx
-UNIVERSAL=gdImageCreateFromGdPtr
-UNIVERSAL=gdImageCreateFromGd2
-UNIVERSAL=gdImageCreateFromGd2Ctx
-UNIVERSAL=gdImageCreateFromGd2Ptr
-UNIVERSAL=gdImageCreateFromGd2Part
-UNIVERSAL=gdImageCreateFromGd2PartCtx
-UNIVERSAL=gdImageCreateFromGd2PartPtr
-UNIVERSAL=gdImageCreateFromXbm
-UNIVERSAL=gdImageCreateFromXpm
-UNIVERSAL=gdImageDestroy
-UNIVERSAL=gdImageSetPixel
-UNIVERSAL=gdImageGetPixel
-UNIVERSAL=gdImageGetTrueColorPixel
-UNIVERSAL=gdImageAABlend
-UNIVERSAL=gdImageLine
-UNIVERSAL=gdImageDashedLine
-UNIVERSAL=gdImageRectangle
-UNIVERSAL=gdImageFilledRectangle
-UNIVERSAL=gdImageSetClip
-UNIVERSAL=gdImageGetClip
-UNIVERSAL=gdImageBoundsSafe
-UNIVERSAL=gdImageChar
-UNIVERSAL=gdImageCharUp
-UNIVERSAL=gdImageString
-UNIVERSAL=gdImageStringUp
-UNIVERSAL=gdImageString16
-UNIVERSAL=gdImageStringUp16
-UNIVERSAL=gdFontCacheSetup
-UNIVERSAL=gdFontCacheShutdown
-UNIVERSAL=gdFreeFontCache
-UNIVERSAL=gdImageStringTTF
-UNIVERSAL=gdImageStringFT
-UNIVERSAL=gdFTUseFontConfig
-UNIVERSAL=gdImageStringFTEx
-UNIVERSAL=gdImagePolygon
-UNIVERSAL=gdImageOpenPolygon
-UNIVERSAL=gdImageFilledPolygon
-UNIVERSAL=gdImageColorAllocate
-UNIVERSAL=gdImageColorAllocateAlpha
-UNIVERSAL=gdImageColorClosest
-UNIVERSAL=gdImageColorClosestAlpha
-UNIVERSAL=gdImageColorClosestHWB
-UNIVERSAL=gdImageColorExact
-UNIVERSAL=gdImageColorExactAlpha
-UNIVERSAL=gdImageColorResolve
-UNIVERSAL=gdImageColorResolveAlpha
-UNIVERSAL=gdImageColorDeallocate
-UNIVERSAL=gdImageCreatePaletteFromTrueCol
-UNIVERSAL=gdImageTrueColorToPalette
-UNIVERSAL=gdImageColorTransparent
-UNIVERSAL=gdImagePaletteCopy
-UNIVERSAL=gdImageGif
-UNIVERSAL=gdImagePng
-UNIVERSAL=gdImagePngCtx
-UNIVERSAL=gdImageGifCtx
-UNIVERSAL=gdImagePngEx
-UNIVERSAL=gdImagePngCtxEx
-UNIVERSAL=gdImageWBMP
-UNIVERSAL=gdImageWBMPCtx
-UNIVERSAL=gdFree
-UNIVERSAL=gdImageWBMPPtr
-UNIVERSAL=gdImageJpeg
-UNIVERSAL=gdImageJpegCtx
-UNIVERSAL=gdImageJpegPtr
-UNIVERSAL=gdImageGifAnimBegin
-UNIVERSAL=gdImageGifAnimAdd
-UNIVERSAL=gdImageGifAnimEnd
-UNIVERSAL=gdImageGifAnimBeginCtx
-UNIVERSAL=gdImageGifAnimAddCtx
-UNIVERSAL=gdImageGifAnimEndCtx
-UNIVERSAL=gdImageGifAnimBeginPtr
-UNIVERSAL=gdImageGifAnimAddPtr
-UNIVERSAL=gdImageGifAnimEndPtr
-UNIVERSAL=gdImagePngToSink
-UNIVERSAL=gdImageGd
-UNIVERSAL=gdImageGd2
-UNIVERSAL=gdImageGifPtr
-UNIVERSAL=gdImagePngPtr
-UNIVERSAL=gdImagePngPtrEx
-UNIVERSAL=gdImageGdPtr
-UNIVERSAL=gdImageGd2Ptr
-UNIVERSAL=gdImageFilledArc
-UNIVERSAL=gdImageArc
-UNIVERSAL=gdImageFilledEllipse
-UNIVERSAL=gdImageFillToBorder
-UNIVERSAL=gdImageFill
-UNIVERSAL=gdImageCopy
-UNIVERSAL=gdImageCopyMerge
-UNIVERSAL=gdImageCopyMergeGray
-UNIVERSAL=gdImageCopyResized
-UNIVERSAL=gdImageCopyResampled
-UNIVERSAL=gdImageCopyRotated
-UNIVERSAL=gdImageSetBrush
-UNIVERSAL=gdImageSetTile
-UNIVERSAL=gdImageSetAntiAliased
-UNIVERSAL=gdImageSetAntiAliasedDontBlend
-UNIVERSAL=gdImageSetStyle
-UNIVERSAL=gdImageSetThickness
-UNIVERSAL=gdImageInterlace
-UNIVERSAL=gdImageAlphaBlending
-UNIVERSAL=gdImageSaveAlpha
-UNIVERSAL=gdNewFileCtx
-UNIVERSAL=gdNewDynamicCtx
-UNIVERSAL=gdNewDynamicCtxEx
-UNIVERSAL=gdNewSSCtx
-UNIVERSAL=gdDPExtractData
-UNIVERSAL=gdFontGetGiant
-UNIVERSAL=gdFontGetLarge
-UNIVERSAL=gdFontGetMediumBold
-UNIVERSAL=gdFontGetSmall
-UNIVERSAL=gdFontGetTiny
-UNIVERSAL=gdImageCompare
-UNIVERSAL=gdFontGiant
-UNIVERSAL=gdImageCreateFromTiff
-UNIVERSAL=gdImageCreateFromTiffCtx
-UNIVERSAL=gdImageCreateFromTiffPtr
-UNIVERSAL=gdImageCreateFromTga
-UNIVERSAL=gdImageCreateFromTgaCtx
-UNIVERSAL=gdImageCreateFromTgaPtr
-UNIVERSAL=gdImageTiff
-UNIVERSAL=gdImageTiffPtr
-UNIVERSAL=gdImageTiffCtx
-UNIVERSAL=gdImageCrop
-UNIVERSAL=gdImageAutoCrop
-UNIVERSAL=gdImageThresholdCrop
-UNIVERSAL=GDFONTLARGE
-UNIVERSAL=GDFONTMEDIUMBOLD
-UNIVERSAL=GDFONTSMALL
-UNIVERSAL=GDFONTTINY
-
-$ENDIF
-$!
-$!
-$DEF SYS$OUTPUT _NL0:
-$!
-$!Making OPT file for GD$SHR.EXE, i.e without reference to himself
-$COPY SYS$INPUT [.SRC]OPT.OPT
-[]GD/LIB
-$IF ((HAVE_LIBPNG.EQ.1) .AND. (LIBPNG_STATIC.EQ.1))
-$ THEN
-$ APP SYS$INPUT [.SRC]OPT.OPT
-PNG:LIBPNG/LIB
-$ENDIF
-$IF ((HAVE_LIBPNG.EQ.1) .AND. (LIBPNG_STATIC.EQ.0))
-$ THEN
-$ APP PNG:LIBPNG$SHR.OPT [.SRC]OPT.OPT
-$ENDIF
-$!
-$IF ((HAVE_JPEG.EQ.1) .AND. (JPEG_STATIC.EQ.1) .AND. (HAVE_TIFF.NE.1))
-$ THEN
-$ APP SYS$INPUT [.SRC]OPT.OPT
-JPEG:LIBJPEG/LIB
-$ENDIF
-$IF ((HAVE_JPEG.EQ.1) .AND. (JPEG_STATIC.EQ.0) .AND. (HAVE_TIFF.NE.1))
-$ THEN
-$ APP JPEG:LIBJPEG$SHR.OPT [.SRC]OPT.OPT
-$ENDIF
-$!
-$IF (HAVE_TIFF.EQ.1)
-$ THEN
-$ APP TIFF:LIBTIFF.OPT [.SRC]OPT.OPT
-$ENDIF
-$!
-$IF (HAVE_FREETYPE.EQ.1) .AND. (FREETYPE_STATIC.EQ.1)
-$ THEN
-$ APP SYS$INPUT [.SRC]OPT.OPT
- FREETYPE2:FREETYPE/LIB
- ZLIB:LIBZ/LIB
-$ENDIF
-$IF (HAVE_FREETYPE.EQ.1) .AND. (FREETYPE_STATIC.EQ.0)
-$ THEN
-$ APP FREETYPE2:FREETYPE.OPT [.SRC]OPT.OPT
-$ENDIF
-$!
-$IF (HAVE_ZLIB.EQ.1) .AND. ((FREETYPE_STATIC.NE.1).AND.(JPEG_STATIC.NE.1))
-$ THEN
-$ IF (ZLIB_STATIC.EQ.0)
-$ THEN
-$ APP SYS$INPUT [.SRC]OPT.OPT
- SYS$SHARE:LIBZSHR/SHARE
-$ ELSE
-$ APP SYS$INPUT [.SRC]OPT.OPT
- ZLIB:LIBZ/LIB
-$ ENDIF
-$ ELSE
-$ APP SYS$INPUT [.SRC]OPT.OPT
- ZLIB:LIBZ/LIB
-$ENDIF
-$!
-$!
-$PURGE [.SRC]OPT.OPT
-$!
-$!
-$!Making working LIBGD.OPT file
-$!
-$IF (SHARED.GT.0)
-$ THEN
- $COPY SYS$INPUT [.SRC]LIBGD.OPT
- SYS$SHARE:GD$SHR/SHARE
-$ ELSE
- $COPY SYS$INPUT [.SRC]LIBGD.OPT
- LIBGD:GD/LIB
-$ENDIF
-$!
-$!Append OPT files to LIBGD.OPT
-$IF ((HAVE_LIBPNG.EQ.1) .AND. (LIBPNG_STATIC.EQ.1))
-$ THEN
-$ APP SYS$INPUT [.SRC]LIBGD.OPT
-PNG:LIBPNG/LIB
-$ENDIF
-$IF ((HAVE_LIBPNG.EQ.1) .AND. (LIBPNG_STATIC.EQ.0))
-$ THEN
-$ APP PNG:LIBPNG$SHR.OPT [.SRC]LIBGD.OPT
-$ENDIF
-$!
-$IF ((HAVE_JPEG.EQ.1) .AND. (HAVE_TIFF.NE.1) .AND. (JPEG_STATIC.EQ.1))
-$ THEN
-$ APP JPEG:LIBJPEG.OPT [.SRC]LIBGD.OPT
-$ENDIF
-$IF ((HAVE_JPEG.EQ.1) .AND. (JPEG_STATIC.EQ.0) .AND. (HAVE_TIFF.NE.1))
-$ THEN
-$ APP JPEG:LIBJPEG$SHR.OPT [.SRC]LIBGD.OPT
-$ENDIF
-$!
-$IF (HAVE_TIFF.EQ.1)
-$ THEN
-$ APP TIFF:LIBTIFF.OPT [.SRC]LIBGD.OPT
-$ENDIF
-$!
-$IF (HAVE_FREETYPE.EQ.1) .AND. (FREETYPE_STATIC.EQ.1)
-$ THEN
-$ APP SYS$INPUT [.SRC]LIBGD.OPT
- FREETYPE2:FREETYPE/LIB
- ZLIB:LIBZ/LIB
-$ENDIF
-$IF (HAVE_FREETYPE.EQ.1) .AND. (FREETYPE_STATIC.EQ.0)
-$ THEN
-$ APP FREETYPE2:FREETYPE.OPT [.SRC]LIBGD.OPT
-$ENDIF
-$!
-$IF (HAVE_ZLIB.EQ.1) .AND. ((FREETYPE_STATIC.NE.1).AND.(JPEG_STATIC.NE.1))
-$ THEN
-$ IF (ZLIB_STATIC.EQ.0)
-$ THEN
-$ APP SYS$INPUT [.SRC]LIBGD.OPT
- SYS$SHARE:LIBZSHR/SHARE
-$ ELSE
-$ APP SYS$INPUT [.SRC]LIBGD.OPT
- ZLIB:LIBZ/LIB
-$ ENDIF
-$ENDIF
-$!
-$PURGE LIBGD.OPT
-$!
-$DEAS SYS$OUTPUT
-$!
-$OPEN/WRITE OUT BUILD.COM
-$ WRITE OUT "$SET DEF [.SRC]"
-$ WRITE OUT "$",MAKE
-$ WRITE OUT "$ CURRENT = F$ENVIRONMENT (""DEFAULT"") "
-$ WRITE OUT "$TMP=CURRENT"
-$ WRITE OUT "$OPEN/WRITE OUTT [-]LIBGD$STARTUP.COM"
-$ WRITE OUT "$WRITE OUTT ""DEFINE LIBGD """"", "'","'","TMP'"""""""
-$ WRITE OUT "$WRITE OUTT ""GD2COPYPAL==""""$","'","'","TMP'"",""GD2COPYPAL"""" "
-$ WRITE OUT "$WRITE OUTT ""GD2TIME==""""$","'","'","TMP'"",""GD2TIME"""" "
-$ WRITE OUT "$WRITE OUTT ""GD2TOGIF==""""$","'","'","TMP'"",""GD2TOGIF"""" "
-$ WRITE OUT "$WRITE OUTT ""GD2TOPNG==""""$","'","'","TMP'"",""GD2TOPNG"""" "
-$ WRITE OUT "$WRITE OUTT ""GDCMPGIF==""""$","'","'","TMP'"",""GDCMPGIF"""" "
-$ WRITE OUT "$WRITE OUTT ""GDTOPNG==""""$","'","'","TMP'"",""GDTOPNG"""" "
-$ WRITE OUT "$WRITE OUTT ""GIFTOGD2==""""$","'","'","TMP'"",""GIFTOGD2"""" "
-$ WRITE OUT "$WRITE OUTT ""PNGTOGD==""""$","'","'","TMP'"",""PNGTOGD"""" "
-$ WRITE OUT "$WRITE OUTT ""PNGTOGD2==""""$","'","'","TMP'"",""PNGTOGD2"""" "
-$ WRITE OUT "$WRITE OUTT ""WEBPNG==""""$","'","'","TMP'"",""WEBPNG"""" "
-$ WRITE OUT "$CLOSE OUTT"
-$!
-$ WRITE OUT "$WRITE SYS$OUTPUT "" "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""LIBGD$STARTUP.COM has been created. "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""This file setups all logicals needed. It should be execute before using "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""Nice place to call it - LOGIN.COM "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT """" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""Using:"" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""CC/INCL=LIBGD PROG"" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""LINK PROG, LIBGD:LIBGD/OPT"" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" "
-$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" "
-$ WRITE OUT "$SET DEF [-]"
-$CLOSE OUT
-$!
-$!
-$!Writing config.h
-$COPY SYS$INPUT [.SRC]CONFIG.H
-/* Generated by configure.com for OpenVMS */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-
-#define PACKAGE_NAME "GD"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "GD 2.1.0"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "GD"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "2.1.0"
-
-/* Define to necessary symbol if this constant uses a non-standard name on
- * your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "2.1.0"
-
-/* Define to 1 if you have the `m' library (-lm). */
-#define HAVE_LIBM 1
-
-
-/* Define to 1 if you have the <libpng/png.h> header file. */
-/* #undef HAVE_LIBPNG_PNG_H */
-
-
-
-/* Define to 1 if you have the <limits.h> header file. */
-//#define HAVE_LIMITS_H 1
-
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-
-/* Define if you have POSIX threads libraries and header files. */
-#define HAVE_PTHREAD 1
-
-/* Define to 1 if you have the <stddef.h> header file. */
-#define HAVE_STDDEF_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-//#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define as const if the declaration of iconv() needs const. */
-//#define ICONV_CONST
-
-/* Name of package */
-#define PACKAGE "gd"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "http://bugs.libgd.org"
-
-/* Define to the full name of this package. */
-
-
-
-$IF HAVE_ICONV.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- /* Define if you have the iconv() function. */
- #define HAVE_ICONV 1
- /* Define to 1 if you have the <iconv.h> header file. */
- #define HAVE_ICONV_H 1
- /* Define if <iconv.h> defines iconv_t. */
- #define HAVE_ICONV_T_DEF 1
-$ENDIF
-$IF HAVE_TIFF.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBTIFF 1
-$ENDIF
-$IF HAVE_LIBPNG.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBPNG 1
-$ENDIF
-$IF HAVE_FREETYPE.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBFREETYPE 1
- #define HAVE_FT2BUILD_H 1
-$ENDIF
-$IF HAVE_JPEG.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBJPEG 1
-$ENDIF
-$IF HAVE_ZLIB.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBZ 1
-$ENDIF
-$IF HAVE_TIFF.EQ.1
-$ THEN
-$ APP SYS$INPUT [.SRC]CONFIG.H
- #define HAVE_LIBTIFF 1
-$ENDIF
-$!
-$!
-$!
-$!
-$COP SYS$INPUT [.SRC]DESCRIP.MMS
-# Generated by CONFIGURE.COM
-# Alexey Chupahin elvis_75@mail.ru
-# OpenVMS 7.3-1,8.2 DEC 2000 mod.300
-# OpenVMS 8.3 HP rx1620
-
-
-.FIRST
- DEF LIBGD []
-
-CC=cc
-CFLAGS=/OPT=(INLINE=SPEED) /INCL=([],JPEG,PNG,FREETYPE2,ZLIB,TIFF) /DEF=(HAVE_CONFIG_H)/WARN=(DIS=MACROREDEF)
-LIBS=[]LIBGD/OPT
-
-
-ALL : \
-gd.olb,\
-$IF (SHARED.GT.0)
-$ THEN
-$ APP SYS$INPUT [.SRC]DESCRIP.MMS
-gd$shr.exe,\
-$ENDIF
-$!
-$APP SYS$INPUT [.SRC]DESCRIP.MMS
-annotate.exe,\
-circletexttest.exe,\
-fontconfigtest.exe,\
-circletexttest.exe,\
-fontconfigtest.exe,\
-fontsizetest.exe,\
-fontwheeltest.exe,\
-gd2copypal.exe,\
-gd2time.exe,\
-gd2togif.exe,\
-gd2topng.exe,\
-gdcmpgif.exe,\
-gddemo.exe,\
-gdtest.exe,\
-gdtestft.exe,\
-gdtopng.exe,\
-gifanimtest.exe,\
-giftogd2.exe,\
-pngtogd.exe,\
-pngtogd2.exe,\
-testac.exe,\
-testtr.exe,\
-webpng.exe,\
-gdparttopng.exe
- $!
-
-annotate.exe : annotate.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-circletexttest.exe : circletexttest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-fontconfigtest.exe : fontconfigtest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-fontsizetest.exe : fontsizetest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-fontwheeltest.exe : fontwheeltest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-gd2copypal.exe : gd2copypal.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-gd2time.exe : gd2time.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-gd2togif.exe : gd2togif.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-gd2topng.exe : gd2topng.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gdcmpgif.exe : gdcmpgif.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gddemo.exe : gddemo.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gdtest.exe : gdtest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gdtestft.exe : gdtestft.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gdtopng.exe : gdtopng.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gifanimtest.exe : gifanimtest.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-giftogd2.exe : giftogd2.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-giftogd2.obj : giftogd2.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-pngtogd.exe : pngtogd.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-pngtogd2.exe : pngtogd2.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-testac.exe : testac.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-testtr.exe : testtr.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-webpng.exe : webpng.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-gdparttopng.exe : gdparttopng.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=TMP.OBJ
- LINK/EXE=$(MMS$TARGET) TMP.OBJ, $(LIBS)
- DEL TMP.OBJ;*
-
-
-OBJ=\
-gd.obj,\
-gdcache.obj,\
-gdfontg.obj,\
-gdfontl.obj,\
-gdfontmb.obj,\
-gdfonts.obj,\
-gdfontt.obj,\
-gdft.obj,\
-gdfx.obj,\
-gdhelpers.obj,\
-gdkanji.obj,\
-gdtables.obj,\
-gdxpm.obj,\
-gd_bmp.obj,\
-gd_gd.obj,\
-gd_gd2.obj,\
-gd_gif_in.obj,\
-gd_gif_out.obj,\
-gd_io.obj,\
-gd_io_dp.obj,\
-gd_io_file.obj,\
-gd_io_ss.obj,\
-gd_jpeg.obj,\
-gd_png.obj,\
-gd_security.obj,\
-gd_ss.obj,\
-gd_crop.obj,\
-gd_tga.obj,\
-gd_tiff.obj,\
-gd_transform.obj,\
-gd_topal.obj,\
-gd_wbmp.obj,\
-wbmp.obj
-
-
-gd_transform.obj : gd_transform.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_tiff.obj : gd_tiff.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_tga.obj : gd_tga.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_bmp.obj : gd_bmp.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_crop.obj : gd_crop.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd.obj : gd.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdcache.obj : gdcache.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfontg.obj : gdfontg.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfontl.obj : gdfontl.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfontmb.obj : gdfontmb.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfonts.obj : gdfonts.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfontt.obj : gdfontt.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdft.obj : gdft.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdfx.obj : gdfx.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdhelpers.obj : gdhelpers.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdkanji.obj : gdkanji.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdtables.obj : gdtables.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gdxpm.obj : gdxpm.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_gd.obj : gd_gd.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_gd2.obj : gd_gd2.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_gif_in.obj : gd_gif_in.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_gif_out.obj : gd_gif_out.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_io.obj : gd_io.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_io_dp.obj : gd_io_dp.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_io_file.obj : gd_io_file.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_io_ss.obj : gd_io_ss.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_jpeg.obj : gd_jpeg.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_png.obj : gd_png.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_security.obj : gd_security.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_ss.obj : gd_ss.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_topal.obj : gd_topal.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-gd_wbmp.obj : gd_wbmp.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-wbmp.obj : wbmp.c
- $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)
-
-
-GD.OLB : $(OBJ)
- LIB/CREA GD.OLB $(OBJ)
-
-GD$SHR.EXE : $(OBJ)
- LINK/SHARE=GD$SHR GD.OBJ,LIBGD$DEF/OPT,OPT/OPT
- COPY GD$SHR.EXE SYS$SHARE
-
-CLEAN :
- DEL [...]*.OBJ;*
- DEL [...]*.OLB;*
- DEL [...]*.EXE;*
-$!DEL TMP.MMS;*
-$!
-$IF (F$SEARCH("[.SRC]GD.H;2").EQS."")
-$ THEN
-$ WRITE SYS$OUTPUT "Patching GD.H"
-$ DEF SYS$OUTPUT "_NLA0:"
-$ COPY SYS$INPUT [.SRC]GD.H;2
-#define gdImageCreatePaletteFromTrueColor gdImageCreatePaletteFromTrueCol
-
-$ APP [.SRC]GD.H;1 [.SRC]GD.H;2
-$ DEAS SYS$INPUT
-$ENDIF
-$!
-$!
-$!
-$!
-$WRITE SYS$OUTPUT " "
-$WRITE SYS$OUTPUT " "
-$WRITE SYS$OUTPUT "Now you can type @BUILD "
-$!
-$EXIT:
-$DEFINE SYS$OUTPUT _NLA0:
-$DEL TEST.OBJ;*
-$DEL TEST.C;*
-$DEL TEST.EXE;*
-$DEAS SYS$OUTPUT
diff --git a/VMS/README.VMS b/VMS/README.VMS
deleted file mode 100644
index cdeee56..0000000
--- a/VMS/README.VMS
+++ /dev/null
@@ -1,71 +0,0 @@
-Dear OpenVMS user,
-
-Installation process is identical to one in *nix* world and consist to
-four simple steps:
-1. Installing required libraries
-2. Configuration
-3. Compiling
-4. Installation.
-
-
-1. Please install required libraries first:
-
-1. ZLIB 1.2 or newer
-2. PNG 1.2.12 or newer
-3. FreeType 2
-4. JPEG 6B
-
-All may be found at OpenVMS libSDL porting project site
-http://fafner.dyndns.org/~alexey/libsdl/required.html
-
-Also, system should have MMS make utility from DEC or
-free analogue MMK. And C compiler with runtime, of course. ;)
-
-
-2. Configuration is doing automatically by a configuration script:
-
-$@[.VMS]CONFIGURE
-
-The script detects hardware,system and required libraries have been installed.
-Compilation stage will be prepeared to create shared and static libraries.
-Alpha,IA64 or VAX platform are supported. Optional argument "static"
-tells to configurator to make static libraries only:
-
-$@[.VMS]CONFIGURE STATIC
-
-CONFIGURE script checks your ZLIB, FREETYPE, JPEG, PNG libraries.
-If it detects any troubles, you may get and install good and tested ones
-from OpenVMS libSDL porting project site:
-http://fafner.dyndns.org/~alexey/libsdl/required.html
-
-When success, it creates a building script named BUILD.COM
-
-3. Compilation:
-
-$@BUILD
-
-It should be error-free.
-
-When success, it creates a setup script named LIBGD$STARTUP.COM
-
-4. Setup OpenVMS environment before using libGD:
-
-$@LIBGD$STARTUP
-
-LIBGD and its utilites are ready to using.
-
-Optionally you may insert this startup file into your LOGIN.COM
-to set libGD environment every time you login automatically.
-
-To learn libGD please refer libGD official documentation.
-Compiling with library should be:
-
-$CC/INCL=LIBGD PROG
-$LINK PROG, LIBGD:LIBGD/OPT
-
-
-
-yours,
-Alexey Chupahin
-Rostov-on-Don, Russia
-elvis_75@mail.ru alex@rostov.rs-ultra.ru
diff --git a/appveyor.yml b/appveyor.yml
index 70a2b62..268fcef 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,207 +1,207 @@
-version: 2.1.1.{build}
-shallow_clone: true
-
-
-environment:
- # settings
- min_build: 0 # if 1 overwrites tbs_gd_* flags to leave png and jpeg
-
- tbs_gd_png: 1
- tbs_gd_jpeg: 1
- tbs_gd_freetype: 1
- tbs_gd_iconv: 0 # todo: add iconv thumbs
- tbs_gd_tiff: 1
-
- build_bindings: 1 # build .net bidnings
- pack_dlls: 1 # pack dll with upx
-
-
- matrix:
- - tbs_arch: "x86"
- tbs_tools: "msvc12"
- tbs_static_runtime: 0
-
- - tbs_arch: "x64"
- tbs_tools: "msvc12"
- tbs_static_runtime: 0
-
- - tbs_arch: "x86"
- tbs_tools: "mingw"
- tbs_static_runtime: 1
-
- - tbs_arch: "x64"
- tbs_tools: "mingw"
- tbs_static_runtime: 1
-
-
-
-install:
- - if [%min_build%]==[1] (
- SET tbs_gd_png=1&&
- SET tbs_gd_jpeg=1&&
- SET tbs_gd_freetype=0&&
- SET tbs_gd_iconv=0&&
- SET tbs_gd_tiff=0)
-
- - ps: if($env:build_platform -eq 'x64') {
- $env:vcvar_arg = 'x86_amd64';
- }
- else {
- $env:vcvar_arg = 'x86';
- }
-
- - ps: 'function prepend($file, $line) { Set-Content (Resolve-Path $file) -value $line,(Get-Content (Resolve-Path $file)) }'
-
- # get common functions
- - git clone https://github.com/imazen/gd-appveyor-helpers
- - ps: . .\gd-appveyor-helpers\appveyor_funcs.ps1
-
-
- # fetch deps
- - mkdir deps
- - ps: if($env:build_bindings -eq 1) { invoke 'git' 'clone https://github.com/imazen/gd-dotnet-bindings-generator.git --depth 1' }
-
- - nuget install zlib-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/zlib-94hmpf3q011d
- - ps: move zlib*\* deps -force
- - if [%tbs_tools%]==[mingw] move deps\libzlibstatic.a deps\libz.a
- - if [%tbs_tools%]==[msvc12] move deps\zlibstatic.lib deps\zlib.lib
- - SET tbsd_zlib_built=1
- - SET tbsd_zlib_incdir=deps
- - SET tbsd_zlib_libdir=deps
-
- - if [%tbs_gd_jpeg%]==[1] (
- nuget install libjpeg-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libjpeg-turbo-t70qw53csfhj &&
- powershell -Command "move libjpeg*\* deps -force" &&
- (if [%tbs_tools%]==[msvc12] move deps\jpeg_static.lib deps\jpeg.lib) &&
- SET tbsd_libjpeg_turbo_built=1)
-
- - if [%tbs_gd_png%]==[1] (
- nuget install libpng-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libpng-7hwq4pmmrc48 &&
- powershell -Command "move libpng*\* deps -force" &&
- (if [%tbs_tools%]==[mingw] move deps\libpng16.a deps\libpng.a) &&
- (if [%tbs_tools%]==[msvc12] move deps\libpng16_static.lib deps\png.lib) &&
- SET tbsd_libpng_built=1)
-
- - if [%tbs_gd_freetype%]==[1] (
- nuget install freetype-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/freetype-vf7bw7v5ec29 &&
- powershell -Command "move freetype*\* deps -force" &&
- (if [%tbs_tools%]==[msvc12] move deps\freetype_static.lib deps\freetype.lib) &&
- SET tbsd_freetype_built=1)
-
- - if [%tbs_gd_tiff%]==[1] (
- nuget install libtiff-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libtiff-i3h8tqqy7o7b &&
- powershell -Command "move libtiff*\* deps -force" &&
- (if [%tbs_tools%]==[msvc12] move deps\tiff_static.lib deps\tiff.lib) &&
- SET tbsd_libtiff_built=1)
-
- # remove dyn libs
- - del deps\*.dll*
-
-
-
- # get upx (cinst broken; gets dos ver)
- #- if [%pack_dlls%]==[1] cinst upx
- - if [%pack_dlls%]==[1] (
- curl -L -o upx.zip http://upx.sourceforge.net/download/upx391w.zip &&
- 7z e upx.zip *.exe -r )
-
- # get mingw-w64-dgn (C:\mingw64)
- - ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x64') {
- invoke 'curl' '-L -o mw64.7z "http://libgd.blob.core.windows.net/mingw/mingw-w64-dgn-x86_64-20141001.7z"';
- invoke '7z' 'x -oC:\ mw64.7z'; }
-
- # get mingw-w64-32bit (C:\mingw32)
- - ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x86' -and $env:build_bindings -eq 1) {
- invoke 'curl' '-L -o mw64-32.7z "http://libgd.blob.core.windows.net/mingw/i686-4.9.1-release-posix-dwarf-rt_v3-rev1.7z"';
- invoke '7z' 'x -oC:\ mw64-32.7z'; }
-
-
-
-
-build_script:
- - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall" %vcvar_arg%'
- - if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x86] SET PATH=C:\mingw\bin;%PATH%
- - if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x64] SET PATH=C:\mingw64\bin;%PATH%
-
- - SET zip=libgd-%tbs_tools%-%tbs_arch%.zip
- - ps: $nupkg_b = "libgd-$($env:tbs_tools)-$($env:tbs_arch)-$($env:APPVEYOR_REPO_BRANCH)";
- - ps: $nupkg_c = "libgd-$($env:tbs_tools)-$($env:tbs_arch)-$($env:APPVEYOR_REPO_COMMIT)";
-
- - if [%tbs_arch%]==[x86] SET dll_make=C:\mingw32\bin\mingw32-make.exe
- - if [%tbs_arch%]==[x64] SET dll_make=C:\mingw64\bin\mingw32-make.exe
-
- - for /f "tokens=*" %%i in ('thumbs list_bin') do set dll_name=%%i
- - SET dll_name=%dll_name:/=\%
- - for /f %%i in ("%dll_name%") do set dll_basename=%%~nxi
- - SET dll_raw=%dll_name%.raw
- - if [%tbs_tools%]==[msvc12] SET cli_args=%dll_basename%
- - if [%tbs_tools%]==[mingw] SET cli_args=%dll_make% %dll_basename%
-
- - thumbs make
- - for /f "tokens=*" %%i in ('thumbs list') do set files=%%i
-
- - copy %dll_name% %dll_raw%
- - if [%pack_dlls%]==[1] (
- appveyor PushArtifact %dll_raw% &&
- del %dll_name% &&
- upx -o %dll_name% %dll_raw% )
-
- - 7z a %zip% %files%
- - appveyor PushArtifact %zip%
-
- - ps: if(Test-Path $env:zip) {
- zip2nuget $env:zip $nupkg_b;
- zip2nuget $env:zip $nupkg_c; }
-
-
- # build bindings
-
- - ps: if($env:with_tiff -eq 0 -and $env:build_bindings -eq 1) {
- prepend 'gd-dotnet-bindings-generator\LibGD.CLI\LibGDExtensions.cs' '#define NO_TIFF';
- $env:test_defs += 'NO_TIFF;' }
- - ps: if($env:with_freetype -eq 0 -and $env:build_bindings -eq 1) {
- prepend 'gd-dotnet-bindings-generator\LibGD.CLI\LibGDExtensions.cs' '#define NO_FREETYPE';
- $env:test_defs += 'NO_FREETYPE;' }
-
- - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall"'
- - if [%build_bindings%]==[1] (
- cd gd-dotnet-bindings-generator &&
- msbuild LibGD.CLI\LibGD.CLI.csproj /p:Configuration=Debug /p:Platform=AnyCPU /v:m &&
- copy ..\%dll_raw% LibGD.CLI\bin\Debug\%dll_basename% &&
- cd LibGD.CLI\bin\Debug &&
- LibGD.CLI.exe %APPVEYOR_BUILD_FOLDER%\src %cli_args% &&
- cd ..\..\.. &&
- msbuild LibGD.Tests\LibGD.Tests.csproj /p:Configuration=Debug /p:Platform=AnyCPU /p:DefineConstants="%test_defs%" /v:m &&
- cd..)
-
- - SET zip=LibGDSharp-%tbs_tools%-%tbs_arch%.zip
- - ps: if($env:build_bindings -eq 1) {
- invoke '7z' "a $($env:zip)
- .\$($env:dll_pack)
- .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\_iobuf.cs
- .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGD.cs
- .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGDExtensions.cs
- .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGDSharp.dll";
- Push-AppveyorArtifact $($env:zip); }
-
- - appveyor PushArtifact src\config.h
-
-
-
-
-test_script:
- - SET fail=0
- - thumbs check || SET fail=1 & ver > nul
- - ps: Push-Ctest-Results 'build'
- - ps: Push-AppveyorArtifact build\Testing\Temporary\LastTest.log
- - exit %fail%
-
- - if [%build_bindings%]==[1] (
- copy %dll_name% gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\%dll_basename% &&
- (if [%tbs_arch%]==[x86] (nunit-console-x86 gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\LibGD.Tests.dll)
- else if [%tbs_arch%]==[x64] (nunit-console gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\LibGD.Tests.dll)) &&
- appveyor PushArtifact TestResult.xml )
-
-on_success:
- - ps: Push-AppveyorArtifact "$nupkg_b*.nupkg"
- - ps: Push-AppveyorArtifact "$nupkg_c*.nupkg"
+version: 2.1.1.{build}
+shallow_clone: true
+
+
+environment:
+ # settings
+ min_build: 0 # if 1 overwrites tbs_gd_* flags to leave png and jpeg
+
+ tbs_gd_png: 1
+ tbs_gd_jpeg: 1
+ tbs_gd_freetype: 1
+ tbs_gd_iconv: 0 # todo: add iconv thumbs
+ tbs_gd_tiff: 1
+
+ build_bindings: 1 # build .net bidnings
+ pack_dlls: 1 # pack dll with upx
+
+
+ matrix:
+ - tbs_arch: "x86"
+ tbs_tools: "msvc12"
+ tbs_static_runtime: 0
+
+ - tbs_arch: "x64"
+ tbs_tools: "msvc12"
+ tbs_static_runtime: 0
+
+ - tbs_arch: "x86"
+ tbs_tools: "mingw"
+ tbs_static_runtime: 1
+
+ - tbs_arch: "x64"
+ tbs_tools: "mingw"
+ tbs_static_runtime: 1
+
+
+
+install:
+ - if [%min_build%]==[1] (
+ SET tbs_gd_png=1&&
+ SET tbs_gd_jpeg=1&&
+ SET tbs_gd_freetype=0&&
+ SET tbs_gd_iconv=0&&
+ SET tbs_gd_tiff=0)
+
+ - ps: if($env:build_platform -eq 'x64') {
+ $env:vcvar_arg = 'x86_amd64';
+ }
+ else {
+ $env:vcvar_arg = 'x86';
+ }
+
+ - ps: 'function prepend($file, $line) { Set-Content (Resolve-Path $file) -value $line,(Get-Content (Resolve-Path $file)) }'
+
+ # get common functions
+ - git clone https://github.com/imazen/gd-appveyor-helpers
+ - ps: . .\gd-appveyor-helpers\appveyor_funcs.ps1
+
+
+ # fetch deps
+ - mkdir deps
+ - ps: if($env:build_bindings -eq 1) { invoke 'git' 'clone https://github.com/imazen/gd-dotnet-bindings-generator.git --depth 1' }
+
+ - nuget install zlib-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/zlib-94hmpf3q011d
+ - ps: move zlib*\* deps -force
+ - if [%tbs_tools%]==[mingw] move deps\libzlibstatic.a deps\libz.a
+ - if [%tbs_tools%]==[msvc12] move deps\zlibstatic.lib deps\zlib.lib
+ - SET tbsd_zlib_built=1
+ - SET tbsd_zlib_incdir=deps
+ - SET tbsd_zlib_libdir=deps
+
+ - if [%tbs_gd_jpeg%]==[1] (
+ nuget install libjpeg-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libjpeg-turbo-t70qw53csfhj &&
+ powershell -Command "move libjpeg*\* deps -force" &&
+ (if [%tbs_tools%]==[msvc12] move deps\jpeg_static.lib deps\jpeg.lib) &&
+ SET tbsd_libjpeg_turbo_built=1)
+
+ - if [%tbs_gd_png%]==[1] (
+ nuget install libpng-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libpng-7hwq4pmmrc48 &&
+ powershell -Command "move libpng*\* deps -force" &&
+ (if [%tbs_tools%]==[mingw] move deps\libpng16.a deps\libpng.a) &&
+ (if [%tbs_tools%]==[msvc12] move deps\libpng16_static.lib deps\png.lib) &&
+ SET tbsd_libpng_built=1)
+
+ - if [%tbs_gd_freetype%]==[1] (
+ nuget install freetype-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/freetype-vf7bw7v5ec29 &&
+ powershell -Command "move freetype*\* deps -force" &&
+ (if [%tbs_tools%]==[msvc12] move deps\freetype_static.lib deps\freetype.lib) &&
+ SET tbsd_freetype_built=1)
+
+ - if [%tbs_gd_tiff%]==[1] (
+ nuget install libtiff-%tbs_tools%-%tbs_arch%-master -Source https://ci.appveyor.com/nuget/libtiff-i3h8tqqy7o7b &&
+ powershell -Command "move libtiff*\* deps -force" &&
+ (if [%tbs_tools%]==[msvc12] move deps\tiff_static.lib deps\tiff.lib) &&
+ SET tbsd_libtiff_built=1)
+
+ # remove dyn libs
+ - del deps\*.dll*
+
+
+
+ # get upx (cinst broken; gets dos ver)
+ #- if [%pack_dlls%]==[1] cinst upx
+ - if [%pack_dlls%]==[1] (
+ curl -L -o upx.zip http://upx.sourceforge.net/download/upx391w.zip &&
+ 7z e upx.zip *.exe -r )
+
+ # get mingw-w64-dgn (C:\mingw64)
+ - ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x64') {
+ invoke 'curl' '-L -o mw64.7z "http://libgd.blob.core.windows.net/mingw/mingw-w64-dgn-x86_64-20141001.7z"';
+ invoke '7z' 'x -oC:\ mw64.7z'; }
+
+ # get mingw-w64-32bit (C:\mingw32)
+ - ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x86' -and $env:build_bindings -eq 1) {
+ invoke 'curl' '-L -o mw64-32.7z "http://libgd.blob.core.windows.net/mingw/i686-4.9.1-release-posix-dwarf-rt_v3-rev1.7z"';
+ invoke '7z' 'x -oC:\ mw64-32.7z'; }
+
+
+
+
+build_script:
+ - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall" %vcvar_arg%'
+ - if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x86] SET PATH=C:\mingw\bin;%PATH%
+ - if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x64] SET PATH=C:\mingw64\bin;%PATH%
+
+ - SET zip=libgd-%tbs_tools%-%tbs_arch%.zip
+ - ps: $nupkg_b = "libgd-$($env:tbs_tools)-$($env:tbs_arch)-$($env:APPVEYOR_REPO_BRANCH)";
+ - ps: $nupkg_c = "libgd-$($env:tbs_tools)-$($env:tbs_arch)-$($env:APPVEYOR_REPO_COMMIT)";
+
+ - if [%tbs_arch%]==[x86] SET dll_make=C:\mingw32\bin\mingw32-make.exe
+ - if [%tbs_arch%]==[x64] SET dll_make=C:\mingw64\bin\mingw32-make.exe
+
+ - for /f "tokens=*" %%i in ('thumbs list_bin') do set dll_name=%%i
+ - SET dll_name=%dll_name:/=\%
+ - for /f %%i in ("%dll_name%") do set dll_basename=%%~nxi
+ - SET dll_raw=%dll_name%.raw
+ - if [%tbs_tools%]==[msvc12] SET cli_args=%dll_basename%
+ - if [%tbs_tools%]==[mingw] SET cli_args=%dll_make% %dll_basename%
+
+ - thumbs make
+ - for /f "tokens=*" %%i in ('thumbs list') do set files=%%i
+
+ - copy %dll_name% %dll_raw%
+ - if [%pack_dlls%]==[1] (
+ appveyor PushArtifact %dll_raw% &&
+ del %dll_name% &&
+ upx -o %dll_name% %dll_raw% )
+
+ - 7z a %zip% %files%
+ - appveyor PushArtifact %zip%
+
+ - ps: if(Test-Path $env:zip) {
+ zip2nuget $env:zip $nupkg_b;
+ zip2nuget $env:zip $nupkg_c; }
+
+
+ # build bindings
+
+ - ps: if($env:with_tiff -eq 0 -and $env:build_bindings -eq 1) {
+ prepend 'gd-dotnet-bindings-generator\LibGD.CLI\LibGDExtensions.cs' '#define NO_TIFF';
+ $env:test_defs += 'NO_TIFF;' }
+ - ps: if($env:with_freetype -eq 0 -and $env:build_bindings -eq 1) {
+ prepend 'gd-dotnet-bindings-generator\LibGD.CLI\LibGDExtensions.cs' '#define NO_FREETYPE';
+ $env:test_defs += 'NO_FREETYPE;' }
+
+ - '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall"'
+ - if [%build_bindings%]==[1] (
+ cd gd-dotnet-bindings-generator &&
+ msbuild LibGD.CLI\LibGD.CLI.csproj /p:Configuration=Debug /p:Platform=AnyCPU /v:m &&
+ copy ..\%dll_raw% LibGD.CLI\bin\Debug\%dll_basename% &&
+ cd LibGD.CLI\bin\Debug &&
+ LibGD.CLI.exe %APPVEYOR_BUILD_FOLDER%\src %cli_args% &&
+ cd ..\..\.. &&
+ msbuild LibGD.Tests\LibGD.Tests.csproj /p:Configuration=Debug /p:Platform=AnyCPU /p:DefineConstants="%test_defs%" /v:m &&
+ cd..)
+
+ - SET zip=LibGDSharp-%tbs_tools%-%tbs_arch%.zip
+ - ps: if($env:build_bindings -eq 1) {
+ invoke '7z' "a $($env:zip)
+ .\$($env:dll_pack)
+ .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\_iobuf.cs
+ .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGD.cs
+ .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGDExtensions.cs
+ .\gd-dotnet-bindings-generator\LibGD.CLI\bin\Debug\LibGDSharp.dll";
+ Push-AppveyorArtifact $($env:zip); }
+
+ - appveyor PushArtifact src\config.h
+
+
+
+
+test_script:
+ - SET fail=0
+ - thumbs check || SET fail=1 & ver > nul
+ - ps: Push-Ctest-Results 'build'
+ - ps: Push-AppveyorArtifact build\Testing\Temporary\LastTest.log
+ - exit %fail%
+
+ - if [%build_bindings%]==[1] (
+ copy %dll_name% gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\%dll_basename% &&
+ (if [%tbs_arch%]==[x86] (nunit-console-x86 gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\LibGD.Tests.dll)
+ else if [%tbs_arch%]==[x64] (nunit-console gd-dotnet-bindings-generator\LibGD.Tests\bin\Debug\LibGD.Tests.dll)) &&
+ appveyor PushArtifact TestResult.xml )
+
+on_success:
+ - ps: Push-AppveyorArtifact "$nupkg_b*.nupkg"
+ - ps: Push-AppveyorArtifact "$nupkg_c*.nupkg"
diff --git a/bootstrap.sh b/bootstrap.sh
index ffd978c..19beb36 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,5 +1,4 @@
#!/bin/sh --
-# $Id$
# Small shell script to build gd from source
v() { echo "$@"; "$@"; }
@@ -10,8 +9,8 @@ v() { echo "$@"; "$@"; }
# so that random hackers don't need it just to build the code.
v docs/naturaldocs/run_docs.sh --nonfatal
-if echo "${OSTYPE:-$(uname)}" | grep -q '^darwin' ; then
- echo "Having trouble on OS X? Try: brew install autoconf libtool automake gettext apple-gcc42 pkg-config cmake"
+if uname | grep -qi '^darwin' ; then
+ echo "Having trouble on OS X? Try: brew install autoconf libtool automake gettext pkg-config cmake"
fi
if ! v autoreconf -f -i ; then
@@ -20,8 +19,9 @@ fi
(
echo "/* Generated from config.hin via autoheader for cmake; see bootstrap.sh. */"
-sed \
+sed -E \
-e '1d' \
+ -e '/ENABLE_/s:#undef:#cmakedefine01:' \
-e 's:#undef:#cmakedefine:' \
src/config.hin
) > src/config.h.cmake
diff --git a/cmake/distclean.sh b/cmake/distclean.sh
index 0124dd1..c47a6be 100755
--- a/cmake/distclean.sh
+++ b/cmake/distclean.sh
@@ -12,7 +12,7 @@ Clean all the cmake generated output files.
Options:
--automake Do not clean files autotools also creates
EOF
- exit ${1:-0}
+ exit "${1:-0}"
}
AUTOMAKE="false"
diff --git a/cmake/modules/AC_HEADER_STDC.cmake b/cmake/modules/AC_HEADER_STDC.cmake
index d3775ea..fafc76b 100644
--- a/cmake/modules/AC_HEADER_STDC.cmake
+++ b/cmake/modules/AC_HEADER_STDC.cmake
@@ -1,13 +1,8 @@
# Keep in sync with AC_CHECK_HEADERS in configure.ac.
check_include_files(dirent.h HAVE_DIRENT_H)
-check_include_files(errno.h HAVE_ERRNO_H)
check_include_files(inttypes.h HAVE_INTTYPES_H)
-check_include_files(limits.h HAVE_LIMITS_H)
-check_include_files(stddef.h HAVE_STDDEF_H)
check_include_files(stdint.h HAVE_STDINT_H)
-check_include_files(stdlib.h HAVE_STDLIB_H)
-check_include_files(string.h HAVE_STRING_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(unistd.h HAVE_UNISTD_H)
diff --git a/cmake/modules/CMakeParseArguments.cmake b/cmake/modules/CMakeParseArguments.cmake
deleted file mode 100644
index b57b029..0000000
--- a/cmake/modules/CMakeParseArguments.cmake
+++ /dev/null
@@ -1,156 +0,0 @@
-# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
-#
-# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
-# parsing the arguments given to that macro or function.
-# It processes the arguments and defines a set of variables which hold the
-# values of the respective options.
-#
-# The <options> argument contains all options for the respective macro,
-# i.e. keywords which can be used when calling the macro without any value
-# following, like e.g. the OPTIONAL keyword of the install() command.
-#
-# The <one_value_keywords> argument contains all keywords for this macro
-# which are followed by one value, like e.g. DESTINATION keyword of the
-# install() command.
-#
-# The <multi_value_keywords> argument contains all keywords for this macro
-# which can be followed by more than one value, like e.g. the TARGETS or
-# FILES keywords of the install() command.
-#
-# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
-# keywords listed in <options>, <one_value_keywords> and
-# <multi_value_keywords> a variable composed of the given <prefix>
-# followed by "_" and the name of the respective keyword.
-# These variables will then hold the respective value from the argument list.
-# For the <options> keywords this will be TRUE or FALSE.
-#
-# All remaining arguments are collected in a variable
-# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
-# your macro was called with unrecognized parameters.
-#
-# As an example here a my_install() macro, which takes similar arguments as the
-# real install() command:
-#
-# function(MY_INSTALL)
-# set(options OPTIONAL FAST)
-# set(oneValueArgs DESTINATION RENAME)
-# set(multiValueArgs TARGETS CONFIGURATIONS)
-# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
-# ...
-#
-# Assume my_install() has been called like this:
-# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
-#
-# After the cmake_parse_arguments() call the macro will have set the following
-# variables:
-# MY_INSTALL_OPTIONAL = TRUE
-# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
-# MY_INSTALL_DESTINATION = "bin"
-# MY_INSTALL_RENAME = "" (was not used)
-# MY_INSTALL_TARGETS = "foo;bar"
-# MY_INSTALL_CONFIGURATIONS = "" (was not used)
-# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
-#
-# You can the continue and process these variables.
-#
-# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
-# another recognized keyword follows, this is interpreted as the beginning of
-# the new option.
-# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
-# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
-# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
-
-#=============================================================================
-# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# * The names of Kitware, Inc., the Insight Consortium, or the names of
-# any consortium members, or of any contributors, may not be used to
-# endorse or promote products derived from this software without
-# specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#=============================================================================
-
-
-if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
- return()
-endif()
-set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
-
-
-function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
- # first set all result variables to empty/FALSE
- foreach(arg_name ${_singleArgNames} ${_multiArgNames})
- set(${prefix}_${arg_name})
- endforeach()
-
- foreach(option ${_optionNames})
- set(${prefix}_${option} FALSE)
- endforeach()
-
- set(${prefix}_UNPARSED_ARGUMENTS)
-
- set(insideValues FALSE)
- set(currentArgName)
-
- # now iterate over all arguments and fill the result variables
- foreach(currentArg ${ARGN})
- list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
- list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
- list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
-
- if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
- if(insideValues)
- if("${insideValues}" STREQUAL "SINGLE")
- set(${prefix}_${currentArgName} ${currentArg})
- set(insideValues FALSE)
- elseif("${insideValues}" STREQUAL "MULTI")
- list(APPEND ${prefix}_${currentArgName} ${currentArg})
- endif()
- else()
- list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
- endif()
- else()
- if(NOT ${optionIndex} EQUAL -1)
- set(${prefix}_${currentArg} TRUE)
- set(insideValues FALSE)
- elseif(NOT ${singleArgIndex} EQUAL -1)
- set(currentArgName ${currentArg})
- set(${prefix}_${currentArgName})
- set(insideValues "SINGLE")
- elseif(NOT ${multiArgIndex} EQUAL -1)
- set(currentArgName ${currentArg})
- set(${prefix}_${currentArgName})
- set(insideValues "MULTI")
- endif()
- endif()
-
- endforeach()
-
- # propagate the result variables to the caller:
- foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
- set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
- endforeach()
- set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
-
-endfunction()
diff --git a/cmake/modules/CheckDIRSymbolExists.cmake b/cmake/modules/CheckDIRSymbolExists.cmake
index dde6c7f..fd71e7f 100644
--- a/cmake/modules/CheckDIRSymbolExists.cmake
+++ b/cmake/modules/CheckDIRSymbolExists.cmake
@@ -7,16 +7,16 @@
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
-#
+#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
-#
+#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -39,7 +39,7 @@
# the AC_HEADER_DIRENT test programme rather than the CheckSymbolExists.cmake
# test programme which always fails since DIR tends to be typedef'd
# rather than #define'd.
-#
+#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
@@ -53,7 +53,7 @@ MACRO(CHECK_DIRSYMBOL_EXISTS FILES VARIABLE)
SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
SET(MACRO_CHECK_DIRSYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
IF(CMAKE_REQUIRED_LIBRARIES)
- SET(CHECK_DIRSYMBOL_EXISTS_LIBS
+ SET(CHECK_DIRSYMBOL_EXISTS_LIBS
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ELSE(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_DIRSYMBOL_EXISTS_LIBS)
@@ -79,7 +79,7 @@ MACRO(CHECK_DIRSYMBOL_EXISTS FILES VARIABLE)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckDIRSymbolExists.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- CMAKE_FLAGS
+ CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_DIRSYMBOL_EXISTS_FLAGS}
"${CHECK_DIRSYMBOL_EXISTS_LIBS}"
"${CMAKE_DIRSYMBOL_EXISTS_INCLUDES}"
@@ -87,7 +87,7 @@ MACRO(CHECK_DIRSYMBOL_EXISTS FILES VARIABLE)
IF(${VARIABLE})
MESSAGE(STATUS "Looking for DIR in ${FILES} - found")
SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol DIR")
- FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
+ FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Determining if the DIR symbol is defined as in AC_HEADER_DIRENT "
"passed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckDIRSymbolExists.c:\n"
@@ -95,7 +95,7 @@ MACRO(CHECK_DIRSYMBOL_EXISTS FILES VARIABLE)
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for DIR in ${FILES} - not found.")
SET(${VARIABLE} "" CACHE INTERNAL "Have symbol DIR")
- FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
+ FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
"Determining if the DIR symbol is defined as in AC_HEADER_DIRENT "
"failed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckDIRSymbolExists.c:\n"
diff --git a/cmake/modules/CheckPrototypeExists.cmake b/cmake/modules/CheckPrototypeExists.cmake
index 85a1717..191615c 100644
--- a/cmake/modules/CheckPrototypeExists.cmake
+++ b/cmake/modules/CheckPrototypeExists.cmake
@@ -7,16 +7,16 @@
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
-#
+#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
-#
+#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -66,4 +66,3 @@ int main()
")
CHECK_CXX_SOURCE_COMPILES("${_CHECK_PROTO_EXISTS_SOURCE_CODE}" ${_RESULT})
ENDMACRO(CHECK_PROTOTYPE_EXISTS _SYMBOL _HEADER _RESULT)
-
diff --git a/cmake/modules/FindFontConfig.cmake b/cmake/modules/FindFontConfig.cmake
index 23d0020..afe967e 100644
--- a/cmake/modules/FindFontConfig.cmake
+++ b/cmake/modules/FindFontConfig.cmake
@@ -1,17 +1,17 @@
# Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
-#
+#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
-# 3. The name of the author may not be used to endorse or promote products
+# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
diff --git a/cmake/modules/FindFreetype.cmake b/cmake/modules/FindFreetype.cmake
deleted file mode 100644
index dd4db27..0000000
--- a/cmake/modules/FindFreetype.cmake
+++ /dev/null
@@ -1,128 +0,0 @@
-# - Locate FreeType library
-# This module defines
-# FREETYPE_LIBRARIES, the library to link against
-# FREETYPE_FOUND, if false, do not try to link to FREETYPE
-# FREETYPE_INCLUDE_DIRS, where to find headers.
-# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8)
-# This is the concatenation of the paths:
-# FREETYPE_INCLUDE_DIR_ft2build
-# FREETYPE_INCLUDE_DIR_freetype2
-#
-# $FREETYPE_DIR is an environment variable that would
-# correspond to the ./configure --prefix=$FREETYPE_DIR
-# used in building FREETYPE.
-
-#=============================================================================
-# Copyright 2007-2009 Kitware, Inc.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# * The names of Kitware, Inc., the Insight Consortium, or the names of
-# any consortium members, or of any contributors, may not be used to
-# endorse or promote products derived from this software without
-# specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Created by Eric Wing.
-# Modifications by Alexander Neundorf.
-# This file has been renamed to "FindFreetype.cmake" instead of the correct
-# "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex.
-
-# Ugh, FreeType seems to use some #include trickery which
-# makes this harder than it should be. It looks like they
-# put ft2build.h in a common/easier-to-find location which
-# then contains a #include to a more specific header in a
-# more specific location (#include <freetype/config/ftheader.h>).
-# Then from there, they need to set a bunch of #define's
-# so you can do something like:
-# #include FT_FREETYPE_H
-# Unfortunately, using CMake's mechanisms like include_directories()
-# wants explicit full paths and this trickery doesn't work too well.
-# I'm going to attempt to cut out the middleman and hope
-# everything still works.
-find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
- HINTS
- ENV FREETYPE_DIR
- PATHS
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
- PATH_SUFFIXES include/freetype2 include
-)
-
-find_path(FREETYPE_INCLUDE_DIR_freetype2 config/ftheader.h
- HINTS
- ENV FREETYPE_DIR
- PATHS
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
- PATH_SUFFIXES include/freetype2 include
-)
-
-find_library(FREETYPE_LIBRARY
- NAMES freetype libfreetype freetype219 freetype_a
- HINTS
- ENV FREETYPE_DIR
- PATH_SUFFIXES lib
- PATHS
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
-)
-
-# set the user variables
-if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
- set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
-endif()
-set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
-
-if(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
- file(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str
- REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
-
- unset(FREETYPE_VERSION_STRING)
- foreach(VPART MAJOR MINOR PATCH)
- foreach(VLINE ${freetype_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1"
- FREETYPE_VERSION_PART "${VLINE}")
- if(FREETYPE_VERSION_STRING)
- set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
- else()
- set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
- endif()
- unset(FREETYPE_VERSION_PART)
- endif()
- endforeach()
- endforeach()
-endif()
-
-
-# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
-# all listed variables are TRUE
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype
- REQUIRED_VARS FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS
- VERSION_VAR FREETYPE_VERSION_STRING)
-
-mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)
diff --git a/cmake/modules/FindHEIF.cmake b/cmake/modules/FindHEIF.cmake
new file mode 100644
index 0000000..adc5cce
--- /dev/null
+++ b/cmake/modules/FindHEIF.cmake
@@ -0,0 +1,82 @@
+# - Find the native HEIF includes and library
+#
+
+# This module defines
+# HEIF_INCLUDE_DIR, where to find heif.h, etc.
+# HEIF_LIBRARIES, the libraries to link against to use HEIF.
+# HEIF_FOUND, If false, do not try to use HEIF.
+# Also defined, but not for general use are
+# HEIF_LIBRARY, where to find the HEIF library.
+
+# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# * The names of Kitware, Inc., the Insight Consortium, or the names of
+# any consortium members, or of any contributors, may not be used to
+# endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+SET(HEIF_FOUND "NO")
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+if( NOT WIN32 )
+ find_package(PkgConfig)
+
+ pkg_check_modules(HEIF_PKG QUIET fontconfig)
+endif( NOT WIN32 )
+
+FIND_PATH(HEIF_INCLUDE_DIR NAMES libheif/heif.h
+ PATHS
+ /usr/local/include
+ /usr/include
+ HINTS
+ ${HEIF_PKG_INCLUDE_DIRS} # Generated by pkg-config
+)
+
+SET(HEIF_NAMES ${HEIF_NAMES} heif ${HEIF_PKG_LIBRARY})
+FIND_LIBRARY(HEIF_LIBRARY
+ NAMES ${HEIF_NAMES}
+ PATH /usr/local/lib /usr/lib
+ PATH_SUFFIXES lib64 lib
+ HINTS ${HEIF_PKG_LIBRARY_DIRS} # Generated by pkg-config
+)
+
+IF (HEIF_LIBRARY AND HEIF_INCLUDE_DIR)
+ SET(HEIF_FOUND "YES")
+ SET(HAVE_LIBHEIF 1)
+ SET(HEIF_LIBRARIES ${HEIF_LIBRARY})
+ENDIF (HEIF_LIBRARY AND HEIF_INCLUDE_DIR)
+
+IF (HEIF_FOUND)
+ IF (NOT HEIF_FIND_QUIETLY)
+ MESSAGE(STATUS "Find HEIF: ${HEIF_LIBRARY}")
+ ENDIF (NOT HEIF_FIND_QUIETLY)
+ELSE (HEIF_FOUND)
+ IF (HEIF_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find HEIF library")
+ ENDIF (HEIF_FIND_REQUIRED)
+ENDIF (HEIF_FOUND)
+
+MARK_AS_ADVANCED(HEIF_INCLUDE_DIR HEIF_LIBRARY)
diff --git a/cmake/modules/FindICONV.cmake b/cmake/modules/FindICONV.cmake
index 49d5f6b..6973a56 100644
--- a/cmake/modules/FindICONV.cmake
+++ b/cmake/modules/FindICONV.cmake
@@ -1,11 +1,11 @@
-# - Try to find Iconv
-# Once done this will define
-#
-# ICONV_FOUND - system has Iconv
-# ICONV_INCLUDE_DIR - the Iconv include directory
-# ICONV_LIBRARIES - Link these to use Iconv
+# - Try to find Iconv
+# Once done this will define
+#
+# ICONV_FOUND - system has Iconv
+# ICONV_INCLUDE_DIR - the Iconv include directory
+# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
-#
+#
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
@@ -14,13 +14,13 @@ IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
-FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local)
-
+FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local)
+
FIND_LIBRARY(ICONV_LIBRARIES NAMES libiconv_a iconv libiconv c PATHS /opt/local)
-
-IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
- SET(ICONV_FOUND TRUE)
-ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+
+IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+ SET(ICONV_FOUND TRUE)
+ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
@@ -47,18 +47,18 @@ ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
-IF(ICONV_FOUND)
- IF(NOT ICONV_FIND_QUIETLY)
- MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
- ENDIF(NOT ICONV_FIND_QUIETLY)
-ELSE(ICONV_FOUND)
- IF(Iconv_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find Iconv")
- ENDIF(Iconv_FIND_REQUIRED)
-ENDIF(ICONV_FOUND)
+IF(ICONV_FOUND)
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSE(ICONV_FOUND)
+ IF(Iconv_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Iconv")
+ ENDIF(Iconv_FIND_REQUIRED)
+ENDIF(ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
-) \ No newline at end of file
+)
diff --git a/cmake/modules/FindLIQ.cmake b/cmake/modules/FindLIQ.cmake
index bf17fcf..c41d6fc 100644
--- a/cmake/modules/FindLIQ.cmake
+++ b/cmake/modules/FindLIQ.cmake
@@ -4,26 +4,24 @@
# This module defines
# LIQ_INCLUDE_DIR, where to find libimagequant.h
# LIQ_LIBRARIES, the libraries to link against to use libimagequant.
-# LIQ_FOUND, If false, do not try to use libimagequant.
+# LIQ_FOUND, if false, do not try to use libimagequant.
SET(LIQ_FOUND "NO")
FIND_PATH(LIQ_INCLUDE_DIR libimagequant.h
-"${PROJECT_SOURCE_DIR}/libimagequant"
-"${PROJECT_SOURCE_DIR}/pngquant/lib"
-/usr/local/include
-/usr/include
+ /usr/local/include
+ /usr/include
)
FIND_LIBRARY(LIQ_LIBRARY
NAMES libimagequant imagequant
- PATHS "${PROJECT_SOURCE_DIR}/libimagequant" "${PROJECT_SOURCE_DIR}/pngquant/lib" /usr/lib64 /usr/lib /usr/local/lib
+ PATHS /usr/lib64 /usr/lib /usr/local/lib
)
IF (LIQ_LIBRARY AND LIQ_INCLUDE_DIR)
SET(LIQ_FOUND "YES")
SET(LIQ_LIBRARIES ${LIQ_LIBRARY})
- SET(HAVE_LIBIMAGEQUANT 1)
+ SET(HAVE_LIBIMAGEQUANT 1)
ENDIF (LIQ_LIBRARY AND LIQ_INCLUDE_DIR)
IF (LIQ_FOUND)
@@ -31,29 +29,9 @@ IF (LIQ_FOUND)
MESSAGE(STATUS "Found LIQ: ${LIQ_LIBRARY} ${LIQ_INCLUDE_DIR}")
ENDIF (NOT LIQ_FIND_QUIETLY)
ELSE (LIQ_FOUND)
- # if existing library not found, then download and build it
- IF (NOT WIN32 OR CYGWIN OR MINGW) # MSVC's C compiler is too old to compile libimagequant
- IF (CMAKE_VERSION VERSION_GREATER "2.8.1")
- MESSAGE(STATUS "LIQ will be built")
- INCLUDE(ExternalProject)
- EXTERNALPROJECT_ADD(
- libimagequant
- URL "http://pngquant.org/libimagequant-2.0.0-src.tar.bz2"
- SOURCE_DIR libimagequant
- BUILD_IN_SOURCE 1
- INSTALL_DIR libimagequant
- INSTALL_COMMAND true
- CONFIGURE_COMMAND true
- BUILD_COMMAND make static CFLAGSADD='-fPIC'
- )
-
- SET(LIQ_FOUND "SORTOF")
- SET(LIQ_BUILD "YES")
- SET(LIQ_LIBRARIES "${PROJECT_BINARY_DIR}/libimagequant/libimagequant.a")
- SET(LIQ_INCLUDE_DIR "${PROJECT_BINARY_DIR}/libimagequant/")
- SET(HAVE_LIBIMAGEQUANT 1)
- ENDIF(CMAKE_VERSION VERSION_GREATER "2.8.1")
- ENDIF(NOT WIN32 OR CYGWIN OR MINGW)
+ IF (LIQ_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find LIQ library")
+ ENDIF (LIQ_FIND_REQUIRED)
ENDIF (LIQ_FOUND)
MARK_AS_ADVANCED(LIQ_INCLUDE_DIR LIQ_LIBRARIES LIQ_BUILD)
diff --git a/cmake/modules/FindPNG.cmake b/cmake/modules/FindPNG.cmake
deleted file mode 100644
index a44affc..0000000
--- a/cmake/modules/FindPNG.cmake
+++ /dev/null
@@ -1,93 +0,0 @@
-# - Find the native PNG includes and library
-#
-# This module searches libpng, the library for working with PNG images.
-#
-# It defines the following variables
-# PNG_INCLUDE_DIRS, where to find png.h, etc.
-# PNG_LIBRARIES, the libraries to link against to use PNG.
-# PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files.
-# PNG_FOUND, If false, do not try to use PNG.
-# PNG_VERSION_STRING - the version of the PNG library found (since CMake 2.8.8)
-# Also defined, but not for general use are
-# PNG_LIBRARY, where to find the PNG library.
-# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS.
-#
-# Since PNG depends on the ZLib compression library, none of the above will be
-# defined unless ZLib can be found.
-
-#=============================================================================
-# Copyright 2002-2009 Kitware, Inc.
-#
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# * The names of Kitware, Inc., the Insight Consortium, or the names of
-# any consortium members, or of any contributors, may not be used to
-# endorse or promote products derived from this software without
-# specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-if(PNG_FIND_QUIETLY)
- set(_FIND_ZLIB_ARG QUIET)
-endif()
-find_package(ZLIB ${_FIND_ZLIB_ARG})
-
-if(ZLIB_FOUND)
- find_path(PNG_PNG_INCLUDE_DIR png.h
- /usr/local/include/libpng # OpenBSD
- )
-
- set(PNG_NAMES ${PNG_NAMES} png libpng png15 libpng15 png15d libpng15d png14 libpng14 png14d libpng14d png12 libpng12 png12d libpng12d libpng_a)
- find_library(PNG_LIBRARY NAMES ${PNG_NAMES} )
-
- if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
- # png.h includes zlib.h. Sigh.
- set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
- set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity
- set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
-
- if (CYGWIN)
- if(BUILD_SHARED_LIBS)
- # No need to define PNG_USE_DLL here, because it's default for Cygwin.
- else()
- set (PNG_DEFINITIONS -DPNG_STATIC)
- endif()
- endif ()
-
- endif ()
-
- if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h")
- file(STRINGS "${PNG_PNG_INCLUDE_DIR}/png.h" png_version_str REGEX "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\".+\"")
-
- string(REGEX REPLACE "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\"([^\"]+)\".*" "\\1" PNG_VERSION_STRING "${png_version_str}")
- unset(png_version_str)
- endif ()
-endif()
-
-# handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if
-# all listed variables are TRUE
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(PNG
- REQUIRED_VARS PNG_LIBRARY PNG_PNG_INCLUDE_DIR
- VERSION_VAR PNG_VERSION_STRING)
-
-mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )
diff --git a/cmake/modules/FindPTHREAD.cmake b/cmake/modules/FindPTHREAD.cmake
index 0627c6d..0331e17 100644
--- a/cmake/modules/FindPTHREAD.cmake
+++ b/cmake/modules/FindPTHREAD.cmake
@@ -1,92 +1,90 @@
-#############################################################################
-#
-# $Id: FindPTHREAD.cmake 4056 2013-01-05 13:04:42Z fspindle $
-#
-# This file is part of the ViSP software.
-# Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
-#
-# This software is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# ("GPL") version 2 as published by the Free Software Foundation.
-# See the file LICENSE.txt at the root directory of this source
-# distribution for additional information about the GNU GPL.
-#
-# For using ViSP with software that can not be combined with the GNU
-# GPL, please contact INRIA about acquiring a ViSP Professional
-# Edition License.
-#
-# See http://www.irisa.fr/lagadic/visp/visp.html for more information.
-#
-# This software was developed at:
-# INRIA Rennes - Bretagne Atlantique
-# Campus Universitaire de Beaulieu
-# 35042 Rennes Cedex
-# France
-# http://www.irisa.fr/lagadic
-#
-# If you have questions regarding the use of this file, please contact
-# INRIA at visp@inria.fr
-#
-# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-#
-# Description:
-# Try to find pthread library.
-# Once run this will define:
-#
-# PTHREAD_FOUND
-# PTHREAD_INCLUDE_DIRS
-# PTHREAD_LIBRARIES
-#
-# Authors:
-# Fabien Spindler
-#
-#############################################################################
-
-
- FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h
- "$ENV{PTHREAD_HOME}/include"
- "$ENV{PTHREAD_DIR}/include"
- /usr/include
- "C:/MinGW/include"
- )
- #MESSAGE("DBG PTHREAD_INCLUDE_DIR=${PTHREAD_INCLUDE_DIR}")
-
- # pthreadVSE pthreadGCE pthreadGC pthreadVC1 pthreadVC2 are comming from web
- FIND_LIBRARY(PTHREAD_LIBRARY
- NAMES pthread pthreadGC2 pthreadVSE pthreadGCE pthreadGC pthreadVC1 pthreadVC2
- PATHS
- "$ENV{PTHREAD_HOME}/lib"
- "$ENV{PTHREAD_DIR}/lib"
- /usr/lib
- /usr/local/lib
- /lib
- "C:/MinGW/lib"
- )
-
- #MESSAGE(STATUS "DBG PTHREAD_LIBRARY=${PTHREAD_LIBRARY}")
-
- ## --------------------------------
-
- IF(PTHREAD_LIBRARY)
- SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
- ELSE(PTHREAD_LIBRARY)
- #MESSAGE(SEND_ERROR "pthread library not found.")
- ENDIF(PTHREAD_LIBRARY)
-
- IF(NOT PTHREAD_INCLUDE_DIR)
- #MESSAGE(SEND_ERROR "pthread include dir not found.")
- ENDIF(NOT PTHREAD_INCLUDE_DIR)
-
- IF(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
- SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
- SET(PTHREAD_FOUND TRUE)
- ELSE(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
- SET(PTHREAD_FOUND FALSE)
- ENDIF(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
-
- MARK_AS_ADVANCED(
- PTHREAD_INCLUDE_DIR
- PTHREAD_LIBRARY
- )
- #MESSAGE(STATUS "PTHREAD_FOUND : ${PTHREAD_FOUND}")
+#############################################################################
+#
+# This file is part of the ViSP software.
+# Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
+#
+# This software is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# ("GPL") version 2 as published by the Free Software Foundation.
+# See the file LICENSE.txt at the root directory of this source
+# distribution for additional information about the GNU GPL.
+#
+# For using ViSP with software that can not be combined with the GNU
+# GPL, please contact INRIA about acquiring a ViSP Professional
+# Edition License.
+#
+# See http://www.irisa.fr/lagadic/visp/visp.html for more information.
+#
+# This software was developed at:
+# INRIA Rennes - Bretagne Atlantique
+# Campus Universitaire de Beaulieu
+# 35042 Rennes Cedex
+# France
+# http://www.irisa.fr/lagadic
+#
+# If you have questions regarding the use of this file, please contact
+# INRIA at visp@inria.fr
+#
+# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Description:
+# Try to find pthread library.
+# Once run this will define:
+#
+# PTHREAD_FOUND
+# PTHREAD_INCLUDE_DIRS
+# PTHREAD_LIBRARIES
+#
+# Authors:
+# Fabien Spindler
+#
+#############################################################################
+
+
+ FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h
+ "$ENV{PTHREAD_HOME}/include"
+ "$ENV{PTHREAD_DIR}/include"
+ /usr/include
+ "C:/MinGW/include"
+ )
+ #MESSAGE("DBG PTHREAD_INCLUDE_DIR=${PTHREAD_INCLUDE_DIR}")
+
+ # pthreadVSE pthreadGCE pthreadGC pthreadVC1 pthreadVC2 are comming from web
+ FIND_LIBRARY(PTHREAD_LIBRARY
+ NAMES pthread pthreadGC2 pthreadVSE pthreadGCE pthreadGC pthreadVC1 pthreadVC2
+ PATHS
+ "$ENV{PTHREAD_HOME}/lib"
+ "$ENV{PTHREAD_DIR}/lib"
+ /usr/lib
+ /usr/local/lib
+ /lib
+ "C:/MinGW/lib"
+ )
+
+ #MESSAGE(STATUS "DBG PTHREAD_LIBRARY=${PTHREAD_LIBRARY}")
+
+ ## --------------------------------
+
+ IF(PTHREAD_LIBRARY)
+ SET(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+ ELSE(PTHREAD_LIBRARY)
+ #MESSAGE(SEND_ERROR "pthread library not found.")
+ ENDIF(PTHREAD_LIBRARY)
+
+ IF(NOT PTHREAD_INCLUDE_DIR)
+ #MESSAGE(SEND_ERROR "pthread include dir not found.")
+ ENDIF(NOT PTHREAD_INCLUDE_DIR)
+
+ IF(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
+ SET(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
+ SET(PTHREAD_FOUND TRUE)
+ ELSE(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
+ SET(PTHREAD_FOUND FALSE)
+ ENDIF(PTHREAD_LIBRARIES AND PTHREAD_INCLUDE_DIR)
+
+ MARK_AS_ADVANCED(
+ PTHREAD_INCLUDE_DIR
+ PTHREAD_LIBRARY
+ )
+ #MESSAGE(STATUS "PTHREAD_FOUND : ${PTHREAD_FOUND}")
diff --git a/cmake/modules/FindPackageHandleStandardArgs.cmake b/cmake/modules/FindPackageHandleStandardArgs.cmake
deleted file mode 100644
index de124ac..0000000
--- a/cmake/modules/FindPackageHandleStandardArgs.cmake
+++ /dev/null
@@ -1,317 +0,0 @@
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
-#
-# This function is intended to be used in FindXXX.cmake modules files.
-# It handles the REQUIRED, QUIET and version-related arguments to find_package().
-# It also sets the <UPPERCASED_NAME>_FOUND variable.
-# The package is considered found if all variables <var1>... listed contain
-# valid results, e.g. valid filepaths.
-#
-# There are two modes of this function. The first argument in both modes is
-# the name of the Find-module where it is called (in original casing).
-#
-# The first simple mode looks like this:
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
-# If the variables <var1> to <varN> are all valid, then <UPPERCASED_NAME>_FOUND
-# will be set to TRUE.
-# If DEFAULT_MSG is given as second argument, then the function will generate
-# itself useful success and error messages. You can also supply a custom error message
-# for the failure case. This is not recommended.
-#
-# The second mode is more powerful and also supports version checking:
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS <var1>...<varN>]
-# [VERSION_VAR <versionvar>]
-# [HANDLE_COMPONENTS]
-# [CONFIG_MODE]
-# [FAIL_MESSAGE "Custom failure message"] )
-#
-# As above, if <var1> through <varN> are all valid, <UPPERCASED_NAME>_FOUND
-# will be set to TRUE.
-# After REQUIRED_VARS the variables which are required for this package are listed.
-# Following VERSION_VAR the name of the variable can be specified which holds
-# the version of the package which has been found. If this is done, this version
-# will be checked against the (potentially) specified required version used
-# in the find_package() call. The EXACT keyword is also handled. The default
-# messages include information about the required version and the version
-# which has been actually found, both if the version is ok or not.
-# If the package supports components, use the HANDLE_COMPONENTS option to enable
-# handling them. In this case, find_package_handle_standard_args() will report
-# which components have been found and which are missing, and the <NAME>_FOUND
-# variable will be set to FALSE if any of the required components (i.e. not the
-# ones listed after OPTIONAL_COMPONENTS) are missing.
-# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for
-# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set
-# to <NAME>_VERSION and the macro will automatically check whether the
-# Config module was found.
-# Via FAIL_MESSAGE a custom failure message can be specified, if this is not
-# used, the default message will be displayed.
-#
-# Example for mode 1:
-#
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
-#
-# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
-# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
-# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
-# independent whether QUIET was used or not.
-# If it is found, success will be reported, including the content of <var1>.
-# On repeated Cmake runs, the same message won't be printed again.
-#
-# Example for mode 2:
-#
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE
-# VERSION_VAR BISON_VERSION)
-# In this case, BISON is considered to be found if the variable(s) listed
-# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case.
-# Also the version of BISON will be checked by using the version contained
-# in BISON_VERSION.
-# Since no FAIL_MESSAGE is given, the default messages will be printed.
-#
-# Another example for mode 2:
-#
-# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
-# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE)
-# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 NO_MODULE)
-# and adds an additional search directory for automoc4.
-# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
-# success/error message.
-
-#=============================================================================
-# Copyright 2007-2009 Kitware, Inc.
-#
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# * The names of Kitware, Inc., the Insight Consortium, or the names of
-# any consortium members, or of any contributors, may not be used to
-# endorse or promote products derived from this software without
-# specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-include(FindPackageMessage)
-include(CMakeParseArguments)
-
-# internal helper macro
-macro(_FPHSA_FAILURE_MESSAGE _msg)
- if (${_NAME}_FIND_REQUIRED)
- message(FATAL_ERROR "${_msg}")
- else ()
- if (NOT ${_NAME}_FIND_QUIETLY)
- message(STATUS "${_msg}")
- endif ()
- endif ()
-endmacro()
-
-
-# internal helper macro to generate the failure message when used in CONFIG_MODE:
-macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
- # <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
- if(${_NAME}_CONFIG)
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
- else()
- # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
- # List them all in the error message:
- if(${_NAME}_CONSIDERED_CONFIGS)
- set(configsText "")
- list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
- math(EXPR configsCount "${configsCount} - 1")
- foreach(currentConfigIndex RANGE ${configsCount})
- list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
- list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
- set(configsText "${configsText} ${filename} (version ${version})\n")
- endforeach()
- if (${_NAME}_NOT_FOUND_MESSAGE)
- set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
- endif()
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
-
- else()
- # Simple case: No Config-file was found at all:
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
- endif()
- endif()
-endmacro()
-
-
-function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
-
-# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
-# new extended or in the "old" mode:
- set(options CONFIG_MODE HANDLE_COMPONENTS)
- set(oneValueArgs FAIL_MESSAGE VERSION_VAR)
- set(multiValueArgs REQUIRED_VARS)
- set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
- list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
-
- if(${INDEX} EQUAL -1)
- set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
- set(FPHSA_REQUIRED_VARS ${ARGN})
- set(FPHSA_VERSION_VAR)
- else()
-
- CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
-
- if(FPHSA_UNPARSED_ARGUMENTS)
- message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
- endif()
-
- if(NOT FPHSA_FAIL_MESSAGE)
- set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
- endif()
- endif()
-
-# now that we collected all arguments, process them
-
- if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
- set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
- endif()
-
- # In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
- # when it successfully found the config-file, including version checking:
- if(FPHSA_CONFIG_MODE)
- list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
- list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
- set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
- endif()
-
- if(NOT FPHSA_REQUIRED_VARS)
- message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
- endif()
-
- list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
-
- string(TOUPPER ${_NAME} _NAME_UPPER)
- string(TOLOWER ${_NAME} _NAME_LOWER)
-
- # collect all variables which were not found, so they can be printed, so the
- # user knows better what went wrong (#6375)
- set(MISSING_VARS "")
- set(DETAILS "")
- set(${_NAME_UPPER}_FOUND TRUE)
- # check if all passed variables are valid
- foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
- if(NOT ${_CURRENT_VAR})
- set(${_NAME_UPPER}_FOUND FALSE)
- set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
- else()
- set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
- endif()
- endforeach()
-
- # component handling
- unset(FOUND_COMPONENTS_MSG)
- unset(MISSING_COMPONENTS_MSG)
-
- if(FPHSA_HANDLE_COMPONENTS)
- foreach(comp ${${_NAME}_FIND_COMPONENTS})
- if(${_NAME}_${comp}_FOUND)
-
- if(NOT DEFINED FOUND_COMPONENTS_MSG)
- set(FOUND_COMPONENTS_MSG "found components: ")
- endif()
- set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
-
- else()
-
- if(NOT DEFINED MISSING_COMPONENTS_MSG)
- set(MISSING_COMPONENTS_MSG "missing components: ")
- endif()
- set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
-
- if(${_NAME}_FIND_REQUIRED_${comp})
- set(${_NAME_UPPER}_FOUND FALSE)
- set(MISSING_VARS "${MISSING_VARS} ${comp}")
- endif()
-
- endif()
- endforeach()
- set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
- set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
- endif()
-
- # version handling:
- set(VERSION_MSG "")
- set(VERSION_OK TRUE)
- set(VERSION ${${FPHSA_VERSION_VAR}} )
- if (${_NAME}_FIND_VERSION)
-
- if(VERSION)
-
- if(${_NAME}_FIND_VERSION_EXACT) # exact version required
- if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
- set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
- set(VERSION_OK FALSE)
- else ()
- set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
- endif ()
-
- else() # minimum version specified:
- if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
- set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
- set(VERSION_OK FALSE)
- else ()
- set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
- endif ()
- endif()
-
- else()
-
- # if the package was not found, but a version was given, add that to the output:
- if(${_NAME}_FIND_VERSION_EXACT)
- set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
- else()
- set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
- endif()
-
- endif()
- else ()
- if(VERSION)
- set(VERSION_MSG "(found version \"${VERSION}\")")
- endif()
- endif ()
-
- if(VERSION_OK)
- set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
- else()
- set(${_NAME_UPPER}_FOUND FALSE)
- endif()
-
-
- # print the result:
- if (${_NAME_UPPER}_FOUND)
- FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
- else ()
-
- if(FPHSA_CONFIG_MODE)
- _FPHSA_HANDLE_FAILURE_CONFIG_MODE()
- else()
- if(NOT VERSION_OK)
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
- else()
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
- endif()
- endif()
-
- endif ()
-
- set(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
-
-endfunction()
diff --git a/cmake/modules/FindJPEG.cmake b/cmake/modules/FindRAQM.cmake
index bb310d6..ffb908b 100644
--- a/cmake/modules/FindJPEG.cmake
+++ b/cmake/modules/FindRAQM.cmake
@@ -1,14 +1,14 @@
-# - Find JPEG
-# Find the native JPEG includes and library
+# - Find the native RAQM includes and library
+#
+
# This module defines
-# JPEG_INCLUDE_DIR, where to find jpeglib.h, etc.
-# JPEG_LIBRARIES, the libraries needed to use JPEG.
-# JPEG_FOUND, If false, do not try to use JPEG.
-# also defined, but not for general use are
-# JPEG_LIBRARY, where to find the JPEG library.
-
-#=============================================================================
-# Copyright 2001-2009 Kitware, Inc.
+# RAQM_INCLUDE_DIR, where to find raqm.h, etc.
+# RAQM_LIBRARIES, the libraries to link against to use RAQM.
+# RAQM_FOUND, If false, do not try to use RAQM.
+# Also defined, but not for general use are
+# RAQM_LIBRARY, where to find the RAQM library.
+
+# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -16,16 +16,16 @@
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
-#
+#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
-#
+#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,24 +37,33 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-find_path(JPEG_INCLUDE_DIR jpeglib.h)
+SET(RAQM_FOUND "NO")
-set(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg_a)
-find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} )
+FIND_PATH(RAQM_INCLUDE_DIR raqm.h
+ /usr/local/include
+ /usr/include
+)
-# handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if
-# all listed variables are TRUE
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR)
+SET(RAQM_NAMES ${RAQM_NAMES} raqm)
+FIND_LIBRARY(RAQM_LIBRARY
+ NAMES ${RAQM_NAMES}
+ PATH /usr/local/lib /usr/lib
+)
-if(JPEG_FOUND)
- set(JPEG_LIBRARIES ${JPEG_LIBRARY})
-endif()
+IF (RAQM_LIBRARY AND RAQM_INCLUDE_DIR)
+ SET(RAQM_FOUND "YES")
+ SET(HAVE_LIBRAQM 1)
+ SET(RAQM_LIBRARIES ${RAQM_LIBRARY})
+ENDIF (RAQM_LIBRARY AND RAQM_INCLUDE_DIR)
-# Deprecated declarations.
-set (NATIVE_JPEG_INCLUDE_PATH ${JPEG_INCLUDE_DIR} )
-if(JPEG_LIBRARY)
- get_filename_component (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH)
-endif()
+IF (RAQM_FOUND)
+ IF (NOT RAQM_FIND_QUIETLY)
+ MESSAGE(STATUS "Find RAQM: ${RAQM_LIBRARY}")
+ ENDIF (NOT RAQM_FIND_QUIETLY)
+ELSE (RAQM_FOUDN)
+ IF (RAQM_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find RAQM library")
+ ENDIF (RAQM_FIND_REQUIRED)
+ENDIF (RAQM_FOUND)
-mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR )
+MARK_AS_ADVANCED(RAQM_INCLUDE_DIR RAQM_LIBRARY)
diff --git a/cmake/modules/FindWEBP.cmake b/cmake/modules/FindWEBP.cmake
index f7b89c3..cc93552 100644
--- a/cmake/modules/FindWEBP.cmake
+++ b/cmake/modules/FindWEBP.cmake
@@ -2,9 +2,8 @@
#
# This module defines
-# WEBP_INCLUDE_DIR, where to find png.h, etc.
+# WEBP_INCLUDE_DIR, where to find decode.h, etc.
# WEBP_LIBRARIES, the libraries to link against to use WEBP.
-# WEBP_DEFINITIONS - You should ADD_DEFINITONS(${WEBP_DEFINITIONS}) before compiling code that includes png library files.
# WEBP_FOUND, If false, do not try to use WEBP.
# also defined, but not for general use are
# WEBP_LIBRARY, where to find the WEBP library.
@@ -17,16 +16,16 @@
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
-#
+#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
-#
+#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -48,7 +47,7 @@ find_path(WEBP_INCLUDE_DIR decode.h
set(WEBP_NAMES ${WEBP_NAMES} webp)
find_library(WEBP_LIBRARY
NAMES ${WEBP_NAMES}
- PATHS "${PROJECT_SOURCE_DIR}/../deps/lib" /usr/lib64 /usr/lib /usr/local/lib
+ PATHS /usr/lib64 /usr/lib /usr/local/lib
)
if (WEBP_LIBRARY AND WEBP_INCLUDE_DIR)
diff --git a/cmake/modules/FindXPM.cmake b/cmake/modules/FindXPM.cmake
index 9b59fea..2cb0c22 100644
--- a/cmake/modules/FindXPM.cmake
+++ b/cmake/modules/FindXPM.cmake
@@ -2,9 +2,9 @@
#
# This module defines
-# XPM_INCLUDE_DIR, where to find png.h, etc.
+# XPM_INCLUDE_DIR, where to find xpm.h, etc.
# XPM_LIBRARIES, the libraries to link against to use XPM.
-# XPM_DEFINITIONS - You should ADD_DEFINITONS(${XPM_DEFINITIONS}) before compiling code that includes png library files.
+# XPM_DEFINITIONS - You should ADD_DEFINITONS(${XPM_DEFINITIONS}) before compiling code that includes xpm library files.
# XPM_FOUND, If false, do not try to use XPM.
# also defined, but not for general use are
# XPM_LIBRARY, where to find the XPM library.
@@ -17,16 +17,16 @@
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
-#
+#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
-#
+#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
diff --git a/cmake/modules/TestForHighBitCharacters.c b/cmake/modules/TestForHighBitCharacters.c
index 2be5174..0bc34d9 100644
--- a/cmake/modules/TestForHighBitCharacters.c
+++ b/cmake/modules/TestForHighBitCharacters.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2006 Alan W. Irwin
*
* This file is part of PLplot.
diff --git a/cmake/modules/TestForHighBitCharacters.cmake b/cmake/modules/TestForHighBitCharacters.cmake
index b1a1b90..dabf6b2 100644
--- a/cmake/modules/TestForHighBitCharacters.cmake
+++ b/cmake/modules/TestForHighBitCharacters.cmake
@@ -19,11 +19,11 @@
# Check if ctype.h macros work on characters with the high bit set.
if(NOT DEFINED CMAKE_HIGH_BIT_CHARACTERS)
- message(STATUS
+ message(STATUS
"Check for whether ctype.h macros work on characters with the\n"
" high bit set."
)
- try_compile(CMAKE_HIGH_BIT_CHARACTERS
+ try_compile(CMAKE_HIGH_BIT_CHARACTERS
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/CMakeModules/TestForHighBitCharacters.c
OUTPUT_VARIABLE OUTPUT)
diff --git a/cmake/modules/gd.cmake b/cmake/modules/gd.cmake
index bef21f9..831a776 100644
--- a/cmake/modules/gd.cmake
+++ b/cmake/modules/gd.cmake
@@ -7,7 +7,12 @@ MACRO(ADD_GD_TESTS)
FOREACH(test_name ${TESTS_FILES})
SET(test_prog_name "test_${TEST_PREFIX}_${test_name}")
add_executable(${test_prog_name} "${test_name}.c")
- target_link_libraries (${test_prog_name} gdTest ${ARGV0})
+ IF(WIN32)
+ target_link_libraries (${test_prog_name} gdTest ${ARGV0})
+ ELSE(WIN32)
+ target_link_libraries (${test_prog_name} gdTest m ${ARGV0})
+ ENDIF(WIN32)
add_test(NAME ${test_prog_name} COMMAND ${test_prog_name})
+ SET_PROPERTY(TEST ${test_prog_name} PROPERTY SKIP_RETURN_CODE 77)
ENDFOREACH(test_name)
ENDMACRO(ADD_GD_TESTS)
diff --git a/config/Makefile.am b/config/Makefile.am
index ced3c37..c5a8bb5 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
-EXTRA_DIST = gdlib.pc.in getver.pl
+EXTRA_DIST = gdlib.pc.cmake gdlib.pc.in getlib.sh getver.sh
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gdlib.pc
diff --git a/config/gdlib.pc.cmake b/config/gdlib.pc.cmake
new file mode 100644
index 0000000..5fc8af4
--- /dev/null
+++ b/config/gdlib.pc.cmake
@@ -0,0 +1,13 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+
+Name: gd
+Description: GD graphics library
+Version: @GDLIB_VERSION@
+Requires:
+Requires.private: @PKG_REQUIRES_PRIVATES@
+Cflags: -I${includedir}
+Libs.private: @LIBS_PRIVATES@
+Libs: -L${libdir} -lgd
diff --git a/config/gdlib.pc.in b/config/gdlib.pc.in
index b980a60..d6bc375 100644
--- a/config/gdlib.pc.in
+++ b/config/gdlib.pc.in
@@ -6,6 +6,8 @@ includedir=@includedir@
Name: gd
Description: GD graphics library
Version: @VERSION@
+Requires:
+Requires.private: @PKG_REQUIRES_PRIVATES@
Cflags: -I${includedir}
-Libs.private: @LIBS@ @LIBICONV@
+Libs.private: @LIBS_PRIVATES@ @LIBICONV@
Libs: -L${libdir} -lgd
diff --git a/config/getlib.sh b/config/getlib.sh
new file mode 100755
index 0000000..5070e30
--- /dev/null
+++ b/config/getlib.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+GETVER="${0%/*}/getver.sh"
+GDLIB_MAJOR=$("${GETVER}" MAJOR)
+GDLIB_MINOR=$("${GETVER}" MINOR)
+GDLIB_REVISION=$("${GETVER}" RELEASE)
+
+# Dynamic library version information
+# See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
+
+GDLIB_LT_CURRENT=3
+# This is the version where the soname (current above) changes. We use it
+# to reset the revision base back to zero. It's a bit of a pain, but some
+# systems restrict the revision range below to [0..255] (like OS X).
+GDLIB_PREV_MAJOR=2
+GDLIB_PREV_MINOR=2
+# This isn't 100% correct, but it tends to be a close enough approximation
+# for how we manage the codebase. It's rare to do a release that doesn't
+# modify the library since this project is centered around the library.
+GDLIB_LT_REVISION=$(( ((GDLIB_MAJOR - GDLIB_PREV_MAJOR) << 6) | ((GDLIB_MINOR - GDLIB_PREV_MINOR) << 3) | GDLIB_REVISION ))
+GDLIB_LT_AGE=0
+
+# The first three fields we feed into libtool and the OS target determines how
+# they get used. The last two fields we feed into cmake. We use the same rules
+# as Linux SONAME versioning in libtool, but cmake should handle it for us.
+case $1 in
+CURRENT)
+ printf '%s' "${GDLIB_LT_CURRENT}"
+ ;;
+REVISION)
+ printf '%s' "${GDLIB_LT_REVISION}"
+ ;;
+AGE)
+ printf '%s' "${GDLIB_LT_AGE}"
+ ;;
+VERSION)
+ printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE )).${GDLIB_LT_AGE}.${GDLIB_LT_REVISION}"
+ ;;
+SONAME)
+ printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE ))"
+ ;;
+esac
diff --git a/config/getver.pl b/config/getver.pl
deleted file mode 100755
index 52f1b58..0000000
--- a/config/getver.pl
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env perl
-
-# Simple script to extract the version number parts from src/gd.h. If
-# called with the middle word of the version macro, it prints the
-# value of that macro. If called with no argument, it outputs a
-# human-readable version string. This must be run in the project
-# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh.
-
-use strict;
-
-use FindBin;
-
-my $key = shift;
-my @version_parts = ();
-my $dir = $FindBin::Bin;
-
-open FH, "<$dir/../src/gd.h" # old-style filehandle for max. portability
- or die "Unable to open 'gd.h' for reading.\n";
-
-while(<FH>) {
- next unless m{version605b5d1778};
- next unless /^#define\s+GD_([A-Z0-9]+)_VERSION+\s+(\S+)/;
- my ($lk, $lv) = ($1, $2);
- if ($lk eq $key) {
- chomp $lv;
- $lv =~ s/"//g;
-
- print $lv; # no newline
- exit(0); # success!
- }
-
- push @version_parts, $lv if (!$key);
-}
-
-close(FH);
-
-if (scalar @version_parts == 4) {
- my $result = join(".", @version_parts[0..2]);
- $result .= $version_parts[3];
- $result =~ s/"//g;
- print $result;
- exit(0);
-}
-
-exit(1); # failure
diff --git a/config/getver.sh b/config/getver.sh
new file mode 100755
index 0000000..526cbf6
--- /dev/null
+++ b/config/getver.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Simple script to extract the version number parts from src/gd.h. If
+# called with the middle word of the version macro, it prints the
+# value of that macro. If called with no argument, it outputs a
+# human-readable version string. This must be run in the project
+# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh.
+
+TOPDIR="${0%/*}/.."
+HEADER="${TOPDIR}/src/gd.h"
+SENTINEL="/*version605b5d1778*/"
+
+getpart() {
+ awk -v field="GD_${1}_VERSION" -v sentinel="${SENTINEL}" '
+ $1 == "#define" && $2 == field && $NF == sentinel {
+ gsub(/^"/, "", $3)
+ gsub(/"$/, "", $3)
+ print $3
+ }
+ ' "${HEADER}"
+}
+
+case $# in
+0)
+ printf '%s.%s.%s%s\n' \
+ "$(getpart MAJOR)" \
+ "$(getpart MINOR)" \
+ "$(getpart RELEASE)" \
+ "$(getpart EXTRA)"
+ ;;
+1)
+ case $1 in
+ MAJOR|MINOR|RELEASE|EXTRA)
+ part=$(getpart "$1")
+ if [ -n "${part}" ]; then
+ printf '%s' "${part}"
+ fi
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+ ;;
+*)
+ echo "$0: error: script takes at most 1 arg"
+ exit 1
+ ;;
+esac
diff --git a/configure.ac b/configure.ac
index f7a943f..8bdff83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
AC_PREREQ(2.64)
# We extract version numbers from src/versions.h
-define([gv],[perl config/getver.pl ]$1)
+define([gv],[config/getver.sh ]$1)
m4_define([gd_MAJOR],esyscmd(gv(MAJOR)))dnl
m4_define([gd_MINOR],esyscmd(gv(MINOR)))dnl
@@ -18,40 +18,24 @@ AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
-# This is not used anywhere. However, Makefile.netware searches
-# through configure for these definitions to find the version numbers.
-# (Assuming anyone still uses Netware, that should be changed to use
-# gd.h via getver.pl instead.)
-GDLIB_MAJOR=gd_MAJOR
-GDLIB_MINOR=gd_MINOR
-GDLIB_REVISION=gd_REVISION
-GDLIB_EXTRA=gd_EXTRA
-GDLIB_VERSION=gd_PKG_VERSION
-
-AC_SUBST(GDLIB_MAJOR)
-AC_SUBST(GDLIB_MINOR)
-AC_SUBST(GDLIB_REVISION)
-AC_SUBST(GDLIB_EXTRA)
-AC_SUBST(GDLIB_VERSION)
-
-# Dynamic library version information
-# See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
-
-GDLIB_LT_CURRENT=3
-dnl This is the version where the soname (current above) changes. We use it
-dnl to reset the revision base back to zero. It's a bit of a pain, but some
-dnl systems restrict the revision range below to [0..255] (like OS X).
-GDLIB_PREV_MAJOR=2
-GDLIB_PREV_MINOR=2
-dnl This isn't 100% correct, but it tends to be a close enough approximation
-dnl for how we manage the codebase. It's rare to do a release that doesn't
-dnl modify the library since this project is centered around the library.
-GDLIB_LT_REVISION=$(( ((GDLIB_MAJOR - GDLIB_PREV_MAJOR) << 6) | ((GDLIB_MINOR - GDLIB_PREV_MINOR) << 3) | GDLIB_REVISION ))
-GDLIB_LT_AGE=0
+dnl Keep the libtool version details in an external script so cmake can
+dnl access the values too.
+define([lt_gv], [config/getlib.sh ]$1)
+m4_define([gd_LT_CURRENT], esyscmd(lt_gv(CURRENT)))
+m4_define([gd_LT_REVISION], esyscmd(lt_gv(REVISION)))
+m4_define([gd_LT_AGE], esyscmd(lt_gv(AGE)))
+
+GDLIB_LT_CURRENT=gd_LT_CURRENT
+GDLIB_LT_REVISION=gd_LT_REVISION
+GDLIB_LT_AGE=gd_LT_AGE
+
AC_SUBST(GDLIB_LT_CURRENT)
AC_SUBST(GDLIB_LT_REVISION)
AC_SUBST(GDLIB_LT_AGE)
+AC_SUBST(LIBS_PRIVATES)
+AC_SUBST(PKG_REQUIRES_PRIVATES)
+
AM_INIT_AUTOMAKE([1.11 foreign dist-xz -Wall -Werror subdir-objects])
AC_CONFIG_HEADERS([src/config.h:src/config.hin])
@@ -79,13 +63,8 @@ dnl Keep in sync with cmake/modules/AC_HEADER_STDC.cmake.
AC_HEADER_STDC
AC_CHECK_HEADERS_ONCE(m4_flatten([
dirent.h
- errno.h
inttypes.h
- limits.h
- stddef.h
stdint.h
- stdlib.h
- string.h
strings.h
unistd.h
sys/stat.h
@@ -108,14 +87,12 @@ AC_CHECK_HEADERS(iconv.h,
AC_MSG_RESULT(no))])
# Checks for typedefs, structures, and compiler characteristics.
-#AC_C_CONST
#AC_TYPE_SIZE_T
# Checks for library functions.
#AC_FUNC_ERROR_AT_LINE
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
-#AC_FUNC_VPRINTF
#AC_CHECK_FUNCS([floor memset sqrt strchr strdup strtol])
dnl do we need to specify -lm explicitly?
@@ -124,6 +101,21 @@ AC_CHECK_FUNC(sin,,[AC_CHECK_LIB(m,sin)])
AX_PTHREAD()
AX_OPENMP()
+dnl We should default this to off in future releases.
+AC_MSG_CHECKING([whether to support gd image formats])
+AC_ARG_ENABLE([gd-formats],
+ [AS_HELP_STRING([--disable-gd-formats], [Disable support for the legacy/testing gd image formats])],
+ [gd_enable_gd_formats=$enableval],
+ [gd_enable_gd_formats=no])
+AC_MSG_RESULT([$gd_enable_gd_formats])
+if test "$gd_enable_gd_formats" = yes; then
+ gd_ac_value=1
+else
+ gd_ac_value=0
+fi
+AC_DEFINE_UNQUOTED([ENABLE_GD_FORMATS], [$gd_ac_value], [Whether to support gd image formats])
+AM_CONDITIONAL([ENABLE_GD_FORMATS], test "$gd_enable_gd_formats" = yes)
+
dnl Helper macro for working with external libraries.
dnl GD_LIB_CHECK([SYM], [FEATURE], [name], [...test...])
dnl $1 - upper case symbol
@@ -141,6 +133,7 @@ m4_define([GD_LIB_CHECK], [dnl
AC_MSG_RESULT([$gd_with_lib])
gd_found_lib=no
+ gd_require_pkg_name=""
if test "$gd_with_lib" != "no"; then
save_CPPFLAGS=$CPPFLAGS
save_LDFLAGS=$LDFLAGS
@@ -172,6 +165,11 @@ m4_define([GD_LIB_CHECK], [dnl
$1][_CFLAGS="$gd_lib_cflags $][$1][_CFLAGS"
AS_VAR_APPEND([LIBS], [" $][$1][_LIBS"])
AS_VAR_APPEND([CPPFLAGS], [" $][$1][_CFLAGS"])
+ if test -z "$gd_require_pkg_name"; then
+ AS_VAR_APPEND([LIBS_PRIVATES], [" $][$1][_LIBS"])
+ else
+ AS_VAR_APPEND([PKG_REQUIRES_PRIVATES], [" $gd_require_pkg_name"])
+ fi
elif test "$gd_with_lib" = "yes"; then
AC_MSG_ERROR([$3 requested but not found])
else
@@ -191,7 +189,7 @@ dnl $4 - pkg-config module to look for
dnl $5 - fallback test for the feature
m4_define([GD_LIB_PKG_CHECK], [dnl
GD_LIB_CHECK([$1], [$2], [$3], [dnl
- PKG_CHECK_MODULES([$1], [$4], [gd_found_lib=yes], [$5])
+ PKG_CHECK_MODULES([$1], [$4], [gd_found_lib=yes gd_require_pkg_name="$4"], [$5])
])
])
@@ -214,6 +212,7 @@ GD_LIB_PKG_CHECK([LIBPNG], [PNG], [png], [libpng], [
])
dnl Check for FreeType support.
+dnl NB: "9.8.3" corresponds to freetype-2.1.10.
GD_LIB_PKG_CHECK([LIBFREETYPE], [FREETYPE], [freetype], [freetype2 >= 9.8.3], [
FREETYPE_CONFIG=$gd_with_lib/bin/freetype-config
if test -e "$FREETYPE_CONFIG"; then
@@ -243,7 +242,7 @@ GD_LIB_PKG_CHECK([LIBFONTCONFIG], [FONTCONFIG], [fontconfig], [fontconfig], [
])
dnl Check for jpeg support.
-GD_LIB_CHECK([LIBJPEG], [JPEG], [jpeg], [
+GD_LIB_PKG_CHECK([LIBJPEG], [JPEG], [jpeg], [libjpeg], [
AC_CHECK_LIB([jpeg], [jpeg_set_defaults], [dnl
AS_VAR_APPEND([LIBJPEG_LIBS], [" -ljpeg"])
gd_found_lib=yes
@@ -280,13 +279,28 @@ GD_LIB_PKG_CHECK([LIBTIFF], [TIFF], [tiff], [libtiff-4], [
])
dnl Check for webp support.
-GD_LIB_CHECK([LIBWEBP], [WEBP], [webp], [
+GD_LIB_PKG_CHECK([LIBWEBP], [WEBP], [webp], [libwebp], [
AC_CHECK_LIB([webp], [WebPGetInfo], [dnl
AS_VAR_APPEND([LIBWEBP_LIBS], [" -lwebp"])
gd_found_lib=yes
])
])
+dnl Check for heif support.
+GD_LIB_PKG_CHECK([LIBHEIF], [HEIF], [heif], [libheif >= 1.7.0], [
+ AC_CHECK_LIB([heif], [heif_get_version], [dnl
+ AS_VAR_APPEND([LIBHEIF_LIBS], [" -lheif"])
+ ])
+])
+
+dnl Check for avif support.
+GD_LIB_PKG_CHECK([LIBAVIF], [AVIF], [avif], [libavif >= 0.8.2], [
+ AC_CHECK_LIB([avif], [avifVersion], [dnl
+ AS_VAR_APPEND([LIBAVIF_LIBS], [" -lavif"])
+ gd_found_lib=yes
+ ])
+])
+
gl_VISIBILITY()
CFLAGS="$CFLAGS $CFLAG_VISIBILITY"
@@ -301,7 +315,8 @@ AX_CFLAGS_WARN_ALL
dnl Enable -Werror if possible. Do it after all other tests.
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [treat compile warnings as errors])])
-if test "$enable_werror" = "yes" || test "$GCC" = "yes" -a "$enable_werror" != "no"; then
+if test "$enable_werror" = "yes" || \
+ test "$GCC" = "yes" -a "$enable_werror" != "no" -a -d "$srcdir/.git"; then
CFLAGS="-Werror $CFLAGS"
CXXFLAGS="-Werror $CXXFLAGS"
fi
@@ -310,16 +325,19 @@ dnl report configuration
AC_MSG_RESULT([
** Configuration summary for $PACKAGE $VERSION:
+ Support for gd/gd2 images: $gd_enable_gd_formats
Support for Zlib: $gd_with_LIBZ
Support for PNG library: $gd_with_LIBPNG
Support for JPEG library: $gd_with_LIBJPEG
Support for WebP library: $gd_with_LIBWEBP
+ Support for HEIF library: $gd_with_LIBHEIF
+ Support for AVIF library: $gd_with_LIBAVIF
Support for TIFF library: $gd_with_LIBTIFF
Support for Freetype 2.x library: $gd_with_LIBFREETYPE
Support for Fontconfig library: $gd_with_LIBFONTCONFIG
Support for Xpm library: $gd_with_LIBXPM
Support for liq library: $gd_with_LIBIMAGEQUANT
- Support for complext text: $gd_with_LIBRAQM
+ Support for complex text: $gd_with_LIBRAQM
Support for pthreads: $ax_pthread_ok
])
diff --git a/ChangeLog b/docs/ChangeLog.historic
index c5c453c..c5c453c 100644
--- a/ChangeLog
+++ b/docs/ChangeLog.historic
diff --git a/docs/INSTALL b/docs/INSTALL
index a1e89e1..63bf076 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -367,4 +367,3 @@ operates.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
-
diff --git a/NEWS b/docs/NEWS.historic
index 8bf3843..057d33b 100644
--- a/NEWS
+++ b/docs/NEWS.historic
@@ -12,7 +12,7 @@ GD 2.0.36 (2007-11-xx)
(Pierre, Mark Fisher)
88, Fixed support of PNG grayscale image with alpha channel (Pierre)
95, Added Netware builds script (Guenter)
- 97, ease the creation of regexp to match symbols/functions in the sources
+ 97, ease the creation of regexp to match symbols/functions in the sources
(Guenter)
100, spurious horizontal line drawn by gdImageFilledPolygon (Takeshi Abe)
101, _gdCreateFromFile() can crash if gdImageCreate fails (Mattias Bengtsson)
@@ -37,17 +37,17 @@ GD 2.0.36 (2007-11-xx)
198, Fixed useFontConfig() to work as documented (Mojca Miklavec, Ethan Merritt)
GD 2.0.35 (2007-06-21)
-41, Fix valgrind error in gdImageFillTiled (Nuno Lopes)
+41, Fix valgrind error in gdImageFillTiled (Nuno Lopes)
45, Add missing custom cmake macros (required for the tests suite)
51, Avoid signature buffer copy in gd_gif_c (Nuno Lopes)
-48, Race condition in gdImageStringFTEx (Antony Dogval, Pierre
+48, Race condition in gdImageStringFTEx (Antony Dogval, Pierre
Scott MacVicar)
52, Reading GIF images is not thread safe (static usage in private
functions) (Roman Nemecek, Nuno Lopes, Pierre)
60, GIF Local palette is read twice
-66, GIF, Use local frame dimension when possible instead of the
+66, GIF, Use local frame dimension when possible instead of the
logical screen size (Pierre)
-68, OpenVMS build support, see VMS/README.VMS for the details
+68, OpenVMS build support, see VMS/README.VMS for the details
(Alexey Chupahin)
70, GIF, do not try to use the global colmap if it does not exist
(Nuno Lopes, Pierre)
@@ -58,7 +58,7 @@ GD 2.0.35 (2007-06-21)
(Pierre)
86, Possible infinite loop in libgd/gd_png.c, flaw found by Xavier Roche
(Pierre)
-87, Fixed segfault when an invalid color index is present in a GIF
+87, Fixed segfault when an invalid color index is present in a GIF
image data, reported by Elliot <wccode at gmail dot com> (Pierre)
89, Possible integer overflow in gdImageCreateTrueColor (Pierre)
94, gdImageCreateXbm can crash if gdImageCreate fails (Pierre)
diff --git a/docs/README.CMAKE b/docs/README.CMAKE
index 213a181..c9356b2 100644
--- a/docs/README.CMAKE
+++ b/docs/README.CMAKE
@@ -10,13 +10,18 @@ $ cmake -DBUILD_TEST=1 <options> ..
$ make
The available options are:
+ENABLE_GD_FORMATS=1
ENABLE_PNG=1
+ENABLE_LIQ=1
ENABLE_JPEG=1
ENABLE_TIFF=1
+ENABLE_ICONV=1
ENABLE_FREETYPE=1
ENABLE_FONTCONFIG=1
ENABLE_XPM=1
ENABLE_WEBP=1
+ENABLE_AVIF=1
+ENABLE_RAQM=1
You can optionally run our tests suite using:
$ ctest .
diff --git a/docs/README.JPN b/docs/README.JPN
index 65db00b..db128aa 100644
--- a/docs/README.JPN
+++ b/docs/README.JPN
@@ -1,39 +1,38 @@
- gd $B%i%$%V%i%j$GF|K\8lJ8;zNs$r;H$&>e$G$NCm0U;v9`(B
+ gd ライブラリã§æ—¥æœ¬èªžæ–‡å­—列を使ã†ä¸Šã§ã®æ³¨æ„事項
- $B;32l@5?M(B (ma@yama-ga.com)
+ 山賀正人 (ma@yama-ga.com)
-gd-1.7.0 $B$+$i$O$=$N$^$^$G(B gdImageStringTTF() $B$KBP$7$F(B
-SJIS encoding $B$N%U%)%s%H$,;HMQ$G$-$^$9!#(B
+gd-1.7.0 ã‹ã‚‰ã¯ãã®ã¾ã¾ã§ gdImageStringTTF() ã«å¯¾ã—ã¦
+SJIS encoding ã®ãƒ•ã‚©ãƒ³ãƒˆãŒä½¿ç”¨ã§ãã¾ã™ã€‚
- $B"((B Unicode encoding $B$N%U%)%s%H$KBP$7$F$OF|K\8lJ8;zNs$r(B UTF-8 $B$G(B
- $B;XDj$9$l$PF|K\8l$,I=<($G$-$^$9!#(B
+ ※ Unicode encoding ã®ãƒ•ã‚©ãƒ³ãƒˆã«å¯¾ã—ã¦ã¯æ—¥æœ¬èªžæ–‡å­—列を UTF-8 ã§
+ 指定ã™ã‚Œã°æ—¥æœ¬èªžãŒè¡¨ç¤ºã§ãã¾ã™ã€‚
-$B$D$^$j(B gdImageStringTTF() $B$G(B SJIS encoding $B$N%U%)%s%H$r;XDj$9$k$H(B
-$BJ8;zNs$OL5>r7o$KF|K\8l$G$"$k$H2r<a$5$l!"4A;z%3!<%I(B (EUC, SJIS, 7bit JIS)
-$B$,<+F0H=JL$5$l$FE,@Z$K=hM}$5$l$^$9!#(B
+ã¤ã¾ã‚Š gdImageStringTTF() 㧠SJIS encoding ã®ãƒ•ã‚©ãƒ³ãƒˆã‚’指定ã™ã‚‹ã¨
+文字列ã¯ç„¡æ¡ä»¶ã«æ—¥æœ¬èªžã§ã‚ã‚‹ã¨è§£é‡ˆã•ã‚Œã€æ¼¢å­—コード (EUC, SJIS, 7bit JIS)
+ãŒè‡ªå‹•åˆ¤åˆ¥ã•ã‚Œã¦é©åˆ‡ã«å‡¦ç†ã•ã‚Œã¾ã™ã€‚
-$B99$K(B UNICODE encoding $B$N%U%)%s%H$KBP$7$F$b(B JIS $B7O$NF|K\8l(B (EUC, SJIS, 7bit JIS)
-$B$r;HMQ$9$k>l9g$O!"%3%s%Q%$%k;~$K(B -DJISX0208 $B$rIU$1$F%3%s%Q%$%k$7$F$/$@$5$$!#(B
-$B$3$&$9$k$H(B gdImageStringTTF() $B$G;XDj$5$l$?J8;zNs$K(B ASCII $B0J30$NJ8;z$,$"$k$H(B
-$BL5>r7o$KF|K\8lJ8;zNs$G$"$k$H2r<a$5$l!"4A;z%3!<%I$r<+F0H=JL8e$K(B
-$BE,@Z$K=hM}$5$l$^$9!#(B
+æ›´ã« UNICODE encoding ã®ãƒ•ã‚©ãƒ³ãƒˆã«å¯¾ã—ã¦ã‚‚ JIS ç³»ã®æ—¥æœ¬èªž (EUC, SJIS, 7bit JIS)
+を使用ã™ã‚‹å ´åˆã¯ã€ã‚³ãƒ³ãƒ‘イル時㫠-DJISX0208 を付ã‘ã¦ã‚³ãƒ³ãƒ‘イルã—ã¦ãã ã•ã„。
+ã“ã†ã™ã‚‹ã¨ gdImageStringTTF() ã§æŒ‡å®šã•ã‚ŒãŸæ–‡å­—列㫠ASCII 以外ã®æ–‡å­—ãŒã‚ã‚‹ã¨
+ç„¡æ¡ä»¶ã«æ—¥æœ¬èªžæ–‡å­—列ã§ã‚ã‚‹ã¨è§£é‡ˆã•ã‚Œã€æ¼¢å­—コードを自動判別後ã«
+é©åˆ‡ã«å‡¦ç†ã•ã‚Œã¾ã™ã€‚
-$B$?$@$7$3$N>l9g$O(B UTF-8 $B$NF|K\8lJ8;zNs$r07$($J$/$J$j$^$9$N$G!"(B
-$B$4MxMQ$N4D6-Ey$K1~$8$F(B -DJISX0208 $B$rIU$1$k$+H]$+$r7h$a$F$/$@$5$$!#(B
+ãŸã ã—ã“ã®å ´åˆã¯ UTF-8 ã®æ—¥æœ¬èªžæ–‡å­—列を扱ãˆãªããªã‚Šã¾ã™ã®ã§ã€
+ã”利用ã®ç’°å¢ƒç­‰ã«å¿œã˜ã¦ -DJISX0208 を付ã‘ã‚‹ã‹å¦ã‹ã‚’決ã‚ã¦ãã ã•ã„。
-$B4A;z%3!<%I$NJQ49$K(B OS $BIUB0$N(B iconv() $B$r;H$&>l9g$O(B
-CFLAGS $B$K(B -DHAVE_ICONV $B$rIU$1$F%3%s%Q%$%k$7$F$/$@$5$$!#(B
-$B$3$N>l9g$K(B -DHAVE_STDARG_H $B$H(B -DHAVE_ERRNO_H $B$bIU$1$F$*$/$H(B
-$B4A;z%3!<%IJQ49$N:]$K%(%i!<$,H/@8$7$?>l9g$KE,@Z$J%a%C%;!<%8$r(B
-$BI=<($9$k$h$&$K$J$j$^$9!#(B
+漢字コードã®å¤‰æ›ã« OS 付属㮠iconv() を使ã†å ´åˆã¯
+CFLAGS ã« -DHAVE_ICONV を付ã‘ã¦ã‚³ãƒ³ãƒ‘イルã—ã¦ãã ã•ã„。
+漢字コード変æ›ã®éš›ã«ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆã«é©åˆ‡ãªãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’
+表示ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚
-$B!y(B EUC $B$+(B SJIS $B$+H=JL$G$-$J$+$C$?>l9g$N4A;z%3!<%I$NH=JLJ}K!(B
+☆ EUC ã‹ SJIS ã‹åˆ¤åˆ¥ã§ããªã‹ã£ãŸå ´åˆã®æ¼¢å­—コードã®åˆ¤åˆ¥æ–¹æ³•
- (1) $B4D6-JQ?t(B LC_ALL, LC_CTYPE, LANG $B$r$3$N=gHV$G%A%'%C%/$9$k(B
- (2) $B4D6-JQ?t$+$i$bH=JL$G$-$J$+$C$?>l9g$O(B UNIX $B$J$i$P(B EUC$B!"(B
- Win32 $B$J$i$P(B SJIS $B$H8+$J$9(B
+ (1) 環境変数 LC_ALL, LC_CTYPE, LANG ã‚’ã“ã®é †ç•ªã§ãƒã‚§ãƒƒã‚¯ã™ã‚‹
+ (2) 環境変数ã‹ã‚‰ã‚‚判別ã§ããªã‹ã£ãŸå ´åˆã¯ UNIX ãªã‚‰ã° EUCã€
+ Win32 ãªã‚‰ã° SJIS ã¨è¦‹ãªã™
-$B%3%s%Q%$%k;~$K(B -DSJISPRE $B$rIU$1$F%3%s%Q%$%k$9$l$P!"(BUNIX $B$G$"$C$F$b(B
-SJIS $B$rM%@h$9$k$h$&$K$J$j$^$9!#(B
+コンパイル時㫠-DSJISPRE を付ã‘ã¦ã‚³ãƒ³ãƒ‘イルã™ã‚Œã°ã€UNIX ã§ã‚ã£ã¦ã‚‚
+SJIS を優先ã™ã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚
diff --git a/docs/README.TESTING b/docs/README.TESTING
index dc621f0..8a8a102 100644
--- a/docs/README.TESTING
+++ b/docs/README.TESTING
@@ -25,7 +25,7 @@ export CMAKE_LIBRARY_PATH=/path/to/the/gd/lib
then call cmake using:
-$ cmake -DUSE_EXT_GD=1 -DBUILD_TEST=1
+$ cmake -DUSE_EXT_GD=1 -DBUILD_TEST=1
$ make
and finally:
@@ -33,18 +33,18 @@ $ ctest .
I will certainly add a nice CMake option to give prefix later.
-What to do if tests fail on your platform and you use the last GD release?
+What to do if tests fail on your platform and you use the last GD release?
either from your favorite distributions or from http://www.libgd.org or git?
-If you use a packaged version of the GD Library (installed from RPM, deb or
+If you use a packaged version of the GD Library (installed from RPM, deb or
ports, gentoo packages or any other packages format or distribution), please try
to run the tests using the source releases available at:
-http://www.libgd.org/Downloads
+https://github.com/libgd/libgd/releases
If the tests fail using our source release, please report a bug here:
-http://bugs.libgd.org
+https://github.com/libgd/libgd/issues
You can attach the two files available in:
diff --git a/docs/README.TXT b/docs/README.TXT
index 39725dd..6a4d918 100644
--- a/docs/README.TXT
+++ b/docs/README.TXT
@@ -55,7 +55,7 @@ you can use the following command line options:
--with-xpm=DIR
Dto. for xpm library.
-
+
--with-tiff=DIR
Dto. for TIFF library.
diff --git a/docs/naturaldocs/nobgd.pl b/docs/naturaldocs/nobgd.pl
index e1c3462..b9186e0 100644
--- a/docs/naturaldocs/nobgd.pl
+++ b/docs/naturaldocs/nobgd.pl
@@ -55,4 +55,3 @@ sub unslurp {
or die "Error writing file '$filename'\n";
close ($fh);
}
-
diff --git a/docs/naturaldocs/preamble.txt b/docs/naturaldocs/preamble.txt
index ca2e43f..5219d29 100644
--- a/docs/naturaldocs/preamble.txt
+++ b/docs/naturaldocs/preamble.txt
@@ -62,14 +62,14 @@ program; it demonstrates additional features!)
> /* Allocate the color black (red, green and blue all minimum).
> Since this is the first color in a new image, it will
> be the background color. */
-> black = gdImageColorAllocate(im, 0, 0, 0);
+> black = gdImageColorAllocate(im, 0, 0, 0);
>
> /* Allocate the color white (red, green and blue all maximum). */
-> white = gdImageColorAllocate(im, 255, 255, 255);
->
+> white = gdImageColorAllocate(im, 255, 255, 255);
+>
> /* Draw a line from the upper left to the lower right,
> using white color index. */
-> gdImageLine(im, 0, 0, 63, 63, white);
+> gdImageLine(im, 0, 0, 63, 63, white);
>
> /* Open a file for writing. "wb" means "write binary", important
> under MSDOS, harmless under Unix. */
diff --git a/docs/naturaldocs/project/Menu.txt b/docs/naturaldocs/project/Menu.txt
index f12369e..12df023 100644
--- a/docs/naturaldocs/project/Menu.txt
+++ b/docs/naturaldocs/project/Menu.txt
@@ -27,22 +27,22 @@ Format: 1.52
# --------------------------------------------------------------------------
-#
+#
# Cut and paste the lines below to change the order in which your files
# appear on the menu. Don't worry about adding or removing files, Natural
# Docs will take care of that.
-#
+#
# You can further organize the menu by grouping the entries. Add a
# "Group: [name] {" line to start a group, and add a "}" to end it.
-#
+#
# You can add text and web links to the menu by adding "Text: [text]" and
# "Link: [name] ([URL])" lines, respectively.
-#
+#
# The formatting and comments are auto-generated, so don't worry about
# neatness when editing the file. Natural Docs will clean it up the next
# time it is run. When working with groups, just deal with the braces and
# forget about the indentation and comments.
-#
+#
# --------------------------------------------------------------------------
@@ -50,11 +50,13 @@ File: About LibGD 2.3.0-dev (no auto-title, preamble.txt)
Group: Image Formats {
+ File: AVIF IO (no auto-title, gd_avif.c)
File: BMP IO (no auto-title, gd_bmp.c)
File: GD IO (no auto-title, gd_gd.c)
File: GD2 IO (no auto-title, gd_gd2.c)
File: GIF Input (no auto-title, gd_gif_in.c)
File: GIF Output (no auto-title, gd_gif_out.c)
+ File: HEIF IO (no auto-title, gd_heif.c)
File: JPEG IO (no auto-title, gd_jpeg.c)
File: PNG IO (no auto-title, gd_png.c)
File: TGA Input (no auto-title, gd_tga.c)
@@ -65,28 +67,28 @@ Group: Image Formats {
File: XPM Input (no auto-title, gdxpm.c)
} # Group: Image Formats
+File: Color Quantization (gd_topal.c)
+File: Cropping (gd_crop.c)
+File: FreeType font rendering (gdft.c)
File: gd.c (gd.c)
File: gd.h (gd.h)
-File: gd_crop.c (gd_crop.c)
File: gd_filename.c (gd_filename.c)
-File: gd_filter.c (gd_filter.c)
File: gd_interpolation.c (gd_interpolation.c)
File: gd_io.h (gd_io.h)
File: gd_io_dp.c (gd_io_dp.c)
File: gd_ss.c (gd_ss.c)
-File: gd_topal.c (gd_topal.c)
-File: gd_transform.c (gd_transform.c)
File: gd_version.c (gd_version.c)
File: gdColorMapLookup (gd_color_map.c)
File: gdFree (gdhelpers.c)
-File: gdft.c (gdft.c)
File: gdfx.c (gdfx.c)
File: gdImageColorMatch (gd_color_match.c)
File: gdImageNeuQuant (gd_nnquant.c)
File: gdNewFileCtx (gd_io_file.c)
File: gdNewSSCtx (gd_io_ss.c)
+File: Image Filters (gd_filter.c)
File: License (license.txt)
File: Matrix (gd_matrix.c)
+File: Transformations (gd_transform.c)
Group: Built-in Fonts {
@@ -103,6 +105,6 @@ Group: Index {
Index: Everything
File Index: Files
Function Index: Functions
+ Macro Index: Macros
Type Index: Types
} # Group: Index
-
diff --git a/docs/naturaldocs/run_docs.sh b/docs/naturaldocs/run_docs.sh
index dce3072..05e29d0 100755
--- a/docs/naturaldocs/run_docs.sh
+++ b/docs/naturaldocs/run_docs.sh
@@ -15,9 +15,9 @@ usage() {
nd() {
# Figure out the name of this tool.
- if which naturaldocs 2>/dev/null ; then
+ if command -v naturaldocs ; then
return
- elif which NaturalDocs 2>/dev/null ; then
+ elif command -v NaturalDocs ; then
return
else
return 1
@@ -45,8 +45,11 @@ elif [ $# -ne 0 ] ; then
usage "unknown options: $*"
fi
-# Version number
-VERSION=`(cd ../../; perl config/getver.pl)`
+# Dump the tool version info for debugging.
+echo "Found '$(nd)': $($(nd) -h | head -n1)"
+
+# Library version number.
+VERSION=$(cd ../../; config/getver.sh)
# Clear away old docs and ensure the doc dir. is present.
rm -rf html
@@ -66,13 +69,18 @@ sed -e "s/@VERSION@/$VERSION/g" preamble.txt > tmp/preamble.txt
# Run naturaldocs to create the manual.
$(nd) --rebuild --rebuild-output --documented-only \
- -i tmp/ \
- -img images/ \
- -o html html \
- --project project/ \
- -s Default libgd
+ -i tmp/ \
+ -img images/ \
+ -o html html \
+ --project project/ \
+ -s Default libgd
+
+# Strip whitespace.
+sed -i.tmp -E \
+ -e 's:[[:space:]]+$::' \
+ -e '${/^[[:space:]]*$/d}' \
+ project/*.txt
+rm project/*.txt.tmp
# And cleanup the temp files.
rm -rf Data tmp
-
-
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 869880f..120a8f3 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,15 +1,19 @@
include_directories (BEFORE "${GD_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}")
SET(TESTS_FILES
- arc
- crop
- gif
- nnquant
- tgaread
+ gif
)
+if (PNG_FOUND)
+ LIST(APPEND TEST_FILES arc crop tgaread)
+
+ if (JPEG_FOUND)
+ LIST(APPEND TESTS_FILES copyrotated flip nnquant)
+ endif (JPEG_FOUND)
+endif (PNG_FOUND)
+
if (JPEG_FOUND)
- LIST(APPEND TESTS_FILES copyrotated flip)
+ LIST(APPEND TESTS_FILES resize)
endif (JPEG_FOUND)
if (TIFF_FOUND)
@@ -27,11 +31,13 @@ FOREACH(test_name ${TESTS_FILES})
target_link_libraries (${test_name} ${GD_LINK_LIB})
ENDFOREACH(test_name)
-if(JPEG_FOUND)
- if(UNIX)
- target_link_libraries(copyrotated m)
- endif(UNIX)
-endif(JPEG_FOUND)
+# Add libraries *after* we've called add_executable on all the tests.
+
+if (PNG_FOUND AND JPEG_FOUND)
+ if (UNIX)
+ target_link_libraries(copyrotated m)
+ endif (UNIX)
+endif(PNG_FOUND AND JPEG_FOUND)
if (WIN32 AND NOT MINGW AND NOT MSYS)
add_executable(windows WIN32 "windows.c")
diff --git a/examples/arc.c b/examples/arc.c
index 8e86283..8b57c14 100644
--- a/examples/arc.c
+++ b/examples/arc.c
@@ -1,4 +1,3 @@
-/* $Id$ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
@@ -19,11 +18,7 @@ int main()
gdImageDestroy(im);
return 1;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
gdImageDestroy(im);
diff --git a/examples/avif2jpeg.c b/examples/avif2jpeg.c
new file mode 100644
index 0000000..6ced15d
--- /dev/null
+++ b/examples/avif2jpeg.c
@@ -0,0 +1,55 @@
+/**
+ * A short program which converts a .avif file into a .jpg file -
+ * just to get a little practice with the basic functionality.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gd.h"
+
+int main(int argc, char **argv)
+{
+ gdImagePtr im;
+ FILE *in, *out;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: avif2jpeg infile.avif outfile.jpg\n");
+ exit(1);
+ }
+
+ printf("Reading infile %s\n", argv[1]);
+
+ in = fopen(argv[1], "rb");
+ if (!in) {
+ fprintf(stderr, "\nError: input file %s does not exist.\n", argv[1]);
+ exit(1);
+ }
+
+ im = gdImageCreateFromAvif(in);
+ fclose(in);
+ if (!im) {
+ fprintf(stderr, "\nError: input file %s is not in AVIF format.\n", argv[1]);
+ exit(1);
+ }
+
+ out = fopen(argv[2], "wb");
+ if (!out) {
+ fprintf(stderr, "\nError: can't write to output file %s\n", argv[2]);
+ gdImageDestroy(im);
+ exit(1);
+ }
+
+ gdImageJpeg(im, out, 75);
+
+ printf("Wrote outfile %s.\n", argv[2]);
+
+ fclose(out);
+ gdImageDestroy(im);
+
+ return 0;
+}
diff --git a/examples/copyrotated.c b/examples/copyrotated.c
index 03e493d..9006c0c 100644
--- a/examples/copyrotated.c
+++ b/examples/copyrotated.c
@@ -1,4 +1,3 @@
-/* $Id$ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
@@ -60,9 +59,9 @@ int main(int argc, char **arg)
/* to radian */
a2 = angle * .0174532925;
- new_width = ceil(cos(a2) * gdImageSX(im)) +
+ new_width = fabs(ceil(cos(a2) * gdImageSX(im))) +
fabs(sin(a2) * gdImageSY(im));
- new_height = ceil(cos(a2) * gdImageSY(im)) +
+ new_height = fabs(ceil(cos(a2) * gdImageSY(im))) +
fabs(sin(a2) * gdImageSX(im));
diff --git a/examples/crop.c b/examples/crop.c
index bafb6df..569807c 100644
--- a/examples/crop.c
+++ b/examples/crop.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
@@ -12,11 +10,7 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
}
@@ -30,12 +24,7 @@ gdImagePtr read_png(const char *filename)
fprintf(stderr, "Can't read png image %s\n", filename);
return NULL;
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng(fp);
-#else
- im = NULL;
- printf("No PNG support. Cannot read image.\n");
-#endif
fclose(fp);
return im;
}
diff --git a/examples/flip.c b/examples/flip.c
index 2399457..35f92cf 100644
--- a/examples/flip.c
+++ b/examples/flip.c
@@ -1,4 +1,3 @@
-/* $Id$ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/examples/gif.c b/examples/gif.c
index d5103f0..ce99c3f 100644
--- a/examples/gif.c
+++ b/examples/gif.c
@@ -49,4 +49,4 @@ int main(void)
fclose(out);
return 0;
-} \ No newline at end of file
+}
diff --git a/examples/jpeg2avif.c b/examples/jpeg2avif.c
new file mode 100644
index 0000000..af55201
--- /dev/null
+++ b/examples/jpeg2avif.c
@@ -0,0 +1,57 @@
+/**
+ * A short program which converts a .jpg file into a .avif file -
+ * just to get a little practice with the basic functionality.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gd.h"
+
+int main(int argc, char **argv)
+{
+ gdImagePtr im;
+ FILE *in, *out;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: jpeg2avif filename.jpg filename.avif\n");
+ exit(1);
+ }
+
+ printf("Reading infile %s\n", argv[1]);
+
+ in = fopen(argv[1], "rb");
+ if (!in) {
+ fprintf(stderr, "Error: input file %s does not exist.\n", argv[1]);
+ exit(1);
+ }
+
+ im = gdImageCreateFromJpeg(in);
+ fclose(in);
+ if (!im) {
+ fprintf(stderr, "Error: input file %s is not in JPEG format.\n", argv[1]);
+ exit(1);
+ }
+
+ out = fopen(argv[2], "wb");
+ if (!out) {
+ fprintf(stderr, "Error: can't write to output file %s\n", argv[2]);
+ gdImageDestroy(im);
+ exit(1);
+ }
+
+ fprintf(stderr, "Encoding...\n");
+
+ gdImageAvif(im, out);
+
+ printf("Wrote outfile %s.\n", argv[2]);
+
+ fclose(out);
+ gdImageDestroy(im);
+
+ return 0;
+}
diff --git a/examples/jpeg2avifex.c b/examples/jpeg2avifex.c
new file mode 100644
index 0000000..a8afb3b
--- /dev/null
+++ b/examples/jpeg2avifex.c
@@ -0,0 +1,98 @@
+/**
+ * A short program which converts a .jpg file into a .avif file -
+ * just to get a little practice with the basic functionality.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "gd.h"
+
+static void usage() {
+ fprintf(stderr, "Usage: jpeg2avifex [-q quality] [-s speed] infile.jpg outfile.avif\n");
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ gdImagePtr im;
+ FILE *in, *out;
+ int c;
+ int speed = -1, quality = -1; // use default values if unspecified
+ char *infile, *outfile;
+ int failed = 0;
+
+ if (argc < 3) {
+ usage();
+ }
+
+ while ((c = getopt(argc, argv, "q:s:")) != -1) {
+ switch (c) {
+ case 'q':
+ quality = atoi(optarg);
+ break;
+
+ case 's':
+ speed = atoi(optarg);
+ break;
+
+ default:
+ usage();
+ }
+ }
+
+ if (optind > argc - 2)
+ usage();
+
+ infile = strdup(argv[optind++]);
+ outfile = strdup(argv[optind]);
+
+ printf("Reading infile %s\n", infile);
+
+ in = fopen(infile, "rb");
+ if (!in) {
+ fprintf(stderr, "\nError: input file %s does not exist.\n", infile);
+ failed = 1;
+ goto cleanup;
+ }
+
+ im = gdImageCreateFromJpeg(in);
+ fclose(in);
+ if (!im) {
+ fprintf(stderr, "\nError: input file %s is not in JPEG format.\n", infile);
+ failed = 1;
+ goto cleanup;
+ }
+
+ out = fopen(outfile, "wb");
+ if (!out) {
+ fprintf(stderr, "\nError: can't write to output file %s\n", outfile);
+ failed = 1;
+ goto cleanup;
+ }
+
+ fprintf(stderr, "Encoding...\n");
+
+ gdImageAvifEx(im, out, quality, speed);
+
+ printf("Wrote outfile %s.\n", outfile);
+
+ fclose(out);
+
+cleanup:
+ if (im)
+ gdImageDestroy(im);
+
+ gdFree(infile);
+ gdFree(outfile);
+
+ exit(failed);
+}
diff --git a/examples/nnquant.c b/examples/nnquant.c
index 33ed523..82e3672 100644
--- a/examples/nnquant.c
+++ b/examples/nnquant.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
@@ -12,17 +10,12 @@ void save_png(gdImagePtr im, const char *filename)
fprintf(stderr, "Can't save png image %s\n", filename);
return;
}
-#ifdef HAVE_LIBPNG
gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
fclose(fp);
}
int main()
{
-#ifdef HAVE_JPEG
gdImagePtr im, im2;
FILE *fp;
char path[2048];
@@ -56,9 +49,5 @@ int main()
save_png(im, "a_jquant_dither.png");
gdImageDestroy(im);
-#else
- printf("JPEG support is required for this example. Please recompile GD with JPEG or change this example to use another format as input.");
- return 1;
-#endif
return 0;
}
diff --git a/examples/png2avif.c b/examples/png2avif.c
new file mode 100644
index 0000000..18463e7
--- /dev/null
+++ b/examples/png2avif.c
@@ -0,0 +1,58 @@
+/**
+ * A short program which converts a .png file into a .avif file -
+ * just to get a little practice with the basic functionality.
+ * We convert losslessly.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gd.h"
+
+int main(int argc, char **argv)
+{
+ gdImagePtr im;
+ FILE *in, *out;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: png2avif infile.png outfile.avif\n");
+ exit(1);
+ }
+
+ printf("Reading infile %s\n", argv[1]);
+
+ in = fopen(argv[1], "rb");
+ if (!in) {
+ fprintf(stderr, "Error: input file %s does not exist.\n", argv[1]);
+ exit(1);
+ }
+
+ im = gdImageCreateFromPng(in);
+ fclose(in);
+ if (!im) {
+ fprintf(stderr, "Error: input file %s is not in PNG format.\n", argv[1]);
+ exit(1);
+ }
+
+ out = fopen(argv[2], "wb");
+ if (!out) {
+ fprintf(stderr, "Error: can't write to output file %s\n", argv[2]);
+ gdImageDestroy(im);
+ exit(1);
+ }
+
+ fprintf(stderr, "Encoding...\n");
+
+ gdImageAvifEx(im, out, 100, 0);
+
+ printf("Wrote outfile %s.\n", argv[2]);
+
+ fclose(out);
+ gdImageDestroy(im);
+
+ return 0;
+}
diff --git a/examples/resize.c b/examples/resize.c
index 84543cd..8bc3ff7 100644
--- a/examples/resize.c
+++ b/examples/resize.c
@@ -56,4 +56,4 @@ int main (int argc, char *argv[]) {
gdImageDestroy(out);
return 0;
-} \ No newline at end of file
+}
diff --git a/examples/tgaread.c b/examples/tgaread.c
index a8e0807..859f4d4 100644
--- a/examples/tgaread.c
+++ b/examples/tgaread.c
@@ -1,4 +1,3 @@
-/* $Id$ */
/*
* You can fetch a set of samples TIFF images here:
* ftp://ftp.remotesensing.org/pub/libtiff/
@@ -44,11 +43,7 @@ int main()
gdImageDestroy(im);
return 1;
}
-#ifdef HAVE_LIBPNG
- gdImagePng(im, fp);
-#else
- printf("No PNG support. Cannot save image.\n");
-#endif
+ gdImagePng(im, fp);
fclose(fp);
gdImageDestroy(im);
}
diff --git a/examples/tiffread.c b/examples/tiffread.c
index fe63ce0..f1d7836 100644
--- a/examples/tiffread.c
+++ b/examples/tiffread.c
@@ -1,4 +1,3 @@
-/* $Id$ */
/*
* You can fetch a set of samples TIFF images here:
* ftp://ftp.remotesensing.org/pub/libtiff/
diff --git a/examples/windows.c b/examples/windows.c
index 5597638..d68d7a1 100644
--- a/examples/windows.c
+++ b/examples/windows.c
@@ -3,7 +3,6 @@ Sample usage of GD on windows. This little program opens a window, fetch its DIB
and assigns to a GD truecolor image.
Thanks to Mateusz Loskot (http://mateusz.loskot.net) for the AttachBuffer function!
-$Id$
*/
#include <windows.h>
#include <gd.h>
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
index 08f2e07..dd6d8b6 100644
--- a/m4/ax_append_flag.m4
+++ b/m4/ax_append_flag.m4
@@ -1,5 +1,5 @@
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
@@ -23,33 +23,12 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
-#serial 6
+#serial 8
AC_DEFUN([AX_APPEND_FLAG],
[dnl
diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4
index 1f07799..094577e 100644
--- a/m4/ax_cflags_warn_all.m4
+++ b/m4/ax_cflags_warn_all.m4
@@ -1,5 +1,5 @@
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
+# https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
# ===========================================================================
#
# SYNOPSIS
@@ -43,7 +43,7 @@
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
+# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
@@ -58,7 +58,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 15
+#serial 16
AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
index 4c4051e..5fbf9fe 100644
--- a/m4/ax_pthread.m4
+++ b/m4/ax_pthread.m4
@@ -1,5 +1,5 @@
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
+# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
@@ -67,7 +67,7 @@
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
+# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
@@ -82,7 +82,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 23
+#serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
index cae1111..17c3eab 100644
--- a/m4/ax_require_defined.m4
+++ b/m4/ax_require_defined.m4
@@ -1,5 +1,5 @@
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
@@ -30,7 +30,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 1
+#serial 2
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
diff --git a/netware/Makefile.netware b/netware/Makefile.netware
deleted file mode 100644
index 3da6243..0000000
--- a/netware/Makefile.netware
+++ /dev/null
@@ -1,553 +0,0 @@
-#################################################################
-#
-## Makefile for building libgd.nlm (NetWare version - gnu make)
-## Use: make -f Makefile
-##
-## Comments to: Guenter Knauf <eflash@gmx.net>
-##
-## $Id$
-#
-#################################################################
-
-# Edit the path below to point to the base of your Novell NDK.
-ifndef NDKBASE
-NDKBASE = c:/novell
-endif
-
-# Base for the lib sources
-ifndef LIBBASE
-LIBBASE = ../..
-endif
-# All library code is statically linked to avoid problems with other lib NLMs.
-
-# Edit the path below to point to your libpng sources or set environment var.
-ifndef LIBPNG
-LIBPNG = $(LIBBASE)/libpng-1.2.16
-endif
-# Edit the path below to point to your libpng sources or set environment var.
-ifndef LIBJPEG
-LIBJPEG = $(LIBBASE)/jpeg-6b
-endif
-# Edit the path below to point to your freetype sources or set environment var.
-ifndef LIBFT2
-LIBFT2 = $(LIBBASE)/freetype-2.3.4
-endif
-# Edit the path below to point to your zlib sources or set environment var.
-ifndef ZLIBSDK
-ZLIBSDK = $(LIBBASE)/zlib-1.2.3
-endif
-
-LIBGD = ..
-
-ifndef INSTDIR
-INSTDIR = libgd-$(LIBGD_VERSION_STR)-bin-nw
-endif
-
-# Edit the vars below to change NLM target settings.
-TARGET = libgd
-COPYR = Copyright (C) 1996-2007 Boutell.Com, Inc.
-WWW = http://www.libgd.org/
-DESCR = libgd $(LIBGD_VERSION_STR) - $(WWW)
-MTSAFE = YES
-STACK = 64000
-SCREEN = none
-EXPORTS = @$(TARGET).imp
-EPREFIX = LIBGD
-
-# Edit the var below to point to your lib architecture.
-ifndef LIBARCH
-LIBARCH = LIBC
-endif
-
-# must be equal to DEBUG or NDEBUG
-DB = NDEBUG
-# DB = DEBUG
-# Optimization: -O<n> or debugging: -g
-ifeq ($(DB),NDEBUG)
- OPT = -O2
- OBJDIR = release
-else
- OPT = -g
- OBJDIR = debug
-endif
-
-# Include the version info retrieved from xml2ver.h
--include $(OBJDIR)/version.inc
-
-# The following line defines your compiler.
-ifdef METROWERKS
- CC = mwccnlm
-else
- CC = gcc
-endif
-# http://www.gknw.net/development/prgtools/awk.zip
-AWK = awk
-YACC = bison -y
-CP = cp -afv
-# RM = rm -f
-# if you want to mark the target as MTSAFE you will need a tool for
-# generating the xdc data for the linker; here's a minimal tool:
-# http://www.gknw.net/development/prgtools/mkxdc.zip
-MPKXDC = mkxdc
-PATCH = patch
-PERLRUN = perl
-
-# Global flags for all compilers
-CFLAGS = $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
-#CFLAGS += -DHAVE_LIBPNG=1 -DHAVE_LIBJPEG=1
-#CFLAGS += -DHAVE_LIBFREETYPE=1 -DHAVE_FT2BUILD_H=1
-#CFLAGS += -DHAVE_LIBZ=1
-
-ifeq ($(CC),mwccnlm)
-LD = mwldnlm
-LDFLAGS = -nostdlib $(PRELUDE) $(OBJL) $(LDLIBS) -o $@ -commandfile
-AR = mwldnlm
-ARFLAGS = -type library -w nocmdline $(OBJS) -o
-LIBEXT = lib
-CFLAGS += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586
-CFLAGS += -relax_pointers
-#CFLAGS += -w on
-ifeq ($(LIBARCH),LIBC)
- PRELUDE = $(SDK_LIBC)/imports/libcpre.o
- CFLAGS += -align 4
-else
- PRELUDE = "$(METROWERKS)/Novell Support/libraries/runtime/prelude.obj"
-# CFLAGS += -include "$(METROWERKS)/Novell Support/headers/nlm_prefix.h"
- CFLAGS += -align 1
-endif
-else
-LD = nlmconv
-LDFLAGS = -T
-AR = ar
-ARFLAGS = -cq
-LIBEXT = a
-CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
-CFLAGS += -Wall -Wno-unused -Wno-main # -pedantic
-ifeq ($(LIBARCH),LIBC)
- PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
-else
- PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o
- CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
-endif
-endif
-
-NDK_ROOT = $(NDKBASE)/ndk
-SDK_CLIB = $(NDK_ROOT)/nwsdk
-SDK_LIBC = $(NDK_ROOT)/libc
-
-INCLUDES = -I. -I$(LIBGD) -I$(LIBPNG) -I$(LIBJPEG) -I$(LIBFT2)/include -I$(ZLIBSDK)
-
-ifeq ($(LIBARCH),LIBC)
- INCLUDES += -I$(SDK_LIBC)/include
- # INCLUDES += -I$(SDK_LIBC)/include/nks
- CFLAGS += -D_POSIX_SOURCE
- # CFLAGS += -D__ANSIC__
-else
- INCLUDES += -I$(SDK_CLIB)/include/nlm
- # INCLUDES += -I$(SDK_CLIB)/include
- # INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
-endif
-CFLAGS += $(INCLUDES)
-
-ifeq ($(MTSAFE),YES)
- XDCOPT = -n
-endif
-ifeq ($(MTSAFE),NO)
- XDCOPT = -u
-endif
-ifdef XDCOPT
- XDCDATA = $(OBJDIR)/$(TARGET).xdc
-endif
-
-ifeq ($(findstring linux,$(OSTYPE)),linux)
-DL = '
-#-include $(NDKBASE)/nlmconv/ncpfs.inc
-endif
-
-GDLIBOBJS = \
- $(OBJDIR)/gd.o \
- $(OBJDIR)/gd_gd.o \
- $(OBJDIR)/gd_gd2.o \
- $(OBJDIR)/gd_gif_in.o \
- $(OBJDIR)/gd_gif_out.o \
- $(OBJDIR)/gd_io.o \
- $(OBJDIR)/gd_io_dp.o \
- $(OBJDIR)/gd_io_file.o \
- $(OBJDIR)/gd_io_ss.o \
- $(OBJDIR)/gd_jpeg.o \
- $(OBJDIR)/gd_png.o \
- $(OBJDIR)/gd_ss.o \
- $(OBJDIR)/gd_topal.o \
- $(OBJDIR)/gd_wbmp.o \
- $(OBJDIR)/gdcache.o \
- $(OBJDIR)/gdfontg.o \
- $(OBJDIR)/gdfontl.o \
- $(OBJDIR)/gdfontmb.o \
- $(OBJDIR)/gdfonts.o \
- $(OBJDIR)/gdfontt.o \
- $(OBJDIR)/gdft.o \
- $(OBJDIR)/gdfx.o \
- $(OBJDIR)/gdhelpers.o \
- $(OBJDIR)/gdkanji.o \
- $(OBJDIR)/gdtables.o \
- $(OBJDIR)/gdxpm.o \
- $(OBJDIR)/wbmp.o \
- $(EOLIST)
-ifeq "$(wildcard $(LIBGD)/gd_security.c)" "$(LIBGD)/gd_security.c"
-GDLIBOBJS += \
- $(OBJDIR)/gd_security.o \
- $(EOLIST)
-endif
-
-PNGLIBOBJS = \
- $(OBJDIR)/png.o \
- $(OBJDIR)/pngerror.o \
- $(OBJDIR)/pngget.o \
- $(OBJDIR)/pngmem.o \
- $(OBJDIR)/pngpread.o \
- $(OBJDIR)/pngread.o \
- $(OBJDIR)/pngrio.o \
- $(OBJDIR)/pngrtran.o \
- $(OBJDIR)/pngrutil.o \
- $(OBJDIR)/pngset.o \
- $(OBJDIR)/pngtrans.o \
- $(OBJDIR)/pngwio.o \
- $(OBJDIR)/pngwrite.o \
- $(OBJDIR)/pngwtran.o \
- $(OBJDIR)/pngwutil.o \
- $(EOLIST)
-ifeq "$(wildcard $(LIBPNG)/pnggccrd.c)" "$(LIBPNG)/pnggccrd.c"
-PNGLIBOBJS += \
- $(OBJDIR)/pnggccrd.o \
- $(OBJDIR)/pngvcrd.o \
- $(EOLIST)
-endif
-
-OBJ_JPG = $(OBJDIR)
-JPGLIBOBJS = \
- $(OBJ_JPG)/jcapimin.o \
- $(OBJ_JPG)/jcapistd.o \
- $(OBJ_JPG)/jccoefct.o \
- $(OBJ_JPG)/jccolor.o \
- $(OBJ_JPG)/jcdctmgr.o \
- $(OBJ_JPG)/jchuff.o \
- $(OBJ_JPG)/jcinit.o \
- $(OBJ_JPG)/jcmainct.o \
- $(OBJ_JPG)/jcmarker.o \
- $(OBJ_JPG)/jcmaster.o \
- $(OBJ_JPG)/jcomapi.o \
- $(OBJ_JPG)/jcparam.o \
- $(OBJ_JPG)/jcphuff.o \
- $(OBJ_JPG)/jcprepct.o \
- $(OBJ_JPG)/jcsample.o \
- $(OBJ_JPG)/jctrans.o \
- $(OBJ_JPG)/jdapimin.o \
- $(OBJ_JPG)/jdapistd.o \
- $(OBJ_JPG)/jdatadst.o \
- $(OBJ_JPG)/jdatasrc.o \
- $(OBJ_JPG)/jdcoefct.o \
- $(OBJ_JPG)/jdcolor.o \
- $(OBJ_JPG)/jddctmgr.o \
- $(OBJ_JPG)/jdhuff.o \
- $(OBJ_JPG)/jdinput.o \
- $(OBJ_JPG)/jdmainct.o \
- $(OBJ_JPG)/jdmarker.o \
- $(OBJ_JPG)/jdmaster.o \
- $(OBJ_JPG)/jdmerge.o \
- $(OBJ_JPG)/jdphuff.o \
- $(OBJ_JPG)/jdpostct.o \
- $(OBJ_JPG)/jdsample.o \
- $(OBJ_JPG)/jdtrans.o \
- $(OBJ_JPG)/jerror.o \
- $(OBJ_JPG)/jfdctflt.o \
- $(OBJ_JPG)/jfdctfst.o \
- $(OBJ_JPG)/jfdctint.o \
- $(OBJ_JPG)/jidctflt.o \
- $(OBJ_JPG)/jidctfst.o \
- $(OBJ_JPG)/jidctint.o \
- $(OBJ_JPG)/jidctred.o \
- $(OBJ_JPG)/jquant1.o \
- $(OBJ_JPG)/jquant2.o \
- $(OBJ_JPG)/jutils.o \
- $(OBJ_JPG)/jmemmgr.o \
- $(OBJ_JPG)/jmemansi.o \
- $(EOLIST)
-
-LIBFT2OBJS = \
- $(OBJ_FT2)/autohint.o \
- $(OBJ_FT2)/bdf.o \
- $(OBJ_FT2)/cff.o \
- $(OBJ_FT2)/ftbase.o \
- $(OBJ_FT2)/ftcache.o \
- $(OBJ_FT2)/ftglyph.o \
- $(OBJ_FT2)/ftinit.o \
- $(OBJ_FT2)/ftmm.o \
- $(OBJ_FT2)/ftsystem.o \
- $(OBJ_FT2)/pcf.o \
- $(OBJ_FT2)/pfr.o \
- $(OBJ_FT2)/psaux.o \
- $(OBJ_FT2)/pshinter.o \
- $(OBJ_FT2)/psmodule.o \
- $(OBJ_FT2)/raster.o \
- $(OBJ_FT2)/sfnt.o \
- $(OBJ_FT2)/smooth.o \
- $(OBJ_FT2)/truetype.o \
- $(OBJ_FT2)/type1.o \
- $(OBJ_FT2)/type1cid.o \
- $(OBJ_FT2)/type42.o \
- $(OBJ_FT2)/winfnt.o \
- $(OBJ_FT2)/infutil.o \
- $(OBJ_FT2)/ftgzip.o \
- $(OBJ_FT2)/ftlzw.o \
- $(OBJ_FT2)/ftpfr.o \
- $(OBJ_FT2)/ftstroke.o \
- $(OBJ_FT2)/ftsynth.o \
- $(OBJ_FT2)/fttype1.o \
- $(OBJ_FT2)/ftwinfnt.o \
- $(OBJ_FT2)/ftxf86.o \
- $(OBJ_FT2)/ftbbox.o \
- $(EOLIST)
-
-ZLIBOBJS = \
- $(OBJDIR)/adler32.o \
- $(OBJDIR)/compress.o \
- $(OBJDIR)/crc32.o \
- $(OBJDIR)/deflate.o \
- $(OBJDIR)/inflate.o \
- $(OBJDIR)/inffast.o \
- $(OBJDIR)/inftrees.o \
- $(OBJDIR)/trees.o \
- $(OBJDIR)/uncompr.o \
- $(OBJDIR)/zutil.o \
- $(EOLIST)
-ifeq "$(wildcard $(ZLIBSDK)/infblock.c)" "$(ZLIBSDK)/infblock.c"
-ZLIBOBJS += \
- $(OBJDIR)/infblock.o \
- $(OBJDIR)/infcodes.o \
- $(OBJDIR)/infutil.o \
- $(EOLIST)
-endif
-
-LDLIBS += $(LIBFT2)/builds/netware/LIBC/libft2.$(LIBEXT)
-
-OBJS := $(GDLIBOBJS) $(PNGLIBOBJS) $(JPGLIBOBJS) $(ZLIBOBJS)
-
-OBJL = $(OBJS) $(OBJDIR)/nwlibc.o
-
-vpath %.c . $(LIBGD) $(LIBPNG) $(LIBJPEG) $(ZLIBSDK)
-
-.PHONY: all prebuild dist install clean clean-all test-cmds help
-
-all: lib nlm
-
-nlm: prebuild $(TARGET).nlm
-
-lib: prebuild $(TARGET).$(LIBEXT)
-
-prebuild: $(OBJDIR) $(OBJDIR)/version.inc config.h
-
-$(OBJDIR)/%.o: %.c
-# @echo Compiling $<
- $(CC) $(CFLAGS) -c $< -o $@
-
-$(OBJDIR)/version.inc: ../configure $(OBJDIR)
- @echo Creating $@
- @$(AWK) -f get_ver.awk $< > $@ # TODO: get version info from src/gd.h
-
-dist: all
- -$(RM) -r $(OBJDIR)*
-
-install: $(INSTDIR) all
- @$(CP) $(TARGET).nlm $(INSTDIR)
- @$(CP) $(TARGET).$(LIBEXT) $(INSTDIR)
- @$(CP) ../CHANGES $(INSTDIR)
- @$(CP) ../COPYING $(INSTDIR)
- @$(CP) ../README $(INSTDIR)
- @$(CP) ../RELEASE-NOTES $(INSTDIR)
-
-clean:
- -$(RM) config.h
- -$(RM) -r $(OBJDIR)*
- -$(RM) $(TARGET).nlm $(TARGET).$(LIBEXT) $(TARGET).imp
-
-dist-clean:
- -$(RM) config.h
- -$(RM) -r $(OBJDIR)*
-
-clean-all: clean
- -$(MAKE) -C tests -f Makefile clean
-
-test-cmds:
- -$(MAKE) -C tests -f Makefile
-
-$(INSTDIR):
- @mkdir $(INSTDIR)
-
-$(OBJDIR):
- @mkdir $(OBJDIR)
-
-$(TARGET).$(LIBEXT): $(OBJS)
- @echo Creating $@
- @-$(RM) $@
- @$(AR) $(ARFLAGS) $@ $^
-
-$(TARGET).nlm: $(OBJDIR)/$(TARGET).def $(TARGET).imp $(OBJL) $(XDCDATA)
- @echo Linking $@
- @-$(RM) $@
- @$(LD) $(LDFLAGS) $<
-
-$(OBJDIR)/%.xdc: Makefile
- @echo Creating $@
- @$(MPKXDC) $(XDCOPT) $@
-
-$(OBJDIR)/%.def: Makefile
- @echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
- @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
- @echo $(DL)# All your changes will be lost!!$(DL) >> $@
- @echo $(DL)#$(DL) >> $@
- @echo $(DL)copyright "$(COPYR)"$(DL) >> $@
- @echo $(DL)description "$(DESCR)"$(DL) >> $@
- @echo $(DL)version $(LIBGD_VERSION)$(DL) >> $@
-ifdef NLMTYPE
- @echo $(DL)type $(NLMTYPE)$(DL) >> $@
-endif
-ifdef STACK
- @echo $(DL)stack $(STACK)$(DL) >> $@
-endif
-ifdef SCREEN
- @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
-else
- @echo $(DL)screenname "DEFAULT"$(DL) >> $@
-endif
-ifeq ($(DB),DEBUG)
- @echo $(DL)debug$(DL) >> $@
-endif
- @echo $(DL)threadname "$(TARGET)"$(DL) >> $@
-ifdef XDCDATA
- @echo $(DL)xdcdata $(XDCDATA)$(DL) >> $@
-endif
- @echo $(DL)flag_on 64$(DL) >> $@
-ifeq ($(LIBARCH),CLIB)
- @echo $(DL)start _Prelude$(DL) >> $@
- @echo $(DL)exit _Stop$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/socklib.imp$(DL) >> $@
- @echo $(DL)module clib$(DL) >> $@
-else
- @echo $(DL)pseudopreemption$(DL) >> $@
- @echo $(DL)start _LibCPrelude$(DL) >> $@
- @echo $(DL)exit _LibCPostlude$(DL) >> $@
- @echo $(DL)check _LibCCheckUnload$(DL) >> $@
- @echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@
- @echo $(DL)module libc$(DL) >> $@
-endif
-ifdef MODULES
- @echo $(DL)module $(MODULES)$(DL) >> $@
-endif
-ifdef IMPORTS
- @echo $(DL)import $(IMPORTS)$(DL) >> $@
-endif
-ifdef EXPORTS
- @echo $(DL)export $(EXPORTS)$(DL) >> $@
-endif
-ifeq ($(LD),nlmconv)
- @echo $(DL)input $(OBJL)$(DL) >> $@
- @echo $(DL)input $(PRELUDE)$(DL) >> $@
-ifdef LDLIBS
- @echo $(DL)input $(LDLIBS)$(DL) >> $@
-endif
- @echo $(DL)output $(TARGET).nlm$(DL) >> $@
-endif
-
-config.h: Makefile
- @echo Creating $@
- @echo $(DL)/* $@ for NetWare target.$(DL) > $@
- @echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
- @echo $(DL)** All your changes will be lost!!$(DL) >> $@
- @echo $(DL)*/$(DL) >> $@
- @echo $(DL)#define OS "i586-pc-NetWare"$(DL) >> $@
- @echo $(DL)#define VERSION "$(LIBGD_VERSION_STR)"$(DL) >> $@
- @echo $(DL)#define PACKAGE_BUGREPORT "http://bugs.libgd.org/"$(DL) >> $@
- @echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
- @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@
- @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
- @echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
- @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@
- @echo $(DL)#define HAVE_INET_NTOA 1$(DL) >> $@
- @echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
- @echo $(DL)#define HAVE_INTTYPES_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_LIMITS_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_LONGLONG 1$(DL) >> $@
- @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
- @echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_SIGNAL 1$(DL) >> $@
- @echo $(DL)#define HAVE_SOCKET 1$(DL) >> $@
- @echo $(DL)#define HAVE_STDARG_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_STDDEF_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_STDINT_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_STDLIB_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRCASECMP 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRDUP 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRFTIME 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRING_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRLCAT 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRLCPY 1$(DL) >> $@
- @echo $(DL)#define HAVE_STRSTR 1$(DL) >> $@
- @echo $(DL)#define HAVE_SYS_PARAM_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_SYS_SELECT_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_SYS_STAT_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_SYS_TIME_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_TERMIOS_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_TIME_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_UNAME 1$(DL) >> $@
- @echo $(DL)#define HAVE_UNISTD_H 1$(DL) >> $@
- @echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
- @echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
- @echo $(DL)#define HAVE_SYS_TYPES_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_ZLIB_H 1$(DL) >> $@
- @echo $(DL)#define HAVE_LIBZ 1$(DL) >> $@
- @echo $(DL)#define HAVE_LIBPNG 1$(DL) >> $@
- @echo $(DL)#define HAVE_LIBJPEG 1$(DL) >> $@
- @echo $(DL)#define HAVE_LIBFREETYPE 1$(DL) >> $@
- @echo $(DL)#define HAVE_FT2BUILD_H 1$(DL) >> $@
-# @echo $(DL)#define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf"$(DL) >> $@
-# @echo $(DL)#define PATHSEPARATOR ";"$(DL) >> $@
-
-$(TARGET).imp: get_exp.awk $(LIBGD)/gd.h
- @echo Creating $@
- @$(AWK) -v EPREFIX=$(EPREFIX) -f $^ > $@
-
-patch: Makefile
- @echo Patching sources...
- $(PATCH) -d $(LIBGD) -b -p 0 -i $(LIBGD)/netware/$(notdir $(wildcard $(LIBGD)/netware/*.diff))
-
-help:
- @echo $(DL)===========================================================$(DL)
- @echo Novell NDK Base = $(NDKBASE)
- @echo libpng Source = $(LIBPNG)
- @echo libjpeg Source = $(LIBJPEG)
- @echo Freetype 2 SDK = $(LIBFT2)
- @echo Zlib SDK = $(ZLIBSDK)
- @echo $(DL)===========================================================$(DL)
- @echo $(DL)libgd $(LIBGD_VERSION_STR) - available targets are:$(DL)
- @echo $(DL)$(MAKE) all$(DL)
- @echo $(DL)$(MAKE) nlm$(DL)
- @echo $(DL)$(MAKE) lib$(DL)
- @echo $(DL)$(MAKE) clean$(DL)
- @echo $(DL)$(MAKE) clean-all$(DL)
- @echo $(DL)$(MAKE) test-cmds$(DL)
- @echo $(DL)$(MAKE) patch$(DL)
- @echo $(DL)===========================================================$(DL)
-
-
diff --git a/netware/get_exp.awk b/netware/get_exp.awk
deleted file mode 100644
index 5428bf6..0000000
--- a/netware/get_exp.awk
+++ /dev/null
@@ -1,37 +0,0 @@
-#!awk
-# awk hack to fetch libgd export functions from header
-# and write them to STDOUT. Here you can get an awk version for Win32:
-# http://www.gknw.net/development/prgtools/awk.zip
-# $Id$
-#
-BEGIN {
- print "# Exports extracted from " ARGV[1] "";
- print "# Do not edit this file - it is created by make!";
- print "# All your changes will be lost!!";
- if (EPREFIX) {
- print " (" EPREFIX ")";
- }
- print " gdFontGetGiant,";
- print " gdFontGetLarge,";
- print " gdFontGetMediumBold,";
- print " gdFontGetSmall,";
- print " gdFontGetTiny,";
- print " gdImageSquareToCircle,";
- print " gdImageStringFTCircle,";
- print " gdImageSharpen,";
-}
-
-# try to catch the function names from lines like:
-# BGD_DECLARE(gdImagePtr) function ...
-# BGD_DECLARE(void *) function ...
-#
-/^[ \t]*BGD_DECLARE\([^\)]*\) +(gd[A-Za-z0-9_]+)/ {
- sub(/^[ \t]*BGD_DECLARE\([^\)]+\) +/, "");
- sub(/[ \t]*\(.*$/, "");
- # hack to filter gdImageEllipse() since we have no C implementation.
- if ($0 != "gdImageEllipse") {
- print " " $0 ",";
- }
-}
-
-
diff --git a/netware/get_ver.awk b/netware/get_ver.awk
deleted file mode 100644
index 8747a33..0000000
--- a/netware/get_ver.awk
+++ /dev/null
@@ -1,28 +0,0 @@
-#!awk
-# awk script which fetches libgd version number and string from input file
-# and writes them to STDOUT. Here you can get an awk version for Win32:
-# http://www.gknw.net/development/prgtools/awk.zip
-# $Id$
-#
-BEGIN {
- while ((getline < ARGV[1]) > 0) {
- if (match ($0, /^GDLIB_MAJOR=([0-9]*)$/)) {
- split($1, t, "=");
- v_maj = t[2];
- }
- if (match ($0, /^GDLIB_MINOR=([0-9]*)$/)) {
- split($1, t, "=");
- v_min = t[2];
- }
- if (match ($0, /^GDLIB_REVISION=([0-9]*)$/)) {
- split($1, t, "=");
- v_rev = t[2];
- }
- }
- libgd_ver = v_maj "," v_min "," v_rev;
- libgd_ver_str = v_maj "." v_min "." v_rev;
- print "LIBGD_VERSION = " libgd_ver "";
- print "LIBGD_VERSION_STR = " libgd_ver_str "";
-}
-
-
diff --git a/netware/keepscreen.c b/netware/keepscreen.c
deleted file mode 100644
index 0ff8562..0000000
--- a/netware/keepscreen.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Simple _NonAppStop() implementation which can be linked to your
- * NLM in order to keep the screen open when the NLM terminates
- * (the good old clib behaviour).
- * You dont have to call it, its done automatically from LibC.
- *
- * 2004-Aug-11 by Guenter Knauf
- *
- * URL: http://www.gknw.com/development/mk_nlm/
- *
- * $Id$
- */
-
-#include <stdio.h>
-#include <screen.h>
-
-void _NonAppStop()
-{
- uint16_t row, col;
-
- GetScreenSize(&row, &col);
- gotorowcol(row-1, 0);
- /* pressanykey(); */
- printf("<Press any key to close screen> ");
- getcharacter();
-}
-
-
diff --git a/netware/nwlibc.c b/netware/nwlibc.c
deleted file mode 100644
index b981a55..0000000
--- a/netware/nwlibc.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*********************************************************************
- * Universal NetWare library stub. *
- * written by Ulrich Neuman and given to OpenSource copyright-free. *
- * version: 1.0 *
- * $Id$
- *********************************************************************/
-
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <library.h>
-#include <netware.h>
-#include <screen.h>
-#include <nks/thread.h>
-#include <nks/synch.h>
-
-
-typedef struct {
- int _errno;
- void *twentybytes;
-} libthreaddata_t;
-
-typedef struct {
- int x;
- int y;
- int z;
- void *tenbytes;
- NXKey_t perthreadkey; /* if -1, no key obtained... */
- NXMutex_t *lock;
-} libdata_t;
-
-int gLibId = -1;
-void *gLibHandle = (void *) NULL;
-rtag_t gAllocTag = (rtag_t) NULL;
-NXMutex_t *gLibLock = (NXMutex_t *) NULL;
-
-/* internal library function prototypes... */
-int DisposeLibraryData ( void * );
-void DisposeThreadData ( void * );
-int GetOrSetUpData ( int id, libdata_t **data, libthreaddata_t **threaddata );
-
-
-int _NonAppStart
-(
- void *NLMHandle,
- void *errorScreen,
- const char *cmdLine,
- const char *loadDirPath,
- size_t uninitializedDataLength,
- void *NLMFileHandle,
- int (*readRoutineP)( int conn, void *fileHandle, size_t offset,
- size_t nbytes, size_t *bytesRead, void *buffer ),
- size_t customDataOffset,
- size_t customDataSize,
- int messageCount,
- const char **messages
-)
-{
- NX_LOCK_INFO_ALLOC(liblock, "Per-Application Data Lock", 0);
-
-#ifndef __GNUC__
-#pragma unused(cmdLine)
-#pragma unused(loadDirPath)
-#pragma unused(uninitializedDataLength)
-#pragma unused(NLMFileHandle)
-#pragma unused(readRoutineP)
-#pragma unused(customDataOffset)
-#pragma unused(customDataSize)
-#pragma unused(messageCount)
-#pragma unused(messages)
-#endif
-
- /*
- ** Here we process our command line, post errors (to the error screen),
- ** perform initializations and anything else we need to do before being able
- ** to accept calls into us. If we succeed, we return non-zero and the NetWare
- ** Loader will leave us up, otherwise we fail to load and get dumped.
- */
- gAllocTag = AllocateResourceTag(NLMHandle,
- "<library-name> memory allocations", AllocSignature);
-
- if (!gAllocTag) {
- OutputToScreen(errorScreen, "Unable to allocate resource tag for "
- "library memory allocations.\n");
- return -1;
- }
-
- gLibId = register_library(DisposeLibraryData);
-
- if (gLibId < -1) {
- OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
- return -1;
- }
-
- gLibHandle = NLMHandle;
-
- gLibLock = NXMutexAlloc(0, 0, &liblock);
-
- if (!gLibLock) {
- OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
- return -1;
- }
-
- return 0;
-}
-
-/*
-** Here we clean up any resources we allocated. Resource tags is a big part
-** of what we created, but NetWare doesn't ask us to free those.
-*/
-void _NonAppStop( void )
-{
- (void) unregister_library(gLibId);
- NXMutexFree(gLibLock);
-}
-
-/*
-** This function cannot be the first in the file for if the file is linked
-** first, then the check-unload function's offset will be nlmname.nlm+0
-** which is how to tell that there isn't one. When the check function is
-** first in the linked objects, it is ambiguous. For this reason, we will
-** put it inside this file after the stop function.
-**
-** Here we check to see if it's alright to ourselves to be unloaded. If not,
-** we return a non-zero value. Right now, there isn't any reason not to allow
-** it.
-*/
-int _NonAppCheckUnload( void )
-{
- return 0;
-}
-
-int GetOrSetUpData
-(
- int id,
- libdata_t **appData,
- libthreaddata_t **threadData
-)
-{
- int err;
- libdata_t *app_data;
- libthreaddata_t *thread_data;
- NXKey_t key;
- NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
-
- err = 0;
- thread_data = (libthreaddata_t *) NULL;
-
- /*
- ** Attempt to get our data for the application calling us. This is where we
- ** store whatever application-specific information we need to carry in support
- ** of calling applications.
- */
- app_data = (libdata_t *) get_app_data(id);
-
- if (!app_data) {
- /*
- ** This application hasn't called us before; set up application AND per-thread
- ** data. Of course, just in case a thread from this same application is calling
- ** us simultaneously, we better lock our application data-creation mutex. We
- ** also need to recheck for data after we acquire the lock because WE might be
- ** that other thread that was too late to create the data and the first thread
- ** in will have created it.
- */
- NXLock(gLibLock);
-
- if (!(app_data = (libdata_t *) get_app_data(id))) {
- app_data = (libdata_t *) malloc(sizeof(libdata_t));
-
- if (app_data) {
- memset(app_data, 0, sizeof(libdata_t));
-
- app_data->tenbytes = malloc(10);
- app_data->lock = NXMutexAlloc(0, 0, &liblock);
-
- if (!app_data->tenbytes || !app_data->lock) {
- if (app_data->lock)
- NXMutexFree(app_data->lock);
-
- free(app_data);
- app_data = (libdata_t *) NULL;
- err = ENOMEM;
- }
-
- if (app_data) {
- /*
- ** Here we burn in the application data that we were trying to get by calling
- ** get_app_data(). Next time we call the first function, we'll get this data
- ** we're just now setting. We also go on here to establish the per-thread data
- ** for the calling thread, something we'll have to do on each application
- ** thread the first time it calls us.
- */
- err = set_app_data(gLibId, app_data);
-
- if (err) {
- free(app_data);
- app_data = (libdata_t *) NULL;
- err = ENOMEM;
- } else {
- /* create key for thread-specific data... */
- err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
-
- if (err) /* (no more keys left?) */
- key = -1;
-
- app_data->perthreadkey = key;
- }
- }
- }
- }
-
- NXUnlock(gLibLock);
- }
-
- if (app_data) {
- key = app_data->perthreadkey;
-
- if ( key != -1 /* couldn't create a key? no thread data */
- && !(err = NXKeyGetValue(key, (void **) &thread_data))
- && !thread_data) {
- /*
- ** Allocate the per-thread data for the calling thread. Regardless of whether
- ** there was already application data or not, this may be the first call by a
- ** a new thread. The fact that we allocation 20 bytes on a pointer is not very
- ** important, this just helps to demonstrate that we can have arbitrarily
- ** complex per-thread data.
- */
- thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
-
- if (thread_data) {
- thread_data->_errno = 0;
- thread_data->twentybytes = malloc(20);
-
- if (!thread_data->twentybytes) {
- free(thread_data);
- thread_data = (libthreaddata_t *) NULL;
- err = ENOMEM;
- }
-
- if ((err = NXKeySetValue(key, thread_data))) {
- free(thread_data->twentybytes);
- free(thread_data);
- thread_data = (libthreaddata_t *) NULL;
- }
- }
- }
- }
-
- if (appData)
- *appData = app_data;
-
- if (threadData)
- *threadData = thread_data;
-
- return err;
-}
-
-int DisposeLibraryData
-(
- void *data
-)
-{
- if (data) {
- void *tenbytes = ((libdata_t *) data)->tenbytes;
-
- if (tenbytes)
- free(tenbytes);
-
- free(data);
- }
-
- return 0;
-}
-
-void DisposeThreadData
-(
- void *data
-)
-{
- if (data) {
- void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
-
- if (twentybytes)
- free(twentybytes);
-
- free(data);
- }
-}
-
-
diff --git a/netware/tests/Makefile.netware b/netware/tests/Makefile.netware
deleted file mode 100644
index 74cc234..0000000
--- a/netware/tests/Makefile.netware
+++ /dev/null
@@ -1,285 +0,0 @@
-###################################################################
-#
-## Makefile for building libgd tests (NetWare version - gnu make)
-## Use: make -f Makefile
-##
-## Comments to: Guenter Knauf <eflash@gmx.net>
-##
-## $Id$
-#
-###################################################################
-
-# Edit the path below to point to the base of your Novell NDK.
-ifndef NDKBASE
-NDKBASE = c:/novell
-endif
-
-LIBGD = ../..
-
-ifndef INSTDIR
-INSTDIR = ../libgd-$(LIBGD_VERSION_STR)-bin-nw
-endif
-
-# Edit the vars below to change NLM target settings.
-TARGETS = gddemo.nlm gdtest.nlm gdtestft.nlm gdtopng.nlm gdcmpgif.nlm
-TARGETS += gd2time.nlm gd2togif.nlm gd2topng.nlm gd2copypal.nlm
-TARGETS += gifanimtest.nlm giftogd2.nlm pngtogd2.nlm pngtogd.nlm webpng.nlm
-TARGETS += annotate.nlm circletexttest.nlm fontsizetest.nlm fontwheeltest.nlm
-TARGETS += testac.nlm testtr.nlm
-
-DTARGET = ../libgd.nlm
-LTARGET = ../libgd.lib
-COPYR = Copyright (C) 1996-2007 Boutell.Com, Inc.
-WWW = http://www.libgd.org/
-DESCR = libgd $(LIBGD_VERSION_STR) $(subst .def,,$(notdir $@)) - $(WWW)
-MTSAFE = YES
-STACK = 64000
-#SCREEN = NONE
-#SCREEN = $(DESCR)
-# Comment the line below if you dont want to load protected automatically.
-#LDRING = 3
-
-# Comment the line below if you dont want to link the static libgd.lib.
-#LSTATIC = 1
-
-ifdef LSTATIC
-LDLIBS = $(LTARGET)
-else
-IMPORTS = @../libgd.imp
-MODULES = $(notdir $(DTARGET))
-endif
-
-# Edit the var below to point to your lib architecture.
-ifndef LIBARCH
-LIBARCH = LIBC
-endif
-
-# must be equal to DEBUG or NDEBUG
-DB = NDEBUG
-# DB = DEBUG
-# DB = CURLDEBUG
-# Optimization: -O<n> or debugging: -g
-ifeq ($(DB),NDEBUG)
- OPT = -O2
- OBJDIR = release
-else
- OPT = -g
- OBJDIR = debug
-endif
-
-# Include the version info retrieved from header.
--include $(OBJDIR)/version.inc
-
-# The following line defines your compiler.
-ifdef METROWERKS
- CC = mwccnlm
-else
- CC = gcc
-endif
-YACC = bison -y
-CP = cp -afv
-# RM = rm -f
-# if you want to mark the target as MTSAFE you will need a tool for
-# generating the xdc data for the linker; here's a minimal tool:
-# http://www.gknw.net/development/prgtools/mkxdc.zip
-MPKXDC = mkxdc
-
-# Global flags for all compilers
-CFLAGS = $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
-
-ifeq ($(CC),mwccnlm)
-LD = mwldnlm
-#LDFLAGS = -nostdlib $(PRELUDE) $(LDLIBS) $(<:.def=.o) -o $@ -commandfile
-LDFLAGS = -nostdlib $(PRELUDE) $(OBJSCR) $(LDLIBS) $(OBJDIR)/$(basename $@).o -o $@ -commandfile
-AR = mwldnlm
-ARFLAGS = -type library -w nocmdline $(OBJS) -o
-CFLAGS += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586
-CFLAGS += -relax_pointers
-#CFLAGS += -w on
-ifeq ($(LIBARCH),LIBC)
- PRELUDE = $(SDK_LIBC)/imports/libcpre.o
- CFLAGS += -align 4
-else
- PRELUDE = "$(METROWERKS)/Novell Support/libraries/runtime/prelude.obj"
-# CFLAGS += -include "$(METROWERKS)/Novell Support/headers/nlm_prefix.h"
- CFLAGS += -align 1
-endif
-else
-LD = nlmconv
-LDFLAGS = -T
-AR = ar
-ARFLAGS = -cq
-CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
-CFLAGS += -Wall -Wno-unused #-Wno-format # -pedantic
-ifeq ($(LIBARCH),LIBC)
- PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
-else
- PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o
- CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
-endif
-endif
-
-NDK_ROOT = $(NDKBASE)/ndk
-SDK_CLIB = $(NDK_ROOT)/nwsdk
-SDK_LIBC = $(NDK_ROOT)/libc
-
-ifeq ($(LIBARCH),LIBC)
- INCLUDES += -I$(SDK_LIBC)/include
- # INCLUDES += -I$(SDK_LIBC)/include/nks
- CFLAGS += -D_POSIX_SOURCE
- # CFLAGS += -D__ANSIC__
-else
- INCLUDES += -I$(SDK_CLIB)/include/nlm
- # INCLUDES += -I$(SDK_CLIB)/include
- # INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete
-endif
-CFLAGS += -I. -I.. -I$(LIBGD)
-CFLAGS += $(INCLUDES)
-
-ifeq ($(MTSAFE),YES)
- XDCOPT = -n
-endif
-ifeq ($(MTSAFE),NO)
- XDCOPT = -u
-endif
-
-ifeq ($(findstring linux,$(OSTYPE)),linux)
-DL = '
-#-include $(NDKBASE)/nlmconv/ncpfs.inc
-endif
-
-vpath %.c . .. $(LIBGD)
-
-ifdef SCREEN
-ifneq ($(SCREEN),NONE)
-OBJSCR = $(OBJDIR)/keepscreen.o
-endif
-endif
-
-.PHONY: all prebuild dist install clean
-.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.def $(OBJDIR)/%.xdc $(LTARGET) $(DTARGET)
-
-all: prebuild $(TARGETS)
-
-prebuild: $(OBJDIR) $(OBJDIR)/version.inc
-ifdef LSTATIC
- $(MAKE) -C ../ -f Makefile lib
-else
- $(MAKE) -C ../ -f Makefile nlm
-endif
-
-dist: all
- -$(RM) -r $(OBJDIR)
-
-install: $(INSTDIR) all
- @$(CP) *.nlm $(INSTDIR)
- @$(CP) ../CHANGES $(INSTDIR)
- @$(CP) ../COPYING $(INSTDIR)
- @$(CP) ../README $(INSTDIR)
- @$(CP) ../RELEASE-NOTES $(INSTDIR)
-
-clean:
- -$(RM) -r $(OBJDIR)
- -$(RM) $(TARGETS)
-
-clean-all: clean
- -$(MAKE) -C ../ -f Makefile clean
-
-%.lib: $(OBJS)
- @echo Creating $@
- @-$(RM) $@
- @$(AR) $(ARFLAGS) $@ $^
-
-%.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc $(OBJSCR) $(LDLIBS)
- @echo Linking $@
- @-$(RM) $@
- @$(LD) $(LDFLAGS) $<
-
-$(INSTDIR):
- @mkdir $(INSTDIR)
-
-$(OBJDIR):
- @mkdir $(OBJDIR)
-
-$(OBJDIR)/%.o: %.c
-# @echo Compiling $<
- $(CC) $(CFLAGS) -c $< -o $@
-
-$(OBJDIR)/version.inc: ../../configure.ac $(OBJDIR)
- @echo Creating $@
- @awk -f ../get_ver.awk $< > $@
-
-$(OBJDIR)/%.xdc: Makefile
- @echo Creating $@
- @$(MPKXDC) $(XDCOPT) $@
-
-$(OBJDIR)/%.def: Makefile
- @echo Creating $@
- @echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
- @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
- @echo $(DL)# All your changes will be lost!!$(DL) >> $@
- @echo $(DL)#$(DL) >> $@
- @echo $(DL)copyright "$(COPYR)"$(DL) >> $@
- @echo $(DL)description "$(DESCR)"$(DL) >> $@
- @echo $(DL)version $(LIBGD_VERSION)$(DL) >> $@
-ifdef NLMTYPE
- @echo $(DL)type $(NLMTYPE)$(DL) >> $@
-endif
-ifdef STACK
- @echo $(DL)stack $(STACK)$(DL) >> $@
-endif
-ifdef SCREEN
- @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
-else
- @echo $(DL)screenname "DEFAULT"$(DL) >> $@
-endif
-ifeq ($(DB),DEBUG)
- @echo $(DL)debug$(DL) >> $@
-endif
- @echo $(DL)threadname "$(subst .def,,$(notdir $@))"$(DL) >> $@
-ifdef XDCOPT
- @echo $(DL)xdcdata $(@:.def=.xdc)$(DL) >> $@
-endif
-ifeq ($(LDRING),0)
- @echo $(DL)flag_on 16$(DL) >> $@
-endif
-ifeq ($(LDRING),3)
- @echo $(DL)flag_on 512$(DL) >> $@
-endif
- @echo $(DL)flag_on 64$(DL) >> $@
-ifeq ($(LIBARCH),CLIB)
- @echo $(DL)start _Prelude$(DL) >> $@
- @echo $(DL)exit _Stop$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
- @echo $(DL)module clib$(DL) >> $@
-else
- @echo $(DL)pseudopreemption$(DL) >> $@
- @echo $(DL)start _LibCPrelude$(DL) >> $@
- @echo $(DL)exit _LibCPostlude$(DL) >> $@
- @echo $(DL)check _LibCCheckUnload$(DL) >> $@
- @echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@
- @echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@
- @echo $(DL)module libc$(DL) >> $@
-endif
-ifdef MODULES
- @echo $(DL)module $(MODULES)$(DL) >> $@
-endif
-ifdef EXPORTS
- @echo $(DL)export $(EXPORTS)$(DL) >> $@
-endif
-ifdef IMPORTS
- @echo $(DL)import $(IMPORTS)$(DL) >> $@
-endif
-ifeq ($(LD),nlmconv)
- @echo $(DL)input $(PRELUDE)$(DL) >> $@
- @echo $(DL)input $(OBJSCR)$(DL) >> $@
- @echo $(DL)input $(@:.def=.o)$(DL) >> $@
-ifdef LSTATIC
- @echo $(DL)input $(LTARGET)$(DL) >> $@
-endif
- @echo $(DL)output $(notdir $(@:.def=.nlm))$(DL) >> $@
-endif
-
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 08fd699..eb8d519 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,8 +1,8 @@
-
SET (LIBGD_SRC_FILES
bmp.h
gd.c
gd.h
+ gd_avif.c
gd_bmp.c
gd_color.c
gd_color.h
@@ -16,6 +16,7 @@ SET (LIBGD_SRC_FILES
gd_gd2.c
gd_gif_in.c
gd_gif_out.c
+ gd_heif.c
gd_intern.h
gd_interpolation.c
gd_io.c
@@ -69,17 +70,22 @@ SET (LIBGD_SRC_FILES
wbmp.h
)
-if(MSVC AND MSVC_VERSION LESS 1900)
- set(LIBGD_SRC_FILES ${LIBGD_SRC_FILES}
- snprintf.c
+# Static library just for utility programs.
+SET (GD_PROGRAMS_LIB_SRC_FILES)
+
+if(MSVC)
+ set(GD_PROGRAMS_LIB_SRC_FILES ${GD_PROGRAMS_LIB_SRC_FILES}
+ getopt.c
)
-endif(MSVC AND MSVC_VERSION LESS 1900)
+endif(MSVC)
include(GNUInstallDirs)
if (BUILD_SHARED_LIBS)
add_library(${GD_LIB} ${LIBGD_SRC_FILES})
set_target_properties(${GD_LIB} PROPERTIES
+ SOVERSION ${GDLIB_LIB_SOVERSION}
+ VERSION ${GDLIB_LIB_VERSION}
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
)
@@ -92,14 +98,24 @@ if (BUILD_STATIC_LIBS)
endif()
endif()
+if (NOT "${GD_PROGRAMS_LIB_SRC_FILES}" STREQUAL "")
+ add_library(gd_programs_lib STATIC ${GD_PROGRAMS_LIB_SRC_FILES})
+endif()
+
if (WIN32 AND NOT MINGW AND NOT MSYS)
# SET_TARGET_PROPERTIES(${GD_LIB} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:msvcrt.lib")
- SET_PROPERTY(TARGET ${GD_LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS NONDLL=1)
+
+ if (BUILD_STATIC_LIBS)
+ SET_PROPERTY(TARGET ${GD_LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS NONDLL=1)
+ endif()
+
ENDIF(WIN32 AND NOT MINGW AND NOT MSYS)
if (MINGW OR MSYS)
ADD_DEFINITIONS("-mms-bitfields")
- set_target_properties(${GD_LIB_STATIC} PROPERTIES OUTPUT_NAME ${GD_LIB})
+ if (BUILD_STATIC_LIBS)
+ set_target_properties(${GD_LIB_STATIC} PROPERTIES OUTPUT_NAME ${GD_LIB})
+ endif()
endif (MINGW OR MSYS)
INCLUDE_DIRECTORIES(BEFORE "${PROJECT_BINARY_DIR}" "${CMAKE_BINARY_DIR}" "${GD_SOURCE_DIR}/src")
@@ -115,6 +131,9 @@ SET(LIBGD_DEP_LIBS
${XPM_LIBRARIES}
${FONTCONFIG_LIBRARY}
${WEBP_LIBRARIES}
+ ${AVIF_LIBRARIES}
+ ${RAQM_LIBRARIES}
+ ${HEIF_LIBRARIES}
)
if (BUILD_SHARED_LIBS)
target_link_libraries(${GD_LIB} ${LIBGD_DEP_LIBS})
@@ -123,6 +142,12 @@ if (BUILD_STATIC_LIBS)
target_link_libraries(${GD_LIB_STATIC} ${LIBGD_DEP_LIBS})
endif()
+SET(LIBS_PRIVATES
+ ${ICONV_LIBRARIES}
+ ${LIQ_LIBRARIES}
+ ${WEBP_LIBRARIES}
+)
+
set(GD_PROGRAMS gdcmpgif)
if (PNG_FOUND)
@@ -132,7 +157,7 @@ if (PNG_FOUND)
endif()
endif()
-if (FREETYPE_FOUND)
+if (FREETYPE_FOUND AND JPEG_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} annotate)
endif()
@@ -147,6 +172,9 @@ foreach(program ${GD_PROGRAMS})
else()
target_link_libraries(${program} ${GD_LIB_STATIC})
endif()
+ if (NOT "${GD_PROGRAMS_LIB_SRC_FILES}" STREQUAL "")
+ target_link_libraries(${program} gd_programs_lib)
+ endif()
endforeach(program)
set(GD_INSTALL_TARGETS ${GD_PROGRAMS})
@@ -163,7 +191,6 @@ install(TARGETS ${GD_INSTALL_TARGETS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(PROGRAMS bdftogd DESTINATION bin)
install(FILES
- entities.h
gd.h
gd_color_map.h
gd_errors.h
@@ -177,3 +204,6 @@ install(FILES
gdfx.h
gdpp.h
DESTINATION include)
+
+CONFIGURE_FILE(../config/gdlib.pc.cmake gdlib.pc @ONLY)
+INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/gdlib.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
diff --git a/src/COPYING b/src/COPYING
deleted file mode 100644
index 90ef1c8..0000000
--- a/src/COPYING
+++ /dev/null
@@ -1,53 +0,0 @@
-
- Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002 by Cold Spring Harbor Laboratory. Funded under Grant
- P41-RR02188 by the National Institutes of Health.
-
- Portions copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 by
- Boutell.Com, Inc.
-
- Portions relating to GD2 format copyright 1999, 2000, 2001, 2002
- Philip Warner.
-
- Portions relating to PNG copyright 1999, 2000, 2001, 2002 Greg
- Roelofs.
-
- Portions relating to gdttf.c copyright 1999, 2000, 2001, 2002 John
- Ellson (ellson@lucent.com).
-
- Portions relating to gdft.c copyright 2001, 2002 John Ellson
- (ellson@lucent.com).
-
- Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
- 2008 Pierre-Alain Joye (pierre@libgd.org).
-
- Portions relating to JPEG and to color quantization copyright 2000,
- 2001, 2002, Doug Becker and copyright (C) 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, Thomas G. Lane. This software is
- based in part on the work of the Independent JPEG Group. See the
- file README-JPEG.TXT for more information.
-
- Portions relating to WBMP copyright 2000, 2001, 2002 Maurice
- Szmurlo and Johan Van den Brande.
-
- Permission has been granted to copy, distribute and modify gd in
- any context without fee, including a commercial application,
- provided that this notice is present in user-accessible supporting
- documentation.
-
- This does not affect your ownership of the derived work itself, and
- the intent is to assure proper credit for the authors of gd, not to
- interfere with your productive use of gd. If you have questions,
- ask. "Derived works" includes all programs that utilize the
- library. Credit must be given in user-accessible documentation.
-
- This software is provided "AS IS." The copyright holders disclaim
- all warranties, either express or implied, including but not
- limited to implied warranties of merchantability and fitness for a
- particular purpose, with respect to this code and accompanying
- documentation.
-
- Although their code does not appear in gd, the authors wish to thank
- David Koblas, David Rowley, and Hutchison Avenue Software Corporation
- for their prior contributions.
-
diff --git a/src/Makefile.am b/src/Makefile.am
index 93e8838..076aabd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,9 @@ check_PROGRAMS += fontconfigtest
endif
if HAVE_LIBFREETYPE
+if HAVE_LIBJPEG
bin_PROGRAMS += annotate
+endif
check_PROGRAMS += gdtestft testtr
endif
@@ -37,16 +39,29 @@ if HAVE_LIBZ
check_PROGRAMS += gd2time
endif
-EXTRA_DIST = bdftogd demoin.png entities.html entities.tcl CMakeLists.txt config.h.cmake gd_io_stream.cxx gdpp.cxx msinttypes/inttypes.h msinttypes/stdint.h
-
-include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h entities.h gd_color_map.h gd_errors.h gdpp.h
+EXTRA_DIST = \
+ bdftogd \
+ demoin.png \
+ entities.html \
+ entities.tcl \
+ CMakeLists.txt \
+ config.h.cmake \
+ gd_io_stream.cxx \
+ gdpp.cxx \
+ getopt.c \
+ msinttypes/inttypes.h \
+ msinttypes/stdint.h
+
+include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h gd_color_map.h gd_errors.h gdpp.h
lib_LTLIBRARIES = libgd.la
libgd_la_SOURCES = \
bmp.h \
+ entities.h \
gd.c \
gd.h \
+ gd_avif.c \
gd_bmp.c \
gd_color.c \
gd_color.h \
@@ -60,6 +75,7 @@ libgd_la_SOURCES = \
gd_gd2.c \
gd_gif_in.c \
gd_gif_out.c \
+ gd_heif.c \
gd_intern.h \
gd_interpolation.c \
gd_io.c \
@@ -114,4 +130,3 @@ libgd_la_LDFLAGS = -version-info $(GDLIB_LT_CURRENT):$(GDLIB_LT_REVISION):$(GDLI
libgd_la_LIBADD = $(LTLIBICONV)
LDADD = libgd.la $(LIBICONV)
-
diff --git a/src/annotate.c b/src/annotate.c
index 00aaf49..35724b0 100644
--- a/src/annotate.c
+++ b/src/annotate.c
@@ -16,38 +16,28 @@ enum { left, center, right };
int main(int argc, char *argv[])
{
-#ifndef HAVE_LIBFREETYPE
- (void)argc;
- (void)argv;
-
- /* 2.0.12 */
- fprintf(stderr, "annotate is not useful without freetype.\n"
- "Install freetype, then './configure; make clean; make install'\n"
- "the gd library again.\n"
- );
- return 1;
-#else
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
- char s[1024];
+ char *s;
+ size_t len;
int bounds[8];
int lines = 1;
int color = gdTrueColor(0, 0, 0);
- char font[1024];
+ char *font;
int size = 12;
int align = left;
int x = 0, y = 0;
char *fontError;
- strcpy(font, "times");
+ font = strdup("times");
if(argc != 3) {
fprintf(stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
fprintf(stderr, "Standard input should consist of\n");
fprintf(stderr, "lines in the following formats:\n");
fprintf(stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
- fprintf(stderr, "font fontname (max name length 1024)\n");
+ fprintf(stderr, "font fontname\n");
fprintf(stderr, "size pointsize\n");
fprintf(stderr, "align (left|right|center)\n");
fprintf(stderr, "move x y\n");
@@ -70,12 +60,7 @@ int main(int argc, char *argv[])
exit(2);
}
-#ifdef HAVE_LIBJPEG
im = gdImageCreateFromJpeg(in);
-#else
- fprintf(stderr, "No JPEG library support available.\n");
- exit(1);
-#endif
fclose(in);
@@ -84,7 +69,9 @@ int main(int argc, char *argv[])
exit(3);
}
- while(fgets(s, sizeof(s), stdin)) {
+ s = NULL;
+ len = 0;
+ while (getline(&s, &len, stdin) != -1) {
char *st;
char *text;
@@ -99,12 +86,12 @@ int main(int argc, char *argv[])
if(!st) {
goto badLine;
} else {
- const unsigned int font_len = strlen(st);
- if (font_len >= 1024) {
- fprintf(stderr, "Font maximum length is 1024, %d given\n", font_len);
+ free(font);
+ font = strdup(st);
+ if (font == NULL) {
+ perror("Font failed");
goto badLine;
}
- strncpy(font, st, font_len);
}
} else if(!strcmp(st, "align")) {
char *st = strtok(0, " \t\r\n");
@@ -178,7 +165,7 @@ int main(int argc, char *argv[])
fontError = gdImageStringFT(im, 0, color, font, size, 0, rx, y, text);
if(fontError) {
- fprintf(stderr, "font error at line %d: %s\n", lines, fontError);
+ fprintf(stderr, "Font error at line %d: %s\n", lines, fontError);
exit(7);
}
@@ -194,19 +181,16 @@ badLine:
fprintf(stderr, "Bad syntax, line %d\n", lines);
exit(4);
}
+ free(font);
+ free(s);
out = fopen(iout, "wb");
if(!out) {
fprintf(stderr, "Cannot create %s\n", iout);
exit(5);
}
-#ifdef HAVE_LIBJPEG
gdImageJpeg(im, out, 95);
-#else
- fprintf(stderr, "No JPEG library support available.\n");
-#endif
gdImageDestroy(im);
fclose(out);
return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/src/bdftogd b/src/bdftogd
index 66ffcc9..a950003 100755
--- a/src/bdftogd
+++ b/src/bdftogd
@@ -46,18 +46,18 @@ while (<>)
my ($tag, $value) = split / /, $_, 2;
die "Font is not fixed width\n"
if $tag eq 'SPACING' and not $value =~ /[CM]/i;
-
+
$currentchar = $value if $tag eq 'ENCODING';
$minchar = $currentchar if not defined $minchar
or $currentchar < $minchar;
$maxchar = $currentchar if not defined $maxchar
or $currentchar > $maxchar;
-
+
if ($tag eq 'ENDCHAR')
{
$gobitmap = 0;
my $bottom = $globaltop - $bottom[$currentchar];
-
+
if ($bottom > 0)
{ $data[$currentchar] = substr $data[$currentchar], 0, length($data[$currentchar]) - $bottom * $width; }
@@ -80,7 +80,7 @@ while (<>)
{ $fontdef = $value; }
if ($tag eq 'COPYRIGHT' and not defined $copyright)
{ $copyright = $value; }
-
+
if ($tag eq 'BBX')
{
my ($tag, $wid, $hei, $left, $bottom) = split / /;
@@ -100,7 +100,7 @@ while (<>)
$bits = substr $bits, 0, $width;
$data[$currentchar] .= $bits;
}
-
+
if ($tag eq 'BITMAP')
{
$gobitmap = 1;
@@ -150,7 +150,7 @@ for (my $i = $minchar; $i <= $maxchar; $i++)
{
$data[$i] = '' unless defined $data[$i];
$data[$i] = '0' x ($width * $height - length $data[$i]) . $data[$i];
-
+
print FILEC "/* Char $i */\n";
for my $line (0 .. $height - 1)
{ print FILEC join ',', split(//, substr($data[$i], $line * $width, $width)), "\n"; }
@@ -158,7 +158,7 @@ for (my $i = $minchar; $i <= $maxchar; $i++)
print FILEC "\n";
next;
-
+
for my $line (0 .. $height - 1)
{ print substr($data[$i], $line * $width, $width), "\n"; }
}
@@ -202,4 +202,3 @@ extern gdFontPtr $gdname;
EOF
1;
-
diff --git a/src/bmp.h b/src/bmp.h
index cecde03..5644fab 100644
--- a/src/bmp.h
+++ b/src/bmp.h
@@ -1,4 +1,6 @@
-/* $Id$ */
+#ifndef BMP_H
+#define BMP_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -19,9 +21,6 @@ extern "C" {
----------------------------------------------------------------------------
*/
-#ifndef BMP_H
-#define BMP_H 1
-
#define BMP_PALETTE_3 1
#define BMP_PALETTE_4 2
@@ -105,8 +104,8 @@ extern "C" {
} bmp_info_t;
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/src/circletexttest.c b/src/circletexttest.c
index 0f20a34..5345151 100644
--- a/src/circletexttest.c
+++ b/src/circletexttest.c
@@ -8,10 +8,6 @@
int main(void)
{
/* 2.0.22: can't depend on PNG either */
-#ifndef HAVE_LIBPNG
- fprintf(stderr, "Requires PNG support, gd was compiled without it\n");
- return 0;
-#else
char *error;
#ifdef HAVE_LIBJPEG
FILE *in = 0;
@@ -64,6 +60,5 @@ int main(void)
gdImagePng(im, out);
fclose(out);
gdImageDestroy(im);
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/src/config.h.cmake b/src/config.h.cmake
index d9c257a..2b46a17 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -3,15 +3,15 @@
/* Define is you are building for Win32 API */
#cmakedefine BGDWIN32
+/* Whether to support gd image formats */
+#cmakedefine01 ENABLE_GD_FORMATS
+
/* Define to 1 if you have the <dirent.h> header file. */
#cmakedefine HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H
-/* Define to 1 if you have the <errno.h> header file. */
-#cmakedefine HAVE_ERRNO_H
-
/* Define if you have the ft2build.h header. */
#cmakedefine HAVE_FT2BUILD_H
@@ -27,12 +27,18 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H
+/* Define if you have avif */
+#cmakedefine HAVE_LIBAVIF
+
/* Define if you have fontconfig */
#cmakedefine HAVE_LIBFONTCONFIG
/* Define if you have freetype */
#cmakedefine HAVE_LIBFREETYPE
+/* Define if you have heif */
+#cmakedefine HAVE_LIBHEIF
+
/* Define if you have liq */
#cmakedefine HAVE_LIBIMAGEQUANT
@@ -45,6 +51,9 @@
/* Define if you have png */
#cmakedefine HAVE_LIBPNG
+/* Define if you have raqm */
+#cmakedefine HAVE_LIBRAQM
+
/* Define if you have tiff */
#cmakedefine HAVE_LIBTIFF
@@ -57,9 +66,6 @@
/* Define if you have zlib */
#cmakedefine HAVE_LIBZ
-/* Define to 1 if you have the <limits.h> header file. */
-#cmakedefine HAVE_LIMITS_H
-
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
@@ -72,9 +78,6 @@
/* Have PTHREAD_PRIO_INHERIT. */
#cmakedefine HAVE_PTHREAD_PRIO_INHERIT
-/* Define to 1 if you have the <stddef.h> header file. */
-#cmakedefine HAVE_STDDEF_H
-
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H
@@ -103,8 +106,7 @@
/* Define as const if the declaration of iconv() needs const. */
#cmakedefine ICONV_CONST
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#cmakedefine LT_OBJDIR
/* Name of package */
diff --git a/src/entities.html b/src/entities.html
index 5c5d7b6..f3e9909 100644
--- a/src/entities.html
+++ b/src/entities.html
@@ -11,7 +11,7 @@
<body>
<div class="navbar" align="center">&nbsp;<a href="http://www.w3.org/TR/REC-html40/sgml/framesetdtd.html">
previous</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/appendix/changes.html">next</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/cover.html#minitoc">contents</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/elements.html">
-elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a>
+elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a>
<hr></div>
@@ -26,7 +26,7 @@ references in HTML 4</a></h1>
references</a></li>
<li><a class="tocxref" href="#h-24.2">Character entity references for ISO
-8859-1 characters</a>
+8859-1 characters</a>
<ol>
<li><a class="tocxref" href="#h-24.2.1">The list of characters</a></li>
@@ -34,7 +34,7 @@ references</a></li>
</li>
<li><a class="tocxref" href="#h-24.3">Character entity references for symbols,
-mathematical symbols, and Greek letters</a>
+mathematical symbols, and Greek letters</a>
<ol>
<li><a class="tocxref" href="#h-24.3.1">The list of characters</a></li>
@@ -42,7 +42,7 @@ mathematical symbols, and Greek letters</a>
</li>
<li><a class="tocxref" href="#h-24.4">Character entity references for
-markup-significant and internationalization characters</a>
+markup-significant and internationalization characters</a>
<ol>
<li><a class="tocxref" href="#h-24.4.1">The list of characters</a></li>
@@ -55,7 +55,7 @@ markup-significant and internationalization characters</a>
A <a href="http://www.w3.org/TR/REC-html40/charset.html#entities">character entity reference</a> is an SGML
construct that references a character of the <a href="http://www.w3.org/TR/REC-html40/charset.html">document
-character set.</a>
+character set.</a>
<p>This version of HTML supports several sets of character entity
references:</p>
@@ -345,7 +345,7 @@ occasional Greek letters used in technical and mathematical works.</em></p>
existing ISO 8879 entity names. ISO 10646 character numbers
are given for each character, in hex. CDATA values are decimal
conversions of the ISO 10646 values and refer to the document
- character set. Names are ISO 10646 names.
+ character set. Names are ISO 10646 names.
--&gt;
@@ -472,7 +472,7 @@ occasional Greek letters used in technical and mathematical works.</em></p>
&lt;!ENTITY uArr CDATA "&amp;#8657;" -- upwards double arrow, U+21D1 ISOamsa --&gt;
&lt;!ENTITY rArr CDATA "&amp;#8658;" -- rightwards double arrow,
U+21D2 ISOtech --&gt;
-&lt;!-- ISO 10646 does not say this is the 'implies' character but does not have
+&lt;!-- ISO 10646 does not say this is the 'implies' character but does not have
another character with this function so ?
rArr can be used for 'implies' as ISOtech suggests --&gt;
&lt;!ENTITY dArr CDATA "&amp;#8659;" -- downwards double arrow, U+21D3 ISOamsa --&gt;
@@ -525,9 +525,9 @@ occasional Greek letters used in technical and mathematical works.</em></p>
U+2265 ISOtech --&gt;
&lt;!ENTITY sub CDATA "&amp;#8834;" -- subset of, U+2282 ISOtech --&gt;
&lt;!ENTITY sup CDATA "&amp;#8835;" -- superset of, U+2283 ISOtech --&gt;
-&lt;!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
+&lt;!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
font encoding and is not included. Should it be, for symmetry?
- It is in ISOamsn --&gt;
+ It is in ISOamsn --&gt;
&lt;!ENTITY nsub CDATA "&amp;#8836;" -- not a subset of, U+2284 ISOamsn --&gt;
&lt;!ENTITY sube CDATA "&amp;#8838;" -- subset of or equal to, U+2286 ISOtech --&gt;
&lt;!ENTITY supe CDATA "&amp;#8839;" -- superset of or equal to,
@@ -550,11 +550,11 @@ occasional Greek letters used in technical and mathematical works.</em></p>
&lt;!ENTITY rfloor CDATA "&amp;#8971;" -- right floor, U+230B ISOamsc --&gt;
&lt;!ENTITY lang CDATA "&amp;#9001;" -- left-pointing angle bracket = bra,
U+2329 ISOtech --&gt;
-&lt;!-- lang is NOT the same character as U+003C 'less than'
+&lt;!-- lang is NOT the same character as U+003C 'less than'
or U+2039 'single left-pointing angle quotation mark' --&gt;
&lt;!ENTITY rang CDATA "&amp;#9002;" -- right-pointing angle bracket = ket,
U+232A ISOtech --&gt;
-&lt;!-- rang is NOT the same character as U+003E 'greater than'
+&lt;!-- rang is NOT the same character as U+003E 'greater than'
or U+203A 'single right-pointing angle quotation mark' --&gt;
&lt;!-- Geometric Shapes --&gt;
@@ -614,7 +614,7 @@ that contains the requisite glyphs.</p>
existing ISO 8879 entity names. ISO 10646 character numbers
are given for each character, in hex. CDATA values are decimal
conversions of the ISO 10646 values and refer to the document
- character set. Names are ISO 10646 names.
+ character set. Names are ISO 10646 names.
--&gt;
@@ -679,4 +679,4 @@ that contains the requisite glyphs.</p>
<div class="navbar" align="center">
<hr><a href="http://www.w3.org/TR/REC-html40/sgml/framesetdtd.html">previous</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/appendix/changes.html">next</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/cover.html#minitoc">
contents</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/elements.html">elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a></div>
-</body></html> \ No newline at end of file
+</body></html>
diff --git a/src/fontconfigtest.c b/src/fontconfigtest.c
index 47c4849..eda5c95 100644
--- a/src/fontconfigtest.c
+++ b/src/fontconfigtest.c
@@ -9,7 +9,6 @@ int main (int argc, char *argv[])
gdImagePtr im;
int green, blue;
gdFTStringExtra se;
- FILE *out;
im = gdImageCreateTrueColor(300, 100);
green = gdImageColorAllocate(im, 128, 255, 128);
gdImageFilledRectangle(im, 0, 0, 300, 100, green);
@@ -33,7 +32,7 @@ int main (int argc, char *argv[])
gdImageStringFTEx(im, 0, blue, "arial",
12, 0, 20, 80, "plain pathname", &se);
#ifdef HAVE_LIBPNG
- out = fopen("fontconfigtest.png", "wb");
+ FILE *out = fopen("fontconfigtest.png", "wb");
gdImagePng(im, out);
fclose(out);
#else
@@ -41,4 +40,3 @@ int main (int argc, char *argv[])
#endif /* HAVE_LIBPNG */
return 0;
}
-
diff --git a/src/fontsizetest.c b/src/fontsizetest.c
index 55b9209..c32c777 100644
--- a/src/fontsizetest.c
+++ b/src/fontsizetest.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -19,29 +18,17 @@ dosizes (gdImagePtr im, int color, char *fontfile,
sprintf (buf, "%d: %s", cursize, string);
/* The case of newlines is taken care of in the gdImageStringTTF call */
-#if defined(OLDER_GD)
- cp =
- gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
- buf);
-#else
cp =
gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
buf);
-#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
/* render the same fontsize with antialiasing turned off */
-#if defined(OLDER_GD)
- cp =
- gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
- y, buf);
-#else
cp =
gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
y, buf);
-#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
diff --git a/src/fontwheeltest.c b/src/fontwheeltest.c
index b2bb258..a225810 100644
--- a/src/fontwheeltest.c
+++ b/src/fontwheeltest.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -37,13 +36,8 @@ dowheel (gdImagePtr im, int color, char *fontfile, int fontsize,
y0 = y - sin (curangrads) * offset;
/* The case of newlines is taken care of in the gdImageStringTTF call */
-#if defined(OLDER_GD)
- cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
- curangrads, x0, y0, string);
-#else
cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
curangrads, x0, y0, string);
-#endif
if (cp)
doerr (err, cp);
diff --git a/src/gd.c b/src/gd.c
index f0cfacd..aea8015 100644
--- a/src/gd.c
+++ b/src/gd.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include <stdio.h>
#include <math.h>
#include <string.h>
@@ -177,7 +175,7 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
See Also:
- <gdImageCreateTrueColor>
+ <gdImageCreateTrueColor>
*/
BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
@@ -188,6 +186,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
if (overflow2(sx, sy)) {
return NULL;
}
+
if (overflow2(sizeof (unsigned char *), sy)) {
return NULL;
}
@@ -284,7 +283,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
See Also:
- <gdImageCreateTrueColor>
+ <gdImageCreateTrueColor>
*/
BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy)
@@ -415,7 +414,7 @@ BGD_DECLARE(void) gdImageDestroy (gdImagePtr im)
/**
* Function: gdImageColorClosest
- *
+ *
* Gets the closest color of the image
*
* This is a simplified variant of <gdImageColorClosestAlpha> where the alpha
@@ -500,12 +499,6 @@ BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, i
#define HWB_UNDEFINED -1
#define SETUP_RGB(s, r, g, b) {s.R = r/255.0; s.G = g/255.0; s.B = b/255.0;}
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
-#define MAX(a,b) ((a)<(b)?(b):(a))
-#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
-
-
/*
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
* red always maps to 6 in this implementation. Therefore UNDEFINED can be
@@ -907,15 +900,13 @@ BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color)
}
if (!im->trueColor) {
- if((color < -1) || (color >= gdMaxColors)) {
+ if (color >= gdMaxColors) {
return;
}
if (im->transparent != -1) {
im->alpha[im->transparent] = gdAlphaOpaque;
}
- if (color != -1) {
- im->alpha[color] = gdAlphaTransparent;
- }
+ im->alpha[color] = gdAlphaTransparent;
}
im->transparent = color;
}
@@ -1488,7 +1479,7 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y)
/*
Function: gdImageAABlend
-
+
NO-OP, kept for library compatibility.
*/
BGD_DECLARE(void) gdImageAABlend (gdImagePtr im)
@@ -1541,7 +1532,7 @@ static void gdImageVLine(gdImagePtr im, int x, int y1, int y2, int col)
/*
Function: gdImageLine
-
+
Bresenham as presented in Foley & Van Dam.
*/
BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
@@ -1586,7 +1577,7 @@ BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, in
if (dy <= dx) {
/* More-or-less horizontal. use wid for vertical stroke */
/* Doug Claar: watch out for NaN in atan2 (2.0.5) */
-
+
/* 2.0.12: Michael Schwartz: divide rather than multiply;
TBB: but watch out for /0! */
double ac = cos (atan2 (dy, dx));
@@ -1887,6 +1878,8 @@ BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
int cx, cy;
int px, py;
int fline;
+ const int xuppper = (x > INT_MAX - f->w) ? INT_MAX : x + f->w;
+ const int yuppper = (y > INT_MAX - f->h) ? INT_MAX : y + f->h;
cx = 0;
cy = 0;
#ifdef CHARSET_EBCDIC
@@ -1896,8 +1889,8 @@ BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
return;
}
fline = (c - f->offset) * f->h * f->w;
- for (py = y; (py < (y + f->h)); py++) {
- for (px = x; (px < (x + f->w)); px++) {
+ for (py = y; py < yuppper; py++) {
+ for (px = x; px < xuppper; px++) {
if (f->data[fline + cy * f->w + cx]) {
gdImageSetPixel (im, px, py, color);
}
@@ -1916,6 +1909,8 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c
int cx, cy;
int px, py;
int fline;
+ const int xuppper = (x > INT_MAX - f->h) ? INT_MAX : x + f->h;
+ const int ylower = (y < INT_MIN + f->w) ? INT_MIN : y - f->w;
cx = 0;
cy = 0;
#ifdef CHARSET_EBCDIC
@@ -1925,8 +1920,8 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c
return;
}
fline = (c - f->offset) * f->h * f->w;
- for (py = y; (py > (y - f->w)); py--) {
- for (px = x; (px < (x + f->h)); px++) {
+ for (py = y; py > ylower; py--) {
+ for (px = x; px < xuppper; px++) {
if (f->data[fline + cy * f->w + cx]) {
gdImageSetPixel (im, px, py, color);
}
@@ -1939,7 +1934,7 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c
/**
* Function: gdImageString
- *
+ *
* Draws a character string.
*
* Parameters:
@@ -2065,6 +2060,7 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
int i, pti;
int lx = 0, ly = 0;
int fx = 0, fy = 0;
+ int startx = -1, starty = -1, endx = -1, endy = -1;
if ((s % 360) == (e % 360)) {
s = 0;
@@ -2094,8 +2090,8 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
for (i = s, pti = 1; (i <= e); i++, pti++) {
int x, y;
- x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
- y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
+ x = endx = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
+ y = endy = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
if (i != s) {
if (!(style & gdChord)) {
if (style & gdNoFill) {
@@ -2121,8 +2117,8 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
if (!(style & (gdChord | gdNoFill))) {
pts[0].x = cx;
pts[0].y = cy;
- pts[pti].x = x;
- pts[pti].y = y;
+ pts[pti].x = startx = x;
+ pts[pti].y = starty = y;
}
}
lx = x;
@@ -2151,6 +2147,24 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
gdImageLine (im, cx, cy, fx, fy, color);
}
} else {
+ if (e - s < 360) {
+ if (pts[1].x != startx && pts[1].y == starty) {
+ /* start point has been removed due to y-coord fix => insert it */
+ for (i = pti; i > 1; i--) {
+ pts[i].x = pts[i-1].x;
+ pts[i].y = pts[i-1].y;
+ }
+ pts[1].x = startx;
+ pts[1].y = starty;
+ pti++;
+ }
+ if (pts[pti-1].x != endx && pts[pti-1].y == endy) {
+ /* end point has been removed due to y-coord fix => insert it */
+ pts[pti].x = endx;
+ pts[pti].y = endy;
+ pti++;
+ }
+ }
pts[pti].x = cx;
pts[pti].y = cy;
gdImageFilledPolygon(im, pts, pti+1, color);
@@ -2164,7 +2178,7 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h,
BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
{
int x=0,mx1=0,mx2=0,my1=0,my2=0;
- long aq,bq,dx,dy,r,rx,ry,a,b;
+ int64_t aq,bq,dx,dy,r,rx,ry,a,b;
a=w>>1;
b=h>>1;
@@ -2211,7 +2225,7 @@ BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, in
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
{
int x=0,mx1=0,mx2=0,my1=0,my2=0;
- long aq,bq,dx,dy,r,rx,ry,a,b;
+ int64_t aq,bq,dx,dy,r,rx,ry,a,b;
int i;
int old_y2;
@@ -2278,7 +2292,7 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
}
if (!im->trueColor) {
- if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1)) || (color < 0)) {
+ if (color > (im->colorsTotal - 1) || border > (im->colorsTotal - 1)) {
return;
}
}
@@ -2298,7 +2312,7 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
} else if (y < 0) {
y = 0;
}
-
+
for (i = x; (i >= 0); i--) {
if (gdImageGetPixel (im, i, y) == border) {
break;
@@ -2849,14 +2863,6 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
}
}
- if (src->styleLength > 0) {
- dst->styleLength = src->styleLength;
- dst->stylePos = src->stylePos;
- for (i = 0; i < src->styleLength; i++) {
- dst->style[i] = src->style[i];
- }
- }
-
dst->interlace = src->interlace;
dst->alphaBlendingFlag = src->alphaBlendingFlag;
@@ -2891,6 +2897,7 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
if (src->style) {
gdImageSetStyle(dst, src->style, src->styleLength);
+ dst->stylePos = src->stylePos;
}
for (i = 0; i < gdMaxColors; i++) {
@@ -3093,7 +3100,7 @@ BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, in
* Note:
* This function is a substitute for real alpha channel operations,
* so it doesn't pay attention to the alpha channel.
- *
+ *
* Parameters:
* dst - The destination image.
* src - The source image.
@@ -3174,7 +3181,7 @@ BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX
*
* If the source and destination area differ in size, the area will be resized
* using nearest-neighbor interpolation.
- *
+ *
* Parameters:
* dst - The destination image.
* src - The source image.
@@ -3431,7 +3438,7 @@ BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,
* If the source and destination area differ in size, the area will be resized
* using bilinear interpolation for truecolor images, and nearest-neighbor
* interpolation for palette images.
- *
+ *
* Parameters:
* dst - The destination image.
* src - The source image.
@@ -4339,8 +4346,8 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co
/* keep them as 32bits */
long x, y, inc, frac;
long dx, dy,tmp;
- int w, wid, wstart;
- int thick = im->thick;
+ int w, wid, wstart;
+ int thick = im->thick;
if (!im->trueColor) {
/* TBB: don't crash when the image is of the wrong type */
diff --git a/src/gd.h b/src/gd.h
index fa68508..9279407 100644
--- a/src/gd.h
+++ b/src/gd.h
@@ -1,18 +1,18 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef GD_H
+#define GD_H 1
#include <stdlib.h>
-#ifndef GD_H
-#define GD_H 1
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Version information. This gets parsed by build scripts as well as
* gcc so each #define line in this group must also be splittable on
* whitespace, take the form GD_*_VERSION and contain the magical
* trailing comment. */
#define GD_MAJOR_VERSION 2 /*version605b5d1778*/
-#define GD_MINOR_VERSION 3 /*version605b5d1778*/
+#define GD_MINOR_VERSION 4 /*version605b5d1778*/
#define GD_RELEASE_VERSION 0 /*version605b5d1778*/
#define GD_EXTRA_VERSION "-dev" /*version605b5d1778*/
/* End parsable section. */
@@ -29,7 +29,7 @@ extern "C" {
GDXXX_STR(GD_RELEASE_VERSION), \
GD_EXTRA_VERSION)
-
+
/* Do the DLL dance: dllexport when building the DLL,
dllimport when importing from it, nothing when
not on Silly Silly Windows (tm Aardman Productions). */
@@ -51,14 +51,14 @@ extern "C" {
# define BGD_EXPORT_DATA_PROT
# else
# ifdef __GNUC__
-# define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport))
+# define BGD_EXPORT_DATA_PROT __attribute__ ((__dllexport__))
# else
# define BGD_EXPORT_DATA_PROT __declspec(dllexport)
# endif
# endif
# else
# ifdef __GNUC__
-# define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport))
+# define BGD_EXPORT_DATA_PROT __attribute__ ((__dllimport__))
# else
# define BGD_EXPORT_DATA_PROT __declspec(dllimport)
# endif
@@ -67,8 +67,8 @@ extern "C" {
# define BGD_EXPORT_DATA_IMPL
#else
# if defined(__GNUC__) || defined(__clang__)
-# define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default")))
-# define BGD_EXPORT_DATA_IMPL __attribute__ ((visibility ("hidden")))
+# define BGD_EXPORT_DATA_PROT __attribute__ ((__visibility__ ("default")))
+# define BGD_EXPORT_DATA_IMPL __attribute__ ((__visibility__ ("hidden")))
# else
# define BGD_EXPORT_DATA_PROT
# define BGD_EXPORT_DATA_IMPL
@@ -79,24 +79,16 @@ extern "C" {
#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL
/* VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set
- We define inline, snprintf, and strcasecmp if they're missing
+ We define inline, and strcasecmp if they're missing
*/
#ifdef _MSC_VER
# define _ALLOW_KEYWORD_MACROS
# ifndef inline
# define inline __inline
-# endif
+# endif
# ifndef strcasecmp
# define strcasecmp _stricmp
-# endif
-#if _MSC_VER < 1900
- extern int snprintf(char*, size_t, const char*, ...);
-#endif
-#endif
-
-#ifdef __cplusplus
- extern "C"
- {
+# endif
#endif
/* gd.h: declarations file for the graphic-draw module.
@@ -131,9 +123,9 @@ extern "C" {
must be 32 bits wide or more.
True colors are repsented as follows:
-
+
ARGB
-
+
Where 'A' (alpha channel) occupies only the
LOWER 7 BITS of the MSB. This very small
loss of alpha channel resolution allows gd 2.x
@@ -209,7 +201,7 @@ extern "C" {
* Group: Effects
*
* The layering effect
- *
+ *
* When pixels are drawn the new colors are "mixed" with the background
* depending on the effect.
*
@@ -286,7 +278,7 @@ enum gdPaletteQuantizationMethod {
*
* GD_BELL - Bell
* GD_BESSEL - Bessel
- * GD_BILINEAR_FIXED - fixed point bilinear
+ * GD_BILINEAR_FIXED - fixed point bilinear
* GD_BICUBIC - Bicubic
* GD_BICUBIC_FIXED - fixed point bicubic integer
* GD_BLACKMAN - Blackman
@@ -338,6 +330,46 @@ typedef enum {
GD_METHOD_COUNT = 23
} gdInterpolationMethod;
+/**
+ * Group: HEIF Coding Format
+ *
+ * Values that select the HEIF coding format.
+ *
+ * Constants: gdHeifCodec
+ *
+ * GD_HEIF_CODEC_UNKNOWN
+ * GD_HEIF_CODEC_HEVC
+ * GD_HEIF_CODEC_AV1
+ *
+ * See also:
+ * - <gdImageHeif>
+ */
+typedef enum {
+ GD_HEIF_CODEC_UNKNOWN = 0,
+ GD_HEIF_CODEC_HEVC,
+ GD_HEIF_CODEC_AV1 = 4,
+} gdHeifCodec;
+
+/**
+ * Group: HEIF Chroma Subsampling
+ *
+ * Values that select the HEIF chroma subsampling.
+ *
+ * Constants: gdHeifCompression
+ *
+ * GD_HEIF_CHROMA_420
+ * GD_HEIF_CHROMA_422
+ * GD_HEIF_CHROMA_444
+ *
+ * See also:
+ * - <gdImageHeif>
+ */
+typedef const char *gdHeifChroma;
+
+#define GD_HEIF_CHROMA_420 "420"
+#define GD_HEIF_CHROMA_422 "422"
+#define GD_HEIF_CHROMA_444 "444"
+
/* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */
/* Interpolation function ptr */
@@ -346,7 +378,7 @@ typedef double (* interpolation_method )(double);
/*
Group: Types
-
+
typedef: gdImage
typedef: gdImagePtr
@@ -513,7 +545,7 @@ gdPointF, *gdPointFPtr;
structure.
Please see the files gdfontl.c and gdfontl.h for an example of
- the proper declaration of this structure.
+ the proper declaration of this structure.
> typedef struct {
> // # of characters in font
@@ -632,6 +664,14 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile);
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data);
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeif(FILE *inFile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifPtr(int size, void *data);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifCtx(gdIOCtx *infile);
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvif(FILE *inFile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifPtr(int size, void *data);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifCtx(gdIOCtx *infile);
+
BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile);
BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile);
BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data);
@@ -710,7 +750,7 @@ BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);
alpha channel value of 'color'; default is to overwrite.
Tiling and line styling are also implemented
here. All other gd drawing functions pass through this call,
- allowing for many useful effects.
+ allowing for many useful effects.
Overlay and multiply effects are used when gdImageAlphaBlending
is passed gdEffectOverlay and gdEffectMultiply */
@@ -768,14 +808,14 @@ BGD_DECLARE(void) gdFontCacheShutdown (void);
BGD_DECLARE(void) gdFreeFontCache (void);
/* Calls gdImageStringFT. Provided for backwards compatibility only. */
-BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
+BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, const char *fontlist,
double ptsize, double angle, int x, int y,
- char *string);
+ const char *string);
/* FreeType 2 text output */
-BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
+BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
double ptsize, double angle, int x, int y,
- char *string);
+ const char *string);
/*
@@ -808,7 +848,7 @@ typedef struct {
then, on return, xshow is a malloc'ed
string containing xshow position data for
the last string.
-
+
NB. The caller is responsible for gdFree'ing
the xshow string.
*/
@@ -817,7 +857,7 @@ typedef struct {
string containing the actual font file path name
used, which can be interesting when fontconfig
is in use.
-
+
The caller is responsible for gdFree'ing the
fontpath string.
*/
@@ -857,9 +897,9 @@ BGD_DECLARE(int) gdFTUseFontConfig(int flag);
#define gdFTEX_Big5 2
#define gdFTEX_Adobe_Custom 3
-BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
+BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
double ptsize, double angle, int x, int y,
- char *string, gdFTStringExtraPtr strex);
+ const char *string, gdFTStringExtraPtr strex);
/*
@@ -883,6 +923,21 @@ typedef struct {
}
gdPoint, *gdPointPtr;
+/**
+ * Typedef: gdRect
+ *
+ * A rectangle in the coordinate space of the image
+ *
+ * Members:
+ * x - The x-coordinate of the upper left corner.
+ * y - The y-coordinate of the upper left corner.
+ * width - The width.
+ * height - The height.
+ *
+ * Typedef: gdRectPtr
+ *
+ * A pointer to a <gdRect>
+ */
typedef struct {
int x, y;
int width, height;
@@ -962,16 +1017,16 @@ BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color);
anything up to 256. If the original source image
includes photographic information or anything that
came out of a JPEG, 256 is strongly recommended.
-
+
Better yet, don't use these function -- write real
truecolor PNGs and JPEGs. The disk space gain of
conversion to palette is not great (for small images
it can be negative) and the quality loss is ugly.
-
+
DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
returns a new image. gdImageTrueColorToPalette modifies
an existing image, and the truecolor pixels are discarded.
-
+
gdImageTrueColorToPalette() returns TRUE on success, FALSE on failure.
*/
@@ -1087,10 +1142,21 @@ BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size);
BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization);
BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization);
+BGD_DECLARE(void) gdImageHeifEx(gdImagePtr im, FILE *outFile, int quality, gdHeifCodec codec, gdHeifChroma chroma);
+BGD_DECLARE(void) gdImageHeif(gdImagePtr im, FILE *outFile);
+BGD_DECLARE(void *) gdImageHeifPtr(gdImagePtr im, int *size);
+BGD_DECLARE(void *) gdImageHeifPtrEx(gdImagePtr im, int *size, int quality, gdHeifCodec codec, gdHeifChroma chroma);
+BGD_DECLARE(void) gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifCodec codec, gdHeifChroma chroma);
+
+BGD_DECLARE(void) gdImageAvif(gdImagePtr im, FILE *outFile);
+BGD_DECLARE(void) gdImageAvifEx(gdImagePtr im, FILE *outFile, int quality, int speed);
+BGD_DECLARE(void *) gdImageAvifPtr(gdImagePtr im, int *size);
+BGD_DECLARE(void *) gdImageAvifPtrEx(gdImagePtr im, int *size, int quality, int speed);
+BGD_DECLARE(void) gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed);
/**
* Group: GifAnim
- *
+ *
* Legal values for Disposal. gdDisposalNone is always used by
* the built-in optimizer if previm is passed.
*
@@ -1316,7 +1382,7 @@ BGD_DECLARE(gdImagePtr) gdImageCopyGaussianBlurred(gdImagePtr src, int radius,
* Macro: gdImageSX
*
* Gets the width (in pixels) of an image.
- *
+ *
* Parameters:
* im - The image.
*/
@@ -1526,7 +1592,8 @@ BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im);
BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im);
BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im);
-#define GD_FLIP_HORINZONTAL 1
+#define GD_FLIP_HORINZONTAL 1 /* typo, kept for BC */
+#define GD_FLIP_HORIZONTAL 1
#define GD_FLIP_VERTICAL 2
#define GD_FLIP_BOTH 3
@@ -1534,14 +1601,14 @@ BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im);
* Group: Crop
*
* Constants: gdCropMode
- * GD_CROP_DEFAULT - Default crop mode (4 corners or background)
+ * GD_CROP_DEFAULT - Same as GD_CROP_TRANSPARENT
* GD_CROP_TRANSPARENT - Crop using the transparent color
- * GD_CROP_BLACK - Crop black borders
- * GD_CROP_WHITE - Crop white borders
- * GD_CROP_SIDES - Crop using colors of the 4 corners
+ * GD_CROP_BLACK - Crop black borders
+ * GD_CROP_WHITE - Crop white borders
+ * GD_CROP_SIDES - Crop using colors of the 4 corners
*
* See also:
- * <gdImageAutoCrop>
+ * - <gdImageCropAuto>
**/
enum gdCropMode {
GD_CROP_DEFAULT = 0,
@@ -1632,16 +1699,11 @@ BGD_DECLARE(int) gdReleaseVersion(void);
BGD_DECLARE(const char *) gdExtraVersion(void);
BGD_DECLARE(const char *) gdVersionString(void);
-
-#ifdef __cplusplus
-}
-#endif
-
/* newfangled special effects */
#include "gdfx.h"
-#endif /* GD_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GD_H */
diff --git a/src/gd2copypal.c b/src/gd2copypal.c
index eaa67b5..5a46755 100644
--- a/src/gd2copypal.c
+++ b/src/gd2copypal.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/src/gd2togif.c b/src/gd2togif.c
index 5a0be19..5b15994 100644
--- a/src/gd2togif.c
+++ b/src/gd2togif.c
@@ -43,4 +43,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/src/gd2topng.c b/src/gd2topng.c
index 6c0626f..5e8ca87 100644
--- a/src/gd2topng.c
+++ b/src/gd2topng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -52,11 +51,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support available.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/src/gd_avif.c b/src/gd_avif.c
new file mode 100644
index 0000000..2090661
--- /dev/null
+++ b/src/gd_avif.c
@@ -0,0 +1,688 @@
+/**
+ * File: AVIF IO
+ *
+ * Read and write AVIF images using libavif (https://github.com/AOMediaCodec/libavif) .
+ * Currently, the only ICC profile we support is sRGB.
+ * Since that's what web browsers use, it's sufficient for now.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <math.h>
+
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdhelpers.h"
+#include "gd_intern.h"
+
+#ifdef HAVE_LIBAVIF
+#include <avif/avif.h>
+
+/*
+ Define defaults for encoding images:
+ CHROMA_SUBSAMPLING_DEFAULT: 4:2:0 is commonly used for Chroma subsampling.
+ CHROMA_SUBAMPLING_HIGH_QUALITY: Use 4:4:4, or no subsampling, when a sufficient high quality is requested.
+ SUBAMPLING_HIGH_QUALITY_THRESHOLD: At or above this value, use CHROMA_SUBAMPLING_HIGH_QUALITY
+ QUANTIZER_DEFAULT:
+ We need more testing to really know what quantizer settings are optimal,
+ but teams at Google have been using maximum=30 as a starting point.
+ QUALITY_DEFAULT: following gd conventions, -1 indicates the default.
+ SPEED_DEFAULT:
+ AVIF_SPEED_DEFAULT is simply the default encoding speed of the AV1 codec.
+ This could be as slow as 0. So we use 6, which is currently considered to be a fine default.
+
+*/
+
+#define CHROMA_SUBSAMPLING_DEFAULT AVIF_PIXEL_FORMAT_YUV420
+#define CHROMA_SUBAMPLING_HIGH_QUALITY AVIF_PIXEL_FORMAT_YUV444
+#define HIGH_QUALITY_SUBSAMPLING_THRESHOLD 90
+#define QUANTIZER_DEFAULT 30
+#define QUALITY_DEFAULT -1
+#define SPEED_DEFAULT 6
+
+// This initial size for the gdIOCtx is standard among GD image conversion functions.
+#define NEW_DYNAMIC_CTX_SIZE 2048
+
+// Our quality param ranges from 0 to 100.
+// To calculate quality, we convert from AVIF's quantizer scale, which runs from 63 to 0.
+#define MAX_QUALITY 100
+
+// These constants are for computing the number of tiles and threads to use during encoding.
+// Maximum threads are from libavif/contrib/gkd-pixbuf/loader.c.
+#define MIN_TILE_AREA (512 * 512)
+#define MAX_TILES 8
+#define MAX_THREADS 64
+
+/*** Macros ***/
+
+/*
+ From gd_png.c:
+ convert the 7-bit alpha channel to an 8-bit alpha channel.
+ We do a little bit-flipping magic, repeating the MSB
+ as the LSB, to ensure that 0 maps to 0 and
+ 127 maps to 255. We also have to invert to match
+ PNG's convention in which 255 is opaque.
+*/
+#define alpha7BitTo8Bit(alpha7Bit) \
+ (alpha7Bit == 127 ? \
+ 0 : \
+ 255 - ((alpha7Bit << 1) + (alpha7Bit >> 6)))
+
+#define alpha8BitTo7Bit(alpha8Bit) (gdAlphaMax - (alpha8Bit >> 1))
+
+
+/*** Helper functions ***/
+
+/* Convert the quality param we expose to the quantity params used by libavif.
+ The *Quantizer* params values can range from 0 to 63, with 0 = highest quality and 63 = worst.
+ We make the scale 0-100, and we reverse this, so that 0 = worst quality and 100 = highest.
+
+ Values below 0 are set to 0, and values below MAX_QUALITY are set to MAX_QUALITY.
+*/
+static int quality2Quantizer(int quality) {
+ int clampedQuality = CLAMP(quality, 0, MAX_QUALITY);
+
+ float scaleFactor = (float) AVIF_QUANTIZER_WORST_QUALITY / (float) MAX_QUALITY;
+
+ return round(scaleFactor * (MAX_QUALITY - clampedQuality));
+}
+
+/*
+ As of February 2021, this algorithm reflects the latest research on how many tiles
+ and threads to include for a given image size.
+ This is subject to change as research continues.
+
+ Returns false if there was an error, true if all was well.
+ */
+static avifBool setEncoderTilesAndThreads(avifEncoder *encoder, avifRGBImage *rgb) {
+ int imageArea, tiles, tilesLog2, encoderTiles;
+
+ // _gdImageAvifCtx(), the calling function, checks this operation for overflow
+ imageArea = rgb->width * rgb->height;
+
+ tiles = (int) ceil((double) imageArea / MIN_TILE_AREA);
+ tiles = MIN(tiles, MAX_TILES);
+ tiles = MIN(tiles, MAX_THREADS);
+
+ // The number of tiles in any dimension will always be a power of 2. We can only specify log(2)tiles.
+
+ tilesLog2 = floor(log2(tiles));
+
+ // If the image's width is greater than the height, use more tile columns
+ // than tile rows to make the tile size close to a square.
+
+ if (rgb->width >= rgb->height) {
+ encoder->tileRowsLog2 = tilesLog2 / 2;
+ encoder->tileColsLog2 = tilesLog2 - encoder->tileRowsLog2;
+ } else {
+ encoder->tileColsLog2 = tilesLog2 / 2;
+ encoder->tileRowsLog2 = tilesLog2 - encoder->tileColsLog2;
+ }
+
+ // It's good to have one thread per tile.
+ encoderTiles = (1 << encoder->tileRowsLog2) * (1 << encoder->tileColsLog2);
+ encoder->maxThreads = encoderTiles;
+
+ return AVIF_TRUE;
+}
+
+/*
+ We can handle AVIF images whose color profile is sRGB, or whose color profile isn't set.
+*/
+static avifBool isAvifSrgbImage(avifImage *avifIm) {
+ return
+ (avifIm->colorPrimaries == AVIF_COLOR_PRIMARIES_BT709 ||
+ avifIm->colorPrimaries == AVIF_COLOR_PRIMARIES_UNSPECIFIED) &&
+ (avifIm->transferCharacteristics == AVIF_TRANSFER_CHARACTERISTICS_SRGB ||
+ avifIm->transferCharacteristics == AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED)
+ ;
+}
+
+/*
+ Check the result from an Avif function to see if it's an error.
+ If so, decode the error and output it, and return true.
+ Otherwise, return false.
+*/
+static avifBool isAvifError(avifResult result, const char *msg) {
+ if (result != AVIF_RESULT_OK) {
+ gd_error("avif error - %s: %s\n", msg, avifResultToString(result));
+ return AVIF_TRUE;
+ }
+
+ return AVIF_FALSE;
+}
+
+
+/*
+ <readfromCtx> implements the avifIOReadFunc interface by calling the relevant functions
+ in the gdIOCtx. Our logic is inspired by avifIOMemoryReaderRead() and avifIOFileReaderRead().
+ We don't know whether we're reading from a file or from memory. We don't have to know,
+ since we rely on the helper functions in the gdIOCtx.
+ We assume we've stashed the gdIOCtx in io->data, as we do in createAvifIOFromCtx().
+
+ We ignore readFlags, just as the avifIO*ReaderRead() functions do.
+
+ If there's a problem, this returns an avifResult error.
+ If things go well, return AVIF_RESULT_OK.
+ Of course these AVIF codes shouldn't be returned by any top-level GD function.
+*/
+static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, size_t size, avifROData *out)
+{
+ void *dataBuf = NULL;
+ gdIOCtx *ctx = (gdIOCtx *) io->data;
+
+ // readFlags is unsupported
+ if (readFlags != 0) {
+ return AVIF_RESULT_IO_ERROR;
+ }
+
+ // TODO: if we set sizeHint, this will be more efficient.
+
+ if (offset > INT_MAX || size > INT_MAX)
+ return AVIF_RESULT_IO_ERROR;
+
+ // Try to seek offset bytes forward. If we pass the end of the buffer, throw an error.
+ if (!ctx->seek(ctx, (int) offset))
+ return AVIF_RESULT_IO_ERROR;
+
+ dataBuf = gdMalloc(size);
+ if (!dataBuf) {
+ gd_error("avif error - couldn't allocate memory");
+ return AVIF_RESULT_UNKNOWN_ERROR;
+ }
+
+ // Read the number of bytes requested.
+ // If getBuf() returns a negative value, that means there was an error.
+ int charsRead = ctx->getBuf(ctx, dataBuf, (int) size);
+ if (charsRead < 0) {
+ gdFree(dataBuf);
+ return AVIF_RESULT_IO_ERROR;
+ }
+
+ out->data = dataBuf;
+ out->size = charsRead;
+ return AVIF_RESULT_OK;
+}
+
+// avif.h says this is optional, but it seemed easy to implement.
+static void destroyAvifIO(struct avifIO *io) {
+ avifFree(io);
+}
+
+/* Set up an avifIO object.
+ The functions in the gdIOCtx struct may point either to a file or a memory buffer.
+ To us, that's immaterial.
+ Our task is simply to assign avifIO functions to the proper functions from gdIOCtx.
+ The destroy function needs to destroy the avifIO object and anything else it uses.
+
+ Returns NULL if memory for the object can't be allocated.
+*/
+
+// TODO: can we get sizeHint somehow?
+static avifIO *createAvifIOFromCtx(gdIOCtx *ctx) {
+ avifIO *io;
+
+ io = gdMalloc(sizeof(*io));
+ if (io == NULL)
+ return NULL;
+
+ // TODO: setting persistent=FALSE is safe, but it's less efficient. Is it necessary?
+ io->persistent = AVIF_FALSE;
+ io->read = readFromCtx;
+ io->write = NULL; // this function is currently unused; see avif.h
+ io->destroy = destroyAvifIO;
+ io->sizeHint = 0; // sadly, we don't get this information from the gdIOCtx.
+ io->data = ctx;
+
+ return io;
+}
+
+
+/*** Decoding functions ***/
+
+/*
+ Function: gdImageCreateFromAvif
+
+ <gdImageCreateFromAvif> is called to load truecolor images from
+ AVIF format files. Invoke <gdImageCreateFromAvif> with an
+ already opened pointer to a file containing the desired
+ image. <gdImageCreateFromAvif> returns a <gdImagePtr> to the new
+ truecolor image, or NULL if unable to load the image (most often
+ because the file is corrupt or does not contain a AVIF
+ image). <gdImageCreateFromAvif> does not close the file.
+
+ This function creates a gdIOCtx struct from the file pointer it's passed.
+ And then it relies on <gdImageCreateFromAvifCtx> to do the real decoding work.
+ If the file contains an image sequence, we simply read the first one, discarding the rest.
+
+ Variants:
+
+ <gdImageCreateFromAvifPtr> creates an image from AVIF data
+ already in memory.
+
+ <gdImageCreateFromAvifCtx> reads data from the function
+ pointers in a <gdIOCtx> structure.
+
+ Parameters:
+
+ infile - pointer to the input file
+
+ Returns:
+
+ A pointer to the new truecolor image. This will need to be
+ destroyed with <gdImageDestroy> once it is no longer needed.
+
+ On error, returns 0.
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvif(FILE *infile)
+{
+ gdImagePtr im;
+ gdIOCtx *ctx = gdNewFileCtx(infile);
+
+ if (!ctx)
+ return NULL;
+
+ im = gdImageCreateFromAvifCtx(ctx);
+ ctx->gd_free(ctx);
+
+ return im;
+}
+
+/*
+ Function: gdImageCreateFromAvifPtr
+
+ See <gdImageCreateFromAvif>.
+
+ Parameters:
+
+ size - size of Avif data in bytes.
+ data - pointer to Avif data.
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifPtr(int size, void *data)
+{
+ gdImagePtr im;
+ gdIOCtx *ctx = gdNewDynamicCtxEx(size, data, 0);
+
+ if (!ctx)
+ return 0;
+
+ im = gdImageCreateFromAvifCtx(ctx);
+ ctx->gd_free(ctx);
+
+ return im;
+}
+
+/*
+ Function: gdImageCreateFromAvifCtx
+
+ See <gdImageCreateFromAvif>.
+
+ Additional details: the AVIF library comes with functions to create an IO object from
+ a file and from a memory pointer. Of course, it doesn't have a way to create an IO object
+ from a gdIOCtx. So, here, we use our own helper function, <createAvifIOfromCtx>.
+
+ Otherwise, we create the image by calling AVIF library functions in order:
+ * avifDecoderCreate(), to create the decoder
+ * avifDecoderSetIO(), to tell libavif how to read from our data structure
+ * avifDecoderParse(), to parse the image
+ * avifDecoderNextImage(), to read the first image from the decoder
+ * avifRGBImageSetDefaults(), to create the avifRGBImage
+ * avifRGBImageAllocatePixels(), to allocate memory for the pixels
+ * avifImageYUVToRGB(), to convert YUV to RGB
+
+ Finally, we create a new gd image and copy over the pixel data.
+
+ Parameters:
+
+ ctx - a gdIOCtx struct
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifCtx (gdIOCtx *ctx)
+{
+ uint32_t x, y;
+ gdImage *im = NULL;
+ avifResult result;
+ avifIO *io;
+ avifDecoder *decoder;
+ avifRGBImage rgb;
+
+ // this lets us know that memory hasn't been allocated yet for the pixels
+ rgb.pixels = NULL;
+
+ decoder = avifDecoderCreate();
+
+ io = createAvifIOFromCtx(ctx);
+ if (!io) {
+ gd_error("avif error - Could not allocate memory");
+ goto cleanup;
+ }
+
+ avifDecoderSetIO(decoder, io);
+
+ result = avifDecoderParse(decoder);
+ if (isAvifError(result, "Could not parse image"))
+ goto cleanup;
+
+ // Note again that, for an image sequence, we read only the first image, ignoring the rest.
+ result = avifDecoderNextImage(decoder);
+ if (isAvifError(result, "Could not decode image"))
+ goto cleanup;
+
+ if (!isAvifSrgbImage(decoder->image))
+ gd_error_ex(LOG_WARNING, "Image's color profile is not sRGB");
+
+ // Set up the avifRGBImage, and convert it from YUV to an 8-bit RGB image.
+ // (While AVIF image pixel depth can be 8, 10, or 12 bits, GD truecolor images are 8-bit.)
+ avifRGBImageSetDefaults(&rgb, decoder->image);
+ rgb.depth = 8;
+ avifRGBImageAllocatePixels(&rgb);
+
+ result = avifImageYUVToRGB(decoder->image, &rgb);
+ if (isAvifError(result, "Conversion from YUV to RGB failed"))
+ goto cleanup;
+
+ im = gdImageCreateTrueColor(decoder->image->width, decoder->image->height);
+ if (!im) {
+ gd_error("avif error - Could not create GD truecolor image");
+ goto cleanup;
+ }
+
+ im->saveAlphaFlag = 1;
+
+ // Read the pixels from the AVIF image and copy them into the GD image.
+
+ uint8_t *p = rgb.pixels;
+
+ for (y = 0; y < decoder->image->height; y++) {
+ for (x = 0; x < decoder->image->width; x++) {
+ uint8_t r = *(p++);
+ uint8_t g = *(p++);
+ uint8_t b = *(p++);
+ uint8_t a = alpha8BitTo7Bit(*(p++));
+ im->tpixels[y][x] = gdTrueColorAlpha(r, g, b, a);
+ }
+ }
+
+cleanup:
+ // if io has been allocated, this frees it
+ avifDecoderDestroy(decoder);
+
+ if (rgb.pixels)
+ avifRGBImageFreePixels(&rgb);
+
+ return im;
+}
+
+
+/*** Encoding functions ***/
+
+/*
+ Function: gdImageAvifEx
+
+ <gdImageAvifEx> outputs the specified image to the specified file in
+ AVIF format. The file must be open for writing. Under MSDOS and
+ all versions of Windows, it is important to use "wb" as opposed to
+ simply "w" as the mode when opening the file, and under Unix there
+ is no penalty for doing so. <gdImageAvifEx> does not close the file;
+ your code must do so.
+
+ Variants:
+
+ <gdImageAvifEx> writes the image to a file, encoding with the default quality and speed.
+
+ <gdImageAvifPtrEx> stores the image in RAM.
+
+ <gdImageAvifPtr> stores the image in RAM, encoding with the default quality and speed.
+
+ <gdImageAvifCtx> stores the image using a <gdIOCtx> struct.
+
+ Parameters:
+
+ im - The image to save.
+ outFile - The FILE pointer to write to.
+ quality - Compression quality (0-100). 0 is lowest-quality, 100 is highest.
+ speed - The speed of compression (0-10). 0 is slowest, 10 is fastest.
+
+ Notes on parameters:
+ quality - If quality = -1, we use a default quality as defined in QUALITY_DEFAULT.
+ For information on how we convert this quality to libavif's quantity param, see <quality2Quantizer>.
+
+ speed - At slower speeds, encoding may be quite slow. Use judiciously.
+
+ Qualities or speeds that are lower than the minimum value get clamped to the minimum value,
+ and qualities or speeds that are lower than the maximum value get clamped to the maxmum value.
+ Note that AVIF_SPEED_DEFAULT is -1. If we ever set SPEED_DEFAULT = AVIF_SPEED_DEFAULT,
+ we'd want to add a conditional to ensure that value doesn't get clamped.
+
+
+ Returns:
+
+ * for <gdImageAvifEx>, <gdImageAvif>, and <gdImageAvifCtx>, nothing.
+ * for <gdImageAvifPtrEx> and <gdImageAvifPtr>, a pointer to the image in memory.
+*/
+
+/*
+ Function: _gdImageAvifCtx
+
+ We need this underscored function because gdImageAvifCtx() can't return anything.
+ And our functions that operate on a memory buffer need to know whether the encoding has succeeded.
+
+ If we're passed the QUALITY_DEFAULT of -1, set the quantizer params to QUANTIZER_DEFAULT.
+
+ This function returns 0 on success, or 1 on failure.
+ */
+static avifBool _gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
+{
+ avifResult result;
+ avifRGBImage rgb;
+ avifRWData avifOutput = AVIF_DATA_EMPTY;
+ avifBool failed = AVIF_FALSE;
+ avifBool lossless = quality == 100;
+ avifEncoder *encoder = NULL;
+
+ uint32_t val;
+ uint8_t *p;
+ uint32_t x, y;
+
+ if (im == NULL)
+ return 1;
+
+ if (!gdImageTrueColor(im)) {
+ gd_error("avif doesn't support palette images");
+ return 1;
+ }
+
+ if (!gdImageSX(im) || !gdImageSY(im)) {
+ gd_error("image dimensions must not be zero");
+ return 1;
+ }
+
+ if (overflow2(gdImageSX(im), gdImageSY(im))) {
+ gd_error("image dimensions are too large");
+ return 1;
+ }
+
+ speed = CLAMP(speed, AVIF_SPEED_SLOWEST, AVIF_SPEED_FASTEST);
+
+ avifPixelFormat subsampling = quality >= HIGH_QUALITY_SUBSAMPLING_THRESHOLD ?
+ CHROMA_SUBAMPLING_HIGH_QUALITY : CHROMA_SUBSAMPLING_DEFAULT;
+
+ // Create the AVIF image.
+ // Set the ICC to sRGB, as that's what gd supports right now.
+ // Note that MATRIX_COEFFICIENTS_IDENTITY enables lossless conversion from RGB to YUV.
+
+ avifImage *avifIm = avifImageCreate(gdImageSX(im), gdImageSY(im), 8, subsampling);
+
+ avifIm->colorPrimaries = AVIF_COLOR_PRIMARIES_BT709;
+ avifIm->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB;
+ avifIm->matrixCoefficients = lossless ? AVIF_MATRIX_COEFFICIENTS_IDENTITY : AVIF_MATRIX_COEFFICIENTS_BT709;
+
+ avifRGBImageSetDefaults(&rgb, avifIm);
+ // this allocates memory, and sets rgb.rowBytes and rgb.pixels.
+ avifRGBImageAllocatePixels(&rgb);
+
+ // Parse RGB data from the GD image, and copy it into the AVIF RGB image.
+ // Convert 7-bit GD alpha channel values to 8-bit AVIF values.
+
+ p = rgb.pixels;
+ for (y = 0; y < rgb.height; y++) {
+ for (x = 0; x < rgb.width; x++) {
+ val = im->tpixels[y][x];
+
+ *(p++) = gdTrueColorGetRed(val);
+ *(p++) = gdTrueColorGetGreen(val);
+ *(p++) = gdTrueColorGetBlue(val);
+ *(p++) = alpha7BitTo8Bit(gdTrueColorGetAlpha(val));
+ }
+ }
+
+ // Convert the RGB image to YUV.
+
+ result = avifImageRGBToYUV(avifIm, &rgb);
+ failed = isAvifError(result, "Could not convert image to YUV");
+ if (failed)
+ goto cleanup;
+
+ // Encode the image in AVIF format.
+
+ encoder = avifEncoderCreate();
+ int quantizerQuality = quality == QUALITY_DEFAULT ?
+ QUANTIZER_DEFAULT : quality2Quantizer(quality);
+
+ encoder->minQuantizer = quantizerQuality;
+ encoder->maxQuantizer = quantizerQuality;
+ encoder->minQuantizerAlpha = quantizerQuality;
+ encoder->maxQuantizerAlpha = quantizerQuality;
+ encoder->speed = speed;
+
+ failed = !setEncoderTilesAndThreads(encoder, &rgb);
+ if (failed)
+ goto cleanup;
+
+ //TODO: is there a reason to use timeSscales != 1?
+ result = avifEncoderAddImage(encoder, avifIm, 1, AVIF_ADD_IMAGE_FLAG_SINGLE);
+ failed = isAvifError(result, "Could not encode image");
+ if (failed)
+ goto cleanup;
+
+ result = avifEncoderFinish(encoder, &avifOutput);
+ failed = isAvifError(result, "Could not finish encoding");
+ if (failed)
+ goto cleanup;
+
+ // Write the AVIF image bytes to the GD ctx.
+
+ gdPutBuf(avifOutput.data, avifOutput.size, outfile);
+
+cleanup:
+ if (rgb.pixels)
+ avifRGBImageFreePixels(&rgb);
+
+ if (encoder)
+ avifEncoderDestroy(encoder);
+
+ if (avifOutput.data)
+ avifRWDataFree(&avifOutput);
+
+ return failed;
+}
+
+BGD_DECLARE(void) gdImageAvifEx(gdImagePtr im, FILE *outFile, int quality, int speed)
+{
+ gdIOCtx *out = gdNewFileCtx(outFile);
+
+ if (out == NULL)
+ return;
+
+ gdImageAvifCtx(im, out, quality, speed);
+ out->gd_free(out);
+}
+
+BGD_DECLARE(void) gdImageAvif(gdImagePtr im, FILE *outFile)
+{
+ gdImageAvifEx(im, outFile, QUALITY_DEFAULT, SPEED_DEFAULT);
+}
+
+BGD_DECLARE(void *) gdImageAvifPtrEx(gdImagePtr im, int *size, int quality, int speed)
+{
+ void *rv;
+ gdIOCtx *out = gdNewDynamicCtx(NEW_DYNAMIC_CTX_SIZE, NULL);
+
+ if (out == NULL) {
+ return NULL;
+ }
+
+ if (_gdImageAvifCtx(im, out, quality, speed))
+ rv = NULL;
+ else
+ rv = gdDPExtractData(out, size);
+
+ out->gd_free(out);
+ return rv;
+}
+
+BGD_DECLARE(void *) gdImageAvifPtr(gdImagePtr im, int *size)
+{
+ return gdImageAvifPtrEx(im, size, QUALITY_DEFAULT, AVIF_SPEED_DEFAULT);
+}
+
+
+BGD_DECLARE(void) gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
+{
+ _gdImageAvifCtx(im, outfile, quality, speed);
+}
+
+#else /* !HAVE_LIBAVIF */
+
+static void *_noAvifError(void)
+{
+ gd_error("AVIF image support has been disabled\n");
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvif(FILE *ctx)
+{
+ return _noAvifError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifPtr(int size, void *data)
+{
+ return _noAvifError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifCtx(gdIOCtx *ctx)
+{
+ return _noAvifError();
+}
+
+BGD_DECLARE(void) gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
+{
+ _noAvifError();
+}
+
+BGD_DECLARE(void) gdImageAvifEx(gdImagePtr im, FILE *outFile, int quality, int speed)
+{
+ _noAvifError();
+}
+
+BGD_DECLARE(void) gdImageAvif(gdImagePtr im, FILE *outFile)
+{
+ _noAvifError();
+}
+
+BGD_DECLARE(void *) gdImageAvifPtr(gdImagePtr im, int *size)
+{
+ return _noAvifError();
+}
+
+BGD_DECLARE(void *) gdImageAvifPtrEx(gdImagePtr im, int *size, int quality, int speed)
+{
+ return _noAvifError();
+}
+
+#endif /* HAVE_LIBAVIF */
diff --git a/src/gd_bmp.c b/src/gd_bmp.c
index 1eb2ebe..e186ac9 100644
--- a/src/gd_bmp.c
+++ b/src/gd_bmp.c
@@ -19,12 +19,12 @@
* Read and write BMP images.
*/
-/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
+#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
@@ -47,6 +47,8 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info);
+static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression);
+
#define BMP_DEBUG(s)
static int gdBMPPutWord(gdIOCtx *out, int w)
@@ -87,8 +89,10 @@ BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageBmpCtx(im, out, compression);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageBmpCtx(im, out, compression))
+ rv = gdDPExtractData(out, size);
+ else
+ rv = NULL;
out->gd_free(out);
return rv;
}
@@ -142,12 +146,18 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
*/
BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
{
+ _gdImageBmpCtx(im, out, compression);
+}
+
+static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+{
int bitmap_size = 0, info_size, total_size, padding;
int i, row, xpos, pixel;
int error = 0;
unsigned char *uncompressed_row = NULL, *uncompressed_row_start = NULL;
FILE *tmpfile_for_compression = NULL;
gdIOCtxPtr out_original = NULL;
+ int ret = 1;
/* No compression if its true colour or we don't support seek */
if (im->trueColor) {
@@ -213,10 +223,10 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
/* 8-bit colours */
if (!im->trueColor) {
for(i = 0; i< im->colorsTotal; ++i) {
- Putchar(gdImageBlue(im, i), out);
- Putchar(gdImageGreen(im, i), out);
- Putchar(gdImageRed(im, i), out);
- Putchar(0, out);
+ gdPutC(gdImageBlue(im, i), out);
+ gdPutC(gdImageGreen(im, i), out);
+ gdPutC(gdImageRed(im, i), out);
+ gdPutC(0, out);
}
if (compression) {
@@ -237,14 +247,14 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
if (compression) {
*uncompressed_row++ = (unsigned char)gdImageGetPixel(im, xpos, row);
} else {
- Putchar(gdImageGetPixel(im, xpos, row), out);
+ gdPutC(gdImageGetPixel(im, xpos, row), out);
}
}
if (!compression) {
/* Add padding to make sure we have n mod 4 == 0 bytes per row */
for (xpos = padding; xpos > 0; --xpos) {
- Putchar('\0', out);
+ gdPutC('\0', out);
}
} else {
int compressed_size = 0;
@@ -257,8 +267,8 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
gdPutBuf(uncompressed_row, compressed_size, out);
- Putchar(BMP_RLE_COMMAND, out);
- Putchar(BMP_RLE_ENDOFLINE, out);
+ gdPutC(BMP_RLE_COMMAND, out);
+ gdPutC(BMP_RLE_ENDOFLINE, out);
bitmap_size += 2;
}
}
@@ -269,8 +279,8 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
goto cleanup;
}
/* Update filesize based on new values and set compression flag */
- Putchar(BMP_RLE_COMMAND, out);
- Putchar(BMP_RLE_ENDOFBITMAP, out);
+ gdPutC(BMP_RLE_COMMAND, out);
+ gdPutC(BMP_RLE_ENDOFBITMAP, out);
bitmap_size += 2;
/* Write new total bitmap size */
@@ -287,14 +297,14 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
for (xpos = 0; xpos < im->sx; xpos++) {
pixel = gdImageGetPixel(im, xpos, row);
- Putchar(gdTrueColorGetBlue(pixel), out);
- Putchar(gdTrueColorGetGreen(pixel), out);
- Putchar(gdTrueColorGetRed(pixel), out);
+ gdPutC(gdTrueColorGetBlue(pixel), out);
+ gdPutC(gdTrueColorGetGreen(pixel), out);
+ gdPutC(gdTrueColorGetRed(pixel), out);
}
/* Add padding to make sure we have n mod 4 == 0 bytes per row */
for (xpos = padding; xpos > 0; --xpos) {
- Putchar('\0', out);
+ gdPutC('\0', out);
}
}
}
@@ -325,6 +335,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
out_original = NULL;
}
+ ret = 0;
cleanup:
if (tmpfile_for_compression) {
#ifdef _WIN32
@@ -338,7 +349,7 @@ cleanup:
if (out_original) {
out_original->gd_free(out_original);
}
- return;
+ return ret;
}
static int compress_row(unsigned char *row, int length)
@@ -636,6 +647,9 @@ static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info)
return 1;
}
+ /* Unlikely, but possible -- largest signed value won't fit in unsigned. */
+ if (info->height == 0 || info->height == INT_MIN)
+ return 1;
if (info->height < 0) {
info->topdown = 1;
info->height = -info->height;
@@ -645,8 +659,9 @@ static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info)
info->type = BMP_PALETTE_4;
- if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 ||
- info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) {
+ /* Height was checked above. */
+ if (info->width <= 0 || info->numplanes <= 0 || info->depth <= 0 ||
+ info->numcolors < 0 || info->mincolors < 0) {
return 1;
}
@@ -667,11 +682,16 @@ static int bmp_read_os2_v1_info(gdIOCtxPtr infile, bmp_info_t *info)
/* OS2 v1 doesn't support topdown */
info->topdown = 0;
+ /* The spec says the depth can only be a few value values. */
+ if (info->depth != 1 && info->depth != 4 && info->depth != 8 &&
+ info->depth != 16 && info->depth != 24) {
+ return 1;
+ }
+
info->numcolors = 1 << info->depth;
info->type = BMP_PALETTE_3;
- if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 ||
- info->depth <= 0 || info->numcolors < 0) {
+ if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0) {
return 1;
}
@@ -701,6 +721,9 @@ static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info)
return 1;
}
+ /* Unlikely, but possible -- largest signed value won't fit in unsigned. */
+ if (info->height == 0 || info->height == INT_MIN)
+ return 1;
if (info->height < 0) {
info->topdown = 1;
info->height = -info->height;
@@ -710,12 +733,12 @@ static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info)
info->type = BMP_PALETTE_4;
- if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 ||
- info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) {
+ /* Height was checked above. */
+ if (info->width <= 0 || info->numplanes <= 0 || info->depth <= 0 ||
+ info->numcolors < 0 || info->mincolors < 0) {
return 1;
}
-
return 0;
}
@@ -758,10 +781,12 @@ static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, b
return 1;
}
- /* There is a chance the data isn't until later, would be wierd but it is possible */
+ /* There is a chance the data isn't until later, would be weird but it is possible */
if (gdTell(infile) != header->off) {
/* Should make sure we don't seek past the file size */
- gdSeek(infile, header->off);
+ if (!gdSeek(infile, header->off)) {
+ return 1;
+ }
}
/* The line must be divisible by 4, else its padded with NULLs */
@@ -853,14 +878,16 @@ static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
im->colorsTotal = info->numcolors;
- /* There is a chance the data isn't until later, would be wierd but it is possible */
+ /* There is a chance the data isn't until later, would be weird but it is possible */
if (gdTell(infile) != header->off) {
/* Should make sure we don't seek past the file size */
- gdSeek(infile, header->off);
+ if (!gdSeek(infile, header->off)) {
+ return 1;
+ }
}
- /* The line must be divisible by 4, else its padded with NULLs */
- padding = ((int)ceil(0.1 * info->width)) % 4;
+ /* The line must be aligned on a 32 bits word, else it is padded with zeros */
+ padding = (info->width + 7) / 8 % 4;
if (padding) {
padding = 4 - padding;
}
@@ -921,10 +948,12 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
im->colorsTotal = info->numcolors;
- /* There is a chance the data isn't until later, would be wierd but it is possible */
+ /* There is a chance the data isn't until later, would be weird but it is possible */
if (gdTell(infile) != header->off) {
/* Should make sure we don't seek past the file size */
- gdSeek(infile, header->off);
+ if (!gdSeek(infile, header->off)) {
+ return 1;
+ }
}
/* The line must be divisible by 4, else its padded with NULLs */
@@ -1006,10 +1035,12 @@ static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
im->colorsTotal = info->numcolors;
- /* There is a chance the data isn't until later, would be wierd but it is possible */
+ /* There is a chance the data isn't until later, would be weird but it is possible */
if (gdTell(infile) != header->off) {
/* Should make sure we don't seek past the file size */
- gdSeek(infile, header->off);
+ if (!gdSeek(infile, header->off)) {
+ return 1;
+ }
}
/* The line must be divisible by 4, else its padded with NULLs */
diff --git a/src/gd_color.c b/src/gd_color.c
index 6d8a846..ba0efd8 100644
--- a/src/gd_color.c
+++ b/src/gd_color.c
@@ -5,6 +5,11 @@
#include "gd.h"
#include "gd_color.h"
+/**
+ * The threshold method works relatively well but it can be improved.
+ * Maybe L*a*b* and Delta-E will give better results (and a better
+ * granularity).
+ */
int gdColorMatch(gdImagePtr im, int col1, int col2, float threshold)
{
const int dr = gdImageRed(im, col1) - gdImageRed(im, col2);
diff --git a/src/gd_color_match.c b/src/gd_color_match.c
index f0842b6..f019430 100644
--- a/src/gd_color_match.c
+++ b/src/gd_color_match.c
@@ -31,9 +31,8 @@ BGD_DECLARE(int) gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
return -4; /* At least 1 color must be allocated */
}
- buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * im2->colorsTotal);
- memset (buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
-
+ buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * gdMaxColors);
+ memset (buf, 0, sizeof(unsigned long) * 5 * gdMaxColors );
for (x=0; x < im1->sx; x++) {
for( y=0; y<im1->sy; y++ ) {
color = im2->pixels[y][x];
diff --git a/src/gd_crop.c b/src/gd_crop.c
index 9e0b8c8..05a1dce 100644
--- a/src/gd_crop.c
+++ b/src/gd_crop.c
@@ -1,13 +1,24 @@
-/* Crop support
- * manual crop using a gdRect or automatic crop using a background
- * color (automatic detections or using either the transparent color,
- * black or white).
- * An alternative method allows to crop using a given color and a
- * threshold. It works relatively well but it can be improved.
- * Maybe L*a*b* and Delta-E will give better results (and a better
- * granularity).
+/**
+ * File: Cropping
+ *
+ * Crop an image
+ *
+ * Some functions to crop images, automatically (auto detection of the border
+ * color), using a given color (with or without tolerance) or using a given
+ * rectangle.
+ *
+ * Example:
+ * (start code)
+ * im2 = gdImageAutoCrop(im, GD_CROP_SIDES);
+ * if (im2) {
+ * gdImageDestroy(im); // unless you need the original image subsequently
+ * // do something with the cropped image
+ * }
+ * gdImageDestroy(im2);
+ * (end code)
*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -18,12 +29,26 @@
static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color);
-/*
- Function: gdImageCrop
+/**
+ * Function: gdImageCrop
+ *
+ * Crop an image to a given rectangle
+ *
+ * Parameters:
+ * src - The image.
+ * crop - The cropping rectangle, see <gdRect>.
+ *
+ * Returns:
+ * The newly created cropped image, or NULL on failure.
+ *
+ * See also:
+ * - <gdImageCropAuto>
+ * - <gdImageCropThreshold>
*/
BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop)
{
gdImagePtr dst;
+ int alphaBlendingFlag;
if (gdImageTrueColor(src)) {
dst = gdImageCreateTrueColor(crop->width, crop->height);
@@ -31,13 +56,31 @@ BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop)
dst = gdImageCreate(crop->width, crop->height);
}
if (!dst) return NULL;
+ alphaBlendingFlag = dst->alphaBlendingFlag;
+ gdImageAlphaBlending(dst, gdEffectReplace);
gdImageCopy(dst, src, 0, 0, crop->x, crop->y, crop->width, crop->height);
+ gdImageAlphaBlending(dst, alphaBlendingFlag);
return dst;
}
-/*
- Function: gdImageCropAuto
+/**
+ * Function: gdImageCropAuto
+ *
+ * Crop an image automatically
+ *
+ * This function detects the cropping area according to the given _mode_.
+ *
+ * Parameters:
+ * im - The image.
+ * mode - The cropping mode, see <gdCropMode>.
+ *
+ * Returns:
+ * The newly created cropped image, or NULL on failure.
+ *
+ * See also:
+ * - <gdImageCrop>
+ * - <gdImageCropThreshold>
*/
BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode)
{
@@ -87,30 +130,24 @@ BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode)
}
}
- /* Nothing to do > bye
- * Duplicate the image?
- */
- if (y == height - 1) {
+ /* Whole image would be cropped > bye */
+ if (match) {
return NULL;
}
- crop.y = y -1;
+ crop.y = y - 1;
+
match = 1;
for (y = height - 1; match && y >= 0; y--) {
for (x = 0; match && x < width; x++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
-
- if (y == 0) {
- crop.height = height - crop.y + 1;
- } else {
- crop.height = y - crop.y + 2;
- }
+ crop.height = y - crop.y + 2;
match = 1;
for (x = 0; match && x < width; x++) {
- for (y = 0; match && y < crop.y + crop.height - 1; y++) {
+ for (y = 0; match && y < crop.y + crop.height; y++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
@@ -118,7 +155,7 @@ BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode)
match = 1;
for (x = width - 1; match && x >= 0; x--) {
- for (y = 0; match && y < crop.y + crop.height - 1; y++) {
+ for (y = 0; match && y < crop.y + crop.height; y++) {
match = (color == gdImageGetPixel(im, x,y));
}
}
@@ -127,8 +164,26 @@ BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode)
return gdImageCrop(im, &crop);
}
-/*
- Function: gdImageCropThreshold
+/**
+ * Function: gdImageCropThreshold
+ *
+ * Crop an image using a given color
+ *
+ * The _threshold_ defines the tolerance to be used while comparing the image
+ * color and the color to crop. The method used to calculate the color
+ * difference is based on the color distance in the RGB(A) cube.
+ *
+ * Parameters:
+ * im - The image.
+ * color - The crop color.
+ * threshold - The crop threshold.
+ *
+ * Returns:
+ * The newly created cropped image, or NULL on failure.
+ *
+ * See also:
+ * - <gdImageCrop>
+ * - <gdImageCropAuto>
*/
BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int color, const float threshold)
{
@@ -164,31 +219,24 @@ BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int c
}
}
- /* Pierre
- * Nothing to do > bye
- * Duplicate the image?
- */
- if (y == height - 1) {
+ /* Whole image would be cropped > bye */
+ if (match) {
return NULL;
}
- crop.y = y -1;
+ crop.y = y - 1;
+
match = 1;
for (y = height - 1; match && y >= 0; y--) {
for (x = 0; match && x < width; x++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x, y), threshold)) > 0;
}
}
-
- if (y == 0) {
- crop.height = height - crop.y + 1;
- } else {
- crop.height = y - crop.y + 2;
- }
+ crop.height = y - crop.y + 2;
match = 1;
for (x = 0; match && x < width; x++) {
- for (y = 0; match && y < crop.y + crop.height - 1; y++) {
+ for (y = 0; match && y < crop.y + crop.height; y++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x,y), threshold)) > 0;
}
}
@@ -196,7 +244,7 @@ BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int c
match = 1;
for (x = width - 1; match && x >= 0; x--) {
- for (y = 0; match && y < crop.y + crop.height - 1; y++) {
+ for (y = 0; match && y < crop.y + crop.height; y++) {
match = (gdColorMatch(im, color, gdImageGetPixel(im, x,y), threshold)) > 0;
}
}
@@ -233,7 +281,7 @@ static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color)
} else if (tl == tr || tl == bl || tl == br) {
*color = tl;
return 2;
- } else if (tr == bl) {
+ } else if (tr == bl || tr == br) {
*color = tr;
return 2;
} else if (br == bl) {
@@ -242,10 +290,10 @@ static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color)
} else {
register int r,b,g,a;
- r = (int)(0.5f + (gdImageRed(im, tl) + gdImageRed(im, tr) + gdImageRed(im, bl) + gdImageRed(im, br)) / 4);
- g = (int)(0.5f + (gdImageGreen(im, tl) + gdImageGreen(im, tr) + gdImageGreen(im, bl) + gdImageGreen(im, br)) / 4);
- b = (int)(0.5f + (gdImageBlue(im, tl) + gdImageBlue(im, tr) + gdImageBlue(im, bl) + gdImageBlue(im, br)) / 4);
- a = (int)(0.5f + (gdImageAlpha(im, tl) + gdImageAlpha(im, tr) + gdImageAlpha(im, bl) + gdImageAlpha(im, br)) / 4);
+ r = (2 + gdImageRed(im, tl) + gdImageRed(im, tr) + gdImageRed(im, bl) + gdImageRed(im, br)) / 4;
+ g = (2 + gdImageGreen(im, tl) + gdImageGreen(im, tr) + gdImageGreen(im, bl) + gdImageGreen(im, br)) / 4;
+ b = (2 + gdImageBlue(im, tl) + gdImageBlue(im, tr) + gdImageBlue(im, bl) + gdImageBlue(im, br)) / 4;
+ a = (2 + gdImageAlpha(im, tl) + gdImageAlpha(im, tr) + gdImageAlpha(im, bl) + gdImageAlpha(im, br)) / 4;
*color = gdImageColorClosestAlpha(im, r, g, b, a);
return 0;
}
diff --git a/src/gd_filename.c b/src/gd_filename.c
index fd61677..ddfaa02 100644
--- a/src/gd_filename.c
+++ b/src/gd_filename.c
@@ -28,7 +28,7 @@ static void BGD_STDCALL writejpeg(gdImagePtr im, FILE *out) {
static void BGD_STDCALL writewbmp(gdImagePtr im, FILE *out) {
int fg = gdImageColorClosest(im, 0, 0, 0);
-
+
gdImageWBMP(im, fg, out);
}/* writejpeg*/
@@ -37,8 +37,7 @@ static void BGD_STDCALL writebmp(gdImagePtr im, FILE *out) {
}/* writejpeg*/
-enum FType {UNKNOWN, PNG, JPG, GIF, TIFF, GD, GD2, WEBP};
-static struct FileType {
+static const struct FileType {
const char *ext;
ReadFn reader;
WriteFn writer;
@@ -52,6 +51,10 @@ static struct FileType {
{".xbm", gdImageCreateFromXbm, NULL, NULL},
{".tga", gdImageCreateFromTga, NULL, NULL},
+#ifdef HAVE_LIBAVIF
+ {".avif", gdImageCreateFromAvif, gdImageAvif, NULL},
+#endif
+
#ifdef HAVE_LIBPNG
{".png", gdImageCreateFromPng, gdImagePng, NULL},
#endif
@@ -61,7 +64,12 @@ static struct FileType {
{".jpeg", gdImageCreateFromJpeg, writejpeg, NULL},
#endif
-#ifdef HAVE_LIBTIFF
+#ifdef HAVE_LIBHEIF
+ {".heic", gdImageCreateFromHeif, gdImageHeif, NULL},
+ {".heix", gdImageCreateFromHeif, NULL, NULL},
+#endif
+
+#ifdef HAVE_LIBTIFF
{".tiff", gdImageCreateFromTiff, gdImageTiff, NULL},
{".tif" , gdImageCreateFromTiff, gdImageTiff, NULL},
#endif
@@ -82,7 +90,7 @@ static struct FileType {
};
-struct FileType *
+static const struct FileType *
ftype(const char *filename) {
int n;
char *ext;
@@ -90,7 +98,7 @@ ftype(const char *filename) {
/* Find the file extension (i.e. the last period in the string. */
ext = strrchr(filename, '.');
if (!ext) return NULL;
-
+
for (n = 0; Types[n].ext; n++) {
if (strcasecmp(ext, Types[n].ext) == 0) {
return &Types[n];
@@ -103,7 +111,7 @@ ftype(const char *filename) {
/*
Function: gdSupportsFileType
-
+
Tests if a given file type is supported by GD.
Given the name of an image file (which does not have to exist),
@@ -129,6 +137,8 @@ ftype(const char *filename) {
- .tga
- .png
- .jpg, .jpeg
+ - .heif, .heix
+ - .avif
- .tiff, .tif
- .webp
- .xpm
@@ -145,9 +155,9 @@ ftype(const char *filename) {
GD_TRUE (1) if the file type is supported, GD_FALSE (0) if not.
*/
-BGD_DECLARE(int)
+BGD_DECLARE(int)
gdSupportsFileType(const char *filename, int writing) {
- struct FileType *entry = ftype(filename);
+ const struct FileType *entry = ftype(filename);
return !!entry && (!writing || !!entry->writer);
}/* gdSupportsFileType*/
@@ -159,7 +169,7 @@ gdSupportsFileType(const char *filename, int writing) {
Given the path to a file, <gdImageCreateFromFile> will open the
file, read its contents with the appropriate _gdImageCreateFrom*_
- function and return it.
+ function and return it.
File type is determined by the filename extension, so having an
incorrect extension will probably not work. For example, renaming
@@ -179,12 +189,12 @@ gdSupportsFileType(const char *filename, int writing) {
*/
-BGD_DECLARE(gdImagePtr)
+BGD_DECLARE(gdImagePtr)
gdImageCreateFromFile(const char *filename) {
- struct FileType *entry = ftype(filename);
+ const struct FileType *entry = ftype(filename);
FILE *fh;
gdImagePtr result;
-
+
if (!entry) return NULL;
if (entry->loader) return entry->loader((char *)filename);
if (!entry->reader) return NULL;
@@ -193,7 +203,7 @@ gdImageCreateFromFile(const char *filename) {
if (!fh) return NULL;
result = entry->reader(fh);
-
+
fclose(fh);
return result;
@@ -235,9 +245,9 @@ gdImageCreateFromFile(const char *filename) {
*/
-BGD_DECLARE(int)
+BGD_DECLARE(int)
gdImageFile(gdImagePtr im, const char *filename) {
- struct FileType *entry = ftype(filename);
+ const struct FileType *entry = ftype(filename);
FILE *fh;
if (!entry || !entry->writer) return GD_FALSE;
@@ -251,4 +261,3 @@ gdImageFile(gdImagePtr im, const char *filename) {
return GD_TRUE;
}/* gdImageFile*/
-
diff --git a/src/gd_filter.c b/src/gd_filter.c
index 0d52e06..23bc564 100644
--- a/src/gd_filter.c
+++ b/src/gd_filter.c
@@ -30,8 +30,6 @@
typedef int (BGD_STDCALL *FuncPtr)(gdImagePtr, int, int);
#define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#define MAX(a,b) ((a)<(b)?(b):(a))
#ifdef _WIN32
# define GD_SCATTER_SEED() (unsigned int)(time(0) * GetCurrentProcessId())
@@ -236,6 +234,12 @@ BGD_DECLARE(int) gdImageNegate(gdImagePtr src)
*
* Convert an image to grayscale
*
+ * The red, green and blue components of each pixel are replaced by their
+ * weighted sum using the same coefficients as the REC.601 luma (Y')
+ * calculation. The alpha components are retained.
+ *
+ * For palette images the result may differ due to palette limitations.
+ *
* Parameters:
* src - The image.
*
@@ -248,11 +252,15 @@ BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src)
int r,g,b,a;
int new_pxl, pxl;
FuncPtr f;
+ int alpha_blending;
if (src==NULL) {
return 0;
}
+ alpha_blending = src->alphaBlendingFlag;
+ gdImageAlphaBlending(src, gdEffectReplace);
+
f = GET_PIXEL_FUNCTION(src);
for (y=0; y<src->sy; ++y) {
@@ -271,6 +279,8 @@ BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src)
gdImageSetPixel (src, x, y, new_pxl);
}
}
+ gdImageAlphaBlending(src, alpha_blending);
+
return 1;
}
@@ -525,6 +535,7 @@ BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float fi
for ( y=0; y<src->sy; y++) {
for(x=0; x<src->sx; x++) {
new_r = new_g = new_b = 0;
+ pxl = f(srcback, x, y);
new_a = gdImageAlpha(srcback, pxl);
for (j=0; j<3; j++) {
@@ -886,7 +897,7 @@ applyCoeffsLine(gdImagePtr src, gdImagePtr dst, int line, int linelen,
const int srcpx = (axis == HORIZONTAL) ?
src->tpixels[line][rndx] :
src->tpixels[rndx][line];
-
+
r += coeff * (double)gdTrueColorGetRed(srcpx);
g += coeff * (double)gdTrueColorGetGreen(srcpx);
b += coeff * (double)gdTrueColorGetBlue(srcpx);
@@ -900,7 +911,7 @@ applyCoeffsLine(gdImagePtr src, gdImagePtr dst, int line, int linelen,
static void
-applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
+applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
gdAxis axis)
{
int line, numlines, linelen;
@@ -927,7 +938,7 @@ applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
_radius_ is a radius, not a diameter so a radius of 2 (for
example) will blur across a region 5 pixels across (2 to the
center, 1 for the center itself and another 2 to the other edge).
-
+
_sigma_ represents the "fatness" of the curve (lower == fatter).
If _sigma_ is less than or equal to 0,
<gdImageCopyGaussianBlurred> ignores it and instead computes an
@@ -975,10 +986,10 @@ applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
FILE *in;
gdImagePtr result, src;
-
+
in = fopen("foo.png", "rb");
src = gdImageCreateFromPng(in);
-
+
result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
(end code)
@@ -1022,7 +1033,7 @@ gdImageCopyGaussianBlurred(gdImagePtr src, int radius, double sigma)
gdFree(coeffs);
return NULL;
}/* if */
-
+
freeSrc = 1;
}/* if */
@@ -1047,4 +1058,3 @@ gdImageCopyGaussianBlurred(gdImagePtr src, int radius, double sigma)
return result;
}/* gdImageCopyGaussianBlurred*/
-
diff --git a/src/gd_gd.c b/src/gd_gd.c
index a1e9ebf..0771fd3 100644
--- a/src/gd_gd.c
+++ b/src/gd_gd.c
@@ -12,21 +12,34 @@
* - color header (either truecolor or palette)
* - image data
*
- * All numbers are stored in big-endian format.
+ * All numbers are stored in big-endian format. Note that all GD output is done
+ * in the GD 2.x format (not to be confused with the GD2 format), but input may
+ * also be in the GD 1.x format.
*
- * File header structure:
+ * GD 1.x file header structure:
+ * width - 1 word
+ * height - 1 word
+ *
+ * GD 1.x color header (palette only):
+ * count - 1 byte (the number of used palette colors)
+ * transparent - 1 word (257 signals no transparency)
+ * palette - 256×3 bytes (RGB triplets)
+ *
+ * GD 2.x file header structure:
* signature - 1 word ("\xFF\xFE" for truecolor, "\xFF\xFF" for palette)
* width - 1 word
* height - 1 word
*
- * Truecolor image color header:
+ * GD 2.x truecolor image color header:
* truecolor - 1 byte (always "\001")
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (ARGB color); "\377\377\377\377" means that no
+ * transparent color is set
*
- * Palette image color header:
+ * GD 2.x palette image color header:
* truecolor - 1 byte (always "\0")
* count - 1 word (the number of used palette colors)
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (palette index); "\377\377\377\377" means that no
+ * transparent color is set
* palette - 256 dwords (RGBA colors)
*
* Image data:
@@ -44,6 +57,10 @@
#include <string.h>
#include <stdlib.h>
#include "gd.h"
+#include "gd_errors.h"
+
+/* 2.3: gd is no longer mandatory */
+#if ENABLE_GD_FORMATS
#define TRUE 1
#define FALSE 0
@@ -91,9 +108,10 @@ _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
if (!gdGetWord (&im->transparent, in)) {
goto fail1;
}
- if (im->transparent == 257) {
- im->transparent = (-1);
- }
+ }
+ /* Make sure transparent index is within bounds of the palette. */
+ if (!(im->trueColor) && (im->transparent >= im->colorsTotal || im->transparent < 0)) {
+ im->transparent = (-1);
}
GD2_DBG (printf
("Palette had %d colours (T=%d)\n", im->colorsTotal,
@@ -216,7 +234,7 @@ fail1:
> in = fopen("mygd.gd", "rb");
> im = gdImageCreateFromGd(in);
> fclose(in);
- > // ... Use the image ...
+ > // ... Use the image ...
> gdImageDestroy(im);
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * inFile)
@@ -387,3 +405,41 @@ BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size)
out->gd_free (out);
return rv;
}
+
+#else /* no HAVE_LIBZ or !ENABLE_GD_FORMATS */
+
+static void _noGdError (void)
+{
+ gd_error("GD image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * inFile)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * outFile)
+{
+ _noGdError();
+}
+
+BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size)
+{
+ _noGdError();
+ return NULL;
+}
+
+#endif /* ENABLE_GD_FORMATS */
diff --git a/src/gd_gd2.c b/src/gd_gd2.c
index 3c71682..760e85b 100644
--- a/src/gd_gd2.c
+++ b/src/gd_gd2.c
@@ -47,16 +47,18 @@
* offset - 1 dword
* size - 1 dword
*
- * There are x_chunk_count * y_chunk_count chunk headers.
+ * There are x_chunk_count * y_chunk_count chunk headers.
*
* Truecolor image color header:
* truecolor - 1 byte (always "\001")
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (ARGB color); "\377\377\377\377" means that no
+ * transparent color is set
*
* Palette image color header:
* truecolor - 1 byte (always "\0")
* count - 1 word (the number of used palette colors)
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (palette index); "\377\377\377\377" means that no
+ * transparent color is set
* palette - 256 dwords (RGBA colors)
*
* Chunk structure:
@@ -74,6 +76,7 @@
/* 2.0.29: no more errno.h, makes windows happy */
#include <math.h>
+#include <limits.h>
#include <string.h>
#include "gd.h"
#include "gd_errors.h"
@@ -82,7 +85,7 @@
/* 2.03: gd2 is no longer mandatory */
/* JCE - test after including gd.h so that HAVE_LIBZ can be set in
* a config.h file included by gd.h */
-#ifdef HAVE_LIBZ
+#if defined(HAVE_LIBZ) && ENABLE_GD_FORMATS
#include <zlib.h>
#define TRUE 1
@@ -209,6 +212,10 @@ _gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy,
GD2_DBG (printf ("%d Chunks vertically\n", *ncy));
if (gd2_compressed (*fmt)) {
+ if (overflow2(*ncx, *ncy)) {
+ GD2_DBG(printf ("Illegal chunk counts: %d * %d\n", *ncx, *ncy));
+ goto fail1;
+ }
nc = (*ncx) * (*ncy);
GD2_DBG (printf ("Reading %d chunk index entries\n", nc));
@@ -231,7 +238,7 @@ _gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy,
if (gdGetInt (&cidx[i].size, in) != 1) {
goto fail2;
};
- if (cidx[i].offset < 0 || cidx[i].size < 0)
+ if (cidx[i].offset < 0 || cidx[i].size < 0 || cidx[i].size == INT_MAX)
goto fail2;
};
*chunkIdx = cidx;
@@ -400,7 +407,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data)
Function: gdImageCreateFromGd2Ctx
Reads in a GD2 image via a <gdIOCtx> struct. See
- <gdImageCreateFromGd2>.
+ <gdImageCreateFromGd2>.
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
{
@@ -431,8 +438,13 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
}
bytesPerPixel = im->trueColor ? 4 : 1;
+ if (overflow2(ncx, ncy))
+ goto fail;
nc = ncx * ncy;
+ if (overflow2(ncy, cs) || overflow2(ncx, cs) || overflow2(bytesPerPixel, cs))
+ goto fail;
+
if (gd2_compressed (fmt)) {
/* Find the maximum compressed chunk size. */
compMax = 0;
@@ -503,18 +515,14 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
if (im->trueColor) {
if (!gdGetInt (&im->tpixels[y][x], in)) {
- /*printf("EOF while reading\n"); */
- /*gdImageDestroy(im); */
- /*return 0; */
- im->tpixels[y][x] = 0;
+ gd_error("gd2: EOF while reading\n");
+ goto fail;
}
} else {
int ch;
if (!gdGetByte (&ch, in)) {
- /*printf("EOF while reading\n"); */
- /*gdImageDestroy(im); */
- /*return 0; */
- ch = 0;
+ gd_error("gd2: EOF while reading\n");
+ goto fail;
}
im->pixels[y][x] = ch;
}
@@ -1126,57 +1134,61 @@ BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
return rv;
}
-#else /* no HAVE_LIBZ */
-static void _noLibzError (void)
+#else /* no HAVE_LIBZ or !ENABLE_GD_FORMATS */
+static void _noGd2Error (void)
{
+#if !ENABLE_GD_FORMATS
+ gd_error("GD2 image support has been disabled\n");
+#else
gd_error("GD2 support is not available - no libz\n");
+#endif
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * inFile)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, int w,
int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * outFile, int cs, int fmt)
{
- _noLibzError();
+ _noGd2Error();
}
BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
#endif /* HAVE_LIBZ */
diff --git a/src/gd_gif_in.c b/src/gd_gif_in.c
index 9832da8..2b6b34e 100644
--- a/src/gd_gif_in.c
+++ b/src/gd_gif_in.c
@@ -53,7 +53,7 @@ static int set_verbose(void)
#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
-#define ReadOK(file, buffer, len) (gdGetBuf(buffer, len, file) > 0)
+#define ReadOK(file, buffer, len) (gdGetBuf(buffer, len, file) == len)
#define LM_to_uint(a, b) (((b)<<8)|(a))
@@ -149,7 +149,7 @@ static void ReadImage (gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned
> in = fopen("mygif.gif", "rb");
> im = gdImageCreateFromGif(in);
> fclose(in);
- > // ... Use the image ...
+ > // ... Use the image ...
> gdImageDestroy(im);
*/
@@ -216,6 +216,9 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx(gdIOCtxPtr fd)
gdImagePtr im = 0;
+ memset(ColorMap, 0, 3 * MAXCOLORMAPSIZE);
+ memset(localColorMap, 0, 3 * MAXCOLORMAPSIZE);
+
if(!ReadOK(fd, buf, 6)) {
return 0;
}
@@ -312,8 +315,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx(gdIOCtxPtr fd)
ReadImage(im, fd, width, height, localColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock);
} else {
if(!haveGlobalColormap) {
- gdImageDestroy(im);
- return 0;
+ // Still a valid gif, apply simple default palette as per spec
+ ColorMap[CM_RED][1] = 0xff;
+ ColorMap[CM_GREEN][1] = 0xff;
+ ColorMap[CM_BLUE][1] = 0xff;
}
ReadImage(im, fd, width, height, ColorMap, BitSet(buf[8], INTERLACE), &ZeroDataBlock);
@@ -332,11 +337,6 @@ terminated:
return 0;
}
- if(!im->colorsTotal) {
- gdImageDestroy(im);
- return 0;
- }
-
/* Check for open colors at the end, so
* we can reduce colorsTotal and ultimately
* BitsPerPixel */
@@ -348,6 +348,11 @@ terminated:
}
}
+ if(!im->colorsTotal) {
+ gdImageDestroy(im);
+ return 0;
+ }
+
return im;
}
@@ -444,12 +449,12 @@ static int
GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP)
{
int i, j, ret;
- unsigned char count;
+ int count;
if(flag) {
scd->curbit = 0;
scd->lastbit = 0;
- scd->last_byte = 0;
+ scd->last_byte = 2;
scd->done = FALSE;
return 0;
}
@@ -598,6 +603,10 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i
/* Bad compressed data stream */
return -1;
}
+ if(code >= (1 << MAX_LWZ_BITS)) {
+ /* Corrupted code */
+ return -1;
+ }
*sd->sp++ = sd->table[1][code];
@@ -607,6 +616,10 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i
code = sd->table[0][code];
}
+ if(code >= (1 << MAX_LWZ_BITS)) {
+ /* Corrupted code */
+ return -1;
+ }
*sd->sp++ = sd->firstcode = sd->table[1][code];
diff --git a/src/gd_gif_out.c b/src/gd_gif_out.c
index 6fe707d..2dd866a 100644
--- a/src/gd_gif_out.c
+++ b/src/gd_gif_out.c
@@ -99,6 +99,11 @@ static void char_init(GifCtx *ctx);
static void char_out(int c, GifCtx *ctx);
static void flush_char(GifCtx *ctx);
+static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out);
+static int _gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
+ int LocalCM, int LeftOfs, int TopOfs,
+ int Delay, int Disposal,
+ gdImagePtr previm);
@@ -131,8 +136,11 @@ BGD_DECLARE(void *) gdImageGifPtr(gdImagePtr im, int *size)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageGifCtx(im, out);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageGifCtx(im, out)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -221,6 +229,12 @@ BGD_DECLARE(void) gdImageGif(gdImagePtr im, FILE *outFile)
*/
BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
{
+ _gdImageGifCtx(im, out);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
+{
gdImagePtr pim = 0, tim = im;
int interlace, BitsPerPixel;
interlace = im->interlace;
@@ -231,7 +245,7 @@ BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
based temporary image. */
pim = gdImageCreatePaletteFromTrueColor(im, 1, 256);
if(!pim) {
- return;
+ return 1;
}
tim = pim;
}
@@ -247,6 +261,8 @@ BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
/* Destroy palette based temporary image. */
gdImageDestroy( pim);
}
+
+ return 0;
}
@@ -475,8 +491,11 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -546,18 +565,18 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
gdImagePtr im, im2, im3;
int black, white, trans;
FILE *out;
-
+
im = gdImageCreate(100, 100); // Create the image
white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
-
+
out = fopen("anim.gif", "wb");// Open output file in binary mode
gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
// Write the first frame. No local color map. Delay = 1s
gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
-
+
// construct the second frame
im2 = gdImageCreate(100, 100);
(void)gdImageColorAllocate(im2, 255, 255, 255); // White background
@@ -566,7 +585,7 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
// Allow animation compression with transparent pixels
gdImageColorTransparent (im2, trans);
gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
-
+
// construct the third frame
im3 = gdImageCreate(100, 100);
(void)gdImageColorAllocate(im3, 255, 255, 255); // white background
@@ -578,7 +597,7 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
fclose(out); // Close file
-
+
// Destroy images
gdImageDestroy(im);
gdImageDestroy(im2);
@@ -637,6 +656,15 @@ BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
int Delay, int Disposal,
gdImagePtr previm)
{
+ _gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
+ int LocalCM, int LeftOfs, int TopOfs,
+ int Delay, int Disposal,
+ gdImagePtr previm)
+{
gdImagePtr pim = NULL, tim = im;
int interlace, transparent, BitsPerPixel;
interlace = im->interlace;
@@ -653,7 +681,7 @@ BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
based temporary image. */
pim = gdImageCreatePaletteFromTrueColor(im, 1, 256);
if (!pim) {
- return;
+ return 1;
}
tim = pim;
}
@@ -826,12 +854,14 @@ break_right:
out, tim->sx, tim->sy, LeftOfs, TopOfs, interlace, transparent,
Delay, Disposal, BitsPerPixel,
LocalCM ? tim->red : 0, tim->green, tim->blue, tim);
+ return 0;
fail_end:
if(pim) {
/* Destroy palette based temporary image. */
gdImageDestroy(pim);
}
+ return 1;
}
@@ -1374,7 +1404,7 @@ static void compress(int init_bits, gdIOCtxPtr outfile, gdImagePtr im, GifCtx *c
output((code_int)ctx->ClearCode, ctx);
#ifdef SIGNED_COMPARE_SLOW
- while((c = GIFNextPixel(im)) != (unsigned) EOF) {
+ while((c = GIFNextPixel(im, ctx)) != (unsigned) EOF) {
#else /* SIGNED_COMPARE_SLOW */
while((c = GIFNextPixel(im, ctx)) != EOF) {
#endif /* SIGNED_COMPARE_SLOW */
diff --git a/src/gd_heif.c b/src/gd_heif.c
new file mode 100644
index 0000000..47ecd7a
--- /dev/null
+++ b/src/gd_heif.c
@@ -0,0 +1,584 @@
+/**
+ * File: HEIF IO
+ *
+ * Read and write HEIF images.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdhelpers.h"
+
+#ifdef HAVE_LIBHEIF
+#include <libheif/heif.h>
+
+#define GD_HEIF_ALLOC_STEP (4*1024)
+#define GD_HEIF_HEADER 12
+
+typedef enum gd_heif_brand {
+ GD_HEIF_BRAND_AVIF = 1,
+ GD_HEIF_BRAND_MIF1 = 2,
+ GD_HEIF_BRAND_HEIC = 4,
+ GD_HEIF_BRAND_HEIX = 8,
+} gd_heif_brand;
+
+/*
+ Function: gdImageCreateFromHeif
+
+ <gdImageCreateFromHeif> is called to load truecolor images from
+ HEIF format files. Invoke <gdImageCreateFromHeif> with an
+ already opened pointer to a file containing the desired
+ image. <gdImageCreateFromHeif> returns a <gdImagePtr> to the new
+ truecolor image, or NULL if unable to load the image (most often
+ because the file is corrupt or does not contain a HEIF
+ image). <gdImageCreateFromHeif> does not close the file.
+
+ You can inspect the sx and sy members of the image to determine
+ its size. The image must eventually be destroyed using
+ <gdImageDestroy>.
+
+ *The returned image is always a truecolor image.*
+
+ Parameters:
+
+ infile - The input FILE pointer.
+
+ Returns:
+
+ A pointer to the new *truecolor* image. This will need to be
+ destroyed with <gdImageDestroy> once it is no longer needed.
+
+ On error, returns NULL.
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeif(FILE *inFile)
+{
+ gdImagePtr im;
+ gdIOCtx *in = gdNewFileCtx(inFile);
+
+ if (!in)
+ return NULL;
+ im = gdImageCreateFromHeifCtx(in);
+ in->gd_free(in);
+
+ return im;
+}
+
+/*
+ Function: gdImageCreateFromHeifPtr
+
+ See <gdImageCreateFromHeif>.
+
+ Parameters:
+
+ size - size of HEIF data in bytes.
+ data - pointer to HEIF data.
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifPtr(int size, void *data)
+{
+ gdImagePtr im;
+ gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0);
+
+ if (!in)
+ return NULL;
+ im = gdImageCreateFromHeifCtx(in);
+ in->gd_free(in);
+
+ return im;
+}
+
+static int _gdHeifCheckBrand(unsigned char *magic, gd_heif_brand expected_brand)
+{
+ if (memcmp(magic + 4, "ftyp", 4) != 0)
+ return GD_FALSE;
+ if (memcmp(magic + 8, "avif", 4) == 0 && expected_brand & GD_HEIF_BRAND_AVIF)
+ return GD_TRUE;
+ if (memcmp(magic + 8, "heic", 4) == 0 && expected_brand & GD_HEIF_BRAND_HEIC)
+ return GD_TRUE;
+ if (memcmp(magic + 8, "heix", 4) == 0 && expected_brand & GD_HEIF_BRAND_HEIX)
+ return GD_TRUE;
+ if (memcmp(magic + 8, "mif1", 4) == 0 && expected_brand & GD_HEIF_BRAND_MIF1)
+ return GD_TRUE;
+
+ return GD_FALSE;
+}
+
+static gdImagePtr _gdImageCreateFromHeifCtx(gdIOCtx *infile, gd_heif_brand expected_brand)
+{
+ struct heif_context *heif_ctx;
+ struct heif_decoding_options *heif_dec_opts;
+ struct heif_image_handle *heif_imhandle;
+ struct heif_image *heif_im;
+ struct heif_error err;
+ int width, height;
+ uint8_t *filedata = NULL;
+ uint8_t *rgba = NULL;
+ unsigned char *read, *temp, magic[GD_HEIF_HEADER];
+ int magic_len;
+ size_t size = 0, n = GD_HEIF_ALLOC_STEP;
+ gdImagePtr im;
+ int x, y;
+ uint8_t *p;
+
+ magic_len = gdGetBuf(magic, GD_HEIF_HEADER, infile);
+ if (magic_len != GD_HEIF_HEADER || !_gdHeifCheckBrand(magic, expected_brand)) {
+ gd_error("gd-heif incorrect type of file\n");
+ return NULL;
+ }
+ gdSeek(infile, 0);
+
+ while (n == GD_HEIF_ALLOC_STEP) {
+ temp = gdRealloc(filedata, size + GD_HEIF_ALLOC_STEP);
+ if (temp) {
+ filedata = temp;
+ read = temp + size;
+ } else {
+ gdFree(filedata);
+ gd_error("gd-heif decode realloc failed\n");
+ return NULL;
+ }
+
+ n = gdGetBuf(read, GD_HEIF_ALLOC_STEP, infile);
+ if (n > 0) {
+ size += n;
+ }
+ }
+
+ heif_ctx = heif_context_alloc();
+ if (heif_ctx == NULL) {
+ gd_error("gd-heif could not allocate context\n");
+ gdFree(filedata);
+ return NULL;
+ }
+ err = heif_context_read_from_memory_without_copy(heif_ctx, filedata, size, NULL);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif context creation failed\n");
+ gdFree(filedata);
+ heif_context_free(heif_ctx);
+ return NULL;
+ }
+
+ heif_imhandle = NULL;
+ err = heif_context_get_primary_image_handle(heif_ctx, &heif_imhandle);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif cannot retreive handle\n");
+ gdFree(filedata);
+ heif_context_free(heif_ctx);
+ return NULL;
+ }
+
+ heif_im = NULL;
+ heif_dec_opts = heif_decoding_options_alloc();
+ if (heif_dec_opts == NULL) {
+ gd_error("gd-heif could not allocate decode options\n");
+ gdFree(filedata);
+ heif_image_handle_release(heif_imhandle);
+ heif_context_free(heif_ctx);
+ return NULL;
+ }
+
+ heif_dec_opts->convert_hdr_to_8bit = GD_TRUE;
+ heif_dec_opts->ignore_transformations = GD_TRUE;
+ err = heif_decode_image(heif_imhandle, &heif_im, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, heif_dec_opts);
+ heif_decoding_options_free(heif_dec_opts);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif decoding failed\n");
+ gdFree(filedata);
+ heif_image_handle_release(heif_imhandle);
+ heif_context_free(heif_ctx);
+ return NULL;
+ }
+
+ width = heif_image_get_width(heif_im, heif_channel_interleaved);
+ height = heif_image_get_height(heif_im, heif_channel_interleaved);
+
+ im = gdImageCreateTrueColor(width, height);
+ if (!im) {
+ gdFree(filedata);
+ heif_image_release(heif_im);
+ heif_image_handle_release(heif_imhandle);
+ heif_context_free(heif_ctx);
+ return NULL;
+ }
+ rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, NULL);
+ if (!rgba) {
+ gd_error("gd-heif cannot get image plane\n");
+ gdFree(filedata);
+ heif_image_release(heif_im);
+ heif_image_handle_release(heif_imhandle);
+ heif_context_free(heif_ctx);
+ gdImageDestroy(im);
+ return NULL;
+ }
+ for (y = 0, p = rgba; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ uint8_t r = *(p++);
+ uint8_t g = *(p++);
+ uint8_t b = *(p++);
+ uint8_t a = gdAlphaMax - (*(p++) >> 1);
+ im->tpixels[y][x] = gdTrueColorAlpha(r, g, b, a);
+ }
+ }
+ gdFree(filedata);
+ heif_image_release(heif_im);
+ heif_image_handle_release(heif_imhandle);
+ heif_context_free(heif_ctx);
+
+ return im;
+}
+
+/*
+ Function: gdImageCreateFromHeifCtx
+
+ See <gdImageCreateFromHeif>.
+*/
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifCtx(gdIOCtx *infile)
+{
+ return _gdImageCreateFromHeifCtx(infile, GD_HEIF_BRAND_AVIF | GD_HEIF_BRAND_MIF1 | GD_HEIF_BRAND_HEIC | GD_HEIF_BRAND_HEIX);
+}
+
+
+static struct heif_error _gdImageWriteHeif(struct heif_context *heif_ctx, const void *data, size_t size, void *userdata)
+{
+ gdIOCtx *outfile;
+ struct heif_error err;
+
+ outfile = (gdIOCtx *)userdata;
+
+ gdPutBuf(data, size, outfile);
+
+ err.code = heif_error_Ok;
+ err.subcode = heif_suberror_Unspecified;
+ err.message = "";
+
+ return err;
+}
+
+/* returns GD_TRUE on success, GD_FALSE on failure */
+static int _gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ struct heif_context *heif_ctx;
+ struct heif_encoder *heif_enc;
+ struct heif_image *heif_im;
+ struct heif_writer heif_wr;
+ struct heif_error err;
+ uint8_t *rgba;
+ int x, y;
+ uint8_t *p;
+
+ if (im == NULL) {
+ return GD_FALSE;
+ }
+
+ if (codec != GD_HEIF_CODEC_HEVC && codec != GD_HEIF_CODEC_AV1) {
+ gd_error("Unsupported format by heif");
+ return GD_FALSE;
+ }
+
+ if (!gdImageTrueColor(im)) {
+ gd_error("Palette image not supported by heif\n");
+ return GD_FALSE;
+ }
+
+ if (overflow2(gdImageSX(im), 4)) {
+ return GD_FALSE;
+ }
+
+ if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) {
+ return GD_FALSE;
+ }
+
+ heif_ctx = heif_context_alloc();
+ if (heif_ctx == NULL) {
+ gd_error("gd-heif could not allocate context\n");
+ return GD_FALSE;
+ }
+ err = heif_context_get_encoder_for_format(heif_ctx, (enum heif_compression_format)codec, &heif_enc);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif encoder acquisition failed (missing codec support?)\n");
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+
+ if (quality == 200) {
+ err = heif_encoder_set_lossless(heif_enc, GD_TRUE);
+ } else if (quality == -1) {
+ err = heif_encoder_set_lossy_quality(heif_enc, 80);
+ } else {
+ err = heif_encoder_set_lossy_quality(heif_enc, quality);
+ }
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif invalid quality number\n");
+ heif_encoder_release(heif_enc);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+
+ if (heif_get_version_number_major() >= 1 && heif_get_version_number_minor() >= 9) {
+ err = heif_encoder_set_parameter_string(heif_enc, "chroma", chroma);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif invalid chroma subsampling parameter\n");
+ heif_encoder_release(heif_enc);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+ }
+
+ err = heif_image_create(gdImageSX(im), gdImageSY(im), heif_colorspace_RGB, heif_chroma_interleaved_RGBA, &heif_im);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif image creation failed");
+ heif_encoder_release(heif_enc);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+
+ err = heif_image_add_plane(heif_im, heif_channel_interleaved, gdImageSX(im), gdImageSY(im), 32);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif cannot add image plane\n");
+ heif_image_release(heif_im);
+ heif_encoder_release(heif_enc);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+
+ rgba = (uint8_t *)heif_image_get_plane_readonly(heif_im, heif_channel_interleaved, NULL);
+ if (!rgba) {
+ gd_error("gd-heif cannot get image plane\n");
+ heif_image_release(heif_im);
+ heif_encoder_release(heif_enc);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+ p = rgba;
+ for (y = 0; y < gdImageSY(im); y++) {
+ for (x = 0; x < gdImageSX(im); x++) {
+ int c;
+ char a;
+ c = im->tpixels[y][x];
+ a = gdTrueColorGetAlpha(c);
+ if (a == 127) {
+ a = 0;
+ } else {
+ a = 255 - ((a << 1) + (a >> 6));
+ }
+ *(p++) = gdTrueColorGetRed(c);
+ *(p++) = gdTrueColorGetGreen(c);
+ *(p++) = gdTrueColorGetBlue(c);
+ *(p++) = a;
+ }
+ }
+ err = heif_context_encode_image(heif_ctx, heif_im, heif_enc, NULL, NULL);
+ heif_encoder_release(heif_enc);
+ if (err.code != heif_error_Ok) {
+ gd_error("gd-heif encoding failed\n");
+ heif_image_release(heif_im);
+ heif_context_free(heif_ctx);
+ return GD_FALSE;
+ }
+ heif_wr.write = _gdImageWriteHeif;
+ heif_wr.writer_api_version = 1;
+ err = heif_context_write(heif_ctx, &heif_wr, (void *)outfile);
+
+ heif_image_release(heif_im);
+ heif_context_free(heif_ctx);
+
+ return GD_TRUE;
+}
+
+
+/*
+ Function: gdImageHeifCtx
+
+ Write the image as HEIF data via a <gdIOCtx>. See <gdImageHeifEx>
+ for more details.
+
+ Parameters:
+
+ im - The image to write.
+ outfile - The output sink.
+ quality - Image quality.
+ codec - The output coding format.
+ chroma - The output chroma subsampling format.
+
+ Returns:
+
+ Nothing.
+*/
+BGD_DECLARE(void) gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ _gdImageHeifCtx(im, outfile, quality, codec, chroma);
+}
+
+/*
+ Function: gdImageHeifEx
+
+ <gdImageHeifEx> outputs the specified image to the specified file in
+ HEIF format. The file must be open for writing. Under MSDOS and
+ all versions of Windows, it is important to use "wb" as opposed to
+ simply "w" as the mode when opening the file, and under Unix there
+ is no penalty for doing so. <gdImageHeifEx> does not close the file;
+ your code must do so.
+
+ If _quality_ is -1, a reasonable quality value (which should yield a
+ good general quality / size tradeoff for most situations) is used. Otherwise
+ _quality_ should be a value in the range 0-100, higher quality values
+ usually implying both higher quality and larger image sizes or 200, for
+ lossless codec.
+
+ Variants:
+
+ <gdImageHeifCtx> stores the image using a <gdIOCtx> struct.
+
+ <gdImageHeifPtrEx> stores the image to RAM.
+
+ Parameters:
+
+ im - The image to save.
+ outFile - The FILE pointer to write to.
+ quality - Codec quality (0-100).
+ codec - The output coding format.
+ chroma - The output chroma subsampling format.
+
+ Returns:
+
+ Nothing.
+*/
+BGD_DECLARE(void) gdImageHeifEx(gdImagePtr im, FILE *outFile, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ gdIOCtx *out = gdNewFileCtx(outFile);
+ if (out == NULL) {
+ return;
+ }
+ _gdImageHeifCtx(im, out, quality, codec, chroma);
+ out->gd_free(out);
+}
+
+/*
+ Function: gdImageHeif
+
+ Variant of <gdImageHeifEx> which uses the default quality (-1), the
+ default codec (GD_HEIF_Codec_HEVC) and the default chroma
+ subsampling (GD_HEIF_CHROMA_444).
+
+ Parameters:
+
+ im - The image to save
+ outFile - The FILE pointer to write to.
+
+ Returns:
+
+ Nothing.
+*/
+BGD_DECLARE(void) gdImageHeif(gdImagePtr im, FILE *outFile)
+{
+ gdIOCtx *out = gdNewFileCtx(outFile);
+ if (out == NULL) {
+ return;
+ }
+ _gdImageHeifCtx(im, out, -1, GD_HEIF_CODEC_HEVC, GD_HEIF_CHROMA_444);
+ out->gd_free(out);
+}
+
+/*
+ Function: gdImageHeifPtr
+
+ See <gdImageHeifEx>.
+*/
+BGD_DECLARE(void *) gdImageHeifPtr(gdImagePtr im, int *size)
+{
+ void *rv;
+ gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+ if (out == NULL) {
+ return NULL;
+ }
+ if (_gdImageHeifCtx(im, out, -1, GD_HEIF_CODEC_HEVC, GD_HEIF_CHROMA_444)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
+ out->gd_free(out);
+
+ return rv;
+}
+
+/*
+ Function: gdImageHeifPtrEx
+
+ See <gdImageHeifEx>.
+*/
+BGD_DECLARE(void *) gdImageHeifPtrEx(gdImagePtr im, int *size, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ void *rv;
+ gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+ if (out == NULL) {
+ return NULL;
+ }
+ if (_gdImageHeifCtx(im, out, quality, codec, chroma)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
+ out->gd_free(out);
+ return rv;
+}
+
+#else /* HAVE_LIBHEIF */
+
+static void _noHeifError(void)
+{
+ gd_error("HEIF image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeif(FILE *inFile)
+{
+ _noHeifError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifPtr(int size, void *data)
+{
+ _noHeifError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifCtx(gdIOCtx *infile)
+{
+ _noHeifError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ _noHeifError();
+}
+
+BGD_DECLARE(void) gdImageHeifEx(gdImagePtr im, FILE *outFile, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ _noHeifError();
+}
+
+BGD_DECLARE(void) gdImageHeif(gdImagePtr im, FILE *outFile)
+{
+ _noHeifError();
+}
+
+BGD_DECLARE(void *) gdImageHeifPtr(gdImagePtr im, int *size)
+{
+ _noHeifError();
+ return NULL;
+}
+
+BGD_DECLARE(void *) gdImageHeifPtrEx(gdImagePtr im, int *size, int quality, gdHeifCodec codec, gdHeifChroma chroma)
+{
+ _noHeifError();
+ return NULL;
+}
+
+#endif /* HAVE_LIBHEIF */
diff --git a/src/gd_intern.h b/src/gd_intern.h
index 86d817e..f8f3b5d 100644
--- a/src/gd_intern.h
+++ b/src/gd_intern.h
@@ -1,10 +1,9 @@
+/* Internal header for random common utility functions. */
+
#ifndef GD_INTERN_H
#define GD_INTERN_H
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
-
#ifndef MAXPATHLEN
# ifdef PATH_MAX
@@ -32,15 +31,11 @@
#include "gd.h"
-#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
-#ifndef MAX
#define MAX(a,b) ((a)<(b)?(b):(a))
-#endif
#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
-
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
typedef enum {
HORIZONTAL,
@@ -87,4 +82,3 @@ gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
#endif
-
diff --git a/src/gd_interpolation.c b/src/gd_interpolation.c
index d885a49..ce27220 100644
--- a/src/gd_interpolation.c
+++ b/src/gd_interpolation.c
@@ -41,8 +41,8 @@
downscaling using the fixed point implementations are usually much faster
than the existing gdImageCopyResampled while having a similar or better
quality.
-
- For image rotations, the optimized versions have a lazy antialiasing for
+
+ For image rotations, the optimized versions have a lazy antialiasing for
the edges of the images. For a much better antialiased result, the affine
function is recommended.
*/
@@ -78,7 +78,7 @@ TODO:
# include <emmintrin.h>
#endif
-static gdImagePtr gdImageScaleBilinear(gdImagePtr im,
+static gdImagePtr gdImageScaleBilinear(gdImagePtr im,
const unsigned int new_width,
const unsigned int new_height);
static gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src,
@@ -93,9 +93,6 @@ static gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src,
static gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees,
const int bgColor);
-
-#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-
/* only used here, let do a generic fixed point integers later if required by other
part of GD */
typedef long gdFixed;
@@ -278,7 +275,7 @@ static double KernelBessel_Q1(const double x)
static double KernelBessel_Order1(double x)
{
double p, q;
-
+
if (x == 0.0)
return (0.0f);
p = x;
@@ -617,7 +614,7 @@ static double filter_welsh(const double x)
#if defined(_MSC_VER) && !defined(inline)
# define inline __inline
-#endif
+#endif
/* keep it for future usage for affine copy over an existing image, targetting fix for 2.2.2 */
#ifdef FUNCTION_NOT_USED_YET
@@ -654,7 +651,7 @@ static inline int _color_blend (const int dst, const int src)
}
}
-static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
+static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
{
const gdFixed f_127 = gd_itofx(127);
register int c = src->tpixels[y][x];
@@ -829,8 +826,13 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
{
unsigned int u = 0;
LineContribType *res;
- int overflow_error = 0;
+ size_t weights_size;
+ if (overflow2(windows_size, sizeof(double))) {
+ return NULL;
+ } else {
+ weights_size = windows_size * sizeof(double);
+ }
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
@@ -847,15 +849,11 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
- if (overflow2(windows_size, sizeof(double))) {
- overflow_error = 1;
- } else {
- res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
- }
- if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
+ res->ContribRow[u].Weights = (double *) gdMalloc(weights_size);
+ if (res->ContribRow[u].Weights == NULL) {
unsigned int i;
- u--;
- for (i=0;i<=u;i++) {
+
+ for (i=0;i<u;i++) {
gdFree(res->ContribRow[i].Weights);
}
gdFree(res->ContribRow);
@@ -947,8 +945,8 @@ _gdScaleOneAxis(gdImagePtr pSrc, gdImagePtr dst,
double r = 0, g = 0, b = 0, a = 0;
const int left = contrib->ContribRow[ndx].Left;
const int right = contrib->ContribRow[ndx].Right;
- int *dest = (axis == HORIZONTAL) ?
- &dst->tpixels[row][ndx] :
+ int *dest = (axis == HORIZONTAL) ?
+ &dst->tpixels[row][ndx] :
&dst->tpixels[ndx][row];
int i;
@@ -957,7 +955,7 @@ _gdScaleOneAxis(gdImagePtr pSrc, gdImagePtr dst,
for (i = left; i <= right; i++) {
const int left_channel = i - left;
const int srcpx = (axis == HORIZONTAL) ?
- pSrc->tpixels[row][i] :
+ pSrc->tpixels[row][i] :
pSrc->tpixels[i][row];
r += contrib->ContribRow[ndx].Weights[left_channel]
@@ -1243,11 +1241,11 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
f_b1, f_b2, f_b3, f_b4,
f_a1, f_a2, f_a3, f_a4;
- /* zero for the background color, nothig gets outside anyway */
+ /* 0 for bgColor; (n,m) is supposed to be valid anyway */
pixel1 = getPixelOverflowPalette(im, n, m, 0);
- pixel2 = getPixelOverflowPalette(im, n + 1, m, 0);
- pixel3 = getPixelOverflowPalette(im, n, m + 1, 0);
- pixel4 = getPixelOverflowPalette(im, n + 1, m + 1, 0);
+ pixel2 = getPixelOverflowPalette(im, n + 1, m, pixel1);
+ pixel3 = getPixelOverflowPalette(im, n, m + 1, pixel1);
+ pixel4 = getPixelOverflowPalette(im, n + 1, m + 1, pixel1);
f_r1 = gd_itofx(gdTrueColorGetRed(pixel1));
f_r2 = gd_itofx(gdTrueColorGetRed(pixel2));
@@ -1267,10 +1265,10 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
f_a4 = gd_itofx(gdTrueColorGetAlpha(pixel4));
{
- const char red = (char) gd_fxtoi(gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4));
- const char green = (char) gd_fxtoi(gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4));
- const char blue = (char) gd_fxtoi(gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4));
- const char alpha = (char) gd_fxtoi(gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4));
+ const unsigned char red = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_r1) + gd_mulfx(f_w2, f_r2) + gd_mulfx(f_w3, f_r3) + gd_mulfx(f_w4, f_r4));
+ const unsigned char green = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_g1) + gd_mulfx(f_w2, f_g2) + gd_mulfx(f_w3, f_g3) + gd_mulfx(f_w4, f_g4));
+ const unsigned char blue = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_b1) + gd_mulfx(f_w2, f_b2) + gd_mulfx(f_w3, f_b3) + gd_mulfx(f_w4, f_b4));
+ const unsigned char alpha = (unsigned char) gd_fxtoi(gd_mulfx(f_w1, f_a1) + gd_mulfx(f_w2, f_a2) + gd_mulfx(f_w3, f_a3) + gd_mulfx(f_w4, f_a4));
new_img->tpixels[dst_offset_v][dst_offset_h] = gdTrueColorAlpha(red, green, blue, alpha);
}
@@ -1312,8 +1310,8 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
gdFixed f_j = gd_itofx(j);
gdFixed f_a = gd_mulfx(f_i, f_dy);
gdFixed f_b = gd_mulfx(f_j, f_dx);
- const gdFixed m = gd_fxtoi(f_a);
- const gdFixed n = gd_fxtoi(f_b);
+ const long m = gd_fxtoi(f_a);
+ const long n = gd_fxtoi(f_b);
gdFixed f_f = f_a - gd_itofx(m);
gdFixed f_g = f_b - gd_itofx(n);
@@ -1329,11 +1327,11 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
f_g1, f_g2, f_g3, f_g4,
f_b1, f_b2, f_b3, f_b4,
f_a1, f_a2, f_a3, f_a4;
- /* 0 for bgColor, nothing gets outside anyway */
+ /* 0 for bgColor; (n,m) is supposed to be valid anyway */
pixel1 = getPixelOverflowTC(im, n, m, 0);
- pixel2 = getPixelOverflowTC(im, n + 1, m, 0);
- pixel3 = getPixelOverflowTC(im, n, m + 1, 0);
- pixel4 = getPixelOverflowTC(im, n + 1, m + 1, 0);
+ pixel2 = getPixelOverflowTC(im, n + 1, m, pixel1);
+ pixel3 = getPixelOverflowTC(im, n, m + 1, pixel1);
+ pixel4 = getPixelOverflowTC(im, n + 1, m + 1, pixel1);
f_r1 = gd_itofx(gdTrueColorGetRed(pixel1));
f_r2 = gd_itofx(gdTrueColorGetRed(pixel2));
@@ -1612,6 +1610,8 @@ gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width,
* Creates a new image, scaled to the requested size using the current
* <gdInterpolationMethod>.
*
+ * Note that GD_WEIGHTED4 is not yet supported by this function.
+ *
* Parameters:
* src - The source image.
* new_width - The new width.
@@ -1683,7 +1683,7 @@ static int gdRotatedImageSize(gdImagePtr src, const float angle, gdRectPtr bbox)
return GD_TRUE;
}
-static gdImagePtr
+static gdImagePtr
gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees,
const int bgColor)
{
@@ -1796,7 +1796,7 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
return dst;
}
-/**
+/**
* Function: gdImageRotateInterpolated
*
* Rotate an image
@@ -1818,7 +1818,7 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
*/
BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)
{
- /* round to two decimals and keep the 100x multiplication to use it in the common square angles
+ /* round to two decimals and keep the 100x multiplication to use it in the common square angles
case later. Keep the two decimal precisions so smaller rotation steps can be done, useful for
slow animations, f.e. */
const int angle_rounded = fmod((int) floorf(angle * 100), 360 * 100);
@@ -1950,7 +1950,7 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
if (!src->trueColor) {
gdImagePaletteToTrueColor(src);
}
-
+
/* Translate to dst origin (0,0) */
gdAffineTranslate(m, -bbox.x, -bbox.y);
gdAffineConcat(m, affine, m);
@@ -1972,6 +1972,52 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
}
}
+/** Function: getPixelRgbInterpolated
+ * get the index of the image's colors
+ *
+ * Parameters:
+ * im - Image to draw the transformed image
+ * tcolor - TrueColor
+ *
+ * Return:
+ * index of colors
+ */
+static int getPixelRgbInterpolated(gdImagePtr im, const int tcolor)
+{
+ unsigned char r, g, b, a;
+ int ct;
+ int i;
+
+ b = (unsigned char)tcolor;
+ g = (unsigned char)tcolor >> 8;
+ r = (unsigned char)tcolor >> 16;
+ a = (unsigned char)tcolor >> 24;
+
+ b = CLAMP(b, 0, 255);
+ g = CLAMP(g, 0, 255);
+ r = CLAMP(r, 0, 255);
+ a = CLAMP(a, 0, 127);
+
+ for (i = 0; i < im->colorsTotal; i++) {
+ if (im->red[i] == r && im->green[i] == g && im->blue[i] == b && im->alpha[i] == a) {
+ return i;
+ }
+ }
+
+ ct = im->colorsTotal;
+ if (ct == gdMaxColors) {
+ return -1;
+ }
+
+ im->colorsTotal++;
+ im->red[ct] = r;
+ im->green[ct] = g;
+ im->blue[ct] = b;
+ im->alpha[ct] = a;
+ im->open[ct] = 0;
+
+ return ct;
+}
/**
* Function: gdTransformAffineCopy
* Applies an affine transformation to a region and copy the result
@@ -1985,7 +2031,7 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
* src_area - Rectangular region to rotate in the src image
*
* Returns:
- * GD_TRUE if the affine is rectilinear or GD_FALSE
+ * GD_TRUE on success or GD_FALSE on failure
*/
BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
int dst_x, int dst_y,
@@ -1998,21 +2044,21 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
int backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2;
register int x, y, src_offset_x, src_offset_y;
double inv[6];
- int *dst_p;
gdPointF pt, src_pt;
gdRect bbox;
int end_x, end_y;
- gdInterpolationMethod interpolation_id_bak = GD_DEFAULT;
+ gdInterpolationMethod interpolation_id_bak = src->interpolation_id;
/* These methods use special implementations */
if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) {
- interpolation_id_bak = src->interpolation_id;
-
gdImageSetInterpolationMethod(src, GD_BICUBIC);
}
-
gdImageClipRectangle(src, src_region);
+ c1x = src_region->x;
+ c1y = src_region->y;
+ c2x = src_region->x + src_region->width -1;
+ c2y = src_region->y + src_region->height -1;
if (src_region->x > 0 || src_region->y > 0
|| src_region->width < gdImageSX(src)
@@ -2036,13 +2082,14 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
return GD_FALSE;
}
- gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y);
-
end_x = bbox.width + abs(bbox.x);
end_y = bbox.height + abs(bbox.y);
/* Get inverse affine to let us work with destination -> source */
- gdAffineInvert(inv, affine);
+ if (gdAffineInvert(inv, affine) == GD_FALSE) {
+ gdImageSetInterpolationMethod(src, interpolation_id_bak);
+ return GD_FALSE;
+ }
src_offset_x = src_region->x;
src_offset_y = src_region->y;
@@ -2050,28 +2097,51 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
if (dst->alphaBlendingFlag) {
for (y = bbox.y; y <= end_y; y++) {
pt.y = y + 0.5;
- for (x = 0; x <= end_x; x++) {
+ for (x = bbox.x; x <= end_x; x++) {
pt.x = x + 0.5;
gdAffineApplyToPointF(&src_pt, &pt, inv);
- gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0));
+ if (floor(src_offset_x + src_pt.x) < c1x
+ || floor(src_offset_x + src_pt.x) > c2x
+ || floor(src_offset_y + src_pt.y) < c1y
+ || floor(src_offset_y + src_pt.y) > c2y) {
+ continue;
+ }
+ gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), 0));
}
}
} else {
- for (y = 0; y <= end_y; y++) {
- pt.y = y + 0.5 + bbox.y;
+ for (y = bbox.y; y <= end_y; y++) {
+ unsigned char *dst_p = NULL;
+ int *tdst_p = NULL;
+
+ pt.y = y + 0.5;
if ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) {
continue;
}
- dst_p = dst->tpixels[dst_y + y] + dst_x;
+ if (dst->trueColor) {
+ tdst_p = dst->tpixels[dst_y + y] + dst_x;
+ } else {
+ dst_p = dst->pixels[dst_y + y] + dst_x;
+ }
- for (x = 0; x <= end_x; x++) {
- pt.x = x + 0.5 + bbox.x;
+ for (x = bbox.x; x <= end_x; x++) {
+ pt.x = x + 0.5;
gdAffineApplyToPointF(&src_pt, &pt, inv);
if ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) {
break;
}
- *(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1);
+ if (floor(src_offset_x + src_pt.x) < c1x
+ || floor(src_offset_x + src_pt.x) > c2x
+ || floor(src_offset_y + src_pt.y) < c1y
+ || floor(src_offset_y + src_pt.y) > c2y) {
+ continue;
+ }
+ if (dst->trueColor) {
+ *(tdst_p + dst_x + x) = getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), -1);
+ } else {
+ *(dst_p + dst_x + x) = getPixelRgbInterpolated(dst, getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), -1));
+ }
}
}
}
@@ -2134,8 +2204,8 @@ BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine
}
bbox->x = (int) min.x;
bbox->y = (int) min.y;
- bbox->width = (int) ceil((max.x - min.x)) + 1;
- bbox->height = (int) ceil(max.y - min.y) + 1;
+ bbox->width = (int) ceil((max.x - min.x));
+ bbox->height = (int) ceil(max.y - min.y);
return GD_TRUE;
}
@@ -2233,9 +2303,9 @@ BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMet
case GD_DEFAULT:
id = GD_LINEAR;
im->interpolation = filter_linear;
+ break;
default:
return 0;
- break;
}
im->interpolation_id = id;
return 1;
diff --git a/src/gd_io.c b/src/gd_io.c
index 03b8347..9403277 100644
--- a/src/gd_io.c
+++ b/src/gd_io.c
@@ -28,22 +28,6 @@
return 0; \
}
-/*
- * Write out a word to the I/O context pointer
- */
-void Putword(int w, gdIOCtx *ctx)
-{
- unsigned char buf[2];
- buf[0] = w & 0xff;
- buf[1] = (w / 256) & 0xff;
- (ctx->putBuf)(ctx, (char *)buf, 2);
-}
-
-void Putchar(int c, gdIOCtx *ctx)
-{
- (ctx->putC)(ctx, c & 0xff);
-}
-
void gdPutC(const unsigned char c, gdIOCtx *ctx)
{
(ctx->putC)(ctx, c);
@@ -129,7 +113,7 @@ int gdGetWordLSB(signed short int *result, gdIOCtx *ctx)
int gdGetInt(int *result, gdIOCtx *ctx)
{
- int r;
+ unsigned int r;
r = (ctx->getC)(ctx);
if(r == EOF) {
@@ -164,7 +148,7 @@ int gdGetInt(int *result, gdIOCtx *ctx)
int gdGetIntLSB(signed int *result, gdIOCtx *ctx)
{
- int c = 0;
+ unsigned int c;
unsigned int r = 0;
c = (ctx->getC) (ctx);
diff --git a/src/gd_io.h b/src/gd_io.h
index 1039d59..df37fcc 100644
--- a/src/gd_io.h
+++ b/src/gd_io.h
@@ -1,14 +1,10 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef GD_IO_H
#define GD_IO_H 1
#include <stdio.h>
-#ifdef VMS
-# define Putchar gdPutchar
+#ifdef __cplusplus
+extern "C" {
#endif
/*
@@ -17,7 +13,7 @@ extern "C" {
typedef: gdIOCtx
gdIOCtx structures hold function pointers for doing image IO.
-
+
Most of the gd functions that read and write files, such as
<gdImagePng> also have variants that accept a <gdIOCtx> structure;
see <gdImagePngCtx> and <gdImageCreateFromJpegCtx>.
@@ -45,14 +41,14 @@ extern "C" {
> {
> int (*getC) (struct gdIOCtx *);
> int (*getBuf) (struct gdIOCtx *, void *, int wanted);
- >
+ >
> void (*putC) (struct gdIOCtx *, int);
> int (*putBuf) (struct gdIOCtx *, const void *, int wanted);
- >
- > // seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ >
+ > // seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
> int (*seek) (struct gdIOCtx *, const int);
> long (*tell) (struct gdIOCtx *);
- >
+ >
> void (*gd_free) (struct gdIOCtx *);
> } gdIOCtx;
@@ -74,9 +70,6 @@ typedef struct gdIOCtx {
typedef struct gdIOCtx *gdIOCtxPtr;
-void Putword(int w, gdIOCtx *ctx);
-void Putchar(int c, gdIOCtx *ctx);
-
void gdPutC(const unsigned char c, gdIOCtx *ctx);
int gdPutBuf(const void *, int, gdIOCtx *);
void gdPutWord(int w, gdIOCtx *ctx);
@@ -93,8 +86,8 @@ int gdGetIntLSB(signed int *result, gdIOCtx *ctx);
int gdSeek(gdIOCtx *ctx, const int offset);
long gdTell(gdIOCtx *ctx);
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/src/gd_io_dp.c b/src/gd_io_dp.c
index 135eda3..ec259e7 100644
--- a/src/gd_io_dp.c
+++ b/src/gd_io_dp.c
@@ -6,7 +6,7 @@
* Based on GD.pm code by Lincoln Stein for interfacing to libgd.
* Added support for reading as well as support for 'tell' and 'seek'.
*
- * As will all I/O modules, most functions are for local use only (called
+ * As with all I/O modules, most functions are for local use only (called
* via function pointers in the I/O context).
*
* gdDPExtractData is the exception to this: it will return the pointer to
@@ -180,6 +180,9 @@ static int dynamicSeek(struct gdIOCtx *ctx, const int pos)
dynamicPtr *dp;
dpIOCtx *dctx;
+ if (pos < 0) {
+ return FALSE;
+ }
dctx = (dpIOCtx *)ctx;
dp = dctx->dp;
@@ -263,6 +266,7 @@ static void dynamicPutchar(struct gdIOCtx *ctx, int a)
appendDynamic(dctx->dp, &b, 1);
}
+/* returns the number of bytes actually read; 0 on EOF and error */
static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len)
{
int rlen, remain;
@@ -272,21 +276,29 @@ static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len)
dctx = (dpIOCtxPtr) ctx;
dp = dctx->dp;
+ if (dp->pos < 0 || dp->pos >= dp->realSize) {
+ return 0;
+ }
+
remain = dp->logicalSize - dp->pos;
if(remain >= len) {
rlen = len;
} else {
- if(remain == 0) {
- /* 2.0.34: EOF is incorrect. We use 0 for
- * errors and EOF, just like fileGetbuf,
- * which is a simple fread() wrapper.
- * TBB. Original bug report: Daniel Cowgill. */
- return 0; /* NOT EOF */
+ if(remain <= 0) {
+ return 0;
}
rlen = remain;
}
+ if (dp->pos + rlen > dp->realSize) {
+ rlen = dp->realSize - dp->pos;
+ }
+
+ if (rlen < 0) {
+ return 0;
+ }
+
memcpy(buf, (void *) ((char *)dp->data + dp->pos), rlen);
dp->pos += rlen;
diff --git a/src/gd_io_stream.cxx b/src/gd_io_stream.cxx
index 28021af..0d64c72 100644
--- a/src/gd_io_stream.cxx
+++ b/src/gd_io_stream.cxx
@@ -1,12 +1,11 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
*******************************************************************************/
/** \file gd_io_stream.cxx
\brief Implementation of the methods of the gdIOCtx std stream specialization.
-
+
Implements the derived specializations of gdIOCtx.
These methods are not called by users of libgd, they
are internal implementation.
@@ -22,7 +21,7 @@
#include "gd_io_stream.h"
/** Read into buffer from stream
- Return the number of bytes successfully read.
+ Return the number of bytes successfully read.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -33,7 +32,7 @@ int istreamIOCtx::Getbuf (struct gdIOCtx * ctx, void * buf, int size)
return _str->gcount();
}
/** Write from buffer to stream
- Return the number of bytes successfully written.
+ Return the number of bytes successfully written.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -58,7 +57,7 @@ void istreamIOCtx::Putchar (struct gdIOCtx * , int )
}
/** Seek to position offset from the beginning of the stream
- must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
*/
int istreamIOCtx::Seek (struct gdIOCtx * ctx, const int pos)
{
@@ -82,7 +81,7 @@ void istreamIOCtx::FreeCtx (struct gdIOCtx * ctx)
}
/** Read into buffer from stream
- Return the number of bytes successfully read.
+ Return the number of bytes successfully read.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -91,7 +90,7 @@ int ostreamIOCtx::Getbuf (struct gdIOCtx * , void * , int )
return 0;
}
/** Write from buffer to stream
- Return the number of bytes successfully written.
+ Return the number of bytes successfully written.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -119,7 +118,7 @@ void ostreamIOCtx::Putchar (struct gdIOCtx * ctx, int c)
}
/** Seek to position offset from the beginning of the stream
- must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
*/
int ostreamIOCtx::Seek (struct gdIOCtx * ctx, const int pos)
{
diff --git a/src/gd_io_stream.h b/src/gd_io_stream.h
index 703548f..dd76d77 100644
--- a/src/gd_io_stream.h
+++ b/src/gd_io_stream.h
@@ -1,5 +1,4 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
@@ -27,9 +26,9 @@
}
gdImageDestroy(im_in);
*/
-#ifdef __cplusplus
#ifndef _gd_io_stream_h
#define _gd_io_stream_h
+#ifdef __cplusplus
#include "gd.h"
#include <iostream>
@@ -122,5 +121,5 @@ inline gdIOCtx * gdNewOstreamCtx (std::ostream * __stream)
return new ostreamIOCtx(* __stream);
}
-#endif /* _gd_io_stream_h */
#endif /* __cplusplus */
+#endif /* _gd_io_stream_h */
diff --git a/src/gd_jpeg.c b/src/gd_jpeg.c
index 744f229..f2dd329 100644
--- a/src/gd_jpeg.c
+++ b/src/gd_jpeg.c
@@ -47,12 +47,6 @@
# define HAVE_BOOLEAN
#endif
-/* JCE undef two symbols that we don't need anymore but which are
- may be defined in config.h from ./configure but which are
- redefined incompatibly in jpeglib.h */
-#undef HAVE_STDDEF_H
-#undef HAVE_STDLIB_H
-
/* 1.8.1: remove dependency on jinclude.h */
#include "jpeglib.h"
#include "jerror.h"
@@ -108,7 +102,7 @@ static void fatal_jpeg_error(j_common_ptr cinfo)
char buffer[JMSG_LENGTH_MAX];
(*cinfo->err->format_message)(cinfo, buffer);
- gd_error_ex(GD_ERROR, "gd-jpeg: JPEG library reports unrecoverable error: %s", buffer);
+ gd_error_ex(GD_WARNING, "gd-jpeg: JPEG library reports unrecoverable error: %s", buffer);
jmpbufw = (jmpbuf_wrapper *)cinfo->client_data;
jpeg_destroy(cinfo);
@@ -123,6 +117,8 @@ static void fatal_jpeg_error(j_common_ptr cinfo)
exit(99);
}
+static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality);
+
/*
* Write IM to OUTFILE as a JFIF-formatted JPEG image, using quality
* QUALITY. If QUALITY is in the range 0-100, increasing values
@@ -237,8 +233,11 @@ BGD_DECLARE(void *) gdImageJpegPtr(gdImagePtr im, int *size, int quality)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageJpegCtx(im, out, quality);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageJpegCtx(im, out, quality)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -255,11 +254,17 @@ void jpeg_gdIOCtx_dest(j_compress_ptr cinfo, gdIOCtx *outfile);
im - The image to write.
outfile - The output sink.
- quality - Image quality.
+ quality - Image quality.
*/
BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
{
+ _gdImageJpegCtx(im, outfile, quality);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
+{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
int i, j, jidx;
@@ -293,7 +298,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
if(row) {
gdFree(row);
}
- return;
+ return 1;
}
cinfo.err->emit_message = jpeg_emit_message;
@@ -334,7 +339,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
if(row == 0) {
gd_error("gd-jpeg: error: unable to allocate JPEG row structure: gdCalloc returns NULL\n");
jpeg_destroy_compress(&cinfo);
- return;
+ return 1;
}
rowptr[0] = row;
@@ -411,6 +416,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
gdFree(row);
+ return 0;
}
@@ -496,7 +502,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning
Function: gdImageCreateFromJpegPtr
Parameters:
-
+
size - size of JPEG data in bytes.
data - pointer to JPEG data.
@@ -511,7 +517,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr(int size, void *data)
Function: gdImageCreateFromJpegPtrEx
Parameters:
-
+
size - size of JPEG data in bytes.
data - pointer to JPEG data.
ignore_warning - if true, ignore recoverable warnings
@@ -1198,4 +1204,63 @@ void jpeg_gdIOCtx_dest(j_compress_ptr cinfo, gdIOCtx *outfile)
dest->outfile = outfile;
}
+#else /* !HAVE_LIBJPEG */
+
+static void _noJpegError(void)
+{
+ gd_error("JPEG image support has been disabled\n");
+}
+
+BGD_DECLARE(void) gdImageJpeg(gdImagePtr im, FILE *outFile, int quality)
+{
+ _noJpegError();
+}
+
+BGD_DECLARE(void *) gdImageJpegPtr(gdImagePtr im, int *size, int quality)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
+{
+ _noJpegError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg(FILE *inFile)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr(int size, void *data)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx(int size, void *data, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx(gdIOCtx *infile)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx(gdIOCtx *infile, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
#endif /* HAVE_LIBJPEG */
diff --git a/src/gd_matrix.c b/src/gd_matrix.c
index b7827a0..ada63e6 100644
--- a/src/gd_matrix.c
+++ b/src/gd_matrix.c
@@ -57,13 +57,13 @@ BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src,
* <gdAffineIdentity>
*
* Returns:
- * GD_TRUE if the affine is rectilinear or GD_FALSE
+ * GD_TRUE on success or GD_FALSE on failure
*/
BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6])
{
double r_det = (src[0] * src[3] - src[1] * src[2]);
- if (r_det <= 0.0) {
+ if (fabs(r_det) <= 0.0) {
return GD_FALSE;
}
@@ -333,4 +333,3 @@ BGD_DECLARE(int) gdAffineEqual (const double m1[6], const double m2[6])
fabs (m1[4] - m2[4]) < GD_EPSILON &&
fabs (m1[5] - m2[5]) < GD_EPSILON);
}
-
diff --git a/src/gd_nnquant.c b/src/gd_nnquant.c
index 19190b7..8b9aa79 100644
--- a/src/gd_nnquant.c
+++ b/src/gd_nnquant.c
@@ -65,7 +65,6 @@
/* defs for decreasing alpha factor */
#define alphabiasshift 10 /* alpha starts at 1.0 */
#define initalpha (((int) 1)<<alphabiasshift)
-int alphadec;
/* radbias and alpharadbias used for radpower calculation */
#define radbiasshift 8
@@ -113,7 +112,7 @@ typedef struct {
/* Initialise network in range (0,0,0,0) to (255,255,255,255) and set parameters
----------------------------------------------------------------------- */
-void initnet(nnq, thepic, len, sample, colours)
+static void initnet(nnq, thepic, len, sample, colours)
nn_quant *nnq;
unsigned char *thepic;
int len;
@@ -147,7 +146,7 @@ int colours;
*/
/* -------------------------- */
-void unbiasnet(nn_quant *nnq)
+static void unbiasnet(nn_quant *nnq)
{
int i,j,temp;
@@ -163,21 +162,8 @@ void unbiasnet(nn_quant *nnq)
}
}
-/* Output colour map
- ----------------- */
-void writecolourmap(nnq, f)
-nn_quant *nnq;
-FILE *f;
-{
- int i,j;
-
- for (i=3; i>=0; i--)
- for (j=0; j < nnq->netsize; j++)
- putc(nnq->network[j][i], f);
-}
-
/* Output colormap to unsigned char ptr in RGBA format */
-void getcolormap(nnq, map)
+static void getcolormap(nnq, map)
nn_quant *nnq;
unsigned char *map;
{
@@ -192,7 +178,7 @@ unsigned char *map;
/* Insertion sort of network and building of netindex[0..255] (to do after unbias)
------------------------------------------------------------------------------- */
-void inxbuild(nn_quant *nnq)
+static void inxbuild(nn_quant *nnq)
{
register int i,j,smallpos,smallval;
register int *p,*q;
@@ -246,7 +232,7 @@ void inxbuild(nn_quant *nnq)
/* Search for ABGR values 0..255 (after net is unbiased) and return colour index
---------------------------------------------------------------------------- */
-unsigned int inxsearch(nnq, al,b,g,r)
+static unsigned int inxsearch(nnq, al,b,g,r)
nn_quant *nnq;
register int al, b, g, r;
{
@@ -320,7 +306,7 @@ register int al, b, g, r;
/* Search for biased ABGR values
---------------------------- */
-int contest(nnq, al,b,g,r)
+static int contest(nnq, al,b,g,r)
nn_quant *nnq;
register int al,b,g,r;
{
@@ -376,7 +362,7 @@ register int al,b,g,r;
/* Move neuron i towards biased (a,b,g,r) by factor alpha
---------------------------------------------------- */
-void altersingle(nnq, alpha,i,al,b,g,r)
+static void altersingle(nnq, alpha,i,al,b,g,r)
nn_quant *nnq;
register int alpha,i,al,b,g,r;
{
@@ -396,7 +382,7 @@ register int alpha,i,al,b,g,r;
/* Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|]
--------------------------------------------------------------------------------- */
-void alterneigh(nnq, rad,i,al,b,g,r)
+static void alterneigh(nnq, rad,i,al,b,g,r)
nn_quant *nnq;
int rad,i;
register int al,b,g,r;
@@ -443,7 +429,7 @@ register int al,b,g,r;
/* Main Learning Loop
------------------ */
-void learn(nnq, verbose) /* Stu: N.B. added parameter so that main() could control verbosity. */
+static void learn(nnq, verbose) /* Stu: N.B. added parameter so that main() could control verbosity. */
nn_quant *nnq;
int verbose;
{
@@ -464,7 +450,7 @@ int verbose;
radius = initradius;
rad = radius >> radiusbiasshift;
-
+
for (i=0; i<rad; i++)
nnq->radpower[i] = alpha*(((rad*rad - i*i)*radbias)/(rad*rad));
diff --git a/src/gd_nnquant.h b/src/gd_nnquant.h
index b054fb1..11643b7 100644
--- a/src/gd_nnquant.h
+++ b/src/gd_nnquant.h
@@ -1,4 +1,3 @@
-
/* maximum number of colours that can be used.
actual number is now passed to initcolors */
#define MAXNETSIZE 256
@@ -15,5 +14,3 @@
#define prime4 503
#define minpicturebytes (4*prime4) /* minimum size for input image */
-
-
diff --git a/src/gd_png.c b/src/gd_png.c
index db8de72..8119cf3 100644
--- a/src/gd_png.c
+++ b/src/gd_png.c
@@ -1,4 +1,3 @@
-/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -68,7 +67,7 @@ gdPngErrorHandler (png_structp png_ptr, png_const_charp msg)
* regardless of whether _BSD_SOURCE or anything else has (or has not)
* been defined. */
- gd_error_ex(GD_ERROR, "gd-png: fatal libpng error: %s\n", msg);
+ gd_error_ex(GD_WARNING, "gd-png: fatal libpng error: %s\n", msg);
jmpbuf_ptr = png_get_error_ptr (png_ptr);
if (jmpbuf_ptr == NULL) { /* we are completely hosed now */
@@ -592,7 +591,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
gdImagePtr im;
int black, white;
FILE *out;
-
+
im = gdImageCreate(100, 100); // Create the image
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
@@ -634,6 +633,7 @@ BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * outFile)
out->gd_free (out);
}
+static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level);
/*
Function: gdImagePngPtr
@@ -657,8 +657,11 @@ BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size)
void *rv;
gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
if (out == NULL) return NULL;
- gdImagePngCtxEx (im, out, -1);
- rv = gdDPExtractData (out, size);
+ if (!_gdImagePngCtxEx (im, out, -1)) {
+ rv = gdDPExtractData (out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free (out);
return rv;
}
@@ -692,8 +695,11 @@ BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level)
void *rv;
gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
if (out == NULL) return NULL;
- gdImagePngCtxEx (im, out, level);
- rv = gdDPExtractData (out, size);
+ if (!_gdImagePngCtxEx (im, out, level)) {
+ rv = gdDPExtractData (out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free (out);
return rv;
}
@@ -742,12 +748,17 @@ BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
Nothing.
*/
+BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
+{
+ _gdImagePngCtxEx(im, outfile, level);
+}
/* This routine is based in part on code from Dale Lutz (Safe Software Inc.)
* and in part on demo code from Chapter 15 of "PNG: The Definitive Guide"
* (http://www.libpng.org/pub/png/book/).
*/
-BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
+/* returns 0 on success, 1 on failure */
+static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level)
{
int i, j, bit_depth = 0, interlace_type;
int width = im->sx;
@@ -760,15 +771,17 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
png_color palette[gdMaxColors];
png_structp png_ptr;
png_infop info_ptr;
+ png_bytep *row_pointers = NULL;
volatile int transparent = im->transparent;
volatile int remap = FALSE;
#ifdef PNG_SETJMP_SUPPORTED
jmpbuf_wrapper jbw;
#endif
+ int ret = 0;
/* width or height of value 0 is invalid in IHDR;
see http://www.w3.org/TR/PNG-Chunks.html */
- if (width == 0 || height ==0) return;
+ if (width == 0 || height ==0) return 1;
#ifdef PNG_SETJMP_SUPPORTED
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING,
@@ -779,21 +792,28 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
#endif
if (png_ptr == NULL) {
gd_error("gd-png error: cannot allocate libpng main struct\n");
- return;
+ return 1;
}
info_ptr = png_create_info_struct (png_ptr);
if (info_ptr == NULL) {
gd_error("gd-png error: cannot allocate libpng info struct\n");
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
- return;
+ return 1;
}
#ifdef PNG_SETJMP_SUPPORTED
if (setjmp(jbw.jmpbuf)) {
gd_error("gd-png error: setjmp returns error condition\n");
png_destroy_write_struct (&png_ptr, &info_ptr);
- return;
+
+ if (row_pointers) {
+ for (i = 0; i < height; ++i)
+ gdFree(row_pointers[i]);
+ gdFree(row_pointers);
+ }
+
+ return 1;
}
#endif
@@ -845,6 +865,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
}
if (colors == 0) {
gd_error("gd-png error: no colors in palette\n");
+ ret = 1;
goto bail;
}
if (colors < im->colorsTotal) {
@@ -967,7 +988,6 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
/* performance optimizations by Phong Tran */
int channels = im->saveAlphaFlag ? 4 : 3;
/* Our little 7-bit alpha channel trick costs us a bit here. */
- png_bytep *row_pointers;
unsigned char *pOutputRow;
int **ptpixels = im->tpixels;
int *pThisRow;
@@ -976,11 +996,14 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
png_bytep *prow_pointers;
int saveAlphaFlag = im->saveAlphaFlag;
if (overflow2(sizeof (png_bytep), height)) {
+ ret = 1;
goto bail;
}
- row_pointers = gdMalloc (sizeof (png_bytep) * height);
+ /* Need to use calloc so we can clean it up sanely in the error handler. */
+ row_pointers = gdCalloc(height, sizeof (png_bytep));
if (row_pointers == NULL) {
gd_error("gd-png error: unable to allocate row_pointers\n");
+ ret = 1;
goto bail;
}
prow_pointers = row_pointers;
@@ -992,6 +1015,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
gdFree (row_pointers[i]);
/* 2.0.29: memory leak TBB */
gdFree(row_pointers);
+ ret = 1;
goto bail;
}
pOutputRow = *prow_pointers++;
@@ -1025,11 +1049,13 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
if (remap) {
png_bytep *row_pointers;
if (overflow2(sizeof (png_bytep), height)) {
+ ret = 1;
goto bail;
}
row_pointers = gdMalloc (sizeof (png_bytep) * height);
if (row_pointers == NULL) {
gd_error("gd-png error: unable to allocate row_pointers\n");
+ ret = 1;
goto bail;
}
for (j = 0; j < height; ++j) {
@@ -1039,6 +1065,7 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
gdFree (row_pointers[i]);
/* TBB: memory leak */
gdFree (row_pointers);
+ ret = 1;
goto bail;
}
for (i = 0; i < width; ++i)
@@ -1059,7 +1086,60 @@ BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
/* 1.6.3: maybe we should give that memory BACK! TBB */
bail:
png_destroy_write_struct (&png_ptr, &info_ptr);
+ return ret;
}
+#else /* !HAVE_LIBPNG */
+
+static void _noPngError(void)
+{
+ gd_error("PNG image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * inFile)
+{
+ _noPngError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data)
+{
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * outFile, int level)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * outFile)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
+{
+ _noPngError();
+}
#endif /* HAVE_LIBPNG */
diff --git a/src/gd_rotate.c b/src/gd_rotate.c
index 3f7b5e6..3d70250 100644
--- a/src/gd_rotate.c
+++ b/src/gd_rotate.c
@@ -362,182 +362,3 @@ gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent)
return dst;
}
-
-gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-{
- gdImagePtr dst1,dst2,dst3;
- double dRadAngle, dSinE, dTan, dShear;
- double dOffset; /* Variable skew offset */
- int u, iShear, newx, newy;
- int clrBackR, clrBackG, clrBackB, clrBackA;
-
- /* See GEMS I for the algorithm details */
- dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
- dSinE = sin (dRadAngle);
- dTan = tan (dRadAngle / 2.0);
-
- newx = (int)(src->sx + src->sy * fabs(dTan));
- newy = src->sy;
-
- /* 1st shear */
- dst1 = gdImageCreateTrueColor(newx, newy);
- /******* Perform 1st shear (horizontal) ******/
- if (dst1 == NULL) {
- return NULL;
- }
- gdImageAlphaBlending(dst1, 0);
- if (dAngle == 0.0) {
- /* Returns copy of src */
- gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy);
- return dst1;
- }
-
- gdImagePaletteCopy (dst1, src);
-
- if (ignoretransparent) {
- if (gdImageTrueColor(src)) {
- dst1->transparent = src->transparent;
- } else {
-
- dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127);
- }
- }
-
- for (u = 0; u < dst1->sy; u++) {
- if (dTan >= 0.0) {
- dShear = ((double)(u + 0.5)) * dTan;
- } else {
- dShear = ((double)(u - dst1->sy) + 0.5) * dTan;
- }
-
- iShear = (int)floor(dShear);
- gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent);
- }
-
- /*
- The 1st shear may use the original clrBack as color index
- Convert it once here
- */
- if(!src->trueColor) {
- clrBackR = gdImageRed(src, clrBack);
- clrBackG = gdImageGreen(src, clrBack);
- clrBackB = gdImageBlue(src, clrBack);
- clrBackA = gdImageAlpha(src, clrBack);
- clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
- }
- /* 2nd shear */
- newx = dst1->sx;
-
- if (dSinE > 0.0) {
- dOffset = (src->sx-1) * dSinE;
- } else {
- dOffset = -dSinE * (src->sx - newx);
- }
-
- newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;
-
- dst2 = gdImageCreateTrueColor(newx, newy);
- if (dst2 == NULL) {
- gdImageDestroy(dst1);
- return NULL;
- }
-
- gdImageAlphaBlending(dst2, 0);
-
- if (ignoretransparent) {
- dst2->transparent = dst1->transparent;
- }
-
- for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) {
- iShear = (int)floor (dOffset);
- gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent);
- }
-
- /* 3rd shear */
- gdImageDestroy(dst1);
-
- newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
- newy = dst2->sy;
-
- dst3 = gdImageCreateTrueColor(newx, newy);
- if (dst3 == NULL) {
- gdImageDestroy(dst2);
- return NULL;
- }
-
- gdImageAlphaBlending(dst3, 0);
-
- if (ignoretransparent) {
- dst3->transparent = dst2->transparent;
- }
-
- if (dSinE >= 0.0) {
- dOffset = (double)(src->sx - 1) * dSinE * -dTan;
- } else {
- dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy));
- }
-
- for (u = 0; u < dst3->sy; u++, dOffset += dTan) {
- int iShear = (int)floor(dOffset);
- gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent);
- }
-
- gdImageDestroy(dst2);
-
- return dst3;
-}
-
-gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-{
- gdImagePtr pMidImg;
- gdImagePtr rotatedImg;
-
- if (src == NULL) {
- return NULL;
- }
-
- if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) {
- return NULL;
- }
-
- while (dAngle >= 360.0) {
- dAngle -= 360.0;
- }
-
- while (dAngle < 0) {
- dAngle += 360.0;
- }
-
- if (dAngle == 90.00) {
- return gdImageRotate90(src, ignoretransparent);
- }
- if (dAngle == 180.00) {
- return gdImageRotate180(src, ignoretransparent);
- }
- if(dAngle == 270.00) {
- return gdImageRotate270 (src, ignoretransparent);
- }
-
- if ((dAngle > 45.0) && (dAngle <= 135.0)) {
- pMidImg = gdImageRotate90 (src, ignoretransparent);
- dAngle -= 90.0;
- } else if ((dAngle > 135.0) && (dAngle <= 225.0)) {
- pMidImg = gdImageRotate180 (src, ignoretransparent);
- dAngle -= 180.0;
- } else if ((dAngle > 225.0) && (dAngle <= 315.0)) {
- pMidImg = gdImageRotate270 (src, ignoretransparent);
- dAngle -= 270.0;
- } else {
- return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent);
- }
-
- if (pMidImg == NULL) {
- return NULL;
- }
-
- rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent);
- gdImageDestroy(pMidImg);
-
- return rotatedImg;
-}
-/* End Rotate function */
diff --git a/src/gd_tga.c b/src/gd_tga.c
index 8737b04..cae9428 100644
--- a/src/gd_tga.c
+++ b/src/gd_tga.c
@@ -206,7 +206,7 @@ int read_header_tga(gdIOCtx *ctx, oTga *tga)
int read_image_tga( gdIOCtx *ctx, oTga *tga )
{
int pixel_block_size = (tga->bits / 8);
- int image_block_size = (tga->width * tga->height) * pixel_block_size;
+ int image_block_size;
int* decompression_buffer = NULL;
unsigned char* conversion_buffer = NULL;
int buffer_caret = 0;
@@ -223,6 +223,7 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
return -1;
}
+ image_block_size = (tga->width * tga->height) * pixel_block_size;
if(overflow2(image_block_size, sizeof(int))) {
return -1;
}
@@ -295,12 +296,19 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
buffer_caret = 0;
while( bitmap_caret < image_block_size ) {
-
+
+ if (buffer_caret + pixel_block_size > rle_size) {
+ gdFree( decompression_buffer );
+ gdFree( conversion_buffer );
+ return -1;
+ }
+
if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) {
encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 );
buffer_caret++;
- if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) {
+ if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size
+ || buffer_caret + pixel_block_size > rle_size) {
gdFree( decompression_buffer );
gdFree( conversion_buffer );
return -1;
@@ -316,7 +324,8 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
encoded_pixels = decompression_buffer[ buffer_caret ] + 1;
buffer_caret++;
- if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size) {
+ if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size
+ || buffer_caret + (encoded_pixels * pixel_block_size) > rle_size) {
gdFree( decompression_buffer );
gdFree( conversion_buffer );
return -1;
diff --git a/src/gd_tiff.c b/src/gd_tiff.c
index b4f1e63..699d719 100644
--- a/src/gd_tiff.c
+++ b/src/gd_tiff.c
@@ -27,7 +27,6 @@
----------------------------------------------------------------------------
*/
-/* $Id$ */
/**
* File: TIFF IO
@@ -44,6 +43,7 @@
#include "gd.h"
#include "gd_errors.h"
+#include "gd_intern.h"
#include "gdfonts.h"
#include <stdio.h>
#include <stdlib.h>
@@ -72,10 +72,6 @@
#define GD_INDEXED 4
#define GD_RGB 5
-#define MIN(a,b) (a < b) ? a : b;
-#define MAX(a,b) (a > b) ? a : b;
-
-
typedef struct tiff_handle {
int size;
int pos;
@@ -241,10 +237,10 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth)
int transparentColorR = -1;
int transparentColorG = -1;
int transparentColorB = -1;
- uint16 extraSamples[1];
- uint16 *colorMapRed = NULL;
- uint16 *colorMapGreen = NULL;
- uint16 *colorMapBlue = NULL;
+ uint16_t extraSamples[1];
+ uint16_t *colorMapRed = NULL;
+ uint16_t *colorMapGreen = NULL;
+ uint16_t *colorMapBlue = NULL;
tiff_handle *th;
@@ -296,18 +292,18 @@ void tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth)
/* build the color map for 8 bit images */
if(bitDepth != 24) {
- colorMapRed = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
+ colorMapRed = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample));
if (!colorMapRed) {
gdFree(th);
return;
}
- colorMapGreen = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
+ colorMapGreen = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample));
if (!colorMapGreen) {
gdFree(colorMapRed);
gdFree(th);
return;
}
- colorMapBlue = (uint16 *) gdMalloc(3 * (1 << bitsPerSample));
+ colorMapBlue = (uint16_t *) gdMalloc(3 * (1 << bitsPerSample));
if (!colorMapBlue) {
gdFree(colorMapRed);
gdFree(colorMapGreen);
@@ -452,7 +448,7 @@ BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out)
/* Check if we are really in 8bit mode */
static int checkColorMap(n, r, g, b)
int n;
-uint16 *r, *g, *b;
+uint16_t *r, *g, *b;
{
while (n-- > 0)
if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
@@ -464,8 +460,8 @@ uint16 *r, *g, *b;
/* Read and convert a TIFF colormap */
static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometric)
{
- uint16 *redcmap, *greencmap, *bluecmap;
- uint16 bps;
+ uint16_t *redcmap, *greencmap, *bluecmap;
+ uint16_t bps;
int i;
if (is_bw) {
@@ -477,7 +473,7 @@ static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometri
gdImageColorAllocate(im, 255,255,255);
}
} else {
- uint16 min_sample_val, max_sample_val;
+ uint16_t min_sample_val, max_sample_val;
if (!TIFFGetField(tif, TIFFTAG_MINSAMPLEVALUE, &min_sample_val)) {
min_sample_val = 0;
@@ -519,7 +515,7 @@ static int readTiffColorMap(gdImagePtr im, TIFF *tif, char is_bw, int photometri
static void readTiffBw (const unsigned char *src,
gdImagePtr im,
- uint16 photometric,
+ uint16_t photometric,
int startx,
int starty,
int width,
@@ -535,14 +531,14 @@ static void readTiffBw (const unsigned char *src,
(void)align;
for (y = starty; y < starty + height; y++) {
- for (x = startx; x < startx + width; x++) {
+ for (x = startx; x < startx + width;) {
register unsigned char curr = *src++;
register unsigned char mask;
if (photometric == PHOTOMETRIC_MINISWHITE) {
curr = ~curr;
}
- for (mask = 0x80; mask != 0 && x < startx + width; mask >>= 1) {
+ for (mask = 0x80; mask != 0 && x < startx + width; x++, mask >>= 1) {
gdImageSetPixel(im, x, y, ((curr & mask) != 0)?0:1);
}
}
@@ -551,7 +547,7 @@ static void readTiffBw (const unsigned char *src,
static void readTiff8bit (const unsigned char *src,
gdImagePtr im,
- uint16 photometric,
+ uint16_t photometric,
int startx,
int starty,
int width,
@@ -638,14 +634,15 @@ static void readTiff8bit (const unsigned char *src,
}
}
-static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16 bps, uint16 photometric,
+static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16_t bps, uint16_t photometric,
char has_alpha, char is_bw, int extra)
{
- uint16 planar;
+ uint16_t planar;
int im_width, im_height;
int tile_width, tile_height;
int x, y, height, width;
unsigned char *buffer;
+ int success = GD_SUCCESS;
if (!TIFFGetField (tif, TIFFTAG_PLANARCONFIG, &planar)) {
planar = PLANARCONFIG_CONTIG;
@@ -664,7 +661,10 @@ static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16 bps, uint16 phot
for (y = 0; y < im_height; y += tile_height) {
for (x = 0; x < im_width; x += tile_width) {
- TIFFReadTile(tif, buffer, x, y, 0, 0);
+ if (TIFFReadTile(tif, buffer, x, y, 0, 0) < 0) {
+ success = GD_FAILURE;
+ goto end;
+ }
width = MIN(im_width - x, tile_width);
height = MIN(im_height - y, tile_height);
if (bps == 16) {
@@ -677,17 +677,19 @@ static int createFromTiffTiles(TIFF *tif, gdImagePtr im, uint16 bps, uint16 phot
}
}
}
+end:
gdFree(buffer);
- return TRUE;
+ return success;
}
-static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16 bps, uint16 photometric,
+static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16_t bps, uint16_t photometric,
char has_alpha, char is_bw, int extra)
{
- uint16 planar;
- uint32 im_height, im_width, y;
+ uint16_t planar;
+ uint32_t im_height, im_width, y;
unsigned char *buffer;
+ int success = GD_SUCCESS;
if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planar)) {
planar = PLANARCONFIG_CONTIG;
@@ -717,8 +719,9 @@ static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16 bps, uint16 phot
case 8:
for (y = 0; y < im_height; y++ ) {
- if (!TIFFReadScanline (tif, buffer, y, 0)) {
+ if (TIFFReadScanline (tif, buffer, y, 0) < 0) {
gd_error("Error while reading scanline %i", y);
+ success = GD_FAILURE;
break;
}
/* reading one line at a time */
@@ -729,8 +732,9 @@ static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16 bps, uint16 phot
default:
if (is_bw) {
for (y = 0; y < im_height; y++ ) {
- if (!TIFFReadScanline (tif, buffer, y, 0)) {
+ if (TIFFReadScanline (tif, buffer, y, 0) < 0) {
gd_error("Error while reading scanline %i", y);
+ success = GD_FAILURE;
break;
}
/* reading one line at a time */
@@ -746,7 +750,7 @@ static int createFromTiffLines(TIFF *tif, gdImagePtr im, uint16 bps, uint16 phot
}
gdFree(buffer);
- return GD_SUCCESS;
+ return success;
}
static int createFromTiffRgba(TIFF * tif, gdImagePtr im)
@@ -757,8 +761,14 @@ static int createFromTiffRgba(TIFF * tif, gdImagePtr im)
int color;
int width = im->sx;
int height = im->sy;
- uint32 *buffer;
- uint32 rgba;
+ uint32_t *buffer;
+ uint32_t rgba;
+ int success;
+
+ buffer = (uint32_t *) gdCalloc(sizeof(uint32_t), width * height);
+ if (!buffer) {
+ return GD_FAILURE;
+ }
/* switch off colour merging on target gd image just while we write out
* content - we want to preserve the alpha data until the user chooses
@@ -766,23 +776,20 @@ static int createFromTiffRgba(TIFF * tif, gdImagePtr im)
alphaBlendingFlag = im->alphaBlendingFlag;
gdImageAlphaBlending(im, 0);
- buffer = (uint32 *) gdCalloc(sizeof(uint32), width * height);
- if (!buffer) {
- return GD_FAILURE;
- }
+ success = TIFFReadRGBAImage(tif, width, height, buffer, 1);
- TIFFReadRGBAImage(tif, width, height, buffer, 0);
+ if (success) {
+ for(y = 0; y < height; y++) {
+ for(x = 0; x < width; x++) {
+ /* if it doesn't already exist, allocate a new colour,
+ * else use existing one */
+ rgba = buffer[(y * width + x)];
+ a = (0xff - TIFFGetA(rgba)) / 2;
+ color = gdTrueColorAlpha(TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), a);
- for(y = 0; y < height; y++) {
- for(x = 0; x < width; x++) {
- /* if it doesn't already exist, allocate a new colour,
- * else use existing one */
- rgba = buffer[(y * width + x)];
- a = (0xff - TIFFGetA(rgba)) / 2;
- color = gdTrueColorAlpha(TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), a);
-
- /* set pixel colour to this colour */
- gdImageSetPixel(im, x, height - y - 1, color);
+ /* set pixel colour to this colour */
+ gdImageSetPixel(im, x, height - y - 1, color);
+ }
}
}
@@ -790,7 +797,7 @@ static int createFromTiffRgba(TIFF * tif, gdImagePtr im)
/* now reset colour merge for alpha blending routines */
gdImageAlphaBlending(im, alphaBlendingFlag);
- return GD_SUCCESS;
+ return success;
}
/*
@@ -803,11 +810,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
TIFF *tif;
tiff_handle *th;
- uint16 bps, spp, photometric;
- uint16 orientation;
+ uint16_t bps, spp, photometric;
+ uint16_t orientation;
int width, height;
- uint16 extra, *extra_types;
- uint16 planar;
+ uint16_t extra, *extra_types;
+ uint16_t planar;
char has_alpha, is_bw, is_gray;
char force_rgba = FALSE;
char save_transparent;
@@ -849,7 +856,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
TIFFGetFieldDefaulted (tif, TIFFTAG_BITSPERSAMPLE, &bps);
/* Unsupported bps, force to RGBA */
- if (1/*bps > 8 && bps != 16*/) {
+ if (bps != 1 /*bps > 8 && bps != 16*/) {
force_rgba = TRUE;
}
@@ -860,7 +867,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
}
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photometric)) {
- uint16 compression;
+ uint16_t compression;
if (TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression) &&
(compression == COMPRESSION_CCITTFAX3 ||
compression == COMPRESSION_CCITTFAX4 ||
@@ -932,6 +939,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
break;
}
+ /* Force rgba if image has 1bps, but is not bw */
+ if (bps == 1 && !is_bw) {
+ force_rgba = TRUE;
+ }
+
if (!TIFFGetField (tif, TIFFTAG_PLANARCONFIG, &planar)) {
planar = PLANARCONFIG_CONTIG;
}
@@ -977,10 +989,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
goto error;
}
- if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &res_float)) {
+ if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &res_float)) {
im->res_x = (unsigned int)res_float; //truncate
}
- if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &res_float)) {
+ if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &res_float)) {
im->res_y = (unsigned int)res_float; //truncate
}
@@ -1054,4 +1066,45 @@ BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size)
return rv;
}
+#else
+
+static void _noTiffError(void)
+{
+ gd_error("TIFF image support has been disabled\n");
+}
+
+BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out)
+{
+ _noTiffError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile)
+{
+ _noTiffError();
+}
+
+BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size)
+{
+ _noTiffError();
+ return NULL;
+}
+
#endif
diff --git a/src/gd_topal.c b/src/gd_topal.c
index 3419512..5ac226a 100644
--- a/src/gd_topal.c
+++ b/src/gd_topal.c
@@ -1383,7 +1383,7 @@ zeroHistogram (hist3d histogram)
* method - The quantization method, see <gdPaletteQuantizationMethod>.
* speed - The quantization speed between 1 (highest quality) and
* 10 (fastest). 0 selects a method-specific default (recommended).
- *
+ *
* Returns:
* Zero if the given method is invalid or not available; non-zero otherwise.
*
@@ -1451,7 +1451,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
*
* Returns:
* A newly create palette image; NULL on failure.
- *
+ *
* See also:
* - <gdImageCreatePaletteFromTrueColor>
* - <gdImageTrueColorToPaletteSetMethod>
@@ -1523,6 +1523,15 @@ static void free_truecolor_image_data(gdImagePtr oim)
oim->tpixels = 0;
}
+#ifdef HAVE_LIBIMAGEQUANT
+/* liq requires 16 byte aligned heap memory */
+static void *malloc16(size_t size)
+{
+ void *p;
+ return posix_memalign(&p, 16, size) == 0 ? p : NULL;
+}
+#endif
+
/*
* Module initialization routine for 2-pass color quantization.
*/
@@ -1586,7 +1595,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
nim = gdImageNeuQuant(oim, colorsWanted, oim->paletteQuantizationSpeed ? oim->paletteQuantizationSpeed : 2);
if (cimP) {
*cimP = nim;
- }
+ }
if (!nim) {
return FALSE;
} else {
@@ -1601,7 +1610,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
#ifdef HAVE_LIBIMAGEQUANT
if (oim->paletteQuantizationMethod == GD_QUANT_DEFAULT ||
oim->paletteQuantizationMethod == GD_QUANT_LIQ) {
- liq_attr *attr = liq_attr_create_with_allocator(gdMalloc, gdFree);
+ liq_attr *attr = liq_attr_create_with_allocator(malloc16, free);
liq_image *image;
liq_result *remap;
int remapped_ok = 0;
diff --git a/src/gd_transform.c b/src/gd_transform.c
index 1a96daa..fae1a58 100644
--- a/src/gd_transform.c
+++ b/src/gd_transform.c
@@ -120,5 +120,3 @@ BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im)
gdImageFlipVertical(im);
gdImageFlipHorizontal(im);
}
-
-
diff --git a/src/gd_wbmp.c b/src/gd_wbmp.c
index 0028273..a49bdbe 100644
--- a/src/gd_wbmp.c
+++ b/src/gd_wbmp.c
@@ -88,6 +88,8 @@ int gd_getin(void *in)
return (gdGetC((gdIOCtx *)in));
}
+static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
+
/*
Function: gdImageWBMPCtx
@@ -101,13 +103,19 @@ int gd_getin(void *in)
*/
BGD_DECLARE(void) gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
{
+ _gdImageWBMPCtx(image, fg, out);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
+{
int x, y, pos;
Wbmp *wbmp;
/* create the WBMP */
if((wbmp = createwbmp(gdImageSX(image), gdImageSY(image), WBMP_WHITE)) == NULL) {
gd_error("Could not create WBMP\n");
- return;
+ return 1;
}
/* fill up the WBMP structure */
@@ -123,18 +131,22 @@ BGD_DECLARE(void) gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
/* write the WBMP to a gd file descriptor */
if(writewbmp(wbmp, &gd_putout, out)) {
+ freewbmp(wbmp);
gd_error("Could not save WBMP\n");
+ return 1;
}
/* des submitted this bugfix: gdFree the memory. */
freewbmp(wbmp);
+
+ return 0;
}
/*
Function: gdImageCreateFromWBMPCtx
Reads in a WBMP image via a <gdIOCtx> struct. See
- <gdImageCreateFromWBMP>.
+ <gdImageCreateFromWBMP>.
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx(gdIOCtx *infile)
{
@@ -271,8 +283,11 @@ BGD_DECLARE(void *) gdImageWBMPPtr(gdImagePtr im, int *size, int fg)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageWBMPCtx(im, fg, out);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageWBMPCtx(im, fg, out)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
diff --git a/src/gd_webp.c b/src/gd_webp.c
index b2805da..d887b71 100644
--- a/src/gd_webp.c
+++ b/src/gd_webp.c
@@ -9,7 +9,6 @@
#endif /* HAVE_CONFIG_H */
-#ifdef HAVE_LIBWEBP
#include <stdio.h>
#include <math.h>
#include <string.h>
@@ -17,6 +16,8 @@
#include "gd.h"
#include "gd_errors.h"
#include "gdhelpers.h"
+
+#ifdef HAVE_LIBWEBP
#include "webp/decode.h"
#include "webp/encode.h"
@@ -41,10 +42,10 @@
Variants:
- <gdImageCreateFromJpegPtr> creates an image from WebP data
+ <gdImageCreateFromWebpPtr> creates an image from WebP data
already in memory.
- <gdImageCreateFromJpegCtx> reads its data via the function
+ <gdImageCreateFromWebpCtx> reads its data via the function
pointers in a <gdIOCtx> structure.
Parameters:
@@ -162,37 +163,24 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
return im;
}
-/*
- Function: gdImageWebpCtx
-
- Write the image as WebP data via a <gdIOCtx>. See <gdImageWebpEx>
- for more details.
-
- Parameters:
-
- im - The image to write.
- outfile - The output sink.
- quality - Image quality.
- Returns:
-
- Nothing.
-*/
-BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
+/* returns 0 on success, 1 on failure */
+static int _gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
{
uint8_t *argb;
int x, y;
uint8_t *p;
uint8_t *out;
size_t out_size;
+ int ret = 0;
if (im == NULL) {
- return;
+ return 1;
}
if (!gdImageTrueColor(im)) {
- gd_error("Paletter image not supported by webp");
- return;
+ gd_error("Palette image not supported by webp");
+ return 1;
}
if (quality == -1) {
@@ -200,16 +188,16 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
}
if (overflow2(gdImageSX(im), 4)) {
- return;
+ return 1;
}
if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) {
- return;
+ return 1;
}
argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im));
if (!argb) {
- return;
+ return 1;
}
p = argb;
for (y = 0; y < gdImageSY(im); y++) {
@@ -225,7 +213,7 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
}
*(p++) = gdTrueColorGetRed(c);
*(p++) = gdTrueColorGetGreen(c);
- *(p++) = gdTrueColorGetBlue(c);
+ *(p++) = gdTrueColorGetBlue(c);
*(p++) = a;
}
}
@@ -236,6 +224,7 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
}
if (out_size == 0) {
gd_error("gd-webp encoding failed");
+ ret = 1;
goto freeargb;
}
gdPutBuf(out, out_size, outfile);
@@ -243,6 +232,30 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
freeargb:
gdFree(argb);
+
+ return ret;
+}
+
+
+/*
+ Function: gdImageWebpCtx
+
+ Write the image as WebP data via a <gdIOCtx>. See <gdImageWebpEx>
+ for more details.
+
+ Parameters:
+
+ im - The image to write.
+ outfile - The output sink.
+ quality - Image quality.
+
+ Returns:
+
+ Nothing.
+*/
+BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
+{
+ _gdImageWebpCtx(im, outfile, quality);
}
/*
@@ -285,7 +298,7 @@ BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quality)
if (out == NULL) {
return;
}
- gdImageWebpCtx(im, out, quality);
+ _gdImageWebpCtx(im, out, quality);
out->gd_free(out);
}
@@ -309,7 +322,7 @@ BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)
if (out == NULL) {
return;
}
- gdImageWebpCtx(im, out, -1);
+ _gdImageWebpCtx(im, out, -1);
out->gd_free(out);
}
@@ -325,8 +338,11 @@ BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size)
if (out == NULL) {
return NULL;
}
- gdImageWebpCtx(im, out, -1);
- rv = gdDPExtractData(out, size);
+ if (_gdImageWebpCtx(im, out, -1)) {
+ rv = NULL;
+ } else {
+ rv = gdDPExtractData(out, size);
+ }
out->gd_free(out);
return rv;
@@ -344,9 +360,65 @@ BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
if (out == NULL) {
return NULL;
}
- gdImageWebpCtx(im, out, quality);
- rv = gdDPExtractData(out, size);
+ if (_gdImageWebpCtx(im, out, quality)) {
+ rv = NULL;
+ } else {
+ rv = gdDPExtractData(out, size);
+ }
out->gd_free(out);
return rv;
}
+
+#else /* !HAVE_LIBWEBP */
+
+static void _noWebpError(void)
+{
+ gd_error("WEBP image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quality)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
+{
+ _noWebpError();
+ return NULL;
+}
+
#endif /* HAVE_LIBWEBP */
diff --git a/src/gd_xbm.c b/src/gd_xbm.c
index 5f09b56..6fd64d0 100644
--- a/src/gd_xbm.c
+++ b/src/gd_xbm.c
@@ -18,10 +18,6 @@
#include "gd_errors.h"
#include "gdhelpers.h"
-#ifdef _MSC_VER
-# define strcasecmp _stricmp
-#endif
-
#define MAX_XBM_LINE_SIZE 255
@@ -40,6 +36,9 @@
its size. The image must eventually be destroyed using
<gdImageDestroy>.
+ X11 X bitmaps (which define a char[]) as well as X10 X bitmaps (which define
+ a short[]) are supported.
+
Parameters:
fd - The input FILE pointer
@@ -108,7 +107,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
max_bit = 32768;
}
if (max_bit) {
- bytes = (width * height / 8) + 1;
+ bytes = (width + 7) / 8 * height;
if (!bytes) {
return 0;
}
@@ -166,7 +165,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
}
h[3] = ch;
}
- sscanf(h, "%x", &b);
+ if (sscanf(h, "%x", &b) != 1) {
+ gd_error("invalid XBM");
+ gdImageDestroy(im);
+ return 0;
+ }
for (bit = 1; bit <= max_bit; bit = bit << 1) {
gdImageSetPixel(im, x++, y, (b & bit) ? 1 : 0);
if (x == im->sx) {
@@ -203,10 +206,22 @@ static void gdCtxPrintf(gdIOCtx * out, const char *format, ...)
/* The compiler will optimize strlen(constant) to a constant number. */
#define gdCtxPuts(out, s) out->putBuf(out, s, strlen(s))
-/* {{{ gdImageXbmCtx */
-/*
- Function: gdImageXbmCtx
-*/
+
+/**
+ * Function: gdImageXbmCtx
+ *
+ * Writes an image to an IO context in X11 bitmap format.
+ *
+ * Parameters:
+ *
+ * image - The <gdImagePtr> to write.
+ * file_name - The prefix of the XBM's identifiers. Illegal characters are
+ * automatically stripped.
+ * gd - Which color to use as forground color. All pixels with another
+ * color are unset.
+ * out - The <gdIOCtx> to write the image file to.
+ *
+ */
BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out)
{
int x, y, c, b, sx, sy, p;
@@ -282,4 +297,3 @@ BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOC
}
gdCtxPuts(out, "};\n");
}
-/* }}} */
diff --git a/src/gdcache.c b/src/gdcache.c
index b264d6e..3aad153 100644
--- a/src/gdcache.c
+++ b/src/gdcache.c
@@ -25,7 +25,9 @@
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c -lgd
+ * or
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c libgd.a
*
* The cache is implemented by a singly-linked list of elements
* each containing a pointer to a user struct that is being managed by
@@ -137,8 +139,13 @@ void * gdCacheGet(gdCache_head_t *head, void *keydata)
}
} else {
/* cache full - replace least-recently-used */
- /* preveprev becomes new end of list */
- prevprev->next = NULL;
+ if(!prevprev) {
+ /* cache size is 1 */
+ head->mru = NULL;
+ } else {
+ /* prevprev becomes new end of list */
+ prevprev->next = NULL;
+ }
elem = prev;
(*(head->gdCacheRelease))(elem->userdata);
}
@@ -192,7 +199,7 @@ static void cacheRelease(void *map)
gdFree((char *)map);
}
-int main(char *argv[], int argc)
+int main(int argc, char **argv)
{
gdCache_head_t *cacheTable;
int elem, key;
diff --git a/src/gdcache.h b/src/gdcache.h
index bf451dc..751a842 100644
--- a/src/gdcache.h
+++ b/src/gdcache.h
@@ -12,7 +12,9 @@ extern "C" {
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c -lgd
+ * or
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c libgd.a
*
* The cache is implemented by a singly-linked list of elements
* each containing a pointer to a user struct that is being managed by
diff --git a/src/gdcmpgif.c b/src/gdcmpgif.c
index 737f7ba..d440f71 100644
--- a/src/gdcmpgif.c
+++ b/src/gdcmpgif.c
@@ -89,5 +89,3 @@ void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2)
printf("-%s: INFO actual colours of pixels differ\n",msg);
}
}
-
-
diff --git a/src/gddemo.c b/src/gddemo.c
index 28afd3c..69d9d35 100644
--- a/src/gddemo.c
+++ b/src/gddemo.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -16,7 +15,6 @@
int
main (void)
{
-#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
FILE *out;
@@ -181,8 +179,5 @@ main (void)
if (im_in) {
gdImageDestroy (im_in);
}
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/src/gdfontg.c b/src/gdfontg.c
index 2adf6da..2fe7166 100644
--- a/src/gdfontg.c
+++ b/src/gdfontg.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.51 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/src/gdfontl.c b/src/gdfontl.c
index 97f7a65..f7ce272 100644
--- a/src/gdfontl.c
+++ b/src/gdfontl.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/src/gdfontmb.c b/src/gdfontmb.c
index debee4e..ed0f1ac 100644
--- a/src/gdfontmb.c
+++ b/src/gdfontmb.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/src/gdfontt.c b/src/gdfontt.c
index e7bb345..1fb96e1 100644
--- a/src/gdfontt.c
+++ b/src/gdfontt.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/src/gdft.c b/src/gdft.c
index 014e2c1..04fcbba 100644
--- a/src/gdft.c
+++ b/src/gdft.c
@@ -1,4 +1,3 @@
-
/********************************************/
/* gd interface to freetype library */
/* */
@@ -72,9 +71,7 @@ static char *font_path(char **fontpath, char *name_list);
*/
#ifndef DEFAULT_FONTPATH
-# ifdef NETWARE
-# define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;."
-# elif defined(_WIN32)
+# if defined(_WIN32)
# define DEFAULT_FONTPATH "C:\\WINDOWS\\FONTS;C:\\WINNT\\FONTS"
# elif defined(__APPLE__) || (defined(__MWERKS__) && defined(macintosh))
# define DEFAULT_FONTPATH "/usr/share/fonts/truetype:/System/Library/Fonts:/Library/Fonts"
@@ -85,7 +82,7 @@ static char *font_path(char **fontpath, char *name_list);
#endif
#ifndef PATHSEPARATOR
-# if defined(NETWARE) || defined(_WIN32)
+# if defined(_WIN32)
# define PATHSEPARATOR ";"
# else
# define PATHSEPARATOR ":"
@@ -103,8 +100,8 @@ static char *font_path(char **fontpath, char *name_list);
*
* Alias of <gdImageStringFT>.
*/
-BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
/* 2.0.6: valid return */
return gdImageStringFT (im, brect, fg, fontlist, ptsize,
@@ -112,8 +109,8 @@ BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fo
}
#ifndef HAVE_LIBFREETYPE
-BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string,
+BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string,
gdFTStringExtraPtr strex)
{
(void)im;
@@ -130,8 +127,8 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
return "libgd was not built with FreeType font support\n";
}
-BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
(void)im;
(void)brect;
@@ -184,7 +181,7 @@ typedef struct {
font_t;
typedef struct {
- char *fontlist; /* key */
+ const char *fontlist; /* key */
int flags; /* key */
FT_Library *library;
}
@@ -260,7 +257,7 @@ static int comp_entities(const void *e1, const void *e2)
return strcmp(en1->name, en2->name);
}
-extern int any2eucjp (char *, char *, unsigned int);
+extern int any2eucjp (char *, const char *, unsigned int);
/* Persistent font cache until explicitly cleared */
/* Fonts can be used across multiple images */
@@ -273,7 +270,7 @@ static FT_Library library;
#define Tcl_UniChar int
#define TCL_UTF_MAX 3
static int
-gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
+gdTcl_UtfToUniChar (const char *str, Tcl_UniChar * chPtr)
/* str is the UTF8 next character pointer */
/* chPtr is the int for the result */
{
@@ -444,7 +441,7 @@ typedef struct {
uint32_t cluster;
} glyphInfo;
-static size_t
+static ssize_t
textLayout(uint32_t *text, int len,
FT_Face face, gdFTStringExtraPtr strex,
glyphInfo **glyph_info)
@@ -452,6 +449,10 @@ textLayout(uint32_t *text, int len,
size_t count;
glyphInfo *info;
+ if (!len) {
+ return 0;
+ }
+
#ifdef HAVE_LIBRAQM
size_t i;
raqm_glyph_t *glyphs;
@@ -462,19 +463,19 @@ textLayout(uint32_t *text, int len,
!raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) ||
!raqm_layout (rq)) {
raqm_destroy (rq);
- return 0;
+ return -1;
}
glyphs = raqm_get_glyphs (rq, &count);
if (!glyphs) {
raqm_destroy (rq);
- return 0;
+ return -1;
}
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count);
if (!info) {
raqm_destroy (rq);
- return 0;
+ return -1;
}
for (i = 0; i < count; i++) {
@@ -492,7 +493,7 @@ textLayout(uint32_t *text, int len,
FT_Error err;
info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len);
if (!info) {
- return 0;
+ return -1;
}
for (count = 0; count < len; count++) {
/* Convert character code to glyph index */
@@ -511,7 +512,7 @@ textLayout(uint32_t *text, int len,
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
if (err) {
gdFree (info);
- return 0;
+ return -1;
}
info[count].index = glyph_index;
info[count].x_offset = 0;
@@ -530,7 +531,7 @@ textLayout(uint32_t *text, int len,
#endif
*glyph_info = info;
- return count;
+ return count <= SSIZE_MAX ? count : -1;
}
/********************************************************************/
@@ -576,7 +577,7 @@ fontFetch (char **error, void *key)
gdFree(a);
return "could not alloc full list of fonts";
}
- strncpy(a->fontlist, b->fontlist, b_font_list_len);
+ memcpy(a->fontlist, b->fontlist, b_font_list_len);
a->fontlist[b_font_list_len] = 0;
a->flags = b->flags;
@@ -925,8 +926,8 @@ BGD_DECLARE(void) gdFontCacheShutdown ()
* See also:
* - <gdImageString>
*/
-BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
return gdImageStringFTEx (im, brect, fg, fontlist,
ptsize, angle, x, y, string, 0);
@@ -973,13 +974,13 @@ BGD_DECLARE(int) gdFontCacheSetup (void)
typedef struct {
// logical OR of gdFTEX_ values
int flags;
-
+
// fine tune line spacing for '\n'
double linespacing;
-
+
// Preferred character mapping
int charmap;
-
+
// Rendering resolution
int hdpi;
int vdpi;
@@ -1083,15 +1084,15 @@ BGD_DECLARE(int) gdFontCacheSetup (void)
> flags | gdFTEX_FONTPATHNAME;
- For more information, see <gdImageStringFT>.
+ For more information, see <gdImageStringFT>.
*/
/* the platform-independent resolution used for size and position calculations */
/* the size of the error introduced by rounding is affected by this number */
#define METRIC_RES 300
-BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string,
+BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string,
gdFTStringExtraPtr strex)
{
FT_Matrix matrix;
@@ -1107,11 +1108,11 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
int i, ch;
font_t *font;
fontkey_t fontkey;
- char *next;
+ const char *next;
char *tmpstr = 0;
uint32_t *text;
glyphInfo *info = NULL;
- size_t count;
+ ssize_t count;
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
FT_BitmapGlyph bm;
/* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing
@@ -1204,7 +1205,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
gdMutexUnlock(gdFontCacheMutex);
return "could not alloc full list of fonts";
}
- strncpy(strex->fontpath, font->fontpath, fontpath_len);
+ memcpy(strex->fontpath, font->fontpath, fontpath_len);
strex->fontpath[fontpath_len] = 0;
}
}
@@ -1243,7 +1244,6 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
for (i = 0; i < face->num_charmaps; i++) {
charmap = face->charmaps[i];
-#if ((defined(FREETYPE_MAJOR)) && (((FREETYPE_MAJOR == 2) && (((FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 3)) || (FREETYPE_MINOR > 1))) || (FREETYPE_MAJOR > 2)))
if (encoding == gdFTEX_Unicode) {
if (charmap->encoding == FT_ENCODING_MS_SYMBOL
|| charmap->encoding == FT_ENCODING_UNICODE
@@ -1276,27 +1276,6 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
break;
}
}
-#else
- if (encoding == gdFTEX_Unicode) {
- if ((charmap->platform_id = 3 && charmap->encoding_id == 1) /* Windows Unicode */
- || (charmap->platform_id == 3 && charmap->encoding_id == 0) /* Windows Symbol */
- || (charmap->platform_id == 2 && charmap->encoding_id == 1) /* ISO Unicode */
- || (charmap->platform_id == 0)) { /* Apple Unicode */
- encodingfound++;
- break;
- }
- } else if (encoding == gdFTEX_Big5) {
- if (charmap->platform_id == 3 && charmap->encoding_id == 4) { /* Windows Big5 */
- encodingfound++;
- break;
- }
- } else if (encoding == gdFTEX_Shift_JIS) {
- if (charmap->platform_id == 3 && charmap->encoding_id == 2) { /* Windows Sjis */
- encodingfound++;
- break;
- }
- }
-#endif
}
if (encodingfound) {
FT_Set_Charmap(face, charmap);
@@ -1336,12 +1315,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
/* EAM DEBUG */
/* TBB: get this exactly right: 2.1.3 *or better*, all possible cases. */
/* 2.0.24: David R. Morrison: use the more complete ifdef here. */
-#if ((defined(FREETYPE_MAJOR)) && (((FREETYPE_MAJOR == 2) && (((FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 3)) || (FREETYPE_MINOR > 1))) || (FREETYPE_MAJOR > 2)))
- if (charmap->encoding == FT_ENCODING_MS_SYMBOL)
-#else
- if (charmap->platform_id == 3 && charmap->encoding_id == 0)
-#endif /* Freetype 2.1 or better */
- {
+ if (charmap->encoding == FT_ENCODING_MS_SYMBOL) {
/* I do not know the significance of the constant 0xf000. */
/* It was determined by inspection of the character codes */
/* stored in Microsoft font symbol.ttf */
@@ -1412,7 +1386,8 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
count = textLayout (text , i, face, strex, &info);
- if (!count) {
+ if (count < 0) {
+ gdFree (text);
gdFree (tmpstr);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
@@ -1568,7 +1543,9 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
}
gdFree(text);
- gdFree(info);
+ if (info) {
+ gdFree(info);
+ }
/* Save the (unkerned) advance from the last character in the xshow vector */
if (strex && (strex->flags & gdFTEX_XSHOW) && strex->xshow) {
@@ -1581,12 +1558,6 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
double scalex = (double)hdpi / (64 * METRIC_RES);
double scaley = (double)vdpi / (64 * METRIC_RES);
- /* increase by 1 pixel to allow for rounding */
- total_min.x -= METRIC_RES;
- total_min.y -= METRIC_RES;
- total_max.x += METRIC_RES;
- total_max.y += METRIC_RES;
-
/* rotate bounding rectangle, scale and round to int pixels, and translate */
brect[0] = x + (total_min.x * cos_a + total_max.y * sin_a)*scalex;
brect[1] = y - (total_min.x * sin_a - total_max.y * cos_a)*scaley;
@@ -1768,7 +1739,7 @@ static char * font_pattern(char **fontpath, char *fontpattern)
if (*fontpath == NULL) {
return "could not alloc font path";
}
- strncpy(*fontpath, (const char *)file, file_len);
+ memcpy(*fontpath, (const char *)file, file_len);
(*fontpath)[file_len] = 0;
}
FcPatternDestroy(font);
@@ -1808,7 +1779,7 @@ static char * font_path(char **fontpath, char *name_list)
gdFree(path);
return "could not alloc full list of fonts";
}
- strncpy(fontlist, name_list, name_list_len);
+ memcpy(fontlist, name_list, name_list_len);
fontlist[name_list_len] = 0;
/*
@@ -1833,14 +1804,9 @@ static char * font_path(char **fontpath, char *name_list)
return "could not alloc full path of font";
}
/* if name is an absolute or relative pathname then test directly */
-#ifdef NETWARE
- /* netware uses the format "volume:/path" or the standard "/path" */
- if (name[0] != 0 && (strstr(name, ":/") || name[0] == '/'))
-#else
if (strchr (name, '/')
|| (name[0] != 0 && name[1] == ':'
&& (name[2] == '/' || name[2] == '\\')))
-#endif
{
sprintf (fullname, "%s", name);
if (access (fullname, R_OK) == 0) {
@@ -1922,4 +1888,3 @@ BGD_DECLARE(int) gdFTUseFontConfig(int flag)
return 0;
#endif /* HAVE_LIBFONTCONFIG */
}
-
diff --git a/src/gdfx.c b/src/gdfx.c
index d71a342..dfc8fa7 100644
--- a/src/gdfx.c
+++ b/src/gdfx.c
@@ -4,6 +4,7 @@
#include "gd.h"
#include "gd_errors.h"
+#include "gd_intern.h"
#include <math.h>
/* In tests this is sufficient to prevent obvious artifacts */
@@ -12,9 +13,6 @@
#define PI 3.141592
#define DEG2RAD(x) ((x)*PI/180.)
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-
#define MAX4(x,y,z,w) \
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
#define MIN4(x,y,z,w) \
@@ -522,4 +520,3 @@ gdImageSharpen (gdImagePtr im, int pct)
}
}
}
-
diff --git a/src/gdfx.h b/src/gdfx.h
index dbd7498..b00f573 100644
--- a/src/gdfx.h
+++ b/src/gdfx.h
@@ -1,10 +1,10 @@
+#ifndef GDFX_H
+#define GDFX_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef GDFX_H
-#define GDFX_H 1
-
BGD_DECLARE(gdImagePtr) gdImageSquareToCircle(gdImagePtr im, int radius);
BGD_DECLARE(char *) gdImageStringFTCircle(
@@ -22,9 +22,8 @@ BGD_DECLARE(char *) gdImageStringFTCircle(
BGD_DECLARE(void) gdImageSharpen (gdImagePtr im, int pct);
-#endif /* GDFX_H */
-
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GDFX_H */
diff --git a/src/gdhelpers.c b/src/gdhelpers.c
index 20fff5c..de7a0a3 100644
--- a/src/gdhelpers.c
+++ b/src/gdhelpers.c
@@ -114,5 +114,3 @@ BGD_DECLARE(void) gdFree (void *ptr)
{
free (ptr);
}
-
-
diff --git a/src/gdhelpers.h b/src/gdhelpers.h
index 2a96b8b..9c7ef10 100644
--- a/src/gdhelpers.h
+++ b/src/gdhelpers.h
@@ -1,10 +1,10 @@
+#ifndef GDHELPERS_H
+#define GDHELPERS_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef GDHELPERS_H
-#define GDHELPERS_H 1
-
/* sys/types.h is needed for size_t on Sparc-SunOS-4.1 */
#ifndef _WIN32_WCE
#include <sys/types.h>
@@ -69,8 +69,8 @@ extern "C" {
#define DPI2DPCM(dpi) (unsigned int)((dpi)/2.54 + 0.5)
#define DPI2DPM(dpi) (unsigned int)((dpi)/0.0254 + 0.5)
-#endif /* GDHELPERS_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GDHELPERS_H */
diff --git a/src/gdkanji.c b/src/gdkanji.c
index f05187e..c670d98 100644
--- a/src/gdkanji.c
+++ b/src/gdkanji.c
@@ -11,11 +11,7 @@
#include "gd.h"
#include "gdhelpers.h"
#include "gd_errors.h"
-
-#ifdef HAVE_ERRNO_H
#include <errno.h>
-#endif
-
#include <stdarg.h>
#if defined(HAVE_ICONV_H)
#include <iconv.h>
@@ -98,7 +94,7 @@ iconv_close (iconv_t cd)
/* DetectKanjiCode() derived from DetectCodeType() by Ken Lunde. */
static int
-DetectKanjiCode (unsigned char *str)
+DetectKanjiCode (const unsigned char *str)
{
static int whatcode = ASCII;
int oldcode = ASCII;
@@ -146,7 +142,7 @@ DetectKanjiCode (unsigned char *str)
whatcode = EUCORSJIS;
else if (c >= 224 && c <= 239) {
whatcode = EUCORSJIS;
- while (c >= 64 && c != '\0' && whatcode == EUCORSJIS) {
+ while (c >= 64 && whatcode == EUCORSJIS) {
if (c >= 129) {
if (c <= 141 || (c >= 143 && c <= 159))
whatcode = SJIS;
@@ -334,20 +330,20 @@ han2zen (int *p1, int *p2)
#define ustrncpy(A,B, maxsize) (strncpy((char*)(A),(const char*)(B), maxsize))
static void
-do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
+do_convert (unsigned char **to_p, const unsigned char **from_p, const char *code)
{
unsigned char *to = *to_p;
- unsigned char *from = *from_p;
+ const unsigned char *from = *from_p;
#ifdef HAVE_ICONV
iconv_t cd;
size_t from_len, to_len;
if ((cd = iconv_open (EUCSTR, code)) == (iconv_t) - 1) {
gd_error ("iconv_open() error");
-#ifdef HAVE_ERRNO_H
+
if (errno == EINVAL)
gd_error ("invalid code specification: \"%s\" or \"%s\"", EUCSTR, code);
-#endif
+
ustrcpy (to, from);
return;
}
@@ -357,7 +353,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
if ((int) (iconv (cd, (char **)from_p, &from_len, (char **)to_p, &to_len))
== -1) {
-#ifdef HAVE_ERRNO_H
+
if (errno == EINVAL)
gd_error ("invalid end of input string");
else if (errno == EILSEQ)
@@ -365,7 +361,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
else if (errno == E2BIG)
gd_error ("output buffer overflow at do_convert()");
else
-#endif
+
gd_error ("something happen");
ustrcpy (to, from);
return;
@@ -436,7 +432,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
}
static int
-do_check_and_conv (unsigned char *to, unsigned char *from)
+do_check_and_conv (unsigned char *to, const unsigned char *from)
{
static unsigned char tmp[BUFSIZ];
unsigned char *tmp_p = &tmp[0];
@@ -527,7 +523,7 @@ do_check_and_conv (unsigned char *to, unsigned char *from)
}
int
-any2eucjp (unsigned char *dest, unsigned char *src, unsigned int dest_max)
+any2eucjp (unsigned char *dest, const unsigned char *src, unsigned int dest_max)
{
static unsigned char tmp_dest[BUFSIZ];
int ret;
diff --git a/src/gdparttopng.c b/src/gdparttopng.c
index 42d6df2..4bf2fc8 100644
--- a/src/gdparttopng.c
+++ b/src/gdparttopng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -49,11 +48,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/src/gdpp.cxx b/src/gdpp.cxx
index a8101fc..5e579da 100644
--- a/src/gdpp.cxx
+++ b/src/gdpp.cxx
@@ -1,12 +1,11 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
*******************************************************************************/
/** \file gdpp.cxx
\brief Implements the non-trivial methods of GD::Image.
-
+
Implementation of the more complex methods defined
in gdpp.h.
Notably includes the methods which determine the image file
@@ -19,13 +18,13 @@ namespace GD
{
/**
Load an image from a file, after attempting to
- determine it's image file format.
+ determine it's image file format.
Invoke CreateFrom with an already opened
- pointer to a file containing the desired image.
+ pointer to a file containing the desired image.
CreateFrom does not close the file.
\param[in] in An opened FILE * pointer.
- \return true for success, or false if unable to load the image (most often because the
- file is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ file is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
*/
bool Image::CreateFrom(FILE * in)
@@ -40,50 +39,47 @@ namespace GD
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
== .PNG\r\n.\n
*/
-#ifdef HAVE_LIBPNG
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
-#endif
+
/* GIF
0x47 0x49 0x46
*/
case 0x47: // GIF
rtn = CreateFromGif(in);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(in);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(in);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
/* XBM
#define test_width 16
#define test_height 7
- */
+ */
case 0x23: // XBM
rtn = CreateFromXbm(in);
break;
@@ -91,18 +87,18 @@ namespace GD
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
/**
Load an image from a standard input stream, after attempting to
- determine it's image file format.
+ determine it's image file format.
Invoke CreateFrom with an already opened stream
- containing the desired image.
+ containing the desired image.
CreateFrom does not close the stream.
\param[in] in An opened standard library input stream.
- \return true for success, or false if unable to load the image (most often because the
- file is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ file is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
Example usage, convert anything to gif:
#include <fstream>
@@ -122,7 +118,6 @@ namespace GD
bool rtn;
switch (in.peek())
{
-#ifdef HAVE_LIBPNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@@ -131,7 +126,6 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
-#endif
/* GIF
0x47 0x49 0x46
@@ -140,51 +134,49 @@ namespace GD
rtn = CreateFromGif(in);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(in);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(in);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
default:
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
/**
Load an image from an in-RAM memory block, after attempting to
- determine it's image format.
+ determine it's image format.
CreateFrom does not de-allocate the memory.
\param[in] size The byte count of the memory block.
\param[in] data A pointer to the memory block.
- \return true for success, or false if unable to load the image (most often because the
- formatting is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ formatting is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
*/
bool Image::CreateFrom(int size, void * data)
@@ -193,7 +185,6 @@ namespace GD
switch (((unsigned char * )data)[0])
{
-#ifdef HAVE_LIBPNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@@ -202,7 +193,7 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(size, data);
break;
-#endif
+
/* GIF
0x47 0x49 0x46
*/
@@ -210,45 +201,43 @@ namespace GD
rtn = CreateFromGif(size, data);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(size, data);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(size, data);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(size, data);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
default:
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
} // namespace GD
/**
- Load an image from a standard input stream, regardless of it's image file format.
+ Load an image from a standard input stream, regardless of it's image file format.
You can call Width() and Height() member functions of the image to determine its size.
Example usage, convert anything to gif:
#include <fstream>
diff --git a/src/gdpp.h b/src/gdpp.h
index 2ebda16..3d58d89 100644
--- a/src/gdpp.h
+++ b/src/gdpp.h
@@ -1,5 +1,4 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
@@ -20,13 +19,9 @@
im.Gif(out);
}
*/
-#ifdef __cplusplus
#ifndef _gdpp_h
#define _gdpp_h
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#ifdef __cplusplus
#include "gd_io_stream.h"
#include <string>
@@ -292,7 +287,7 @@ public:
:im(0) {
CreateFrom(size, data);
}
-#ifdef HAVE_LIBPNG
+
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
@@ -330,7 +325,6 @@ public:
:im(0) {
CreateFromPng(size, data);
}
-#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@@ -408,7 +402,6 @@ public:
CreateFromWBMP(size, data);
}
-#ifdef HAVE_LIBJPEG
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
@@ -446,7 +439,6 @@ public:
:im(0) {
CreateFromJpeg(size, data);
}
-#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@@ -608,7 +600,6 @@ public:
/// Read an image from a memory block, after determining the image format
bool CreateFrom(int size, void * data);
-#ifdef HAVE_LIBPNG
// Png
bool CreateFromPng(FILE * in) {
clear();
@@ -627,7 +618,6 @@ public:
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
}
-#endif
// Gif
bool CreateFromGif(FILE * in) {
@@ -666,7 +656,6 @@ public:
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
}
-#ifdef HAVE_LIBJPEG
// Jpeg
/**
Load a truecolor image from a JPEG format file.
@@ -720,7 +709,6 @@ public:
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
}
-#endif
// Gd
bool CreateFromGd(FILE * in) {
@@ -1089,7 +1077,6 @@ public:
gdImageGifCtx(im, & _out_ctx);
}
-#ifdef HAVE_LIBPNG
/**
Write out this image in PNG file format to \p out.
\param out A FILE * handle
@@ -1154,7 +1141,6 @@ public:
ostreamIOCtx _out_ctx(out);
gdImagePngCtxEx(im, & _out_ctx, level);
}
-#endif
/**
Write out this image in WBMP file format ( black and white only ) to \p out.
@@ -1191,7 +1177,6 @@ public:
gdImageWBMPCtx(im, fg, & _out_ctx);
}
-#ifdef HAVE_LIBJPEG
/**
Write out this image in JPEG file format to \p out.
\param out A FILE * handle
@@ -1226,7 +1211,6 @@ public:
ostreamIOCtx _out_ctx(out);
gdImageJpegCtx(im, & _out_ctx, quality);
}
-#endif
void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const {
gdImageGifAnimBegin(im, out, GlobalCM, Loops);
@@ -1542,5 +1526,5 @@ protected:
/// Read in an image from a standard library input stream
std::istream & operator>> (std::istream & in, GD::Image & img);
-#endif /* _gdpp_h */
#endif /* __cplusplus */
+#endif /* _gdpp_h */
diff --git a/src/gdtables.c b/src/gdtables.c
index 7753b21..d368b8d 100644
--- a/src/gdtables.c
+++ b/src/gdtables.c
@@ -1,4 +1,3 @@
-
const int gdCosT[] = {
1024,
1023,
diff --git a/src/gdtest.c b/src/gdtest.c
index 0f8febe..bfd1826 100644
--- a/src/gdtest.c
+++ b/src/gdtest.c
@@ -24,7 +24,6 @@ static int fwriteWrapper (void *context, const char *buffer, int len);
int
main (int argc, char **argv)
{
-#ifdef HAVE_LIBPNG
gdImagePtr im, ref, im2, im3;
FILE *in, *out;
void *iptr;
@@ -67,11 +66,7 @@ main (int argc, char **argv)
/* */
/* Send to PNG File then Ptr */
/* */
-#ifdef VMS
- sprintf (of, "%s-png", argv[1]);
-#else
sprintf (of, "%s.png", argv[1]);
-#endif
out = fopen (of, "wb");
if (!out) {
fprintf(stderr, "PNG Output file does not exist!\n");
@@ -87,12 +82,12 @@ main (int argc, char **argv)
}
im2 = gdImageCreateFromPng (in);
fclose (in);
-
+
if (!im2) {
fprintf(stderr, "gdImageCreateFromPng failed.\n");
exit (1);
}
-
+
CompareImages ("GD->PNG File->GD", ref, im2);
unlink (of);
@@ -113,11 +108,7 @@ main (int argc, char **argv)
/* */
/* Send to GD2 File then Ptr */
/* */
-#ifdef VMS
- sprintf (of, "%s-gd2", argv[1]);
-#else
sprintf (of, "%s.gd2", argv[1]);
-#endif
out = fopen (of, "wb");
if (!out) {
fprintf(stderr, "GD2 Output file does not exist!\n");
@@ -158,11 +149,7 @@ main (int argc, char **argv)
/* */
/* Send to GD File then Ptr */
/* */
-#ifdef VMS
- sprintf (of, "%s-gd", argv[1]);
-#else
sprintf (of, "%s.gd", argv[1]);
-#endif
out = fopen (of, "wb");
if (!out) {
fprintf(stderr, "GD Output file does not exist!\n");
@@ -196,7 +183,7 @@ main (int argc, char **argv)
fprintf(stderr, "gdImageCreateFromGdPtr failed.\n");
exit (1);
}
-
+
CompareImages ("GD->GD ptr->GD", ref, im2);
gdImageDestroy (im2);
@@ -224,11 +211,7 @@ main (int argc, char **argv)
/*
* Test gdImagePngToSink'
*/
-#ifdef VMS
- sprintf (of, "%s-snk", argv[1]);
-#else
sprintf (of, "%s.snk", argv[1]);
-#endif
out = fopen (of, "wb");
if (!out) {
fprintf (stderr,
@@ -409,9 +392,6 @@ main (int argc, char **argv)
}
gdImageDestroy (im);
gdImageDestroy (ref);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/src/gdtestft.c b/src/gdtestft.c
index 53945a6..0663bf3 100644
--- a/src/gdtestft.c
+++ b/src/gdtestft.c
@@ -1,18 +1,15 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gd.h"
+#include "gd_intern.h"
#include <string.h>
#include <stdlib.h>
#define PI 3.141592
#define DEG2RAD(x) ((x)*PI/180.)
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-
#define MAX4(x,y,z,w) \
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
#define MIN4(x,y,z,w) \
@@ -26,13 +23,6 @@
int
main (int argc, char *argv[])
{
-#ifndef HAVE_LIBFREETYPE
- fprintf(stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n");
- fprintf(stderr, "Install the FreeType library, including the\n");
- fprintf(stderr, "header files. Then edit the gd Makefile, type\n");
- fprintf(stderr, "make clean, and type make again.\n");
- return 1;
-#else
gdImagePtr im;
int blue;
int blueAlpha;
@@ -40,7 +30,6 @@ main (int argc, char *argv[])
int brect[8];
int x, y, sx, sy;
char *err;
- FILE *out;
#ifdef JISX0208
char *s = "Hello. ‚±‚ñ‚É‚¿‚Í Qyjpqg,"; /* String to draw. */
#else
@@ -155,7 +144,7 @@ main (int argc, char *argv[])
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
if (im->trueColor) {
#ifdef HAVE_LIBJPEG
- out = fopen ("test/fttest.jpg", "wb");
+ FILE *out = fopen ("test/fttest.jpg", "wb");
if (!out) {
fprintf(stderr, "Can't create test/fttest.jpg\n");
exit (1);
@@ -169,7 +158,7 @@ main (int argc, char *argv[])
#endif
} else {
#ifdef HAVE_LIBPNG
- out = fopen ("test/fttest.png", "wb");
+ FILE *out = fopen ("test/fttest.png", "wb");
if (!out) {
fprintf(stderr, "Can't create test/fttest.png\n");
exit (1);
@@ -186,5 +175,4 @@ main (int argc, char *argv[])
gdImageDestroy (im);
return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/src/gdtopng.c b/src/gdtopng.c
index d3341b4..c937558 100644
--- a/src/gdtopng.c
+++ b/src/gdtopng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -38,11 +37,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/src/getopt.c b/src/getopt.c
new file mode 100644
index 0000000..8651b87
--- /dev/null
+++ b/src/getopt.c
@@ -0,0 +1,129 @@
+/* $NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt(int nargc, char * const nargv[], const char *ostr)
+{
+ static const char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || *place == 0) { /* update scanning pointer */
+ optreset = 0;
+ place = nargv[optind];
+ if (optind >= nargc || *place++ != '-') {
+ /* Argument is absent or is not an option */
+ place = EMSG;
+ return (-1);
+ }
+ optopt = *place++;
+ if (optopt == '-' && *place == 0) {
+ /* "--" => end of options */
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ if (optopt == 0) {
+ /* Solitary '-', treat as a '-' option
+ if the program (eg su) is looking for it. */
+ place = EMSG;
+ if (strchr(ostr, '-') == NULL)
+ return -1;
+ optopt = '-';
+ }
+ } else
+ optopt = *place++;
+
+ /* See if option letter is one the caller wanted... */
+ if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
+ if (*place == 0)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: unknown option -- %c\n", nargv[0],
+ optopt);
+ return (BADCH);
+ }
+
+ /* Does this option need an argument? */
+ if (oli[1] != ':') {
+ /* don't need argument */
+ optarg = NULL;
+ if (*place == 0)
+ ++optind;
+ } else {
+ /* Option-argument is either the rest of this argument or the
+ entire next argument. */
+ if (*place)
+ optarg = (char *)place;
+ else if (oli[2] == ':')
+ /*
+ * GNU Extension, for optional arguments if the rest of
+ * the argument is empty, we return NULL
+ */
+ optarg = NULL;
+ else if (nargc > ++optind)
+ optarg = nargv[optind];
+ else {
+ /* option-argument absent */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ nargv[0], optopt);
+ return (BADCH);
+ }
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* return option letter */
+}
diff --git a/src/gifanimtest.c b/src/gifanimtest.c
index da17b9e..28b7d27 100644
--- a/src/gifanimtest.c
+++ b/src/gifanimtest.c
@@ -32,4 +32,3 @@ int main(void)
gdImageDestroy(im);
return 0;
}
-
diff --git a/src/giftogd2.c b/src/giftogd2.c
index e7d0c6b..68c82a1 100644
--- a/src/giftogd2.c
+++ b/src/giftogd2.c
@@ -49,4 +49,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/src/jisx0208.h b/src/jisx0208.h
index d49dddc..118c23e 100644
--- a/src/jisx0208.h
+++ b/src/jisx0208.h
@@ -1,9 +1,9 @@
+#ifndef JISX0208_H
+#define JISX0208_H
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef JISX0208_H
-#define JISX0208_H
/* This file was derived from "src/VF_Ftype.c" in VFlib2-2.24.2
by Dr. Kakugawa */
@@ -1299,8 +1299,8 @@ extern "C" {
}
};
-#endif /* JISX0208_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* JISX0208_H */
diff --git a/src/msinttypes/inttypes.h b/src/msinttypes/inttypes.h
index 4b3828a..ead903f 100644
--- a/src/msinttypes/inttypes.h
+++ b/src/msinttypes/inttypes.h
@@ -1,32 +1,32 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
// Copyright (c) 2006 Alexander Chemeris
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
+//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
diff --git a/src/msinttypes/stdint.h b/src/msinttypes/stdint.h
index d02608a..c66fbb8 100644
--- a/src/msinttypes/stdint.h
+++ b/src/msinttypes/stdint.h
@@ -1,32 +1,32 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
// Copyright (c) 2006-2008 Alexander Chemeris
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
+//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
diff --git a/src/pngtogd.c b/src/pngtogd.c
index f00fe8f..4f9804d 100644
--- a/src/pngtogd.c
+++ b/src/pngtogd.c
@@ -25,11 +25,7 @@ main (int argc, char **argv)
fprintf (stderr, "Input file does not exist!\n");
exit (1);
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
-#else
- fprintf (stderr, "No PNG library support available.\n");
-#endif
fclose (in);
if (!im) {
fprintf (stderr, "Input is not in PNG format!\n");
diff --git a/src/pngtogd2.c b/src/pngtogd2.c
index e474afb..20fbee2 100644
--- a/src/pngtogd2.c
+++ b/src/pngtogd2.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -30,12 +29,7 @@ main (int argc, char **argv)
fprintf(stderr, "Input file does not exist!\n");
exit (1);
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
-#else
- im = NULL;
- fprintf(stderr, "No PNG library support available.\n");
-#endif
fclose (in);
if (!im) {
fprintf(stderr, "Input is not in PNG format!\n");
diff --git a/src/snprintf.c b/src/snprintf.c
deleted file mode 100644
index 33d1b42..0000000
--- a/src/snprintf.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Provide a snprintf on Windows for older Visual Studio builds.
- * VS2013 and older do not support C99 snprintf(). The subsitute _snprintf()
- * does not correctly NUL-terminate buffers in case of overflow.
- * This implementation emulates the ISO C99 snprintf() for VS2013 and older.
- */
-
-#if defined(_MSC_VER) && _MSC_VER < 1900
-
-#include <stdio.h>
-#include <stdarg.h>
-
-int snprintf(char* buf, size_t len, const char* fmt, ...)
-{
- int n;
- va_list ap;
- va_start(ap, fmt);
-
- n = _vscprintf(fmt, ap);
- vsnprintf_s(buf, len, _TRUNCATE, fmt, ap);
-
- va_end(ap);
- return n;
-}
-
-#endif
diff --git a/src/testac.c b/src/testac.c
index 0d200f0..bea4308 100644
--- a/src/testac.c
+++ b/src/testac.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -17,7 +16,6 @@ void testDrawing (gdImagePtr im_in,
int
main (int argc, char *argv[])
{
-#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
@@ -55,9 +53,6 @@ main (int argc, char *argv[])
testDrawing (im_in, 2.0, 0, 1, "noblending-doublesize-palette.png");
testDrawing (im_in, 2.0, 1, 1, "blending-doublesize-palette.png");
gdImageDestroy (im_in);
-#else
- fprintf (stderr, "No PNG library support.\n");
-#endif
return 0;
}
@@ -116,11 +111,7 @@ testDrawing (gdImagePtr im_in,
gdImageTrueColorToPalette (im_out, 1, 256);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im_out, out);
-#else
- fprintf (stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im_out);
diff --git a/src/testtr.c b/src/testtr.c
index b7b419f..ed1b374 100644
--- a/src/testtr.c
+++ b/src/testtr.c
@@ -11,8 +11,6 @@
int
main(void)
{
-#ifdef HAVE_LIBFREETYPE
- FILE *out;
int transparent, green, black;
gdImagePtr im;
@@ -37,17 +35,15 @@ main(void)
gdImageSaveAlpha (im, TRUE);
#ifdef HAVE_LIBPNG
- out = fopen ("testtr.png", "wb");
- gdImagePng (im, out);
- fclose (out);
+ {
+ FILE *out = fopen("testtr.png", "wb");
+ gdImagePng(im, out);
+ fclose(out);
+ }
#else
fprintf(stderr, "Compiled without libpng support\n");
#endif /* HAVE_LIBPNG */
gdImageDestroy (im);
return 0;
-#else
- fprintf(stderr, "Compiled without freetype support\n");
- return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/src/wbmp.c b/src/wbmp.c
index 6be3941..6f187f9 100644
--- a/src/wbmp.c
+++ b/src/wbmp.c
@@ -38,7 +38,8 @@
*/
int getmbi(int (*getin) (void *in), void *in)
{
- int i, mbi = 0;
+ unsigned int mbi = 0;
+ int i;
do {
i = getin(in);
diff --git a/src/wbmp.h b/src/wbmp.h
index f163b4b..9a93d6e 100644
--- a/src/wbmp.h
+++ b/src/wbmp.h
@@ -1,7 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* WBMP
* ----
* WBMP Level 0: B/W, Uncompressed
@@ -16,6 +12,10 @@ extern "C" {
#ifndef __WBMP_H
#define __WBMP_H 1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* WBMP struct
* -----------
* A Wireless bitmap structure
@@ -44,8 +44,8 @@ extern "C" {
void freewbmp(Wbmp *wbmp);
void printwbmp(Wbmp *wbmp);
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/src/webpng.c b/src/webpng.c
index 6faa909..b376253 100644
--- a/src/webpng.c
+++ b/src/webpng.c
@@ -4,16 +4,10 @@
/* Bring in standard I/O and string manipulation functions */
#include <stdarg.h>
-#ifdef HAVE_ERRNO_H
#include <errno.h>
-#endif
#include <stdio.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -26,6 +20,8 @@
/* Bring in the gd library functions */
#include "gd.h"
+#define KEEP_TRANS (-100)
+
static const char argv0[] = "webpng";
static void usage(const char *msg)
@@ -74,7 +70,7 @@ main(int argc, char **argv)
int interlace = -100;
int list_color_table = 0;
- int trans_col = -1;
+ int trans_col = KEEP_TRANS;
int report_details = 0;
int print_alpha = 0;
@@ -251,7 +247,7 @@ main(int argc, char **argv)
else if (interlace == 0)
gdImageInterlace(im, 0);
- if (trans_col != -100)
+ if (trans_col != KEEP_TRANS)
gdImageColorTransparent(im, trans_col);
if (use_stdin_stdout) {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c4fa9ca..b279f63 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,3 @@
-
if (BUILD_TEST)
SET(DART_TESTING_TIMEOUT 5)
@@ -18,6 +17,7 @@ if (BUILD_TEST)
include_directories (BEFORE ${GD_INCLUDE_DIR} "${GDTEST_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/tests/gdtest")
SET(TESTS_DIRS
+ avif
bmp
fontconfig
freetype
@@ -28,16 +28,23 @@ if (BUILD_TEST)
gdimageclone
gdimagecolor
gdimagecolorclosest
+ gdimagecolorclosesthwb
gdimagecolordeallocate
gdimagecolorexact
+ gdimagecolormatch
gdimagecolorreplace
gdimagecolorresolve
gdimagecolortransparent
+ gdimagecompare
gdimagecontrast
gdimageconvolution
gdimagecopy
+ gdimagecopymerge
+ gdimagecopymergegray
gdimagecopyresampled
+ gdimagecopyresized
gdimagecopyrotated
+ gdimagecreate
gdimagecrop
gdimagefile
gdimagefill
@@ -48,6 +55,7 @@ if (BUILD_TEST)
gdimagefilltoborder
gdimagefilter
gdimageflip
+ gdimageellipse
gdimagegrayscale
gdimageline
gdimagenegate
@@ -58,16 +66,24 @@ if (BUILD_TEST)
gdimagerotate
gdimagescale
gdimagescatterex
+ gdimagesetinterpolationmethod
gdimagesetpixel
+ gdimagesquaretocircle
+ gdimagestring
+ gdimagestring16
gdimagestringft
gdimagestringftex
+ gdimagestringup
+ gdimagestringup16
gdimagetruecolortopalette
gdinterpolatedscale
gdnewfilectx
gdtest
gdtiled
gdtransformaffineboundingbox
+ gdtransformaffinecopy
gif
+ heif
jpeg
png
tga
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fc5ed2b..3630810 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,6 +13,7 @@ CLEANFILES =
EXTRA_DIST =
TESTS =
+include avif/Makemodule.am
include bmp/Makemodule.am
include fontconfig/Makemodule.am
include freetype/Makemodule.am
@@ -23,16 +24,23 @@ include gdimagebrightness/Makemodule.am
include gdimageclone/Makemodule.am
include gdimagecolor/Makemodule.am
include gdimagecolorclosest/Makemodule.am
+include gdimagecolorclosesthwb/Makemodule.am
include gdimagecolordeallocate/Makemodule.am
include gdimagecolorexact/Makemodule.am
+include gdimagecolormatch/Makemodule.am
include gdimagecolorreplace/Makemodule.am
include gdimagecolorresolve/Makemodule.am
include gdimagecolortransparent/Makemodule.am
+include gdimagecompare/Makemodule.am
include gdimagecontrast/Makemodule.am
include gdimageconvolution/Makemodule.am
include gdimagecopy/Makemodule.am
+include gdimagecopymerge/Makemodule.am
+include gdimagecopymergegray/Makemodule.am
include gdimagecopyresampled/Makemodule.am
+include gdimagecopyresized/Makemodule.am
include gdimagecopyrotated/Makemodule.am
+include gdimagecreate/Makemodule.am
include gdimagecrop/Makemodule.am
include gdimagefile/Makemodule.am
include gdimagefill/Makemodule.am
@@ -43,6 +51,7 @@ include gdimagefilledrectangle/Makemodule.am
include gdimagefilltoborder/Makemodule.am
include gdimagefilter/Makemodule.am
include gdimageflip/Makemodule.am
+include gdimageellipse/Makemodule.am
include gdimagegrayscale/Makemodule.am
include gdimageline/Makemodule.am
include gdimagenegate/Makemodule.am
@@ -53,16 +62,24 @@ include gdimagerectangle/Makemodule.am
include gdimagerotate/Makemodule.am
include gdimagescale/Makemodule.am
include gdimagescatterex/Makemodule.am
+include gdimagesetinterpolationmethod/Makemodule.am
include gdimagesetpixel/Makemodule.am
+include gdimagesquaretocircle/Makemodule.am
+include gdimagestring/Makemodule.am
+include gdimagestring16/Makemodule.am
include gdimagestringft/Makemodule.am
include gdimagestringftex/Makemodule.am
+include gdimagestringup/Makemodule.am
+include gdimagestringup16/Makemodule.am
include gdimagetruecolortopalette/Makemodule.am
include gdinterpolatedscale/Makemodule.am
include gdnewfilectx/Makemodule.am
include gdtest/Makemodule.am
include gdtiled/Makemodule.am
include gdtransformaffineboundingbox/Makemodule.am
+include gdtransformaffinecopy/Makemodule.am
include gif/Makemodule.am
+include heif/Makemodule.am
include jpeg/Makemodule.am
include png/Makemodule.am
include tga/Makemodule.am
@@ -83,10 +100,12 @@ EXTRA_DIST += \
# We don't keep any media files in the top dir ... just generated outputs.
CLEANFILES += \
+ *.avif \
*.bmp \
*.gd \
*.gd2 \
*.gif \
+ *.heif \
*.jpeg \
*.jpg \
*.png \
diff --git a/tests/avif/.gitignore b/tests/avif/.gitignore
new file mode 100644
index 0000000..66233b0
--- /dev/null
+++ b/tests/avif/.gitignore
@@ -0,0 +1,5 @@
+/avif_im2im
+/avif_null
+/avif_ptr_double_free
+/bad_input
+/compare_avif_to_png
diff --git a/tests/avif/CMakeLists.txt b/tests/avif/CMakeLists.txt
new file mode 100644
index 0000000..e2df47b
--- /dev/null
+++ b/tests/avif/CMakeLists.txt
@@ -0,0 +1,17 @@
+IF(AVIF_FOUND)
+LIST(APPEND TESTS_FILES
+ avif_ptr_double_free
+ avif_im2im
+ avif_null
+ bad_input
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ compare_avif_to_png
+)
+ENDIF(PNG_FOUND)
+
+ENDIF(AVIF_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/avif/Makemodule.am b/tests/avif/Makemodule.am
new file mode 100644
index 0000000..f7b965a
--- /dev/null
+++ b/tests/avif/Makemodule.am
@@ -0,0 +1,24 @@
+if HAVE_LIBAVIF
+libgd_test_programs += \
+ avif/avif_ptr_double_free
+ avif/avif_im2im
+ avif/avif_null
+ avif/bad_input
+
+if HAVE_LIBPNG
+libgd_test_programs += \
+ avif/compare_avif_to_png
+endif
+
+endif
+
+EXTRA_DIST += \
+ avif/CMakeLists.txt \
+ avif/baboon.avif \
+ avif/baboon.png \
+ avif/dice_with_alpha.avif \
+ avif/dice_with_alpha.png \
+ avif/plum_blossom_12bit.avif \
+ avif/plum_blossom_12bit.png \
+ avif/sunset.avif \
+ avif/sunset.png
diff --git a/tests/avif/avif_im2im.c b/tests/avif/avif_im2im.c
new file mode 100644
index 0000000..3a07ebd
--- /dev/null
+++ b/tests/avif/avif_im2im.c
@@ -0,0 +1,67 @@
+/**
+ * File: avif_im2im
+ *
+ * Sanity check for AVIF encoding and decoding.
+ * We create a simple gd image, we encode it to AVIF, and we decode it back to gd.
+ * Then we make sure the image we started with and the image we finish with are the same.
+ *
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+#include <stdio.h>
+
+int main()
+{
+ gdImagePtr srcGdIm, destGdIm;
+ void *avifImageDataPtr;
+ FILE *fp;
+ int r, g, b;
+ int size = 0;
+ CuTestImageResult result = {0, 0};
+
+ // Create new gd image and add some shapes to it.
+ srcGdIm = gdImageCreateTrueColor(100, 100);
+ gdTestAssertMsg(srcGdIm != NULL, "could not create source image\n");
+
+ r = gdImageColorAllocate(srcGdIm, 0xFF, 0, 0);
+ g = gdImageColorAllocate(srcGdIm, 0, 0xFF, 0);
+ b = gdImageColorAllocate(srcGdIm, 0, 0, 0xFF);
+ gdImageFilledRectangle(srcGdIm, 0, 0, 99, 99, r);
+ gdImageRectangle(srcGdIm, 20, 20, 79, 79, g);
+ gdImageEllipse(srcGdIm, 70, 25, 30, 20, b);
+
+ // Encode the gd image to a test AVIF file.
+ fp = gdTestTempFp();
+ gdImageAvif(srcGdIm, fp);
+ fclose(fp);
+
+ // Encode the gd image to an AVIF image in memory.
+ avifImageDataPtr = gdImageAvifPtrEx(srcGdIm, &size, 100, 10);
+ gdTestAssertMsg(avifImageDataPtr != NULL, "gdImageAvifPtr() returned null\n");
+ gdTestAssertMsg(size > 0, "gdImageAvifPtr() returned a non-positive size\n");
+
+ // Encode the AVIF image back into a gd image.
+ destGdIm = gdImageCreateFromAvifPtr(size, avifImageDataPtr);
+ gdTestAssertMsg(destGdIm != NULL, "gdImageAvifPtr() returned null\n");
+
+ // Encode that gd image to a test AVIF file.
+ fp = gdTestTempFp();
+ gdImageAvif(destGdIm, fp);
+ fclose(fp);
+
+ // Make sure the image we started with is the same as the image after two conversions.
+ gdTestImageDiff(srcGdIm, destGdIm, NULL, &result);
+ gdTestAssertMsg(result.pixels_changed == 0, "pixels changed: %d\n", result.pixels_changed);
+
+ if (srcGdIm)
+ gdImageDestroy(srcGdIm);
+
+ if (destGdIm)
+ gdImageDestroy(destGdIm);
+
+ if (avifImageDataPtr)
+ gdFree(avifImageDataPtr);
+
+ return gdNumFailures();
+}
diff --git a/tests/avif/avif_null.c b/tests/avif/avif_null.c
new file mode 100644
index 0000000..bbcc9c6
--- /dev/null
+++ b/tests/avif/avif_null.c
@@ -0,0 +1,23 @@
+/**
+ * File: avif_null.c
+ *
+ * Simple test case, confirming that if you try to create an AVIF image from a
+ * null file pointer, the creation will fail, and it will return NULL.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreateFromAvif(NULL);
+ if (!gdTestAssert(im == NULL))
+ gdImageDestroy(im);
+
+ gdImageAvif(im, NULL); /* noop safely */
+
+ return gdNumFailures();
+}
diff --git a/tests/avif/avif_ptr_double_free.c b/tests/avif/avif_ptr_double_free.c
new file mode 100644
index 0000000..8160950
--- /dev/null
+++ b/tests/avif/avif_ptr_double_free.c
@@ -0,0 +1,34 @@
+/**
+ * Test that failure to convert to AVIF returns NULL
+ *
+ * We are creating an image, set its width to zero, and pass this image to
+ * gdImageAvifPtr().
+ * This is supposed to fail, and as such should return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ int size;
+
+ src = gdImageCreateTrueColor(1, 10);
+ gdTestAssert(src != NULL);
+
+ src->sx = 0; // making the width 0 should cause gdImageAvifPtr() to fail
+
+ dst = gdImageAvifPtr(src, &size);
+ gdTestAssert(dst == NULL);
+
+ if (src)
+ gdImageDestroy(src);
+
+ if (dst)
+ gdImageDestroy(dst);
+
+ return gdNumFailures();
+}
diff --git a/tests/avif/baboon.avif b/tests/avif/baboon.avif
new file mode 100644
index 0000000..f5821db
--- /dev/null
+++ b/tests/avif/baboon.avif
Binary files differ
diff --git a/tests/avif/baboon.png b/tests/avif/baboon.png
new file mode 100644
index 0000000..fdc5dcb
--- /dev/null
+++ b/tests/avif/baboon.png
Binary files differ
diff --git a/tests/avif/bad_input.c b/tests/avif/bad_input.c
new file mode 100644
index 0000000..0f814c9
--- /dev/null
+++ b/tests/avif/bad_input.c
@@ -0,0 +1,57 @@
+/**
+ * File: bad_input.c
+ *
+ * Make sure that the AVIF encoding and decoding functions handle bad input gracefully.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int main() {
+ FILE *fp;
+ int retval;
+ gdImagePtr realIm, badIm;
+ void *rv;
+ int size;
+
+ // Read in an AVIF image for testing.
+
+ fp = gdTestFileOpen2("avif", "sunset.avif");
+ realIm = gdImageCreateFromAvif(fp);
+ fclose(fp);
+ if (!gdTestAssertMsg(realIm != NULL, "gdImageCreateFromAvif() failed\n"))
+ return 1;
+
+ // Try to decode a non-AVIF file.
+ fp = gdTestFileOpen2("avif", "sunset.png");
+ badIm = gdImageCreateFromAvif(fp);
+ fclose(fp);
+ gdTestAssertMsg(badIm == NULL, "gdImageCreateFromAvif() failed to return NULL when passed a non-AVIF file\n");
+
+ if (badIm)
+ gdImageDestroy(badIm);
+
+ // Try to encode a valid image with bad quality parameters. This should still work.
+
+ rv = gdImageAvifPtrEx(realIm, &size, 400, 10);
+ gdTestAssertMsg(rv != NULL, "gdImageAvifPtrEx() rejected an overly high quality param instead of clamping it to a valid value");
+ gdFree(rv);
+
+ rv = gdImageAvifPtrEx(realIm, &size, -4, 10);
+ gdTestAssertMsg(rv != NULL, "gdImageAvifPtrEx() rejected a negative quality param instead of clamping it to a valid value");
+ gdFree(rv);
+
+ rv = gdImageAvifPtrEx(realIm, &size, 30, 30);
+ gdTestAssertMsg(rv != NULL, "gdImageAvifPtrEx() rejected an overly high speed param instead of clamping it to a valid value");
+ gdFree(rv);
+
+ rv = gdImageAvifPtrEx(realIm, &size, 30, -4);
+ gdTestAssertMsg(rv != NULL, "gdImageAvifPtrEx() rejected a negative speed param instead of clamping it to a valid value");
+ gdFree(rv);
+
+ gdImageDestroy(realIm);
+
+ return gdNumFailures();
+}
diff --git a/tests/avif/compare_avif_to_png.c b/tests/avif/compare_avif_to_png.c
new file mode 100644
index 0000000..6330ea3
--- /dev/null
+++ b/tests/avif/compare_avif_to_png.c
@@ -0,0 +1,92 @@
+/**
+ * File: compare_avif_to_png
+ *
+ * Thorough check for AVIF encoding and decoding.
+ * This test reqiures a set of PNG images that have been losslessly encoded to AVIFs.
+ * For each such image, we encode the PNG into an AVIF, with the GD format as an intermediary,
+ * then compare the resulting AVIF with the original PNG.
+ *
+ * We then do this process in reverse, encoding the AVIF into a PNG,
+ * and compare the resulting PNG with the original AVIF.
+ *
+ * We report any discrepancies in the images, or any other errors that may occur.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int main() {
+ FILE *fp;
+ gdImagePtr imFromPng = NULL, imFromAvif = NULL;
+ void *avifImDataPtr = NULL, *pngImDataPtr = NULL;
+ int size;
+ char pngFilename[100], avifFilename[100], *pngFilePath;
+ char errMsg[4096];
+
+ static const char * const filenames[] = {"baboon", "dice_with_alpha", "plum_blossom_12bit", "sunset"};
+ const int filesCount = sizeof(filenames) / sizeof(filenames[0]);
+
+ for (int i = 0; i < filesCount; i++) {
+
+ // First, encode each PNG into an AVIF (with the GD format as an intermediary),
+ // then compare the result with the original PNG.
+ sprintf(pngFilename, "%s.png", filenames[i]);
+
+ fp = gdTestFileOpen2("avif", pngFilename);
+ imFromPng = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ strcat(strcpy(errMsg, filenames[i]), ".png: gdImageCreateFromPng failed\n");
+ if (!gdTestAssertMsg(imFromPng != NULL, errMsg))
+ goto avif2png;
+
+ strcat(strcpy(errMsg, filenames[i]), ": gdImageAvifPtrEx failed\n");
+ avifImDataPtr = gdImageAvifPtrEx(imFromPng, &size, 100, 0);
+ if (!gdTestAssertMsg(avifImDataPtr != NULL, errMsg))
+ goto avif2png;
+
+ strcat(strcpy(errMsg, filenames[i]), ": gdImageCreateFromAvifPtr failed\n");
+ imFromAvif = gdImageCreateFromAvifPtr(size, avifImDataPtr);
+ if (!gdTestAssertMsg(imFromAvif != NULL, errMsg))
+ goto avif2png;
+
+ strcat(strcpy(errMsg, filenames[i]), ".png: Encoded AVIF image did not match original PNG\n");
+ gdTestAssertMsg(gdAssertImageEquals(imFromPng, imFromAvif), errMsg);
+
+ // Then, decode each AVIF into a GD format, and compare that with the orginal PNG.
+avif2png:
+
+ // Skip this reverse test for now, until we can find images that encode to PNGs losslessly.
+if (0) {
+ sprintf(avifFilename, "%s.avif", filenames[i]);
+ fp = gdTestFileOpen2("avif", avifFilename);
+ imFromAvif = gdImageCreateFromAvif(fp);
+ fclose(fp);
+
+ strcat(strcpy(errMsg, filenames[i]), ".avif: gdImageCreateFromAvif failed\n");
+ if (!gdTestAssertMsg(imFromAvif != NULL, errMsg))
+ continue;
+
+ strcat(strcpy(errMsg, filenames[i]), ".avif: Encoded PNG image did not match original AVIF\n");
+ pngFilePath = gdTestFilePath2("avif", pngFilename);
+ gdTestAssertMsg(gdAssertImageEqualsToFile(pngFilePath, imFromAvif), errMsg);
+ free(pngFilePath);
+}
+ }
+
+ if (imFromPng)
+ gdImageDestroy(imFromPng);
+
+ if (imFromAvif)
+ gdImageDestroy(imFromAvif);
+
+ if (avifImDataPtr)
+ gdFree(avifImDataPtr);
+
+ if (pngImDataPtr)
+ gdFree(pngImDataPtr);
+
+ return gdNumFailures();
+}
diff --git a/tests/avif/dice_with_alpha.avif b/tests/avif/dice_with_alpha.avif
new file mode 100644
index 0000000..dce625b
--- /dev/null
+++ b/tests/avif/dice_with_alpha.avif
Binary files differ
diff --git a/tests/avif/dice_with_alpha.png b/tests/avif/dice_with_alpha.png
new file mode 100644
index 0000000..d2809d1
--- /dev/null
+++ b/tests/avif/dice_with_alpha.png
Binary files differ
diff --git a/tests/avif/plum_blossom_12bit.avif b/tests/avif/plum_blossom_12bit.avif
new file mode 100644
index 0000000..7959d15
--- /dev/null
+++ b/tests/avif/plum_blossom_12bit.avif
Binary files differ
diff --git a/tests/avif/plum_blossom_12bit.png b/tests/avif/plum_blossom_12bit.png
new file mode 100644
index 0000000..e6901e2
--- /dev/null
+++ b/tests/avif/plum_blossom_12bit.png
Binary files differ
diff --git a/tests/avif/sunset.avif b/tests/avif/sunset.avif
new file mode 100644
index 0000000..4964558
--- /dev/null
+++ b/tests/avif/sunset.avif
Binary files differ
diff --git a/tests/avif/sunset.png b/tests/avif/sunset.png
new file mode 100644
index 0000000..21f45d5
--- /dev/null
+++ b/tests/avif/sunset.png
Binary files differ
diff --git a/tests/bmp/.gitignore b/tests/bmp/.gitignore
index 7c4edd0..c2cd2af 100644
--- a/tests/bmp/.gitignore
+++ b/tests/bmp/.gitignore
@@ -2,3 +2,4 @@
/bmp_null
/bug00275
/bug00276
+/bug00450
diff --git a/tests/bmp/CMakeLists.txt b/tests/bmp/CMakeLists.txt
index 82dfb67..0cc1d06 100644
--- a/tests/bmp/CMakeLists.txt
+++ b/tests/bmp/CMakeLists.txt
@@ -1,7 +1,8 @@
LIST(APPEND TESTS_FILES
- bmp_im2im
bmp_null
bug00275
+ bug00450
+ bmp_im2im
bug00276
)
diff --git a/tests/bmp/Makemodule.am b/tests/bmp/Makemodule.am
index 27dc7ec..e7908f3 100644
--- a/tests/bmp/Makemodule.am
+++ b/tests/bmp/Makemodule.am
@@ -1,12 +1,10 @@
libgd_test_programs += \
bmp/bmp_null \
bmp/bug00275 \
+ bmp/bug00450 \
+ bmp/bmp_im2im \
bmp/bug00276
-if HAVE_LIBPNG
-libgd_test_programs += \
- bmp/bmp_im2im
-endif
-
EXTRA_DIST += \
+ bmp/bug00450.bmp \
bmp/CMakeLists.txt
diff --git a/tests/bmp/bug00275.c b/tests/bmp/bug00275.c
index 710c084..775d849 100644
--- a/tests/bmp/bug00275.c
+++ b/tests/bmp/bug00275.c
@@ -6,7 +6,7 @@
#ifdef __GNUC__
-#define UNUSED __attribute__((unused))
+#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
@@ -49,5 +49,7 @@ int main()
/* "save" the image as BMP */
gdImageBmpCtx(im, &ctx, 2);
+ gdImageDestroy(im);
+
return gdNumFailures();
}
diff --git a/tests/bmp/bug00276.c b/tests/bmp/bug00276.c
index 58ca423..dd5d513 100644
--- a/tests/bmp/bug00276.c
+++ b/tests/bmp/bug00276.c
@@ -28,5 +28,7 @@ int main()
gdImageDestroy(im_orig);
gdImageDestroy(im_saved);
+ gdFree(data);
+
return gdNumFailures();
}
diff --git a/tests/bmp/bug00450.bmp b/tests/bmp/bug00450.bmp
new file mode 100644
index 0000000..2db27a3
--- /dev/null
+++ b/tests/bmp/bug00450.bmp
Binary files differ
diff --git a/tests/bmp/bug00450.c b/tests/bmp/bug00450.c
new file mode 100644
index 0000000..e048845
--- /dev/null
+++ b/tests/bmp/bug00450.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main(void) {
+ char *path = gdTestFilePath("bmp/bug00450.bmp");
+ gdImagePtr im = gdImageCreateFromFile(path);
+ gdTestAssert(im != NULL);
+
+ if (im) {
+ char const ref[] =
+ "# "
+ "## "
+ "### "
+ "#### "
+ "##### "
+ "###### "
+ "####### "
+ "######## "
+ "######### "
+ "##########"
+ ;
+ int x, y;
+
+ for (y = 0; y < 10; ++y) {
+ for (x = 0; x < 10; ++x) {
+ int const expected_pixel = ref[x + y * 10] == '#';
+ int const actual_pixel = gdImageGetPixel(im, x, y);
+ gdTestAssert(expected_pixel == actual_pixel);
+ }
+ }
+
+ gdImageDestroy(im);
+ }
+
+ free(path);
+
+ return gdNumFailures();
+}
diff --git a/tests/fontconfig/CMakeLists.txt b/tests/fontconfig/CMakeLists.txt
index 159130d..f78c4cf 100644
--- a/tests/fontconfig/CMakeLists.txt
+++ b/tests/fontconfig/CMakeLists.txt
@@ -1,7 +1,9 @@
-IF(FREETYPE_FOUND AND FONTCONFIG_FOUND)
+if(FONTCONFIG_FOUND)
+IF(FREETYPE_FOUND)
LIST(APPEND TESTS_FILES
basic
)
-ENDIF(FREETYPE_FOUND AND FONTCONFIG_FOUND)
+ENDIF(FREETYPE_FOUND)
+ENDIF(FONTCONFIG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/freetype/CMakeLists.txt b/tests/freetype/CMakeLists.txt
index a5d8086..9a1e018 100644
--- a/tests/freetype/CMakeLists.txt
+++ b/tests/freetype/CMakeLists.txt
@@ -1,7 +1,9 @@
IF(FREETYPE_FOUND)
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00132
)
+ENDIF(PNG_FOUND)
ENDIF(FREETYPE_FOUND)
ADD_GD_TESTS()
diff --git a/tests/freetype/Makemodule.am b/tests/freetype/Makemodule.am
index d252493..a0dda49 100644
--- a/tests/freetype/Makemodule.am
+++ b/tests/freetype/Makemodule.am
@@ -1,7 +1,9 @@
if HAVE_LIBFREETYPE
+if HAVE_LIBPNG
libgd_test_programs += \
freetype/bug00132
endif
+endif
EXTRA_DIST += \
freetype/CMakeLists.txt \
diff --git a/tests/freetype/bug00132.c b/tests/freetype/bug00132.c
index 713dd2d..42ed5b1 100644
--- a/tests/freetype/bug00132.c
+++ b/tests/freetype/bug00132.c
@@ -11,6 +11,9 @@ int main()
char *path;
char *ret = NULL;
+ /* disable subpixel hinting */
+ putenv("FREETYPE_PROPERTIES=truetype:interpreter-version=35");
+
im = gdImageCreateTrueColor(50, 30);
if (!im) {
diff --git a/tests/gd/.gitignore b/tests/gd/.gitignore
index 5edc65c..8a7d284 100644
--- a/tests/gd/.gitignore
+++ b/tests/gd/.gitignore
@@ -1,3 +1,4 @@
+/bug00383
/gd_im2im
/gd_null
/gd_num_colors
diff --git a/tests/gd/CMakeLists.txt b/tests/gd/CMakeLists.txt
index 3b7ace2..e86c780 100644
--- a/tests/gd/CMakeLists.txt
+++ b/tests/gd/CMakeLists.txt
@@ -1,8 +1,14 @@
LIST(APPEND TESTS_FILES
- gd_im2im
+ gd_versiontest
+)
+
+IF(ENABLE_GD_FORMATS)
+LIST(APPEND TESTS_FILES
+ bug00383
gd_null
gd_num_colors
- gd_versiontest
+ gd_im2im
)
+ENDIF(ENABLE_GD_FORMATS)
ADD_GD_TESTS()
diff --git a/tests/gd/Makemodule.am b/tests/gd/Makemodule.am
index e4a741f..4a45bc2 100644
--- a/tests/gd/Makemodule.am
+++ b/tests/gd/Makemodule.am
@@ -1,13 +1,15 @@
libgd_test_programs += \
- gd/gd_null \
- gd/gd_num_colors \
gd/gd_versiontest
-if HAVE_LIBPNG
+if ENABLE_GD_FORMATS
libgd_test_programs += \
+ gd/bug00383 \
+ gd/gd_null \
+ gd/gd_num_colors \
gd/gd_im2im
endif
EXTRA_DIST += \
+ gd/bug00383.gd \
gd/crafted_num_colors.gd \
gd/CMakeLists.txt
diff --git a/tests/gd/bug00383.c b/tests/gd/bug00383.c
new file mode 100644
index 0000000..edcfd05
--- /dev/null
+++ b/tests/gd/bug00383.c
@@ -0,0 +1,32 @@
+/**
+ * Test that invalid transparent colors can't be read
+ *
+ * We're reading a corrupt palette image in GD format, which has only a single
+ * palette entry, but claims that the transparent color would be 1. We check
+ * that the transparency is simply ignored in this case.
+ *
+ * See also <https://github.com/libgd/libgd/issues/383>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd", "bug00383.gd");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ gdTestAssert(gdImageGetTransparent(im) == -1);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd/bug00383.gd b/tests/gd/bug00383.gd
new file mode 100644
index 0000000..7f8611c
--- /dev/null
+++ b/tests/gd/bug00383.gd
Binary files differ
diff --git a/tests/gd2/.gitignore b/tests/gd2/.gitignore
index 136a2d5..a0e2fa3 100644
--- a/tests/gd2/.gitignore
+++ b/tests/gd2/.gitignore
@@ -1,8 +1,14 @@
/bug_289
+/bug00209
/bug00309
+/bug00354
+/bug00383
+/createimagefromgd2part
+/createimagefromgd2partptr
/gd2_empty_file
/gd2_im2im
/gd2_null
/gd2_read
/gd2_read_corrupt
/php_bug_72339
+/too_few_image_data
diff --git a/tests/gd2/CMakeLists.txt b/tests/gd2/CMakeLists.txt
index 8fcc906..cc188ca 100644
--- a/tests/gd2/CMakeLists.txt
+++ b/tests/gd2/CMakeLists.txt
@@ -1,12 +1,27 @@
+IF(ENABLE_GD_FORMATS)
+IF(ZLIB_FOUND)
LIST(APPEND TESTS_FILES
bug_289
+ bug00209
bug00309
+ bug00354
+ bug00383
+ createimagefromgd2part
+ createimagefromgd2partptr
gd2_empty_file
- gd2_im2im
- gd2_null
php_bug_72339
- gd2_read
+ gd2_null
gd2_read_corrupt
+ too_few_image_data
+ gd2_im2im
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gd2_read
)
+ENDIF(PNG_FOUND)
+ENDIF(ZLIB_FOUND)
+ENDIF(ENABLE_GD_FORMATS)
ADD_GD_TESTS()
diff --git a/tests/gd2/Makemodule.am b/tests/gd2/Makemodule.am
index d69aee0..5cd29e6 100644
--- a/tests/gd2/Makemodule.am
+++ b/tests/gd2/Makemodule.am
@@ -1,26 +1,37 @@
+if ENABLE_GD_FORMATS
+if HAVE_LIBZ
libgd_test_programs += \
gd2/bug_289 \
+ gd2/bug00209 \
gd2/bug00309 \
+ gd2/bug00354 \
+ gd2/bug00383 \
+ gd2/createimagefromgd2part \
+ gd2/createimagefromgd2partptr \
gd2/gd2_empty_file \
gd2/php_bug_72339 \
- gd2/gd2_read_corrupt
-
-if HAVE_LIBZ
-libgd_test_programs += \
- gd2/gd2_null
+ gd2/gd2_null \
+ gd2/gd2_read_corrupt \
+ gd2/too_few_image_data \
+ gd2/gd2_im2im
if HAVE_LIBPNG
libgd_test_programs += \
- gd2/gd2_im2im \
gd2/gd2_read
endif
endif
+endif
EXTRA_DIST += \
gd2/CMakeLists.txt \
+ gd2/bug00209.gd2 \
+ gd2/bug00354a.gd2 \
+ gd2/bug00354b.gd2 \
+ gd2/bug00383.gd2 \
gd2/conv_gd2_exp.gd2 \
gd2/conv_test.gd2 \
gd2/conv_test_exp.png \
gd2/empty.gd2 \
gd2/invalid_header.gd2 \
- gd2/invalid_neg_size.gd2
+ gd2/invalid_neg_size.gd2 \
+ gd2/too_few_image_data.gd2
diff --git a/tests/gd2/bug00209.c b/tests/gd2/bug00209.c
new file mode 100644
index 0000000..7904d01
--- /dev/null
+++ b/tests/gd2/bug00209.c
@@ -0,0 +1,26 @@
+/**
+ * Regression test for github issue #209
+ *
+ * We're testing that bug00209.gd2, which claims to have 12336 x 48 pixels, but
+ * actually provides not enough image data, is rejected, i.e. that
+ * gdImageCreateFromGd2() returns NULL
+ *
+ * See <https://github.com/libgd/libgd/issues/209>.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "bug00209.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd2/bug00209.gd2 b/tests/gd2/bug00209.gd2
new file mode 100644
index 0000000..1c797d1
--- /dev/null
+++ b/tests/gd2/bug00209.gd2
Binary files differ
diff --git a/tests/gd2/bug00354.c b/tests/gd2/bug00354.c
new file mode 100644
index 0000000..1bce091
--- /dev/null
+++ b/tests/gd2/bug00354.c
@@ -0,0 +1,30 @@
+/**
+ * We're testing GD2 image files which report illegal chunk counts. These should
+ * not cause integer overflows or other issues, but instead simply fail to be
+ * loaded.
+ *
+ * See also <https://github.com/libgd/libgd/issues/354>.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "bug00354a.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ fp = gdTestFileOpen2("gd2", "bug00354b.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd2/bug00354a.gd2 b/tests/gd2/bug00354a.gd2
new file mode 100644
index 0000000..5060bfd
--- /dev/null
+++ b/tests/gd2/bug00354a.gd2
Binary files differ
diff --git a/tests/gd2/bug00354b.gd2 b/tests/gd2/bug00354b.gd2
new file mode 100644
index 0000000..8600126
--- /dev/null
+++ b/tests/gd2/bug00354b.gd2
Binary files differ
diff --git a/tests/gd2/bug00383.c b/tests/gd2/bug00383.c
new file mode 100644
index 0000000..dbbf661
--- /dev/null
+++ b/tests/gd2/bug00383.c
@@ -0,0 +1,32 @@
+/**
+ * Test that invalid transparent colors can't be read
+ *
+ * We're reading a corrupt palette image in GD2 format, which has only a single
+ * palette entry, but claims that the transparent color would be 1. We check
+ * that the transparency is simply ignored in this case.
+ *
+ * See also <https://github.com/libgd/libgd/issues/383>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "bug00383.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ gdTestAssert(gdImageGetTransparent(im) == -1);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd2/bug00383.gd2 b/tests/gd2/bug00383.gd2
new file mode 100644
index 0000000..dcb164d
--- /dev/null
+++ b/tests/gd2/bug00383.gd2
Binary files differ
diff --git a/tests/gd2/bug_289.c b/tests/gd2/bug_289.c
index ad311e9..9ca03cc 100644
--- a/tests/gd2/bug_289.c
+++ b/tests/gd2/bug_289.c
@@ -29,5 +29,7 @@ int main()
gdTestAssertMsg(buffer[12] == 0, MSG, "1st", 0, buffer[12]);
gdTestAssertMsg(buffer[13] == GD2_FMT_TRUECOLOR_COMPRESSED, MSG, "2nd", GD2_FMT_TRUECOLOR_COMPRESSED, buffer[13]);
+ gdFree(buffer);
+
return gdNumFailures();
}
diff --git a/tests/gd2/createimagefromgd2part.c b/tests/gd2/createimagefromgd2part.c
new file mode 100644
index 0000000..0c81ba6
--- /dev/null
+++ b/tests/gd2/createimagefromgd2part.c
@@ -0,0 +1,35 @@
+/**
+ *Base test for gdImageCreateFromGd2Part()
+ */
+#include "gd.h"
+#include "gdtest.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+ gdImagePtr im;
+ FILE *p;
+ int expected_color = 0xffffff;
+ int actual_color = 0;
+
+ p = gdTestFileOpen2("gd2", "conv_test.gd2");
+
+ if (!p) {
+ gdTestErrorMsg("failed, connot open gd2 file: conv_test.gd2");
+ return 1;
+ }
+
+ im = gdImageCreateFromGd2Part(p, 3, 3, 3, 3);
+ fclose(p);
+
+ if (!im) {
+ return 1;
+ }
+
+ actual_color = gdImageGetPixel(im, 2, 2);
+ gdImageDestroy(im);
+ gdTestAssert(expected_color == actual_color);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd2/createimagefromgd2partptr.c b/tests/gd2/createimagefromgd2partptr.c
new file mode 100644
index 0000000..e432874
--- /dev/null
+++ b/tests/gd2/createimagefromgd2partptr.c
@@ -0,0 +1,59 @@
+/**
+ * Base test for gdImageCreateFromGd2PartPtr()
+ */
+#include "gd.h"
+#include "gdtest.h"
+#include <stdio.h>
+
+int main()
+{
+ FILE *p;
+ gdImagePtr im, partim;
+ void *pg;
+ int size = 0;
+ int status = 0;
+ int actual_color = 0;
+ int expected_color = 0xffffff;
+
+ p = gdTestFileOpen2("gd2", "conv_test.gd2");
+ if (!p) {
+ gdTestErrorMsg("failed, cannot open gd2 file:conv_test.gd2");
+ return 1;
+ }
+
+ im = gdImageCreateFromGd2(p);
+ fclose(p);
+
+ if (!im) {
+ gdTestErrorMsg("failed, cannot create gd2 file.");
+ return 1;
+ }
+
+ pg = gdImageGd2Ptr(im, (GD2_CHUNKSIZE_MIN + GD2_CHUNKSIZE_MAX) / 2, GD2_FMT_COMPRESSED, &size);
+ if (!pg) {
+ status = 1;
+ goto done1;
+ }
+
+ if (size <= 0) {
+ status = 1;
+ goto done0;
+ }
+
+ partim = gdImageCreateFromGd2PartPtr(size, pg, 3, 3, 3, 3);
+ if (!partim) {
+ status = 1;
+ goto done0;
+ }
+
+ actual_color = gdImageGetPixel(partim, 2, 2);
+ status = (expected_color == actual_color) ? 0 : 1;
+ gdImageDestroy(partim);
+
+done0:
+ gdFree(pg);
+done1:
+ gdImageDestroy(im);
+
+ return status;
+}
diff --git a/tests/gd2/gd2_read.c b/tests/gd2/gd2_read.c
index 8ce8bd1..9f2b808 100644
--- a/tests/gd2/gd2_read.c
+++ b/tests/gd2/gd2_read.c
@@ -33,17 +33,18 @@ int main(int argc, char *argv[])
fp = gdTestFileOpen2("gd2", path_exp[i]);
if (!fp) {
gdTestErrorMsg("failed, cannot open file: %s\n", path_exp[i]);
+ gdImageDestroy(im);
return 1;
}
exp = gdImageCreateFromPng(fp);
if (!gdAssertImageEquals(exp, im)) {
gdTestErrorMsg("image %s differs from expected result\n", path[i]);
- gdImageDestroy(im);
error = 1;
}
if (exp) {
gdImageDestroy(exp);
}
+ gdImageDestroy(im);
} else {
/* expected to fail */
if (im) {
diff --git a/tests/gd2/php_bug_72339.c b/tests/gd2/php_bug_72339.c
index 7ce6028..8217c87 100644
--- a/tests/gd2/php_bug_72339.c
+++ b/tests/gd2/php_bug_72339.c
@@ -29,7 +29,7 @@ int main()
im = gdImageCreateFromGd2(fp);
fclose(fp);
-
+
gdTestAssertMsg(im == NULL, "Image should have failed to be loaded\n");
return gdNumFailures();
diff --git a/tests/gd2/too_few_image_data.c b/tests/gd2/too_few_image_data.c
new file mode 100644
index 0000000..3153a08
--- /dev/null
+++ b/tests/gd2/too_few_image_data.c
@@ -0,0 +1,22 @@
+/*
+too_few_image_data.gd2 claims to have a size of 12336x48 pixels, but doesn't
+provide as much image data. We test that gdImageCreateFromGd2Ctx() returns NULL
+in this case.
+*/
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gd2", "too_few_image_data.gd2");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd2(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/gd2/too_few_image_data.gd2 b/tests/gd2/too_few_image_data.gd2
new file mode 100644
index 0000000..1c797d1
--- /dev/null
+++ b/tests/gd2/too_few_image_data.gd2
Binary files differ
diff --git a/tests/gdimagearc/CMakeLists.txt b/tests/gdimagearc/CMakeLists.txt
index 77117fb..fc8ca57 100644
--- a/tests/gdimagearc/CMakeLists.txt
+++ b/tests/gdimagearc/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00079
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagebrightness/CMakeLists.txt b/tests/gdimagebrightness/CMakeLists.txt
index 381c74d..802c382 100644
--- a/tests/gdimagebrightness/CMakeLists.txt
+++ b/tests/gdimagebrightness/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagebrightness/basic.c b/tests/gdimagebrightness/basic.c
index 8c3a73c..dfed242 100644
--- a/tests/gdimagebrightness/basic.c
+++ b/tests/gdimagebrightness/basic.c
@@ -1,41 +1,37 @@
-/**
- * Basic test for gdImageBrightness()
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-static void test_brightness(int brightness);
-
-
-int main()
-{
- test_brightness(+100);
- test_brightness(-100);
-
- return gdNumFailures();
-}
-
-
-static void test_brightness(int brightness)
-{
- gdImagePtr im;
- FILE *fp;
- char basename[256];
- char *path;
-
- fp = gdTestFileOpen2("gdimagebrightness", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- gdImageBrightness(im, brightness);
-
- sprintf(basename, "basic%+03d.png", brightness);
- path = gdTestFilePath2("gdimagebrightness", basename);
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-}
+/**
+ * Basic test for gdImageBrightness()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+static void test_brightness(int brightness);
+
+int main()
+{
+ test_brightness(+100);
+ test_brightness(-100);
+
+ return gdNumFailures();
+}
+
+static void test_brightness(int brightness)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagebrightness", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageBrightness(im, brightness);
+
+ sprintf(basename, "basic%+03d.png", brightness);
+ path = gdTestFilePath2("gdimagebrightness", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/tests/gdimageclone/.gitignore b/tests/gdimageclone/.gitignore
index a70782d..f4129cc 100644
--- a/tests/gdimageclone/.gitignore
+++ b/tests/gdimageclone/.gitignore
@@ -1 +1,2 @@
/bug00300
+/style
diff --git a/tests/gdimageclone/CMakeLists.txt b/tests/gdimageclone/CMakeLists.txt
index e6ccc31..662f4e9 100644
--- a/tests/gdimageclone/CMakeLists.txt
+++ b/tests/gdimageclone/CMakeLists.txt
@@ -1,5 +1,6 @@
LIST(APPEND TESTS_FILES
bug00300
+ style
)
ADD_GD_TESTS()
diff --git a/tests/gdimageclone/Makemodule.am b/tests/gdimageclone/Makemodule.am
index 4b1b54c..51abf5c 100644
--- a/tests/gdimageclone/Makemodule.am
+++ b/tests/gdimageclone/Makemodule.am
@@ -1,5 +1,6 @@
libgd_test_programs += \
- gdimageclone/bug00300
+ gdimageclone/bug00300 \
+ gdimageclone/style
EXTRA_DIST += \
gdimageclone/CMakeLists.txt
diff --git a/tests/gdimageclone/style.c b/tests/gdimageclone/style.c
new file mode 100644
index 0000000..c2b246e
--- /dev/null
+++ b/tests/gdimageclone/style.c
@@ -0,0 +1,30 @@
+/**
+ * Cloning an image should exactly reproduce all style related data
+ */
+
+
+#include <string.h>
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im, clone;
+ int style[] = {0, 0, 0};
+
+ im = gdImageCreate(8, 8);
+ gdImageSetStyle(im, style, sizeof(style)/sizeof(style[0]));
+
+ clone = gdImageClone(im);
+ gdTestAssert(clone != NULL);
+
+ gdTestAssert(clone->styleLength == im->styleLength);
+ gdTestAssert(clone->stylePos == im->stylePos);
+ gdTestAssert(!memcmp(clone->style, im->style, sizeof(style)/sizeof(style[0])));
+
+ gdImageDestroy(clone);
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecolor/CMakeLists.txt b/tests/gdimagecolor/CMakeLists.txt
index 381c74d..802c382 100644
--- a/tests/gdimagecolor/CMakeLists.txt
+++ b/tests/gdimagecolor/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagecolor/basic.c b/tests/gdimagecolor/basic.c
index 2ad0f3c..86c0aff 100644
--- a/tests/gdimagecolor/basic.c
+++ b/tests/gdimagecolor/basic.c
@@ -1,29 +1,27 @@
-/**
- * Basic test for gdImageColor()
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- FILE *fp;
- char *path;
-
- fp = gdTestFileOpen2("gdimagecolor", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- gdImageColor(im, 127, -127, -127, 0);
-
- path = gdTestFilePath2("gdimagecolor", "basic_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * Basic test for gdImageColor()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecolor", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageColor(im, 127, -127, -127, 0);
+
+ path = gdTestFilePath2("gdimagecolor", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecolorclosest/Makemodule.am b/tests/gdimagecolorclosest/Makemodule.am
index f4da8be..be42204 100644
--- a/tests/gdimagecolorclosest/Makemodule.am
+++ b/tests/gdimagecolorclosest/Makemodule.am
@@ -1,7 +1,5 @@
-if HAVE_LIBPNG
libgd_test_programs += \
gdimagecolorclosest/gdimagecolorclosest
-endif
EXTRA_DIST += \
gdimagecolorclosest/CMakeLists.txt
diff --git a/tests/gdimagecolorclosesthwb/.gitignore b/tests/gdimagecolorclosesthwb/.gitignore
new file mode 100644
index 0000000..f46016c
--- /dev/null
+++ b/tests/gdimagecolorclosesthwb/.gitignore
@@ -0,0 +1 @@
+/gdImageColorClosestHWB
diff --git a/tests/gdimagecolorclosesthwb/CMakeLists.txt b/tests/gdimagecolorclosesthwb/CMakeLists.txt
new file mode 100644
index 0000000..7a8afdc
--- /dev/null
+++ b/tests/gdimagecolorclosesthwb/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdImageColorClosestHWB
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecolorclosesthwb/Makemodule.am b/tests/gdimagecolorclosesthwb/Makemodule.am
new file mode 100644
index 0000000..14eddbd
--- /dev/null
+++ b/tests/gdimagecolorclosesthwb/Makemodule.am
@@ -0,0 +1,7 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecolorclosesthwb/gdImageColorClosestHWB
+endif
+
+EXTRA_DIST += \
+ gdimagecolorclosesthwb/CMakeLists.txt
diff --git a/tests/gdimagecolorclosesthwb/gdImageColorClosestHWB.c b/tests/gdimagecolorclosesthwb/gdImageColorClosestHWB.c
new file mode 100644
index 0000000..ab20187
--- /dev/null
+++ b/tests/gdimagecolorclosesthwb/gdImageColorClosestHWB.c
@@ -0,0 +1,26 @@
+/**
+ * Basic test for gdImageColorClosestHWB()
+ **/
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gdimageflip", "remi.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ int result = gdImageColorClosestHWB(im, 255, 0, 255);
+
+ if (gdTestAssert(result <= 0))
+ {
+ gdImageDestroy(im);
+ return 1;
+ }
+
+ gdImageDestroy(im);
+ return 0;
+}
diff --git a/tests/gdimagecolorexact/Makemodule.am b/tests/gdimagecolorexact/Makemodule.am
index 835b25e..7427999 100644
--- a/tests/gdimagecolorexact/Makemodule.am
+++ b/tests/gdimagecolorexact/Makemodule.am
@@ -1,7 +1,5 @@
-if HAVE_LIBPNG
libgd_test_programs += \
gdimagecolorexact/gdimagecolorexact
-endif
EXTRA_DIST += \
gdimagecolorexact/CMakeLists.txt
diff --git a/tests/gdimagecolormatch/.gitignore b/tests/gdimagecolormatch/.gitignore
new file mode 100644
index 0000000..f68c491
--- /dev/null
+++ b/tests/gdimagecolormatch/.gitignore
@@ -0,0 +1,2 @@
+/cve_2019_6977
+/gdimagecolormatch
diff --git a/tests/gdimagecolormatch/CMakeLists.txt b/tests/gdimagecolormatch/CMakeLists.txt
new file mode 100644
index 0000000..857b99a
--- /dev/null
+++ b/tests/gdimagecolormatch/CMakeLists.txt
@@ -0,0 +1,6 @@
+LIST(APPEND TESTS_FILES
+ cve_2019_6977
+ gdimagecolormatch
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecolormatch/Makemodule.am b/tests/gdimagecolormatch/Makemodule.am
new file mode 100644
index 0000000..4ed48ce
--- /dev/null
+++ b/tests/gdimagecolormatch/Makemodule.am
@@ -0,0 +1,6 @@
+libgd_test_programs += \
+ gdimagecolormatch/cve_2019_6977 \
+ gdimagecolormatch/gdimagecolormatch
+
+EXTRA_DIST += \
+ gdimagecolormatch/CMakeLists.txt
diff --git a/tests/gdimagecolormatch/cve_2019_6977.c b/tests/gdimagecolormatch/cve_2019_6977.c
new file mode 100644
index 0000000..fdd7af5
--- /dev/null
+++ b/tests/gdimagecolormatch/cve_2019_6977.c
@@ -0,0 +1,25 @@
+/**
+ * Test for CVE-2019-6977
+ */
+
+#include "gd.h"
+
+int main()
+{
+ gdImagePtr im1;
+ gdImagePtr im2;
+
+ im1 = gdImageCreateTrueColor(0xfff, 0xfff);
+ im2 = gdImageCreate(0xfff, 0xfff);
+ if (gdImageColorAllocate(im2, 0, 0, 0) < 0)
+ {
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+ return 1;
+ }
+ gdImageSetPixel(im2, 0, 0, 255);
+ gdImageColorMatch(im1, im2);
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+ return 0;
+}
diff --git a/tests/gdimagecolormatch/gdimagecolormatch.c b/tests/gdimagecolormatch/gdimagecolormatch.c
new file mode 100644
index 0000000..f59c769
--- /dev/null
+++ b/tests/gdimagecolormatch/gdimagecolormatch.c
@@ -0,0 +1,32 @@
+/**
+ * Basic test for gdImageColorMatch()
+ **/
+#include "gd.h"
+#include "gdtest.h"
+
+int main(){
+ gdImagePtr im1, im2;
+
+ im1 = gdImageCreateTrueColor(80, 80);
+ im2 = gdImageCreate(80, 80);
+
+ gdImageColorAllocate(im1, 255, 36, 74);
+
+ gdImageColorAllocate(im2, 255, 36, 74);
+ gdImageColorAllocate(im2, 40, 0, 240);
+ gdImageColorAllocate(im2, 255, 100, 255);
+ gdImageColorAllocate(im2, 80, 60, 44);
+
+ int ifMatch = gdImageColorMatch(im1, im2);
+
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+
+ if (gdTestAssert(ifMatch != 0))
+ {
+ gdTestErrorMsg("gdImageColorMatch failed.\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/gdimagecolorreplace/Makemodule.am b/tests/gdimagecolorreplace/Makemodule.am
index a8badb0..3ea38e5 100644
--- a/tests/gdimagecolorreplace/Makemodule.am
+++ b/tests/gdimagecolorreplace/Makemodule.am
@@ -1,7 +1,5 @@
-if HAVE_LIBPNG
libgd_test_programs += \
gdimagecolorreplace/gdimagecolorreplace
-endif
EXTRA_DIST += \
gdimagecolorreplace/CMakeLists.txt
diff --git a/tests/gdimagecolorresolve/Makemodule.am b/tests/gdimagecolorresolve/Makemodule.am
index 316484c..a3e9442 100644
--- a/tests/gdimagecolorresolve/Makemodule.am
+++ b/tests/gdimagecolorresolve/Makemodule.am
@@ -1,7 +1,5 @@
-if HAVE_LIBPNG
libgd_test_programs += \
gdimagecolorresolve/gdimagecolorresolve
-endif
EXTRA_DIST += \
gdimagecolorresolve/CMakeLists.txt
diff --git a/tests/gdimagecompare/.gitignore b/tests/gdimagecompare/.gitignore
new file mode 100755
index 0000000..312a8c8
--- /dev/null
+++ b/tests/gdimagecompare/.gitignore
@@ -0,0 +1 @@
+/gdimagecompare
diff --git a/tests/gdimagecompare/CMakeLists.txt b/tests/gdimagecompare/CMakeLists.txt
new file mode 100644
index 0000000..2974a07
--- /dev/null
+++ b/tests/gdimagecompare/CMakeLists.txt
@@ -0,0 +1,4 @@
+LIST(APPEND TESTS_FILES
+ gdimagecompare
+)
+ADD_GD_TESTS()
diff --git a/tests/gdimagecompare/Makemodule.am b/tests/gdimagecompare/Makemodule.am
new file mode 100644
index 0000000..b4b0ebb
--- /dev/null
+++ b/tests/gdimagecompare/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimagecompare/gdimagecompare
+
+EXTRA_DIST += \
+ gdimagecompare/CMakeLists.txt
diff --git a/tests/gdimagecompare/gdimagecompare.c b/tests/gdimagecompare/gdimagecompare.c
new file mode 100644
index 0000000..0e8367a
--- /dev/null
+++ b/tests/gdimagecompare/gdimagecompare.c
@@ -0,0 +1,56 @@
+/**
+ * Base test for gdImageCompare()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im1;
+ gdImagePtr im2;
+ int black;
+ int red1, red2;
+ int yellow1, yellow2;
+ int white;
+ int blue;
+ int ret;
+
+ im1 = gdImageCreate(128, 128);
+ im2 = gdImageCreateTrueColor(256, 256);
+
+ /* Set different interlace */
+ gdImageInterlace(im1, 1);
+ gdImageInterlace(im2, 2);
+
+ /* Set different transparent */
+ gdImageColorTransparent(im1, 10);
+ gdImageColorTransparent(im2, 20);
+
+ /* Allocate different color number */
+ black = gdImageColorAllocate(im1, 0, 0, 0);
+ red1 = gdImageColorAllocate(im1, 255, 0, 0);
+ yellow1 = gdImageColorAllocate(im1, 255, 255, 0);
+ red2 = gdImageColorAllocate(im2, 255, 0, 0);
+ yellow2 = gdImageColorAllocate(im2, 255, 255, 0);
+ white = gdImageColorAllocate(im2, 255, 255, 255);
+ blue = gdImageColorAllocate(im2, 0, 0, 255);
+
+ /* Filled different color */
+ gdImageFilledRectangle(im1, 0, 0, 127, 8, black);
+ gdImageFilledRectangle(im1, 9, 0, 127, 16, red1);
+ gdImageFilledRectangle(im1, 17, 0, 127, 24, yellow1);
+ gdImageFilledRectangle(im2, 0, 0, 127, 8, red2);
+ gdImageFilledRectangle(im2, 9, 0, 127, 16, yellow2);
+ gdImageFilledRectangle(im2, 17, 0, 127, 24, white);
+ gdImageFilledRectangle(im2, 25, 0, 127, 32, blue);
+
+ ret = gdImageCompare(im1, im2);
+
+ gdTestAssert(ret == (GD_CMP_INTERLACE | GD_CMP_TRANSPARENT | GD_CMP_TRUECOLOR | GD_CMP_SIZE_X | GD_CMP_SIZE_Y | GD_CMP_COLOR | GD_CMP_IMAGE | GD_CMP_NUM_COLORS));
+
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecontrast/CMakeLists.txt b/tests/gdimagecontrast/CMakeLists.txt
index 381c74d..802c382 100644
--- a/tests/gdimagecontrast/CMakeLists.txt
+++ b/tests/gdimagecontrast/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagecontrast/basic.c b/tests/gdimagecontrast/basic.c
index d001bf9..ef1f44a 100644
--- a/tests/gdimagecontrast/basic.c
+++ b/tests/gdimagecontrast/basic.c
@@ -1,41 +1,37 @@
-/**
- * Basic test for gdImageContrast()
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-static void test_contrast(double contrast);
-
-
-int main()
-{
- test_contrast(+50.0);
- test_contrast(-50.0);
-
- return gdNumFailures();
-}
-
-
-static void test_contrast(double contrast)
-{
- gdImagePtr im;
- FILE *fp;
- char basename[256];
- char *path;
-
- fp = gdTestFileOpen2("gdimagecontrast", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- gdImageContrast(im, contrast);
-
- sprintf(basename, "basic%+03.0f.png", contrast);
- path = gdTestFilePath2("gdimagecontrast", basename);
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-}
+/**
+ * Basic test for gdImageContrast()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+static void test_contrast(double contrast);
+
+int main()
+{
+ test_contrast(+50.0);
+ test_contrast(-50.0);
+
+ return gdNumFailures();
+}
+
+static void test_contrast(double contrast)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecontrast", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageContrast(im, contrast);
+
+ sprintf(basename, "basic%+03.0f.png", contrast);
+ path = gdTestFilePath2("gdimagecontrast", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/tests/gdimageconvolution/.gitignore b/tests/gdimageconvolution/.gitignore
index 1ffd796..6665df0 100644
--- a/tests/gdimageconvolution/.gitignore
+++ b/tests/gdimageconvolution/.gitignore
@@ -1 +1,2 @@
/basic
+/bug00369
diff --git a/tests/gdimageconvolution/CMakeLists.txt b/tests/gdimageconvolution/CMakeLists.txt
index 381c74d..dc1fc51 100644
--- a/tests/gdimageconvolution/CMakeLists.txt
+++ b/tests/gdimageconvolution/CMakeLists.txt
@@ -1,5 +1,9 @@
+LIST(APPEND TESTS_FILES bug00369)
+
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimageconvolution/Makemodule.am b/tests/gdimageconvolution/Makemodule.am
index 8f65b0f..df5249d 100644
--- a/tests/gdimageconvolution/Makemodule.am
+++ b/tests/gdimageconvolution/Makemodule.am
@@ -1,3 +1,6 @@
+libgd_test_programs += \
+ gdimageconvolution/bug00369
+
if HAVE_LIBPNG
libgd_test_programs += \
gdimageconvolution/basic
diff --git a/tests/gdimageconvolution/basic.c b/tests/gdimageconvolution/basic.c
index 7ca98be..5fe308c 100644
--- a/tests/gdimageconvolution/basic.c
+++ b/tests/gdimageconvolution/basic.c
@@ -1,62 +1,55 @@
-/**
- * Basic test for gdImageConvolution() and related functions
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-static void test_convolution(void (*convolution_func)(gdImagePtr im), const char *expected)
-{
- gdImagePtr im;
- FILE *fp;
- char *path;
-
- fp = gdTestFileOpen2("gdimageconvolution", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- convolution_func(im);
-
- path = gdTestFilePath2("gdimageconvolution", expected);
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-}
-
-
-static void test_edge_detect_quick(gdImagePtr im)
-{
- gdImageEdgeDetectQuick(im);
-}
-
-
-static void test_smooth(gdImagePtr im)
-{
- gdImageSmooth(im, 5);
-}
-
-
-static void test_emboss(gdImagePtr im)
-{
- gdImageEmboss(im);
-}
-
-
-static void test_mean_removal(gdImagePtr im)
-{
- gdImageMeanRemoval(im);
-}
-
-
-int main()
-{
- test_convolution(&test_edge_detect_quick, "basic_edge_detect_quick.png");
- test_convolution(&test_smooth, "basic_smooth.png");
- test_convolution(&test_emboss, "basic_emboss.png");
- test_convolution(&test_mean_removal, "basic_mean_removal.png");
-
- return gdNumFailures();
-}
+/**
+ * Basic test for gdImageConvolution() and related functions
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+static void test_convolution(void (*convolution_func)(gdImagePtr im), const char *expected)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimageconvolution", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ convolution_func(im);
+
+ path = gdTestFilePath2("gdimageconvolution", expected);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
+
+static void test_edge_detect_quick(gdImagePtr im)
+{
+ gdImageEdgeDetectQuick(im);
+}
+
+static void test_smooth(gdImagePtr im)
+{
+ gdImageSmooth(im, 5);
+}
+
+static void test_emboss(gdImagePtr im)
+{
+ gdImageEmboss(im);
+}
+
+static void test_mean_removal(gdImagePtr im)
+{
+ gdImageMeanRemoval(im);
+}
+
+int main()
+{
+ test_convolution(&test_edge_detect_quick, "basic_edge_detect_quick.png");
+ test_convolution(&test_smooth, "basic_smooth.png");
+ test_convolution(&test_emboss, "basic_emboss.png");
+ test_convolution(&test_mean_removal, "basic_mean_removal.png");
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageconvolution/bug00369.c b/tests/gdimageconvolution/bug00369.c
new file mode 100644
index 0000000..631cb7a
--- /dev/null
+++ b/tests/gdimageconvolution/bug00369.c
@@ -0,0 +1,28 @@
+/**
+ * Test Issue #369 for gdImageConvolution()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ float matrix[3][3] = {
+ {1, 0, 1},
+ {0, 5, 0},
+ {1, 0, 0}
+ };
+
+ im = gdImageCreateTrueColor(40, 40);
+ gdImageAlphaBlending(im, gdEffectReplace);
+ gdImageFilledRectangle(im, 0, 0, 39, 39, 0x7FFFFFFF);
+ gdImageFilledEllipse(im, 19, 19, 20, 20, 0x00FF00);
+
+ gdImageConvolution(im, matrix, 9, 1);
+ gdTestAssert(0x7F010101 == gdImageGetPixel(im, 0, 0));
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecopy/CMakeLists.txt b/tests/gdimagecopy/CMakeLists.txt
index d9d0eda..f586300 100644
--- a/tests/gdimagecopy/CMakeLists.txt
+++ b/tests/gdimagecopy/CMakeLists.txt
@@ -1,6 +1,11 @@
LIST(APPEND TESTS_FILES
bug00007
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
bug00081
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagecopymerge/.gitignore b/tests/gdimagecopymerge/.gitignore
new file mode 100644
index 0000000..c56b41b
--- /dev/null
+++ b/tests/gdimagecopymerge/.gitignore
@@ -0,0 +1 @@
+/gdimagecopymerge
diff --git a/tests/gdimagecopymerge/CMakeLists.txt b/tests/gdimagecopymerge/CMakeLists.txt
new file mode 100644
index 0000000..df9bdc6
--- /dev/null
+++ b/tests/gdimagecopymerge/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagecopymerge
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecopymerge/Makemodule.am b/tests/gdimagecopymerge/Makemodule.am
new file mode 100644
index 0000000..6751168
--- /dev/null
+++ b/tests/gdimagecopymerge/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecopymerge/gdimagecopymerge
+endif
+
+EXTRA_DIST += \
+ gdimagecopymerge/CMakeLists.txt \
+ gdimagecopymerge/gdimagecopymerge_exp.png
diff --git a/tests/gdimagecopymerge/gdimagecopymerge.c b/tests/gdimagecopymerge/gdimagecopymerge.c
new file mode 100644
index 0000000..9f08020
--- /dev/null
+++ b/tests/gdimagecopymerge/gdimagecopymerge.c
@@ -0,0 +1,38 @@
+/**
+ * Basic test for gdImageCopyMerge()
+ */
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr dst = NULL;
+ gdImagePtr src = NULL;
+ int error = 0;
+
+ dst = gdImageCreate(100, 100);
+ src = gdImageCreate(50, 50);
+
+ if (gdTestAssert(!dst)) {
+ error = 1;
+ goto done;
+ }
+ if (gdTestAssert(!src)) {
+ error = 1;
+ goto done;
+ }
+
+ gdImageColorAllocate(src, 255, 255, 255);
+ gdImageColorAllocate(dst, 0, 0, 0);
+ gdImageCopyMerge(dst, src, 25, 25, 0, 0, 50, 50, 50);
+
+ if (!gdAssertImageEqualsToFile("gdimagecopymerge/gdimagecopymerge_exp.png", dst)) {
+ error = 1;
+ }
+
+done:
+ gdImageDestroy(dst);
+ gdImageDestroy(src);
+
+ return error;
+}
diff --git a/tests/gdimagecopymerge/gdimagecopymerge_exp.png b/tests/gdimagecopymerge/gdimagecopymerge_exp.png
new file mode 100644
index 0000000..1830281
--- /dev/null
+++ b/tests/gdimagecopymerge/gdimagecopymerge_exp.png
Binary files differ
diff --git a/tests/gdimagecopymergegray/.gitignore b/tests/gdimagecopymergegray/.gitignore
new file mode 100644
index 0000000..a85d2ac
--- /dev/null
+++ b/tests/gdimagecopymergegray/.gitignore
@@ -0,0 +1 @@
+/gdimagecopymergegray
diff --git a/tests/gdimagecopymergegray/CMakeLists.txt b/tests/gdimagecopymergegray/CMakeLists.txt
new file mode 100644
index 0000000..e0656ef
--- /dev/null
+++ b/tests/gdimagecopymergegray/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagecopymergegray
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecopymergegray/Makemodule.am b/tests/gdimagecopymergegray/Makemodule.am
new file mode 100644
index 0000000..6856d75
--- /dev/null
+++ b/tests/gdimagecopymergegray/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecopymergegray/gdimagecopymergegray
+endif
+
+EXTRA_DIST += \
+ gdimagecopymergegray/CMakeLists.txt \
+ gdimagecopymergegray/gdimagecopymergegray_exp.png
diff --git a/tests/gdimagecopymergegray/gdimagecopymergegray.c b/tests/gdimagecopymergegray/gdimagecopymergegray.c
new file mode 100644
index 0000000..34a8923
--- /dev/null
+++ b/tests/gdimagecopymergegray/gdimagecopymergegray.c
@@ -0,0 +1,38 @@
+/**
+ * Basic test for gdImageCopyMergeGray()
+ */
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr dst = NULL;
+ gdImagePtr src = NULL;
+ int error = 0;
+
+ dst = gdImageCreate(100, 100);
+ src = gdImageCreate(50, 50);
+
+ if (gdTestAssert(!dst)) {
+ error = 1;
+ goto done;
+ }
+ if (gdTestAssert(!src)) {
+ error = 1;
+ goto done;
+ }
+
+ gdImageColorAllocate(src, 255, 255, 255);
+ gdImageColorAllocate(dst, 0, 0, 0);
+ gdImageCopyMergeGray(dst, src, 25, 25, 0, 0, 50, 50, 50);
+
+ if (!gdAssertImageEqualsToFile("gdimagecopymergegray/gdimagecopymergegray_exp.png", dst)) {
+ error = 1;
+ }
+
+done:
+ gdImageDestroy(dst);
+ gdImageDestroy(src);
+
+ return error;
+}
diff --git a/tests/gdimagecopymergegray/gdimagecopymergegray_exp.png b/tests/gdimagecopymergegray/gdimagecopymergegray_exp.png
new file mode 100644
index 0000000..1830281
--- /dev/null
+++ b/tests/gdimagecopymergegray/gdimagecopymergegray_exp.png
Binary files differ
diff --git a/tests/gdimagecopyresampled/CMakeLists.txt b/tests/gdimagecopyresampled/CMakeLists.txt
index 636c811..00351ca 100644
--- a/tests/gdimagecopyresampled/CMakeLists.txt
+++ b/tests/gdimagecopyresampled/CMakeLists.txt
@@ -1,8 +1,12 @@
LIST(APPEND TESTS_FILES
+ exact_alpha
+)
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
basic
basic_alpha
- exact_alpha
bug00201
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagecopyresampled/Makemodule.am b/tests/gdimagecopyresampled/Makemodule.am
index 5d0d714..d42eab5 100644
--- a/tests/gdimagecopyresampled/Makemodule.am
+++ b/tests/gdimagecopyresampled/Makemodule.am
@@ -1,8 +1,10 @@
+libgd_test_programs += \
+ gdimagecopyresampled/exact_alpha
+
if HAVE_LIBPNG
libgd_test_programs += \
gdimagecopyresampled/basic \
gdimagecopyresampled/basic_alpha \
- gdimagecopyresampled/exact_alpha \
gdimagecopyresampled/bug00201
endif
diff --git a/tests/gdimagecopyresampled/bug00201.c b/tests/gdimagecopyresampled/bug00201.c
index 053b6db..0287267 100644
--- a/tests/gdimagecopyresampled/bug00201.c
+++ b/tests/gdimagecopyresampled/bug00201.c
@@ -48,23 +48,23 @@ int main()
fp = gdTestFileOpen2("gdimagecopyresampled", "bug00201_src.png");
logo_source = gdImageCreateFromPng(fp);
fclose(fp);
-
+
logo = blank_image(SRC_WIDTH,SRC_HEIGHT);
gdImageAlphaBlending(logo, 0);
gdImageCopy(logo, logo_source, 0,0, 0,0, SRC_WIDTH,SRC_HEIGHT);
gdImageDestroy(logo_source);
-
+
scaled_logo = blank_image(DEST_WIDTH,DEST_HEIGHT);
gdImageAlphaBlending(scaled_logo, 0);
gdImageCopyResampled(scaled_logo, logo, 0,0, 0,0, 200,105, SRC_WIDTH,SRC_HEIGHT);
gdImageDestroy(logo);
-
+
layers[0] = background;
layers[1] = scaled_logo;
img = flatten(layers, 2, DEST_WIDTH, DEST_HEIGHT);
gdImageDestroy(background);
gdImageDestroy(scaled_logo);
-
+
gdAssertImageEqualsToFile("gdimagecopyresampled/bug00201_exp.png", img);
gdImageDestroy(img);
return gdNumFailures();
diff --git a/tests/gdimagecopyresized/.gitignore b/tests/gdimagecopyresized/.gitignore
new file mode 100644
index 0000000..185cf1f
--- /dev/null
+++ b/tests/gdimagecopyresized/.gitignore
@@ -0,0 +1 @@
+/gdimagecopyresized
diff --git a/tests/gdimagecopyresized/CMakeLists.txt b/tests/gdimagecopyresized/CMakeLists.txt
new file mode 100644
index 0000000..78b4fa9
--- /dev/null
+++ b/tests/gdimagecopyresized/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagecopyresized
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecopyresized/Makemodule.am b/tests/gdimagecopyresized/Makemodule.am
new file mode 100644
index 0000000..9d83e40
--- /dev/null
+++ b/tests/gdimagecopyresized/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecopyresized/gdimagecopyresized
+endif
+
+EXTRA_DIST += \
+ gdimagecopyresized/CMakeLists.txt \
+ gdimagecopyresized/gdimagecopyresized_exp.png
diff --git a/tests/gdimagecopyresized/gdimagecopyresized.c b/tests/gdimagecopyresized/gdimagecopyresized.c
new file mode 100644
index 0000000..137f84b
--- /dev/null
+++ b/tests/gdimagecopyresized/gdimagecopyresized.c
@@ -0,0 +1,35 @@
+/**
+ * add test case for gdImageCopyResized
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src;
+ gdImagePtr dst;
+ gdImagePtr dst_tc;
+
+ /* We prepare two image type: Palette and True Color */
+ /* src image is white, while dst and dst_tc is black */
+ src = gdImageCreate(64, 64);
+ gdImageColorAllocate(src, 255, 255, 255);
+ dst = gdImageCreate(128, 128);
+ gdImageColorAllocate(dst, 0, 0, 0);
+ dst_tc = gdImageCreateTrueColor(128, 128);
+
+ /* Copy src to two image type separately */
+ /* We copy src to the center of dst and dst_tc */
+ gdImageCopyResized(dst, src, 32, 32, 0, 0, 64, 64, 64, 64);
+ gdImageCopyResized(dst_tc, src, 32, 32, 0, 0, 64, 64, 64, 64);
+
+ gdAssertImageEqualsToFile("gdimagecopyresized/gdimagecopyresized_exp.png", dst);
+ gdAssertImageEqualsToFile("gdimagecopyresized/gdimagecopyresized_exp.png", dst_tc);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+ gdImageDestroy(dst_tc);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecopyresized/gdimagecopyresized_exp.png b/tests/gdimagecopyresized/gdimagecopyresized_exp.png
new file mode 100644
index 0000000..32fa084
--- /dev/null
+++ b/tests/gdimagecopyresized/gdimagecopyresized_exp.png
Binary files differ
diff --git a/tests/gdimagecopyrotated/CMakeLists.txt b/tests/gdimagecopyrotated/CMakeLists.txt
index fc17e9d..7f1a678 100644
--- a/tests/gdimagecopyrotated/CMakeLists.txt
+++ b/tests/gdimagecopyrotated/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00020
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagecreate/.gitignore b/tests/gdimagecreate/.gitignore
new file mode 100644
index 0000000..6300aed
--- /dev/null
+++ b/tests/gdimagecreate/.gitignore
@@ -0,0 +1 @@
+/bug00340
diff --git a/tests/gdimagecreate/CMakeLists.txt b/tests/gdimagecreate/CMakeLists.txt
new file mode 100644
index 0000000..1cd0c1a
--- /dev/null
+++ b/tests/gdimagecreate/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ bug00340
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecreate/Makemodule.am b/tests/gdimagecreate/Makemodule.am
new file mode 100644
index 0000000..8866086
--- /dev/null
+++ b/tests/gdimagecreate/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimagecreate/bug00340
+
+EXTRA_DIST += \
+ gdimagecreate/CMakeLists.txt
diff --git a/tests/gdimagecreate/bug00340.c b/tests/gdimagecreate/bug00340.c
new file mode 100644
index 0000000..9c6eff3
--- /dev/null
+++ b/tests/gdimagecreate/bug00340.c
@@ -0,0 +1,29 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/340>
+ *
+ * We're testing that trying to create an oversized image fails early,
+ * triggering an appropriate warning.
+ */
+
+#include <string.h>
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdtest.h"
+
+#define MSG "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n"
+
+void error_handler(int priority, const char *format, ...)
+{
+ gdTestAssert(priority == GD_WARNING);
+ gdTestAssert(!strcmp(format, MSG));
+}
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreate(64970, 65111);
+ gdTestAssert(im == NULL);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecrop/.gitignore b/tests/gdimagecrop/.gitignore
index a90ef00..ada3cad 100644
--- a/tests/gdimagecrop/.gitignore
+++ b/tests/gdimagecrop/.gitignore
@@ -1,2 +1,6 @@
/bug00297
+/bug00432
+/bug00485_auto
+/bug00485_threshold
+/bug00486
/php_bug_72494
diff --git a/tests/gdimagecrop/CMakeLists.txt b/tests/gdimagecrop/CMakeLists.txt
index 4b1e97e..43f6f6c 100644
--- a/tests/gdimagecrop/CMakeLists.txt
+++ b/tests/gdimagecrop/CMakeLists.txt
@@ -1,6 +1,10 @@
-SET(TESTS_FILES
+LIST(APPEND TESTS_FILES
bug00297
+ bug00432
+ bug00485_auto
+ bug00485_threshold
php_bug_72494
+ bug00486
)
ADD_GD_TESTS()
diff --git a/tests/gdimagecrop/Makemodule.am b/tests/gdimagecrop/Makemodule.am
index fe73c1d..1725f6c 100644
--- a/tests/gdimagecrop/Makemodule.am
+++ b/tests/gdimagecrop/Makemodule.am
@@ -1,5 +1,9 @@
libgd_test_programs += \
gdimagecrop/bug00297 \
+ gdimagecrop/bug00432 \
+ gdimagecrop/bug00485_auto \
+ gdimagecrop/bug00485_threshold \
+ gdimagecrop/bug00486 \
gdimagecrop/php_bug_72494
EXTRA_DIST += \
diff --git a/tests/gdimagecrop/bug00432.c b/tests/gdimagecrop/bug00432.c
new file mode 100644
index 0000000..d3f681f
--- /dev/null
+++ b/tests/gdimagecrop/bug00432.c
@@ -0,0 +1,45 @@
+/**
+ * Test that gdImageCrop() retains transparency
+ *
+ * We create an image with transparent pixels, crop the image, and check whether
+ * all pixels are identical to the respective source image.
+ *
+ * See <https://github.com/libgd/libgd/issues/432>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+#define WIDTH 10
+#define HEIGHT 10
+#define XOFF 1
+#define YOFF 1
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect crop = {XOFF, YOFF, WIDTH-XOFF-1, HEIGHT-YOFF-1};
+ int i, j;
+
+ src = gdImageCreateTrueColor(WIDTH, HEIGHT);
+ gdImageAlphaBlending(src, gdEffectReplace);
+ gdImageFilledRectangle(src, 0, 0, WIDTH-1, HEIGHT-1,
+ gdTrueColorAlpha(gdRedMax, gdGreenMax, gdBlueMax, gdAlphaMax));
+
+ dst = gdImageCrop(src, &crop);
+ gdTestAssert(dst != NULL);
+
+ for (i = 0; i < gdImageSX(dst); i++) {
+ for (j = 0; j < gdImageSY(dst); j++) {
+ gdTestAssert(gdImageGetPixel(dst, i, j) == gdImageGetPixel(src, i+XOFF, j+YOFF));
+ }
+ }
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecrop/bug00485_auto.c b/tests/gdimagecrop/bug00485_auto.c
new file mode 100644
index 0000000..3c0627e
--- /dev/null
+++ b/tests/gdimagecrop/bug00485_auto.c
@@ -0,0 +1,52 @@
+/**
+ * Test that gdImageCropAuto() works pixel precise
+ *
+ * We test that a single black pixel anywhere (but the corners) on an 8x8 pixel
+ * image with a white background is auto-cropped to a 1x1 pixel image with a
+ * black pixel.
+ *
+ * See <https://github.com/libgd/libgd/issues/485>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+gdImagePtr createWhiteImageWithBlackPixelAt(int x, int y)
+{
+ gdImagePtr im = gdImageCreateTrueColor(8, 8);
+ gdImageFilledRectangle(im, 0, 0, 7, 7, 0xffffff);
+ gdImageSetPixel(im, x, y, 0x000000);
+ return im;
+}
+
+
+int main()
+{
+ int x, y, height, width, color;
+ gdImagePtr orig, cropped;
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++) {
+ if ((x == 0 && (y == 0 || y == 7)) || (x == 7 && (y == 0 || y == 7))) {
+ continue; // skip the corners
+ }
+ orig = createWhiteImageWithBlackPixelAt(x, y);
+ cropped = gdImageCropAuto(orig, GD_CROP_SIDES);
+ gdTestAssertMsg(cropped != NULL, "Pixel at %d, %d: unexpected NULL crop\n", x, y);
+ if (cropped) {
+ width = gdImageSX(cropped);
+ gdTestAssertMsg(width == 1, "Pixel at %d, %d: unexpected width (%d)\n", x, y, width);
+ height = gdImageSY(cropped);
+ gdTestAssertMsg(height == 1, "Pixel at %d, %d: unexpected height (%d)\n", x, y, height);
+ color = gdImageGetPixel(cropped, 0, 0);
+ gdTestAssertMsg(color == 0x000000, "Pixel at %d, %d: unexpected color (%d)\n", x, y, color);
+ gdImageDestroy(cropped);
+ }
+ gdImageDestroy(orig);
+ }
+ }
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecrop/bug00485_threshold.c b/tests/gdimagecrop/bug00485_threshold.c
new file mode 100644
index 0000000..31ac38f
--- /dev/null
+++ b/tests/gdimagecrop/bug00485_threshold.c
@@ -0,0 +1,48 @@
+/**
+ * Test that gdImageCropThreshold() works pixel precise
+ *
+ * We test that a single black pixel anywhere on an 8x8 pixel image with a white
+ * background is threshold-cropped to a 1x1 pixel image with a black pixel.
+ *
+ * See <https://github.com/libgd/libgd/issues/485>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+gdImagePtr createWhiteImageWithBlackPixelAt(int x, int y)
+{
+ gdImagePtr im = gdImageCreateTrueColor(8, 8);
+ gdImageFilledRectangle(im, 0, 0, 7, 7, 0xffffff);
+ gdImageSetPixel(im, x, y, 0x000000);
+ return im;
+}
+
+
+int main()
+{
+ int x, y, height, width, color;
+ gdImagePtr orig, cropped;
+
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++) {
+ orig = createWhiteImageWithBlackPixelAt(x, y);
+ cropped = gdImageCropThreshold(orig, 0xffffff, 1.0);
+ gdTestAssertMsg(cropped != NULL, "Pixel at %d, %d: unexpected NULL crop\n", x, y);
+ if (cropped) {
+ width = gdImageSX(cropped);
+ gdTestAssertMsg(width == 1, "Pixel at %d, %d: unexpected width (%d)\n", x, y, width);
+ height = gdImageSY(cropped);
+ gdTestAssertMsg(height == 1, "Pixel at %d, %d: unexpected height (%d)\n", x, y, height);
+ color = gdImageGetPixel(cropped, 0, 0);
+ gdTestAssertMsg(color == 0x000000, "Pixel at %d, %d: unexpected color (%d)\n", x, y, color);
+ gdImageDestroy(cropped);
+ }
+ gdImageDestroy(orig);
+ }
+ }
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecrop/bug00486.c b/tests/gdimagecrop/bug00486.c
new file mode 100644
index 0000000..289d88f
--- /dev/null
+++ b/tests/gdimagecrop/bug00486.c
@@ -0,0 +1,48 @@
+/**
+ * Test that gdImageCropAuto() crops left and right as well
+ *
+ * We test that an image with four unicolored quadrants, where either both left
+ * quadrants or both right quadrants have the same color, but the remaining
+ * quadrants have different colors, are treated identically by
+ * gdImageCropAuto(…, GD_CROP_SIDES).
+ *
+ * See <https://github.com/libgd/libgd/issues/486>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr orig, croppedLeft, croppedRight;
+ int red, green, blue;
+
+ orig = gdImageCreateTrueColor(8, 8);
+ red = gdImageColorAllocate(orig, 255, 0, 0);
+ green = gdImageColorAllocate(orig, 0, 255, 0);
+ blue = gdImageColorAllocate(orig, 0, 0, 255);
+
+ gdImageFilledRectangle(orig, 0, 0, 3, 3, green); // tl
+ gdImageFilledRectangle(orig, 4, 0, 7, 3, red); // tr
+ gdImageFilledRectangle(orig, 0, 4, 3, 7, green); // bl
+ gdImageFilledRectangle(orig, 4, 4, 7, 7, blue); // br
+ croppedLeft = gdImageCropAuto(orig, GD_CROP_SIDES);
+ gdTestAssert(croppedLeft != NULL);
+
+ gdImageFilledRectangle(orig, 0, 0, 3, 3, red); // tl
+ gdImageFilledRectangle(orig, 4, 0, 7, 3, green); // tr
+ gdImageFilledRectangle(orig, 0, 4, 3, 7, blue); // bl
+ gdImageFilledRectangle(orig, 4, 4, 7, 7, green); // br
+ croppedRight = gdImageCropAuto(orig, GD_CROP_SIDES);
+ gdTestAssert(croppedRight != NULL);
+
+ gdAssertImageEquals(croppedRight, croppedLeft);
+
+ gdImageDestroy(orig);
+ gdImageDestroy(croppedLeft);
+ gdImageDestroy(croppedRight);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageellipse/.gitignore b/tests/gdimageellipse/.gitignore
new file mode 100644
index 0000000..58e31a6
--- /dev/null
+++ b/tests/gdimageellipse/.gitignore
@@ -0,0 +1 @@
+/bug00169
diff --git a/tests/gdimageellipse/CMakeLists.txt b/tests/gdimageellipse/CMakeLists.txt
new file mode 100644
index 0000000..b7d79f2
--- /dev/null
+++ b/tests/gdimageellipse/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ bug00169
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimageellipse/Makemodule.am b/tests/gdimageellipse/Makemodule.am
new file mode 100644
index 0000000..11d2079
--- /dev/null
+++ b/tests/gdimageellipse/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimageellipse/bug00169
+endif
+
+EXTRA_DIST += \
+ gdimageellipse/CMakeLists.txt \
+ gdimageellipse/bug00169_exp.png
diff --git a/tests/gdimageellipse/bug00169.c b/tests/gdimageellipse/bug00169.c
new file mode 100644
index 0000000..8246c8c
--- /dev/null
+++ b/tests/gdimageellipse/bug00169.c
@@ -0,0 +1,22 @@
+/**
+ * add test case for gdImageEllipse
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int white = 0;
+
+ im = gdImageCreateTrueColor(2200, 2200);
+ white = gdImageColorAllocate(im, 255, 255, 255);
+
+ gdImageEllipse(im, 1100, 1100, 2200, 2200, white);
+ gdAssertImageEqualsToFile("gdimageellipse/bug00169_exp.png", im);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageellipse/bug00169_exp.png b/tests/gdimageellipse/bug00169_exp.png
new file mode 100644
index 0000000..f844608
--- /dev/null
+++ b/tests/gdimageellipse/bug00169_exp.png
Binary files differ
diff --git a/tests/gdimagefile/CMakeLists.txt b/tests/gdimagefile/CMakeLists.txt
index 55ae374..8676264 100644
--- a/tests/gdimagefile/CMakeLists.txt
+++ b/tests/gdimagefile/CMakeLists.txt
@@ -1,5 +1,11 @@
+IF(TIFF_FOUND)
+IF(WEBP_FOUND)
+IF(ENABLE_GD_FORMATS)
LIST(APPEND TESTS_FILES
gdnametest
)
+ENDIF(ENABLE_GD_FORMATS)
+ENDIF(WEBP_FOUND)
+ENDIF(TIFF_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagefile/Makemodule.am b/tests/gdimagefile/Makemodule.am
index b537cbc..8c9e4d5 100644
--- a/tests/gdimagefile/Makemodule.am
+++ b/tests/gdimagefile/Makemodule.am
@@ -1,5 +1,11 @@
+if HAVE_LIBTIFF
+if HAVE_LIBWEBP
+if ENABLE_GD_FORMATS
libgd_test_programs += \
gdimagefile/gdnametest
+endif
+endif
+endif
EXTRA_DIST += \
gdimagefile/CMakeLists.txt \
diff --git a/tests/gdimagefile/gdnametest.c b/tests/gdimagefile/gdnametest.c
index 66da484..fcd040a 100644
--- a/tests/gdimagefile/gdnametest.c
+++ b/tests/gdimagefile/gdnametest.c
@@ -11,150 +11,145 @@
#define LY (HEIGHT/2) // Line Y
#define HT 2 // Half of line-thickness
-
-gdImagePtr mkwhite(int x, int y)
+static gdImagePtr
+mkwhite(int x, int y)
{
- gdImagePtr im;
+ gdImagePtr im;
im = gdImageCreateTrueColor(x, y);
gdImageFilledRectangle(im, 0, 0, x-1, y-1,
- gdImageColorExactAlpha(im, 255, 255, 255, 0));
+ gdImageColorExactAlpha(im, 255, 255, 255, 0));
- gdTestAssert(im != NULL);
+ gdTestAssert(im != NULL);
- gdImageSetInterpolationMethod(im, GD_BICUBIC); // FP interp'n
+ gdImageSetInterpolationMethod(im, GD_BICUBIC); // FP interp'n
- return im;
+ return im;
}/* mkwhite*/
+static gdImagePtr
+mkcross(void)
+{
+ gdImagePtr im;
+ int fg, n;
-gdImagePtr mkcross() {
- gdImagePtr im;
- int fg, n;
-
- im = mkwhite(WIDTH, HEIGHT);
- fg = gdImageColorAllocate(im, 0, 0, 0);
+ im = mkwhite(WIDTH, HEIGHT);
+ fg = gdImageColorAllocate(im, 0, 0, 0);
- for (n = -HT; n < HT; n++) {
- gdImageLine(im, LX-n, 0, LX-n, HEIGHT-1, fg);
- gdImageLine(im, 0, LY-n, WIDTH-1, LY-n, fg);
- }/* for */
+ for (n = -HT; n < HT; n++) {
+ gdImageLine(im, LX-n, 0, LX-n, HEIGHT-1, fg);
+ gdImageLine(im, 0, LY-n, WIDTH-1, LY-n, fg);
+ }/* for */
- return im;
+ return im;
}/* mkcross*/
-
-
-
-void
-do_test() {
-
- gdTestAssertMsg(strchr("123",'2') != 0, "strchr() is not functional.\n");
- gdTestAssertMsg(strcasecmp("123abC","123Abc") == 0, "strcasecmp() is not functional.\n");
-
- int n;
- struct {
- const char *nm; // Filename
- unsigned maxdiff; // Maximum total pixel diff
- int required; // 1 -> image type always supported, -1 -> skip it
- int readonly; // 1 -> gd can only read this type
- } names[] = {
- {"img.png", 0, 0, 0},
- {"img.gif", 5, 1, 0}, // This seems to come from tc<->palette
- {"img.GIF", 5, 1, 0}, // Test for case insensitivity
- {"img.gd", 0, 1, 0},
- {"img.gd2", 0, 0, 0},
- {"img.jpg", 25, 0, 0},
- {"img.jpeg", 25, 0, 0},
- {"img.wbmp", 0, 1, 0},
- {"img.bmp", 0, 1, 0},
- {"img-ref.xpm", 0, 0, 1},
-
- // These break the test so I'm skipping them since the point
- // of this test is not those loaders.
- {"img-ref.xbm", 0, -1, 1},
- {"img-ref.tga", 0, -1, 1},
- {"img.webp", 0, -1, 0},
- {"img.tiff", 0, -1, 0},
-
- {NULL, 0}
- };
-
- for (n = 0; names[n].nm; n++) {
- gdImagePtr orig, copy;
- int status;
- char *full_filename = NULL;
-
- /* Some image readers are buggy and crash the program so we
- * skip them. Bug fixers should remove these from the list of
- * skipped items as bugs are fixed. */
- if (names[n].required < 0) {
- printf("Skipping test for '%s'. FIX THIS!\n", names[n].nm);
- continue;
- }/* if */
-
- /* Skip this file if the current library build doesn't support
- * it. (If it's one of the built-in types, *that* a different
- * problem; we assert that here.) */
- if (!gdSupportsFileType(names[n].nm, 0)) {
- gdTestAssertMsg(!names[n].required, "GD doesn't support required file type: %s\n", full_filename);
- continue;
- }/* if */
-
- orig = mkcross();
-
- /* Write the image unless writing is not supported. */
- if (!names[n].readonly) {
- /* Prepend the test directory; this is expected to be run in
- * the parent dir. */
- full_filename = gdTestTempFile(names[n].nm);
- status = gdImageFile(orig, full_filename);
- gdTestAssertMsg(status == GD_TRUE, "Failed to create %s\n", full_filename);
- } else {
- /* Prepend the test directory; this is expected to be run in
- * the parent dir. */
- full_filename = gdTestFilePath2("gdimagefile", names[n].nm);
- }/* if */
-
- copy = gdImageCreateFromFile(full_filename);
- gdTestAssertMsg(!!copy, "Failed to load %s\n", full_filename);
- if (!copy) continue;
-
- gdTestAssertMsg(gdMaxPixelDiff(orig, copy) <= names[n].maxdiff,"Pixels different on %s\n", full_filename, full_filename);
-
- if (!names[n].readonly) {
- status = remove(full_filename);
- gdTestAssertMsg(status == 0, "Failed to delete %s\n", full_filename);
- }/* if */
-
- free(full_filename);
- gdImageDestroy(orig);
- gdImageDestroy(copy);
- }/* for */
+static void
+do_test(void)
+{
+ gdTestAssertMsg(strchr("123",'2') != 0, "strchr() is not functional.\n");
+ gdTestAssertMsg(strcasecmp("123abC","123Abc") == 0, "strcasecmp() is not functional.\n");
+
+ int n;
+ struct {
+ const char *nm; // Filename
+ unsigned maxdiff; // Maximum total pixel diff
+ int required; // 1 -> image type always supported, -1 -> skip it
+ int readonly; // 1 -> gd can only read this type
+ } names[] = {
+ {"img.png", 0, 0, 0},
+ {"img.gif", 5, 1, 0}, // This seems to come from tc<->palette
+ {"img.GIF", 5, 1, 0}, // Test for case insensitivity
+ {"img.gd", 0, 1, 0},
+ {"img.gd2", 0, 0, 0},
+ {"img.jpg", 25, 0, 0},
+ {"img.jpeg", 25, 0, 0},
+ {"img.wbmp", 0, 1, 0},
+ {"img.bmp", 0, 1, 0},
+ {"img-ref.xpm", 0, 0, 1},
+ {"img-ref.xbm", 0, 1, 1},
+ {"img-ref.tga", 0, 1, 1},
+ {"img.webp", 10, 1, 0},
+ {"img.tiff", 0, 1, 0},
+
+ {NULL, 0}
+ };
+
+ for (n = 0; names[n].nm; n++) {
+ gdImagePtr orig, copy;
+ int status;
+ char *full_filename = NULL;
+ unsigned int pixels;
+
+ /* Some image readers are buggy and crash the program so we
+ * skip them. Bug fixers should remove these from the list of
+ * skipped items as bugs are fixed. */
+ if (names[n].required < 0) {
+ printf("Skipping test for '%s'. FIX THIS!\n", names[n].nm);
+ continue;
+ }/* if */
+
+ /* Skip this file if the current library build doesn't support
+ * it. (If it's one of the built-in types, *that* a different
+ * problem; we assert that here.) */
+ if (!gdSupportsFileType(names[n].nm, 0)) {
+ gdTestAssertMsg(!names[n].required, "GD doesn't support required file type: %s\n", names[n].nm);
+ continue;
+ }/* if */
+
+ orig = mkcross();
+
+ /* Write the image unless writing is not supported. */
+ if (!names[n].readonly) {
+ /* Prepend the test directory; this is expected to be run in
+ * the parent dir. */
+ full_filename = gdTestTempFile(names[n].nm);
+ status = gdImageFile(orig, full_filename);
+ gdTestAssertMsg(status == GD_TRUE, "Failed to create %s\n", full_filename);
+ } else {
+ /* Prepend the test directory; this is expected to be run in
+ * the parent dir. */
+ full_filename = gdTestFilePath2("gdimagefile", names[n].nm);
+ }/* if */
+
+ copy = gdImageCreateFromFile(full_filename);
+ gdTestAssertMsg(!!copy, "Failed to load %s\n", full_filename);
+ if (!copy) continue;
+
+ pixels = gdMaxPixelDiff(orig, copy);
+ gdTestAssertMsg(pixels <= names[n].maxdiff, "%u pixels different on %s\n", pixels, full_filename);
+
+ if (!names[n].readonly) {
+ status = remove(full_filename);
+ gdTestAssertMsg(status == 0, "Failed to delete %s\n", full_filename);
+ }/* if */
+
+ free(full_filename);
+ gdImageDestroy(orig);
+ gdImageDestroy(copy);
+ }/* for */
}/* do_test*/
+static void
+do_errortest(void)
+{
+ gdImagePtr im;
-void
-do_errortest() {
- gdImagePtr im;
-
- im = mkcross();
+ im = mkcross();
- gdTestAssert(!gdImageFile(im, "img.xpng"));
- gdTestAssert(!gdImageFile(im, "bobo"));
- gdTestAssert(!gdImageFile(im, "png"));
- gdTestAssert(!gdImageFile(im, ""));
+ gdTestAssert(!gdImageFile(im, "img.xpng"));
+ gdTestAssert(!gdImageFile(im, "bobo"));
+ gdTestAssert(!gdImageFile(im, "png"));
+ gdTestAssert(!gdImageFile(im, ""));
- gdImageDestroy(im);
+ gdImageDestroy(im);
}/* do_errortest*/
-
int main()
{
+ do_test();
+ do_errortest();
- do_test();
- do_errortest();
-
- return gdNumFailures();
+ return gdNumFailures();
}
diff --git a/tests/gdimagefill/CMakeLists.txt b/tests/gdimagefill/CMakeLists.txt
index c54281e..457fd8d 100644
--- a/tests/gdimagefill/CMakeLists.txt
+++ b/tests/gdimagefill/CMakeLists.txt
@@ -1,3 +1,4 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00002_1
bug00002_2
@@ -5,5 +6,6 @@ LIST(APPEND TESTS_FILES
bug00002_4
bug00104_1
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagefill/bug00002_1.c b/tests/gdimagefill/bug00002_1.c
index 752178a..3feaf42 100644
--- a/tests/gdimagefill/bug00002_1.c
+++ b/tests/gdimagefill/bug00002_1.c
@@ -37,4 +37,3 @@ int main()
return error;
}
-
diff --git a/tests/gdimagefill/bug00002_2.c b/tests/gdimagefill/bug00002_2.c
index 982ae8f..4edcd6a 100644
--- a/tests/gdimagefill/bug00002_2.c
+++ b/tests/gdimagefill/bug00002_2.c
@@ -46,4 +46,3 @@ int main()
gdImageDestroy(tile);
return error;
}
-
diff --git a/tests/gdimagefill/bug00002_3.c b/tests/gdimagefill/bug00002_3.c
index b11fbc9..1a1929e 100644
--- a/tests/gdimagefill/bug00002_3.c
+++ b/tests/gdimagefill/bug00002_3.c
@@ -51,4 +51,3 @@ int main()
gdImageDestroy(tile);
return error;
}
-
diff --git a/tests/gdimagefill/bug00104_1.c b/tests/gdimagefill/bug00104_1.c
index 13247ca..694788a 100644
--- a/tests/gdimagefill/bug00104_1.c
+++ b/tests/gdimagefill/bug00104_1.c
@@ -8,26 +8,26 @@ int main()
gdImagePtr im, tile;
int tile_red, tile_blue;
int error = 0;
-
+
im = gdImageCreate(200, 150);
tile = gdImageCreateTrueColor(2, 2);
-
+
tile_red = gdImageColorAllocate(tile, 255, 0, 0);
tile_blue = gdImageColorAllocate(tile, 0, 0, 255);
-
+
gdImageSetPixel(tile, 0, 0, tile_red);
gdImageSetPixel(tile, 1, 1, tile_red);
gdImageSetPixel(tile, 1, 0, tile_blue);
gdImageSetPixel(tile, 0, 1, tile_blue);
-
+
gdImageSetTile(im, tile);
gdImageFill(im, 11, 12, gdTiled);
if (!gdAssertImageEqualsToFile("gdimagefill/bug00104_1_exp.png", im)) {
error = 1;
}
-
+
gdImageDestroy(im);
gdImageDestroy(tile);
return error;
diff --git a/tests/gdimagefilledarc/.gitignore b/tests/gdimagefilledarc/.gitignore
index e6d2cbe..da4b002 100644
--- a/tests/gdimagefilledarc/.gitignore
+++ b/tests/gdimagefilledarc/.gitignore
@@ -1 +1,2 @@
+/bug00351
/php_bug43828
diff --git a/tests/gdimagefilledarc/CMakeLists.txt b/tests/gdimagefilledarc/CMakeLists.txt
index 1a0a204..4042df9 100644
--- a/tests/gdimagefilledarc/CMakeLists.txt
+++ b/tests/gdimagefilledarc/CMakeLists.txt
@@ -1,5 +1,8 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
+ bug00351
php_bug43828
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagefilledarc/Makemodule.am b/tests/gdimagefilledarc/Makemodule.am
index 4af6963..710c0a0 100644
--- a/tests/gdimagefilledarc/Makemodule.am
+++ b/tests/gdimagefilledarc/Makemodule.am
@@ -1,8 +1,10 @@
if HAVE_LIBPNG
libgd_test_programs += \
+ gdimagefilledarc/bug00351 \
gdimagefilledarc/php_bug43828
endif
EXTRA_DIST += \
gdimagefilledarc/CMakeLists.txt \
+ gdimagefilledarc/bug00351_exp.png \
gdimagefilledarc/php_bug43828_exp.png
diff --git a/tests/gdimagefilledarc/bug00351.c b/tests/gdimagefilledarc/bug00351.c
new file mode 100644
index 0000000..20b0fde
--- /dev/null
+++ b/tests/gdimagefilledarc/bug00351.c
@@ -0,0 +1,30 @@
+/**
+ * Test drawing of pies starting and/or ending near 90°
+ *
+ * See <https://github.com/libgd/libgd/issues/351>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int white, navy, red;
+
+ im = gdImageCreateTrueColor(500, 500);
+ white = gdTrueColorAlpha(0xFF, 0xFF, 0xFF, gdAlphaOpaque);
+ navy = gdTrueColorAlpha(0x00, 0x00, 0x80, gdAlphaOpaque);
+ red = gdTrueColorAlpha(0xFF, 0x00, 0x00, gdAlphaOpaque);
+
+ gdImageFilledArc(im, 250, 250, 500, 250, 0, 88, white, gdPie);
+ gdImageFilledArc(im, 250, 250, 500, 250, 88, 91 , navy, gdPie);
+ gdImageFilledArc(im, 250, 250, 500, 250, 91, 360 , red, gdPie);
+
+ gdAssertImageEqualsToFile("gdimagefilledarc/bug00351_exp.png", im);
+
+ gdImageDestroy(im);
+ return gdNumFailures();
+}
diff --git a/tests/gdimagefilledarc/bug00351_exp.png b/tests/gdimagefilledarc/bug00351_exp.png
new file mode 100644
index 0000000..16b2db2
--- /dev/null
+++ b/tests/gdimagefilledarc/bug00351_exp.png
Binary files differ
diff --git a/tests/gdimagefilledellipse/.gitignore b/tests/gdimagefilledellipse/.gitignore
index e039565..9adfb75 100644
--- a/tests/gdimagefilledellipse/.gitignore
+++ b/tests/gdimagefilledellipse/.gitignore
@@ -1,3 +1,4 @@
/bug00010
+/bug00169
/bug00191
/github_bug_00238
diff --git a/tests/gdimagefilledellipse/CMakeLists.txt b/tests/gdimagefilledellipse/CMakeLists.txt
index 63f34f2..48286e4 100644
--- a/tests/gdimagefilledellipse/CMakeLists.txt
+++ b/tests/gdimagefilledellipse/CMakeLists.txt
@@ -1,7 +1,10 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00010
+ bug00169
bug00191
github_bug_00238
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagefilledellipse/Makemodule.am b/tests/gdimagefilledellipse/Makemodule.am
index 6a5185a..0a88686 100644
--- a/tests/gdimagefilledellipse/Makemodule.am
+++ b/tests/gdimagefilledellipse/Makemodule.am
@@ -1,6 +1,7 @@
if HAVE_LIBPNG
libgd_test_programs += \
gdimagefilledellipse/bug00010 \
+ gdimagefilledellipse/bug00169 \
gdimagefilledellipse/bug00191 \
gdimagefilledellipse/github_bug_00238
endif
@@ -8,5 +9,6 @@ endif
EXTRA_DIST += \
gdimagefilledellipse/CMakeLists.txt \
gdimagefilledellipse/bug00010_exp.png \
+ gdimagefilledellipse/bug00169_exp.png \
gdimagefilledellipse/bug00191.png \
gdimagefilledellipse/github_bug_00238_exp.png
diff --git a/tests/gdimagefilledellipse/bug00169.c b/tests/gdimagefilledellipse/bug00169.c
new file mode 100644
index 0000000..639e52f
--- /dev/null
+++ b/tests/gdimagefilledellipse/bug00169.c
@@ -0,0 +1,22 @@
+/**
+ * add test case for gdImageFilledEllipse
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int white = 0;
+
+ im = gdImageCreateTrueColor(2200, 2200);
+ white = gdImageColorAllocate(im, 255, 255, 255);
+
+ gdImageFilledEllipse(im, 1100, 1100, 2200, 2200, white);
+ gdAssertImageEqualsToFile("gdimagefilledellipse/bug00169_exp.png", im);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagefilledellipse/bug00169_exp.png b/tests/gdimagefilledellipse/bug00169_exp.png
new file mode 100644
index 0000000..db88390
--- /dev/null
+++ b/tests/gdimagefilledellipse/bug00169_exp.png
Binary files differ
diff --git a/tests/gdimagefilledellipse/github_bug_00238.c b/tests/gdimagefilledellipse/github_bug_00238.c
index 499923f..67c93fd 100644
--- a/tests/gdimagefilledellipse/github_bug_00238.c
+++ b/tests/gdimagefilledellipse/github_bug_00238.c
@@ -12,7 +12,7 @@ int main()
goto exit;
}
- gdImageAlphaBlending(im, gdEffectNormal);
+ gdImageAlphaBlending(im, gdEffectNormal);
gdImageFilledRectangle(im, 0, 0, 140, 199, gdTrueColorAlpha(0,0,0,127));
gdImageAlphaBlending(im, gdEffectAlphaBlend);
diff --git a/tests/gdimagefilledpolygon/CMakeLists.txt b/tests/gdimagefilledpolygon/CMakeLists.txt
index 97801e2..030a224 100644
--- a/tests/gdimagefilledpolygon/CMakeLists.txt
+++ b/tests/gdimagefilledpolygon/CMakeLists.txt
@@ -1,3 +1,4 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
gdimagefilledpolygon0
gdimagefilledpolygon1
@@ -7,5 +8,6 @@ LIST(APPEND TESTS_FILES
php_bug_64641
self_intersecting
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagefilledpolygon/self_intersecting.c b/tests/gdimagefilledpolygon/self_intersecting.c
index 6123cc1..f9b96da 100644
--- a/tests/gdimagefilledpolygon/self_intersecting.c
+++ b/tests/gdimagefilledpolygon/self_intersecting.c
@@ -1,31 +1,29 @@
-/**
- * We're testing the filling behavior of self-intersecting polygons, which is
- * *currently* using the even-odd fillrule.
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- int black;
- gdPoint points[] = {{50, 5}, {24, 86}, {93, 36}, {7, 36}, {76, 86}};
- char *path;
-
- im = gdImageCreate(100, 100);
- gdImageColorAllocate(im, 255, 255, 255);
- black = gdImageColorAllocate(im, 0, 0, 0);
-
- gdImageFilledPolygon(im, points, 5, black);
-
- path = gdTestFilePath2("gdimagefilledpolygon", "self_intersecting_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * We're testing the filling behavior of self-intersecting polygons, which is
+ * *currently* using the even-odd fillrule.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+ gdPoint points[] = {{50, 5}, {24, 86}, {93, 36}, {7, 36}, {76, 86}};
+ char *path;
+
+ im = gdImageCreate(100, 100);
+ gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+
+ gdImageFilledPolygon(im, points, 5, black);
+
+ path = gdTestFilePath2("gdimagefilledpolygon", "self_intersecting_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagefilledrectangle/bug00004.c b/tests/gdimagefilledrectangle/bug00004.c
index 594e296..87e33dc 100644
--- a/tests/gdimagefilledrectangle/bug00004.c
+++ b/tests/gdimagefilledrectangle/bug00004.c
@@ -24,4 +24,3 @@ int main()
return 1;
}
}
-
diff --git a/tests/gdimagefilledrectangle/bug00078.c b/tests/gdimagefilledrectangle/bug00078.c
index adf244e..4cde698 100644
--- a/tests/gdimagefilledrectangle/bug00078.c
+++ b/tests/gdimagefilledrectangle/bug00078.c
@@ -36,4 +36,3 @@ int main()
gdImageDestroy(im);
return 0;
}
-
diff --git a/tests/gdimagefilledrectangle/bug00106_gdimagefilledrectangle.c b/tests/gdimagefilledrectangle/bug00106_gdimagefilledrectangle.c
index 24f5ceb..a6f5c06 100644
--- a/tests/gdimagefilledrectangle/bug00106_gdimagefilledrectangle.c
+++ b/tests/gdimagefilledrectangle/bug00106_gdimagefilledrectangle.c
@@ -24,4 +24,3 @@ int main()
return 1;
}
}
-
diff --git a/tests/gdimagefilltoborder/Makemodule.am b/tests/gdimagefilltoborder/Makemodule.am
index fc7ed3d..779bda0 100644
--- a/tests/gdimagefilltoborder/Makemodule.am
+++ b/tests/gdimagefilltoborder/Makemodule.am
@@ -1,8 +1,6 @@
-if HAVE_LIBPNG
libgd_test_programs += \
gdimagefilltoborder/bug00037 \
gdimagefilltoborder/github_bug_215
-endif
EXTRA_DIST += \
gdimagefilltoborder/CMakeLists.txt
diff --git a/tests/gdimagefilltoborder/bug00037.c b/tests/gdimagefilltoborder/bug00037.c
index ab7e1b8..72e58b7 100644
--- a/tests/gdimagefilltoborder/bug00037.c
+++ b/tests/gdimagefilltoborder/bug00037.c
@@ -27,4 +27,3 @@ int main()
}
}
-
diff --git a/tests/gdimagefilter/gdCopyBlurred.c b/tests/gdimagefilter/gdCopyBlurred.c
index dee2f1f..aec49f5 100644
--- a/tests/gdimagefilter/gdCopyBlurred.c
+++ b/tests/gdimagefilter/gdCopyBlurred.c
@@ -143,7 +143,7 @@ void do_crosstest()
{
gdImagePtr im = mkcross();
gdImagePtr blurred;
- const int RADIUS = 16;
+ const int RADIUS = 16;
gdTestAssert(!!im);
diff --git a/tests/gdimageflip/CMakeLists.txt b/tests/gdimageflip/CMakeLists.txt
index 39caf08..c532f01 100644
--- a/tests/gdimageflip/CMakeLists.txt
+++ b/tests/gdimageflip/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
gdimageflip
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimageflip/gdimageflip.c b/tests/gdimageflip/gdimageflip.c
index a9dd187..da834ee 100644
--- a/tests/gdimageflip/gdimageflip.c
+++ b/tests/gdimageflip/gdimageflip.c
@@ -1,37 +1,34 @@
-/**
- * Testing the basic operation of the gdImageFlip*() functions
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-static void test_flip(void (*func)(gdImagePtr), const char *filename)
-{
- gdImagePtr im;
- FILE *fp;
- char *path;
-
- fp = gdTestFileOpen2("gdimageflip", "remi.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- func(im);
-
- path = gdTestFilePath2("gdimageflip", filename);
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-}
-
-
-int main()
-{
- test_flip(gdImageFlipVertical, "gdimageflipvertical_exp.png");
- test_flip(gdImageFlipHorizontal, "gdimagefliphorizontal_exp.png");
- test_flip(gdImageFlipBoth, "gdimageflipboth_exp.png");
-
- return gdNumFailures();
-}
+/**
+ * Testing the basic operation of the gdImageFlip*() functions
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+static void test_flip(void (BGD_STDCALL *func)(gdImagePtr), const char *filename)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimageflip", "remi.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ func(im);
+
+ path = gdTestFilePath2("gdimageflip", filename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
+
+int main()
+{
+ test_flip(gdImageFlipVertical, "gdimageflipvertical_exp.png");
+ test_flip(gdImageFlipHorizontal, "gdimagefliphorizontal_exp.png");
+ test_flip(gdImageFlipBoth, "gdimageflipboth_exp.png");
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagegrayscale/.gitignore b/tests/gdimagegrayscale/.gitignore
index 1ffd796..3e79ed7 100644
--- a/tests/gdimagegrayscale/.gitignore
+++ b/tests/gdimagegrayscale/.gitignore
@@ -1 +1,2 @@
/basic
+/bug00386
diff --git a/tests/gdimagegrayscale/CMakeLists.txt b/tests/gdimagegrayscale/CMakeLists.txt
index 381c74d..b83521d 100644
--- a/tests/gdimagegrayscale/CMakeLists.txt
+++ b/tests/gdimagegrayscale/CMakeLists.txt
@@ -1,5 +1,8 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
+ bug00386
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagegrayscale/Makemodule.am b/tests/gdimagegrayscale/Makemodule.am
index e715c5b..c6fec00 100644
--- a/tests/gdimagegrayscale/Makemodule.am
+++ b/tests/gdimagegrayscale/Makemodule.am
@@ -1,9 +1,11 @@
if HAVE_LIBPNG
libgd_test_programs += \
- gdimagegrayscale/basic
+ gdimagegrayscale/basic \
+ gdimagegrayscale/bug00386
endif
EXTRA_DIST += \
gdimagegrayscale/CMakeLists.txt \
gdimagegrayscale/basic.png \
- gdimagegrayscale/basic_exp.png
+ gdimagegrayscale/basic_exp.png \
+ gdimagegrayscale/bug00386.png
diff --git a/tests/gdimagegrayscale/basic.c b/tests/gdimagegrayscale/basic.c
index e3c21d8..3ecc482 100644
--- a/tests/gdimagegrayscale/basic.c
+++ b/tests/gdimagegrayscale/basic.c
@@ -1,29 +1,27 @@
-/**
- * Basic test for gdImageGrayScale()
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- FILE *fp;
- char *path;
-
- fp = gdTestFileOpen2("gdimagegrayscale", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- gdImageGrayScale(im);
-
- path = gdTestFilePath2("gdimagegrayscale", "basic_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * Basic test for gdImageGrayScale()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagegrayscale", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageGrayScale(im);
+
+ path = gdTestFilePath2("gdimagegrayscale", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagegrayscale/bug00386.c b/tests/gdimagegrayscale/bug00386.c
new file mode 100644
index 0000000..2e68ed4
--- /dev/null
+++ b/tests/gdimagegrayscale/bug00386.c
@@ -0,0 +1,53 @@
+/**
+ * Test that gdImageGrayScale() produces pure gray-scale images
+ *
+ * We are reading a PNG image with transparency, apply gdImageGrayScale() and
+ * test that each pixel has equal red, blue and green components. To avoid
+ * flooding the test log, we bail out after the first non gray-scale pixel.
+ *
+ * We also make sure that the image is a truecolor image, since otherwise it is
+ * not guaranteed that all pixels are actually gray-scale.
+ *
+ * See also <https://github.com/libgd/libgd/issues/386>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ int res;
+ int i, j;
+
+ fp = gdTestFileOpen2("gdimagegrayscale", "bug00386.png");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromPng(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ res = gdImageTrueColor(im);
+ gdTestAssert(res != 0);
+
+ res = gdImageGrayScale(im);
+ gdTestAssert(res != 0);
+
+ for (i = 0; i < gdImageSX(im); i++) {
+ for (j = 0; j < gdImageSY(im); j++) {
+ int color = gdImageGetTrueColorPixel(im, i, j);
+ int red = gdImageRed(im, color);
+ int green = gdImageGreen(im, color);
+ int blue = gdImageBlue(im, color);
+ if (!gdTestAssert(red == green && green == blue)) {
+ return gdNumFailures();
+ }
+ }
+ }
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagegrayscale/bug00386.png b/tests/gdimagegrayscale/bug00386.png
new file mode 100644
index 0000000..b5d5d1f
--- /dev/null
+++ b/tests/gdimagegrayscale/bug00386.png
Binary files differ
diff --git a/tests/gdimageline/CMakeLists.txt b/tests/gdimageline/CMakeLists.txt
index 8e1b524..c345ed1 100644
--- a/tests/gdimageline/CMakeLists.txt
+++ b/tests/gdimageline/CMakeLists.txt
@@ -1,12 +1,18 @@
LIST(APPEND TESTS_FILES
- gdimageline_aa
gdimageline_aa_outofrange
- gdImageAALine_thickness
- github_bug_167
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
bug00077
bug00072
bug00111
bug00315
+ gdimageline_aa
+ gdimageline_bug5
+ gdImageAALine_thickness
+ github_bug_167
)
+ENDIF(PNG_FOUND)
-ADD_GD_TESTS(m)
+ADD_GD_TESTS()
diff --git a/tests/gdimageline/bug00315.c b/tests/gdimageline/bug00315.c
index 7c94e41..719d155 100644
--- a/tests/gdimageline/bug00315.c
+++ b/tests/gdimageline/bug00315.c
@@ -1,39 +1,37 @@
-/**
- * Regression test for <https://github.com/libgd/libgd/issues/315>
- *
- * We're testing that a single-pointed gdImageAALine() is drawn as a single
- * non-antialized pixel, according to (two-pointed) vertical and horizontal
- * lines.
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- int white, black;
- char *path;
-
- im = gdImageCreateTrueColor(6, 6);
- white = gdImageColorAllocate(im, 255, 255, 255);
- black = gdImageColorAllocate(im, 0, 0, 0);
- gdImageFilledRectangle(im, 0,0, 5,5, white);
-
- gdImageLine(im, 4,4, 4,4, black);
- gdImageLine(im, 1,4, 2,4, black);
- gdImageLine(im, 4,1, 4,2, black);
-
- gdImageSetAntiAliased(im, black);
- gdImageLine(im, 1,1, 1,1, gdAntiAliased);
-
- path = gdTestFilePath2("gdimageline", "bug00315_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/315>
+ *
+ * We're testing that a single-pointed gdImageAALine() is drawn as a single
+ * non-antialized pixel, according to (two-pointed) vertical and horizontal
+ * lines.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int white, black;
+ char *path;
+
+ im = gdImageCreateTrueColor(6, 6);
+ white = gdImageColorAllocate(im, 255, 255, 255);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageFilledRectangle(im, 0,0, 5,5, white);
+
+ gdImageLine(im, 4,4, 4,4, black);
+ gdImageLine(im, 1,4, 2,4, black);
+ gdImageLine(im, 4,1, 4,2, black);
+
+ gdImageSetAntiAliased(im, black);
+ gdImageLine(im, 1,1, 1,1, gdAntiAliased);
+
+ path = gdTestFilePath2("gdimageline", "bug00315_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageline/gdimageline_bug5.c b/tests/gdimageline/gdimageline_bug5.c
index 44adc8e..d055b0c 100644
--- a/tests/gdimageline/gdimageline_bug5.c
+++ b/tests/gdimageline/gdimageline_bug5.c
@@ -10,7 +10,13 @@ int main() {
/* FILE *pngout; */
int black, white;
+ /* If the data seg size is less than 195000,
+ * gdImageCrateTrueColor will return NULL.
+ * See https://github.com/libgd/libgd/issues/621 */
im = gdImageCreateTrueColor(63318, 771);
+ if (gdTestAssertMsg(im != NULL, "gdImageCreateTrueColor() returns NULL\n") == 0) {
+ return gdNumFailures();
+ }
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);
diff --git a/tests/gdimagenegate/CMakeLists.txt b/tests/gdimagenegate/CMakeLists.txt
index 381c74d..802c382 100644
--- a/tests/gdimagenegate/CMakeLists.txt
+++ b/tests/gdimagenegate/CMakeLists.txt
@@ -1,5 +1,7 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagenegate/basic.c b/tests/gdimagenegate/basic.c
index b904eb8..563eec6 100644
--- a/tests/gdimagenegate/basic.c
+++ b/tests/gdimagenegate/basic.c
@@ -1,29 +1,27 @@
-/**
- * Basic test for gdImageNegate()
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- FILE *fp;
- char *path;
-
- fp = gdTestFileOpen2("gdimagenegate", "basic.png");
- im = gdImageCreateFromPng(fp);
- fclose(fp);
-
- gdImageNegate(im);
-
- path = gdTestFilePath2("gdimagenegate", "basic_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * Basic test for gdImageNegate()
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagenegate", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageNegate(im);
+
+ path = gdTestFilePath2("gdimagenegate", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageopenpolygon/CMakeLists.txt b/tests/gdimageopenpolygon/CMakeLists.txt
index 03c288d..5b3e069 100644
--- a/tests/gdimageopenpolygon/CMakeLists.txt
+++ b/tests/gdimageopenpolygon/CMakeLists.txt
@@ -1,8 +1,10 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
gdimageopenpolygon0
gdimageopenpolygon1
gdimageopenpolygon2
gdimageopenpolygon3
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagepolygon/CMakeLists.txt b/tests/gdimagepolygon/CMakeLists.txt
index 1b4ee83..647636a 100644
--- a/tests/gdimagepolygon/CMakeLists.txt
+++ b/tests/gdimagepolygon/CMakeLists.txt
@@ -1,8 +1,10 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
gdimagepolygon0
gdimagepolygon1
gdimagepolygon2
gdimagepolygon3
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagerectangle/CMakeLists.txt b/tests/gdimagerectangle/CMakeLists.txt
index 2567ae3..e2a2b81 100644
--- a/tests/gdimagerectangle/CMakeLists.txt
+++ b/tests/gdimagerectangle/CMakeLists.txt
@@ -1,9 +1,14 @@
LIST(APPEND TESTS_FILES
bug00003
bug00106_gdimagerectangle
- bug00299
github_bug_00172
point_ordering
)
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ bug00299
+)
+ENDIF(PNG_FOUND)
+
ADD_GD_TESTS()
diff --git a/tests/gdimagerectangle/Makemodule.am b/tests/gdimagerectangle/Makemodule.am
index ea9d52b..cd49b73 100644
--- a/tests/gdimagerectangle/Makemodule.am
+++ b/tests/gdimagerectangle/Makemodule.am
@@ -1,10 +1,14 @@
libgd_test_programs += \
gdimagerectangle/bug00003 \
gdimagerectangle/bug00106_gdimagerectangle \
- gdimagerectangle/bug00299 \
gdimagerectangle/github_bug_00172 \
gdimagerectangle/point_ordering
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagerectangle/bug00299
+endif
+
EXTRA_DIST += \
gdimagerectangle/CMakeLists.txt \
gdimagerectangle/bug00299_exp.png
diff --git a/tests/gdimagerotate/CMakeLists.txt b/tests/gdimagerotate/CMakeLists.txt
index e5ea84a..7b8ab14 100644
--- a/tests/gdimagerotate/CMakeLists.txt
+++ b/tests/gdimagerotate/CMakeLists.txt
@@ -1,7 +1,9 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00067
php_bug_64898
php_bug_65070
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagerotate/Makemodule.am b/tests/gdimagerotate/Makemodule.am
index 99b2398..116c851 100644
--- a/tests/gdimagerotate/Makemodule.am
+++ b/tests/gdimagerotate/Makemodule.am
@@ -1,10 +1,6 @@
-if HAVE_LIBJPEG
-libgd_test_programs += \
- gdimagerotate/bug00067
-endif
-
if HAVE_LIBPNG
libgd_test_programs += \
+ gdimagerotate/bug00067 \
gdimagerotate/php_bug_64898 \
gdimagerotate/php_bug_65070
endif
diff --git a/tests/gdimagerotate/php_bug_65070.c b/tests/gdimagerotate/php_bug_65070.c
index f1b5504..87a43ea 100644
--- a/tests/gdimagerotate/php_bug_65070.c
+++ b/tests/gdimagerotate/php_bug_65070.c
@@ -1,35 +1,33 @@
-/**
- * Regression test for <https://github.com/libgd/libgd/issues/319>
- *
- * We're testing that the rotated image actually has the requested background
- * color.
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr src, dst;
- FILE *fp;
- int black;
- char *path;
-
- fp = gdTestFileOpen2("gdimagerotate", "php_bug_65070.gif");
- src = gdImageCreateFromGif(fp);
- fclose(fp);
-
- black = gdImageColorAllocateAlpha(src, 0, 0, 0, 0);
- dst = gdImageRotateInterpolated(src, 30.0, black);
-
- path = gdTestFilePath2("gdimagerotate", "php_bug_65070_exp.png");
- gdAssertImageEqualsToFile(path, dst);
- gdFree(path);
-
- gdImageDestroy(src);
- gdImageDestroy(dst);
-
- return gdNumFailures();
-}
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/319>
+ *
+ * We're testing that the rotated image actually has the requested background
+ * color.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ FILE *fp;
+ int black;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagerotate", "php_bug_65070.gif");
+ src = gdImageCreateFromGif(fp);
+ fclose(fp);
+
+ black = gdImageColorAllocateAlpha(src, 0, 0, 0, 0);
+ dst = gdImageRotateInterpolated(src, 30.0, black);
+
+ path = gdTestFilePath2("gdimagerotate", "php_bug_65070_exp.png");
+ gdAssertImageEqualsToFile(path, dst);
+ gdFree(path);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagerotate/php_bug_65070_exp.png b/tests/gdimagerotate/php_bug_65070_exp.png
index fba85f6..64b8b10 100644
--- a/tests/gdimagerotate/php_bug_65070_exp.png
+++ b/tests/gdimagerotate/php_bug_65070_exp.png
Binary files differ
diff --git a/tests/gdimagescale/.gitignore b/tests/gdimagescale/.gitignore
index cfa5549..e75e0bc 100644
--- a/tests/gdimagescale/.gitignore
+++ b/tests/gdimagescale/.gitignore
@@ -1,2 +1,4 @@
+/bug00329
+/bug00330
/github_bug_00218
/bug_overflow_large_new_size
diff --git a/tests/gdimagescale/CMakeLists.txt b/tests/gdimagescale/CMakeLists.txt
index f5ebf2e..1174e65 100644
--- a/tests/gdimagescale/CMakeLists.txt
+++ b/tests/gdimagescale/CMakeLists.txt
@@ -1,4 +1,6 @@
LIST(APPEND TESTS_FILES
+ bug00329
+ bug00330
github_bug_00218
bug_overflow_large_new_size
)
diff --git a/tests/gdimagescale/Makemodule.am b/tests/gdimagescale/Makemodule.am
index 23b8924..432ddbe 100644
--- a/tests/gdimagescale/Makemodule.am
+++ b/tests/gdimagescale/Makemodule.am
@@ -1,5 +1,6 @@
-
libgd_test_programs += \
+ gdimagescale/bug00329 \
+ gdimagescale/bug00330 \
gdimagescale/github_bug_00218 \
gdimagescale/bug_overflow_large_new_size
diff --git a/tests/gdimagescale/bug00329.c b/tests/gdimagescale/bug00329.c
new file mode 100644
index 0000000..67a1561
--- /dev/null
+++ b/tests/gdimagescale/bug00329.c
@@ -0,0 +1,50 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/329>
+ *
+ * We're testing that for truecolor as well as palette images after
+ * GD_BILINEAR_FIXED scaling the corner pixels of the scaled image have the
+ * expected color.
+ */
+
+#include <string.h>
+#include "gd.h"
+#include "gdtest.h"
+
+static void test(const char *mode)
+{
+ gdImagePtr src, dst;
+ int expected, actual;
+
+ if (strcmp(mode, "palette")) {
+ src = gdImageCreateTrueColor(100, 100);
+ expected = gdTrueColorAlpha(255, 255, 255, gdAlphaOpaque);
+ gdImageFilledRectangle(src, 0,0, 99,99, expected);
+ } else {
+ src = gdImageCreate(100, 100);
+ gdImageColorAllocate(src, 255, 255, 255);
+ expected = gdImageGetTrueColorPixel(src, 49, 49);
+ }
+
+ gdImageSetInterpolationMethod(src, GD_BILINEAR_FIXED);
+ dst = gdImageScale(src, 200, 200);
+
+ actual = gdImageGetPixel(dst, 0, 0);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 0, 199);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 199, 199);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+ actual = gdImageGetPixel(dst, 199, 0);
+ gdTestAssertMsg(actual == expected, "%s: wrong color; expected %x, but got %x", mode, expected, actual);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+}
+
+int main()
+{
+ test("palette");
+ test("truecolor");
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagescale/bug00330.c b/tests/gdimagescale/bug00330.c
new file mode 100644
index 0000000..44ba2f4
--- /dev/null
+++ b/tests/gdimagescale/bug00330.c
@@ -0,0 +1,30 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/330>.
+ *
+ * We're testing that after scaling a palette image, the center pixel actually
+ * has the expected color value.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ int color;
+
+ src = gdImageCreate(100, 100);
+ gdImageColorAllocate(src, 255, 255, 255);
+
+ gdImageSetInterpolationMethod(src, GD_BILINEAR_FIXED);
+ dst = gdImageScale(src, 200, 200);
+
+ color = gdImageGetPixel(dst, 99, 99);
+ gdTestAssertMsg(color == 0xffffff,
+ "expected color ffffff, but got %x\n", color);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+
+ return 0;
+}
diff --git a/tests/gdimagescale/bug_overflow_large_new_size.c b/tests/gdimagescale/bug_overflow_large_new_size.c
index 0a8503b..20cda1d 100644
--- a/tests/gdimagescale/bug_overflow_large_new_size.c
+++ b/tests/gdimagescale/bug_overflow_large_new_size.c
@@ -15,13 +15,14 @@ int main()
return 1;
}
gdImageSetInterpolationMethod(im, GD_BELL);
-
+
/* here the call may pass if the system has enough memory (physical or swap)
or fails (overflow check or alloc fails.
in both cases the tests pass */
im2 = gdImageScale(im,0x15555556, 1);
if (im2 == NULL) {
printf("gdImageScale failed, expected (out of memory or overflow validation\n");
+ gdImageDestroy(im);
return 0;
}
gdImageDestroy(im);
diff --git a/tests/gdimagescatterex/CMakeLists.txt b/tests/gdimagescatterex/CMakeLists.txt
index 22c46a7..479afe5 100644
--- a/tests/gdimagescatterex/CMakeLists.txt
+++ b/tests/gdimagescatterex/CMakeLists.txt
@@ -1,6 +1,8 @@
+IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
bug00208_1
bug00208_2
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdimagesetinterpolationmethod/.gitignore b/tests/gdimagesetinterpolationmethod/.gitignore
new file mode 100644
index 0000000..db7b3af
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/.gitignore
@@ -0,0 +1 @@
+/github_bug_00584
diff --git a/tests/gdimagesetinterpolationmethod/CMakeLists.txt b/tests/gdimagesetinterpolationmethod/CMakeLists.txt
new file mode 100644
index 0000000..6551062
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ github_bug_00584
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagesetinterpolationmethod/Makemodule.am b/tests/gdimagesetinterpolationmethod/Makemodule.am
new file mode 100644
index 0000000..1b83336
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimagesetinterpolationmethod/github_bug_00584
+
+EXTRA_DIST += \
+ gdimagesetinterpolationmethod/CMakeLists.txt
diff --git a/tests/gdimagesetinterpolationmethod/github_bug_00584.c b/tests/gdimagesetinterpolationmethod/github_bug_00584.c
new file mode 100644
index 0000000..e11f9f0
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/github_bug_00584.c
@@ -0,0 +1,31 @@
+/**
+ * Test that gdImageSetInterpolationMethod(im, GD_DEFAULT) is consistent
+ *
+ * See <https://github.com/libgd/libgd/issues/584>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ gdInterpolationMethod old_m, new_m;
+ interpolation_method old_f, new_f;
+
+ im = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(im != NULL);
+ gdTestAssert(gdImageSetInterpolationMethod(im, GD_SINC));
+ old_m = gdImageGetInterpolationMethod(im);
+ gdTestAssert(old_m == GD_SINC);
+ old_f = im->interpolation;
+ gdTestAssert(gdImageSetInterpolationMethod(im, GD_DEFAULT));
+ new_m = gdImageGetInterpolationMethod(im);
+ gdTestAssert(new_m == GD_LINEAR);
+ new_f = im->interpolation;
+ gdTestAssert(new_m != old_m);
+ gdTestAssert(new_f != old_f);
+ gdImageDestroy(im);
+ return gdNumFailures();
+}
diff --git a/tests/gdimagesetpixel/CMakeLists.txt b/tests/gdimagesetpixel/CMakeLists.txt
index f363899..675bbfd 100644
--- a/tests/gdimagesetpixel/CMakeLists.txt
+++ b/tests/gdimagesetpixel/CMakeLists.txt
@@ -1,8 +1,13 @@
LIST(APPEND TESTS_FILES
- alpha_blending
bug00186
gdeffectoverlay
gdeffectmultiply
)
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ alpha_blending
+)
+ENDIF(PNG_FOUND)
+
ADD_GD_TESTS()
diff --git a/tests/gdimagesetpixel/Makemodule.am b/tests/gdimagesetpixel/Makemodule.am
index 0a574ad..1eb0224 100644
--- a/tests/gdimagesetpixel/Makemodule.am
+++ b/tests/gdimagesetpixel/Makemodule.am
@@ -1,9 +1,13 @@
libgd_test_programs += \
- gdimagesetpixel/alpha_blending \
gdimagesetpixel/bug00186 \
gdimagesetpixel/gdeffectmultiply \
gdimagesetpixel/gdeffectoverlay
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagesetpixel/alpha_blending
+endif
+
EXTRA_DIST += \
gdimagesetpixel/CMakeLists.txt \
gdimagesetpixel/alphablending_exp.png
diff --git a/tests/gdimagesetpixel/alpha_blending.c b/tests/gdimagesetpixel/alpha_blending.c
index 394ced5..f182d59 100644
--- a/tests/gdimagesetpixel/alpha_blending.c
+++ b/tests/gdimagesetpixel/alpha_blending.c
@@ -1,54 +1,52 @@
-/**
- * Testing all effects
- */
-
-
-#include "gd.h"
-#include "gdtest.h"
-
-
-int main()
-{
- gdImagePtr im;
- int effects[] = {
- gdEffectReplace, gdEffectAlphaBlend, gdEffectNormal,
- gdEffectOverlay, gdEffectMultiply
- };
- int red[3], blue[3];
- int x, y, i, j;
- char *path;
-
- red[0] = gdTrueColorAlpha(0, 0, 255, 127);
- red[1] = gdTrueColorAlpha(0, 0, 255, 63);
- red[2] = gdTrueColorAlpha(0, 0, 255, 0);
- blue[0] = gdTrueColorAlpha(255, 0, 0, 127);
- blue[1] = gdTrueColorAlpha(255, 0, 0, 63);
- blue[2] = gdTrueColorAlpha(255, 0, 0, 0);
-
- im = gdImageCreateTrueColor(120, 180);
-
- gdImageAlphaBlending(im, gdEffectReplace);
- for (j = 0; j < 3; j++) {
- y = 60 * j;
- gdImageFilledRectangle(im, 0,y, 119,y+59, red[j]);
- }
-
- for (i = 0; i < 5; i++) {
- x = 20 * i;
- gdImageAlphaBlending(im, effects[i]);
- for (j = 0; j < 9; j++) {
- y = 20 * j;
- gdImageFilledRectangle(im, x+20,y, x+39,y+19, blue[j % 3]);
- }
- }
-
- gdImageSaveAlpha(im, 1);
-
- path = gdTestFilePath2("gdimagesetpixel", "alphablending_exp.png");
- gdAssertImageEqualsToFile(path, im);
- gdFree(path);
-
- gdImageDestroy(im);
-
- return gdNumFailures();
-}
+/**
+ * Testing all effects
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int effects[] = {
+ gdEffectReplace, gdEffectAlphaBlend, gdEffectNormal,
+ gdEffectOverlay, gdEffectMultiply
+ };
+ int red[3], blue[3];
+ int x, y, i, j;
+ char *path;
+
+ red[0] = gdTrueColorAlpha(0, 0, 255, 127);
+ red[1] = gdTrueColorAlpha(0, 0, 255, 63);
+ red[2] = gdTrueColorAlpha(0, 0, 255, 0);
+ blue[0] = gdTrueColorAlpha(255, 0, 0, 127);
+ blue[1] = gdTrueColorAlpha(255, 0, 0, 63);
+ blue[2] = gdTrueColorAlpha(255, 0, 0, 0);
+
+ im = gdImageCreateTrueColor(120, 180);
+
+ gdImageAlphaBlending(im, gdEffectReplace);
+ for (j = 0; j < 3; j++) {
+ y = 60 * j;
+ gdImageFilledRectangle(im, 0,y, 119,y+59, red[j]);
+ }
+
+ for (i = 0; i < 5; i++) {
+ x = 20 * i;
+ gdImageAlphaBlending(im, effects[i]);
+ for (j = 0; j < 9; j++) {
+ y = 20 * j;
+ gdImageFilledRectangle(im, x+20,y, x+39,y+19, blue[j % 3]);
+ }
+ }
+
+ gdImageSaveAlpha(im, 1);
+
+ path = gdTestFilePath2("gdimagesetpixel", "alphablending_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagesquaretocircle/.gitignore b/tests/gdimagesquaretocircle/.gitignore
new file mode 100644
index 0000000..bf6e191
--- /dev/null
+++ b/tests/gdimagesquaretocircle/.gitignore
@@ -0,0 +1 @@
+/gdimagesquaretocircle
diff --git a/tests/gdimagesquaretocircle/CMakeLists.txt b/tests/gdimagesquaretocircle/CMakeLists.txt
new file mode 100644
index 0000000..a8c9430
--- /dev/null
+++ b/tests/gdimagesquaretocircle/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagesquaretocircle
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagesquaretocircle/Makemodule.am b/tests/gdimagesquaretocircle/Makemodule.am
new file mode 100644
index 0000000..77b7a30
--- /dev/null
+++ b/tests/gdimagesquaretocircle/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagesquaretocircle/gdimagesquaretocircle
+endif
+
+EXTRA_DIST += \
+ gdimagesquaretocircle/CMakeLists.txt \
+ gdimagesquaretocircle/gdimagesquaretocircle_exp.png
diff --git a/tests/gdimagesquaretocircle/gdimagesquaretocircle.c b/tests/gdimagesquaretocircle/gdimagesquaretocircle.c
new file mode 100644
index 0000000..f8fba91
--- /dev/null
+++ b/tests/gdimagesquaretocircle/gdimagesquaretocircle.c
@@ -0,0 +1,32 @@
+/**
+ * Basic test for gdImageSquareToCircle()
+ */
+#include "gd.h"
+#include "gdfx.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im1, im2;
+ int white;
+ int black;
+
+ im1 = gdImageCreateTrueColor(128, 128);
+ white = gdImageColorAllocate(im1, 255, 255, 255);
+ black = gdImageColorAllocate(im1, 0, 0, 0);
+ gdImageFilledRectangle(im1, 0, 0, 127, 127, white);
+
+ /* Draw a cross line in the middle of im1 */
+ /* The horizonal line will become a circle in im2 */
+ /* The vertical line will become a horizonal with half len in im2 */
+ gdImageLine(im1, 0, 63, 127, 63, black);
+ gdImageLine(im1, 63, 0, 63, 127, black);
+ im2 = gdImageSquareToCircle(im1, 64);
+
+ gdAssertImageEqualsToFile("gdimagesquaretocircle/gdimagesquaretocircle_exp.png", im2);
+
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png b/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png
new file mode 100644
index 0000000..222bb13
--- /dev/null
+++ b/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png
Binary files differ
diff --git a/tests/gdimagestring/.gitignore b/tests/gdimagestring/.gitignore
new file mode 100644
index 0000000..ecd076c
--- /dev/null
+++ b/tests/gdimagestring/.gitignore
@@ -0,0 +1 @@
+/gdimagestring
diff --git a/tests/gdimagestring/CMakeLists.txt b/tests/gdimagestring/CMakeLists.txt
new file mode 100644
index 0000000..3cabaec
--- /dev/null
+++ b/tests/gdimagestring/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagestring
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagestring/Makemodule.am b/tests/gdimagestring/Makemodule.am
new file mode 100644
index 0000000..84ca656
--- /dev/null
+++ b/tests/gdimagestring/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagestring/gdimagestring
+endif
+
+EXTRA_DIST += \
+ gdimagestring/CMakeLists.txt \
+ gdimagestring/gdimagestring_exp.png
diff --git a/tests/gdimagestring/gdimagestring.c b/tests/gdimagestring/gdimagestring.c
new file mode 100644
index 0000000..c4b4aa1
--- /dev/null
+++ b/tests/gdimagestring/gdimagestring.c
@@ -0,0 +1,34 @@
+/**
+ * Base test for gdImageString()
+ */
+#include <gd.h>
+#include <gdfontl.h>
+#include "gdtest.h"
+#include <string.h>
+
+int main()
+{
+ /* Declare the image */
+ gdImagePtr im = NULL;
+ char *s = "Hello gd";
+ int foreground = 0;
+ int error = 0;
+ gdFontPtr fontptr = gdFontGetLarge();
+
+ im = gdImageCreate(100, 50);
+ gdImageColorAllocate(im, 202, 202, 0);
+ foreground = gdImageColorAllocate(im, 22, 4, 238);
+
+ gdImageString(im, fontptr,
+ im->sx / 2 - (strlen(s) * fontptr->w / 2),
+ im->sy / 2 - fontptr->h / 2,
+ (unsigned char*)s, foreground);
+
+ if (!gdAssertImageEqualsToFile("gdimagestring/gdimagestring_exp.png", im))
+ error= 1;
+
+ /* Destroy the image in memory. */
+ gdImageDestroy(im);
+
+ return error;
+}
diff --git a/tests/gdimagestring/gdimagestring_exp.png b/tests/gdimagestring/gdimagestring_exp.png
new file mode 100644
index 0000000..2435626
--- /dev/null
+++ b/tests/gdimagestring/gdimagestring_exp.png
Binary files differ
diff --git a/tests/gdimagestring16/.gitignore b/tests/gdimagestring16/.gitignore
new file mode 100644
index 0000000..5ebaa0b
--- /dev/null
+++ b/tests/gdimagestring16/.gitignore
@@ -0,0 +1 @@
+/gdimagestring16
diff --git a/tests/gdimagestring16/CMakeLists.txt b/tests/gdimagestring16/CMakeLists.txt
new file mode 100644
index 0000000..e85db9b
--- /dev/null
+++ b/tests/gdimagestring16/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagestring16
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagestring16/Makemodule.am b/tests/gdimagestring16/Makemodule.am
new file mode 100644
index 0000000..84b6b5f
--- /dev/null
+++ b/tests/gdimagestring16/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagestring16/gdimagestring16
+endif
+
+EXTRA_DIST += \
+ gdimagestring16/CMakeLists.txt \
+ gdimagestring16/gdimagestring16_exp.png
diff --git a/tests/gdimagestring16/gdimagestring16.c b/tests/gdimagestring16/gdimagestring16.c
new file mode 100644
index 0000000..0ca0668
--- /dev/null
+++ b/tests/gdimagestring16/gdimagestring16.c
@@ -0,0 +1,30 @@
+/**
+ * Base test for gdImageString16()
+ */
+#include <gd.h>
+#include <gdfontl.h>
+#include "gdtest.h"
+
+int main()
+{
+ /* Declare the image */
+ gdImagePtr im = NULL;
+ unsigned short s[2] = {'H', 0};
+ int foreground;
+ int errorcode = 0;
+ gdFontPtr fontptr = gdFontGetLarge();
+
+ im = gdImageCreate(20, 20);
+ gdImageColorAllocate(im, 255, 255, 255);
+ foreground = gdImageColorAllocate(im, 22, 4, 238);
+
+ gdImageString16(im, fontptr, 2, 2, s, foreground);
+
+ if (!gdAssertImageEqualsToFile("gdimagestring16/gdimagestring16_exp.png", im))
+ errorcode = 1;
+
+ /* Destroy the image in memory */
+ gdImageDestroy(im);
+
+ return errorcode;
+}
diff --git a/tests/gdimagestring16/gdimagestring16_exp.png b/tests/gdimagestring16/gdimagestring16_exp.png
new file mode 100644
index 0000000..5700578
--- /dev/null
+++ b/tests/gdimagestring16/gdimagestring16_exp.png
Binary files differ
diff --git a/tests/gdimagestringft/.gitignore b/tests/gdimagestringft/.gitignore
index f9f01f0..efe5e61 100644
--- a/tests/gdimagestringft/.gitignore
+++ b/tests/gdimagestringft/.gitignore
@@ -1 +1,2 @@
+/bug00615
/gdimagestringft_bbox
diff --git a/tests/gdimagestringft/CMakeLists.txt b/tests/gdimagestringft/CMakeLists.txt
index f46b900..42868a2 100644
--- a/tests/gdimagestringft/CMakeLists.txt
+++ b/tests/gdimagestringft/CMakeLists.txt
@@ -1,5 +1,6 @@
IF(FREETYPE_FOUND)
LIST(APPEND TESTS_FILES
+ bug00615
gdimagestringft_bbox
)
ENDIF(FREETYPE_FOUND)
diff --git a/tests/gdimagestringft/Makemodule.am b/tests/gdimagestringft/Makemodule.am
index 0dfe26f..a62081f 100644
--- a/tests/gdimagestringft/Makemodule.am
+++ b/tests/gdimagestringft/Makemodule.am
@@ -1,5 +1,6 @@
if HAVE_LIBFREETYPE
libgd_test_programs += \
+ gdimagestringft/bug00615 \
gdimagestringft/gdimagestringft_bbox
endif
diff --git a/tests/gdimagestringft/bug00615.c b/tests/gdimagestringft/bug00615.c
new file mode 100644
index 0000000..0da51da
--- /dev/null
+++ b/tests/gdimagestringft/bug00615.c
@@ -0,0 +1,25 @@
+/**
+ * Test that rendering an empty string does not fail
+ *
+ * Rendering an empty string with gdImageStringFT() is not supposed to fail;
+ * it is just a no-op.
+ *
+ * See <https://github.com/libgd/libgd/issues/615>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im = gdImageCreate(100, 100);
+
+ int rect[8];
+ int fg = gdImageColorAllocate(im, 255, 255, 255);
+ char *path = gdTestFilePath("freetype/DejaVuSans.ttf");
+ char *res = gdImageStringFT(im, rect, fg, path, 12, 0, 10, 10, "");
+
+ gdTestAssert(res == NULL);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagestringft/gdimagestringft_bbox.c b/tests/gdimagestringft/gdimagestringft_bbox.c
index 0161ec8..e75248a 100644
--- a/tests/gdimagestringft/gdimagestringft_bbox.c
+++ b/tests/gdimagestringft/gdimagestringft_bbox.c
@@ -8,22 +8,22 @@
#define DELTA (PI/8)
static int EXPECT[16][8] = {
- {498, 401, 630, 401, 630, 374, 498, 374},
- {491, 364, 613, 313, 602, 288, 481, 338},
- {470, 332, 563, 239, 544, 219, 451, 312},
- {438, 310, 488, 189, 463, 178, 412, 300},
- {401, 303, 401, 171, 374, 171, 374, 303},
- {365, 310, 314, 188, 289, 199, 339, 320},
- {334, 331, 241, 238, 221, 257, 314, 350},
- {313, 362, 192, 312, 181, 337, 303, 388},
- {306, 398, 174, 398, 174, 425, 306, 425},
- {313, 433, 191, 484, 202, 509, 323, 459},
- {333, 463, 240, 556, 259, 576, 352, 483},
- {363, 484, 313, 605, 338, 616, 389, 494},
- {398, 490, 398, 622, 425, 622, 425, 490},
- {432, 483, 483, 605, 508, 594, 458, 473},
- {461, 464, 554, 557, 574, 538, 481, 445},
- {481, 435, 602, 485, 613, 460, 491, 409},
+ {500, 400, 628, 400, 628, 376, 500, 376},
+ {492, 362, 611, 312, 601, 290, 483, 339},
+ {470, 330, 561, 239, 544, 221, 453, 312},
+ {437, 308, 486, 189, 464, 180, 414, 299},
+ {400, 301, 400, 173, 376, 173, 376, 301},
+ {363, 309, 313, 190, 291, 200, 340, 318},
+ {332, 331, 241, 240, 223, 257, 314, 348},
+ {311, 363, 192, 314, 183, 336, 302, 386},
+ {304, 399, 176, 399, 176, 423, 304, 423},
+ {312, 435, 193, 485, 203, 507, 321, 458},
+ {333, 465, 242, 556, 259, 574, 350, 483},
+ {364, 486, 315, 605, 337, 614, 387, 495},
+ {399, 492, 399, 620, 423, 620, 423, 492},
+ {434, 484, 484, 603, 506, 593, 457, 475},
+ {463, 464, 554, 555, 572, 538, 481, 447},
+ {483, 434, 602, 483, 611, 461, 492, 411},
};
int main()
@@ -38,6 +38,9 @@ int main()
int error = 0;
FILE *fp;
+ /* disable subpixel hinting */
+ putenv("FREETYPE_PROPERTIES=truetype:interpreter-version=35");
+
path = gdTestFilePath("freetype/DejaVuSans.ttf");
im = gdImageCreate(800, 800);
gdImageColorAllocate(im, 0xFF, 0xFF, 0xFF); /* allocate white for background color */
@@ -52,7 +55,7 @@ int main()
goto done;
}
for (j = 0; j < 8; j++) {
- if (brect[j] != EXPECT[i][j]) {
+ if (brect[j] < EXPECT[i][j] - 1 || brect[j] > EXPECT[i][j] + 1) {
gdTestErrorMsg("(%d, %d) (%d, %d) (%d, %d) (%d, %d) expected, but (%d, %d) (%d, %d) (%d, %d) (%d, %d)\n",
EXPECT[i][0], EXPECT[i][1], EXPECT[i][2], EXPECT[i][3],
EXPECT[i][4], EXPECT[i][5], EXPECT[i][6], EXPECT[i][7],
diff --git a/tests/gdimagestringup/.gitignore b/tests/gdimagestringup/.gitignore
new file mode 100644
index 0000000..4b4bb43
--- /dev/null
+++ b/tests/gdimagestringup/.gitignore
@@ -0,0 +1 @@
+/gdimagestringup
diff --git a/tests/gdimagestringup/CMakeLists.txt b/tests/gdimagestringup/CMakeLists.txt
new file mode 100644
index 0000000..424cb83
--- /dev/null
+++ b/tests/gdimagestringup/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagestringup
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagestringup/Makemodule.am b/tests/gdimagestringup/Makemodule.am
new file mode 100644
index 0000000..b136c80
--- /dev/null
+++ b/tests/gdimagestringup/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagestringup/gdimagestringup
+endif
+
+EXTRA_DIST += \
+ gdimagestringup/CMakeLists.txt \
+ gdimagestringup/gdimagestringup_exp.png
diff --git a/tests/gdimagestringup/gdimagestringup.c b/tests/gdimagestringup/gdimagestringup.c
new file mode 100644
index 0000000..0832bd7
--- /dev/null
+++ b/tests/gdimagestringup/gdimagestringup.c
@@ -0,0 +1,34 @@
+/**
+ * Base test for gdImageStringUp()
+ */
+#include <gd.h>
+#include <gdfontl.h>
+#include "gdtest.h"
+#include <string.h>
+
+int main()
+{
+ /* Declare the image */
+ gdImagePtr im = NULL;
+ char *s = "Hello gd";
+ int errorcode = 0;
+ int foreground;
+ gdFontPtr fontptr = gdFontGetLarge();
+
+ im = gdImageCreate(50, 100);
+ gdImageColorAllocate(im, 202, 202, 0);
+ foreground = gdImageColorAllocate(im, 22, 4, 238);
+
+ gdImageStringUp(im, fontptr,
+ im->sx / 2 - fontptr->h / 2,
+ im->sy / 2 + (strlen(s) * fontptr->w / 2),
+ (unsigned char*)s, foreground);
+
+ if (!gdAssertImageEqualsToFile("gdimagestringup/gdimagestringup_exp.png", im))
+ errorcode = 1;
+
+ /* Destroy the image im memory */
+ gdImageDestroy(im);
+
+ return errorcode;
+}
diff --git a/tests/gdimagestringup/gdimagestringup_exp.png b/tests/gdimagestringup/gdimagestringup_exp.png
new file mode 100644
index 0000000..d1f6d66
--- /dev/null
+++ b/tests/gdimagestringup/gdimagestringup_exp.png
Binary files differ
diff --git a/tests/gdimagestringup16/.gitignore b/tests/gdimagestringup16/.gitignore
new file mode 100644
index 0000000..1c009a5
--- /dev/null
+++ b/tests/gdimagestringup16/.gitignore
@@ -0,0 +1 @@
+/gdimagestringup16
diff --git a/tests/gdimagestringup16/CMakeLists.txt b/tests/gdimagestringup16/CMakeLists.txt
new file mode 100644
index 0000000..08f4ff8
--- /dev/null
+++ b/tests/gdimagestringup16/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagestringup16
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagestringup16/Makemodule.am b/tests/gdimagestringup16/Makemodule.am
new file mode 100644
index 0000000..7735432
--- /dev/null
+++ b/tests/gdimagestringup16/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagestringup16/gdimagestringup16
+endif
+
+EXTRA_DIST += \
+ gdimagestringup16/CMakeLists.txt \
+ gdimagestringup16/gdimagestringup16_exp.png
diff --git a/tests/gdimagestringup16/gdimagestringup16.c b/tests/gdimagestringup16/gdimagestringup16.c
new file mode 100644
index 0000000..c24639f
--- /dev/null
+++ b/tests/gdimagestringup16/gdimagestringup16.c
@@ -0,0 +1,29 @@
+/**
+ * Base test for gdImageStringUp16()
+ */
+#include <gd.h>
+#include <gdfontl.h>
+#include "gdtest.h"
+
+int main()
+{
+ /* Declare the image */
+ gdImagePtr im = NULL;
+ unsigned short s[2] = {'H', 0};
+ int foreground;
+ int errorcode = 0;
+ gdFontPtr fontptr = gdFontGetLarge();
+
+ im = gdImageCreate(20, 20);
+ gdImageColorAllocate(im, 255, 255, 255);
+ foreground = gdImageColorAllocate(im, 22, 4, 238);
+
+ gdImageStringUp16(im, fontptr, 2, 18, s, foreground);
+
+ if (!gdAssertImageEqualsToFile("gdimagestringup16/gdimagestringup16_exp.png", im))
+ errorcode = 1;
+
+ gdImageDestroy(im);
+
+ return errorcode;
+}
diff --git a/tests/gdimagestringup16/gdimagestringup16_exp.png b/tests/gdimagestringup16/gdimagestringup16_exp.png
new file mode 100644
index 0000000..a1a4570
--- /dev/null
+++ b/tests/gdimagestringup16/gdimagestringup16_exp.png
Binary files differ
diff --git a/tests/gdimagetruecolortopalette/CMakeLists.txt b/tests/gdimagetruecolortopalette/CMakeLists.txt
index b23d2a1..fc7f6f7 100644
--- a/tests/gdimagetruecolortopalette/CMakeLists.txt
+++ b/tests/gdimagetruecolortopalette/CMakeLists.txt
@@ -1,4 +1,4 @@
-SET(TESTS_FILES
+LIST(APPEND TESTS_FILES
bug00307
php_bug_72512
)
diff --git a/tests/gdimagetruecolortopalette/Makemodule.am b/tests/gdimagetruecolortopalette/Makemodule.am
index 31f0362..ac9eedc 100644
--- a/tests/gdimagetruecolortopalette/Makemodule.am
+++ b/tests/gdimagetruecolortopalette/Makemodule.am
@@ -1,4 +1,3 @@
-
libgd_test_programs += \
gdimagetruecolortopalette/bug00307 \
gdimagetruecolortopalette/php_bug_72512
diff --git a/tests/gdimagetruecolortopalette/bug00307.c b/tests/gdimagetruecolortopalette/bug00307.c
index a5c6a04..a01eb5a 100644
--- a/tests/gdimagetruecolortopalette/bug00307.c
+++ b/tests/gdimagetruecolortopalette/bug00307.c
@@ -5,7 +5,7 @@
* GD_QUANT_NEUQUANT has its trueColor flag unset.
*/
-
+
#include "gd.h"
#include "gdtest.h"
diff --git a/tests/gdtest/CMakeLists.txt b/tests/gdtest/CMakeLists.txt
index 4b05262..ff9fd7d 100644
--- a/tests/gdtest/CMakeLists.txt
+++ b/tests/gdtest/CMakeLists.txt
@@ -1,3 +1,7 @@
add_definitions(-DGDTEST_TOP_DIR="${CMAKE_CURRENT_SOURCE_DIR}/..")
-add_library (gdTest STATIC gdtest.c)
+SET(GDTEST_FILES gdtest.c)
+if(WIN32)
+ LIST(APPEND GDTEST_FILES readdir.c)
+endif()
+add_library(gdTest STATIC ${GDTEST_FILES})
target_link_libraries(gdTest ${GD_LIB})
diff --git a/tests/gdtest/gdtest.c b/tests/gdtest/gdtest.c
index d173975..832f27a 100644
--- a/tests/gdtest/gdtest.c
+++ b/tests/gdtest/gdtest.c
@@ -1,4 +1,6 @@
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
@@ -21,7 +23,14 @@
#endif
#ifdef _WIN32
-# include "readdir.h"
+#include "readdir.h"
+#include <errno.h>
+#endif
+
+/* GDTEST_TOP_DIR is defined in other compile ways except msys
+ * test_config.h is created by windows/msys/run_test.sh*/
+#ifndef GDTEST_TOP_DIR
+#include <test_config.h>
#endif
#include "gd.h"
@@ -59,7 +68,7 @@ gdImagePtr gdTestImageFromPng(const char *filename)
if (fp == NULL) {
return NULL;
}
-
+
image = gdImageCreateFromPng(fp);
fclose(fp);
return image;
@@ -186,11 +195,11 @@ static int getfilesystemtime(struct timeval *tv)
fft.LowPart = ft.dwLowDateTime;
ff = fft.QuadPart;
- ff /= 10Ui64; /* convert to microseconds */
- ff -= 11644473600000000Ui64; /* convert to unix epoch */
+ ff /= 10ULL; /* convert to microseconds */
+ ff -= 11644473600000000ULL; /* convert to unix epoch */
- tv->tv_sec = (long)(ff / 1000000Ui64);
- tv->tv_usec = (long)(ff % 1000000Ui64);
+ tv->tv_sec = (long)(ff / 1000000ULL);
+ tv->tv_usec = (long)(ff % 1000000ULL);
return 0;
}
@@ -203,7 +212,7 @@ mkdtemp (char *tmpl)
static int counter = 0;
char *XXXXXX;
struct timeval tv;
- _int64 value;
+ __int64 value;
int count;
/* find the last occurrence of "XXXXXX" */
@@ -219,7 +228,7 @@ mkdtemp (char *tmpl)
value = (tv.tv_usec ^ tv.tv_sec) + counter++;
for (count = 0; count < 100; value += 7777, ++count) {
- _int64 v = value;
+ __int64 v = value;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % NLETTERS];
@@ -304,7 +313,7 @@ char *gdTestTempFile(const char *template)
ret);
gdTestAssert(error != 0);
} else {
- sprintf(ret, "%s\\%s", tempdir, template);
+ sprintf(ret, "%s\\%s", tempdir, template);
}
}
#else
@@ -501,7 +510,6 @@ unsigned int gdMaxPixelDiff(gdImagePtr a, gdImagePtr b)
return diff;
}
-
int gdTestImageCompareToImage(const char* file, unsigned int line, const char* message,
gdImagePtr expected, gdImagePtr actual)
{
@@ -561,6 +569,7 @@ int gdTestImageCompareToImage(const char* file, unsigned int line, const char* m
if (!fp) goto fail;
gdImagePng(surface_diff,fp);
fclose(fp);
+ gdImageDestroy(surface_diff);
fp = fopen(file_out, "wb");
if (!fp) goto fail;
@@ -578,13 +587,13 @@ fail:
if (surface_diff) {
gdImageDestroy(surface_diff);
}
- return 0;
+ return 1;
}
int gdTestImageCompareToFile(const char* file, unsigned int line, const char* message,
const char *expected_file, gdImagePtr actual)
{
- gdImagePtr expected;
+ gdImagePtr expected = 0;
int res = 1;
expected = gdTestImageFromPng(expected_file);
@@ -599,7 +608,6 @@ int gdTestImageCompareToFile(const char* file, unsigned int line, const char* me
return res;
}
-
static int failureCount = 0;
int gdNumFailures() {
diff --git a/tests/gdtest/gdtest.h b/tests/gdtest/gdtest.h
index eecf5f6..16d89aa 100644
--- a/tests/gdtest/gdtest.h
+++ b/tests/gdtest/gdtest.h
@@ -63,10 +63,8 @@ int _gdTestErrorMsg(const char* file, unsigned int line, const char* string, ...
/* public assert functions */
#define gdAssertImageEqualsToFile(ex,ac) gdTestImageCompareToFile(__FILE__,__LINE__,NULL,(ex),(ac))
-#define gdAssertImageFileEqualsMsg(ex,ac,ms) gdTestImageCompareFiles(__FILE__,__LINE__,(ms),(ex),(ac))
#define gdAssertImageEquals(ex,ac) gdTestImageCompareToImage(__FILE__,__LINE__,NULL,(ex),(ac))
-#define gdAssertImageEqualsMsg(ex,ac,ms) gdTestImageCompareToImage(__FILE__,__LINE__,(ms),(ex),(ac))
#define gdTestAssert(cond) _gdTestAssert(__FILE__, __LINE__, (cond))
diff --git a/tests/gdtiled/CMakeLists.txt b/tests/gdtiled/CMakeLists.txt
index 921d00e..25f6045 100644
--- a/tests/gdtiled/CMakeLists.txt
+++ b/tests/gdtiled/CMakeLists.txt
@@ -1,5 +1,9 @@
+IF(PNG_FOUND)
+IF(ZLIB_FOUND)
LIST(APPEND TESTS_FILES
bug00032
)
+ENDIF(ZLIB_FOUND)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gdtiled/bug00032.c b/tests/gdtiled/bug00032.c
index 4c788e2..7a2b5cc 100644
--- a/tests/gdtiled/bug00032.c
+++ b/tests/gdtiled/bug00032.c
@@ -29,4 +29,3 @@ int main()
gdImageDestroy(tile);
return 0;
}
-
diff --git a/tests/gdtransformaffineboundingbox/Makemodule.am b/tests/gdtransformaffineboundingbox/Makemodule.am
index e70b073..2566ed5 100644
--- a/tests/gdtransformaffineboundingbox/Makemodule.am
+++ b/tests/gdtransformaffineboundingbox/Makemodule.am
@@ -1,4 +1,3 @@
-
libgd_test_programs += \
gdtransformaffineboundingbox/github_bug_00221
diff --git a/tests/gdtransformaffineboundingbox/github_bug_00221.c b/tests/gdtransformaffineboundingbox/github_bug_00221.c
index c327789..9e75d0e 100644
--- a/tests/gdtransformaffineboundingbox/github_bug_00221.c
+++ b/tests/gdtransformaffineboundingbox/github_bug_00221.c
@@ -10,7 +10,7 @@ int main()
gdRect bbox;
gdRect area;
double affine[6];
-
+
affine[0] = -0.965926;
affine[1] = -0.258819;
affine[2] = 0.258819;
@@ -24,7 +24,7 @@ int main()
if (gdTransformAffineBoundingBox(&area, affine, &bbox) != GD_TRUE) {
return 1;
}
- if (!(bbox.x ==-253 && bbox.y ==-228 && bbox.width == 298 && bbox.height == 230)) {
+ if (!(bbox.x ==-253 && bbox.y ==-228 && bbox.width == 297 && bbox.height == 229)) {
return 1;
}
diff --git a/tests/gdtransformaffinecopy/.gitignore b/tests/gdtransformaffinecopy/.gitignore
new file mode 100644
index 0000000..2af21d5
--- /dev/null
+++ b/tests/gdtransformaffinecopy/.gitignore
@@ -0,0 +1,4 @@
+/github_bug_00583
+/github_bug_00585
+/github_bug_00586
+/github_bug_00596
diff --git a/tests/gdtransformaffinecopy/CMakeLists.txt b/tests/gdtransformaffinecopy/CMakeLists.txt
new file mode 100644
index 0000000..4af9fcc
--- /dev/null
+++ b/tests/gdtransformaffinecopy/CMakeLists.txt
@@ -0,0 +1,8 @@
+LIST(APPEND TESTS_FILES
+ github_bug_00583
+ github_bug_00585
+ github_bug_00586
+ github_bug_00596
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdtransformaffinecopy/Makemodule.am b/tests/gdtransformaffinecopy/Makemodule.am
new file mode 100644
index 0000000..494ec80
--- /dev/null
+++ b/tests/gdtransformaffinecopy/Makemodule.am
@@ -0,0 +1,8 @@
+libgd_test_programs += \
+ gdtransformaffinecopy/github_bug_00583 \
+ gdtransformaffinecopy/github_bug_00585 \
+ gdtransformaffinecopy/github_bug_00586 \
+ gdtransformaffinecopy/github_bug_00596
+
+EXTRA_DIST += \
+ gdtransformaffinecopy/CMakeLists.txt
diff --git a/tests/gdtransformaffinecopy/github_bug_00583.c b/tests/gdtransformaffinecopy/github_bug_00583.c
new file mode 100644
index 0000000..6b0fd53
--- /dev/null
+++ b/tests/gdtransformaffinecopy/github_bug_00583.c
@@ -0,0 +1,30 @@
+/**
+ * Test that a zero determinant matrix causes gdTransformAffineCopy() to fail
+ *
+ * See <https://github.com/libgd/libgd/issues/583>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 8, 8};
+ double matrix[] = {1, 1, 1, 1, 1, 1};
+ int white;
+ int res;
+
+ src = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(src != NULL);
+ dst = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(dst != NULL);
+ white = gdImageColorAllocate(src, 255, 255, 255);
+ gdImageFilledRectangle(src, 0, 0, 7, 7, white);
+ res = gdTransformAffineCopy(dst, 0, 0, src, &rect, matrix);
+ gdTestAssert(res == GD_FALSE);
+ gdImageDestroy(dst);
+ gdImageDestroy(src);
+ return gdNumFailures();
+}
diff --git a/tests/gdtransformaffinecopy/github_bug_00585.c b/tests/gdtransformaffinecopy/github_bug_00585.c
new file mode 100644
index 0000000..e83910c
--- /dev/null
+++ b/tests/gdtransformaffinecopy/github_bug_00585.c
@@ -0,0 +1,33 @@
+/*
+ * Test that gdTransformAffineCopy() does not change the interpolation method
+ *
+ * See <https://github.com/libgd/libgd/issues/585>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 8, 8};
+ double matrix[] = {1, 1, 1, 1, 1, 1};
+ int res;
+ gdInterpolationMethod old_m, new_m;
+
+ src = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(src != NULL);
+ dst = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(dst != NULL);
+
+ res = gdImageSetInterpolationMethod(src, GD_CATMULLROM);
+ gdTestAssert(res == GD_TRUE);
+ old_m = gdImageGetInterpolationMethod(src);
+ gdTransformAffineCopy(dst, 0, 0, src, &rect, matrix);
+ new_m = gdImageGetInterpolationMethod(src);
+ gdTestAssert(new_m == old_m);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+ return gdNumFailures();
+}
diff --git a/tests/gdtransformaffinecopy/github_bug_00586.c b/tests/gdtransformaffinecopy/github_bug_00586.c
new file mode 100644
index 0000000..4cf2f2e
--- /dev/null
+++ b/tests/gdtransformaffinecopy/github_bug_00586.c
@@ -0,0 +1,26 @@
+/*
+ * Test that gdTransformAffineCopy() does not segfault for palette images
+ *
+ * See <>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 8, 8};
+ double matrix[] = {1, 0, 0, 1, 0, 0};
+
+ src = gdImageCreate(8, 8);
+ gdTestAssert(src != NULL);
+ dst = gdImageCreate(8, 8);
+ gdTestAssert(dst != NULL);
+
+ gdTransformAffineCopy(dst, 0, 0, src, &rect, matrix);
+
+ gdImageDestroy(dst);
+ gdImageDestroy(src);
+ return gdNumFailures();
+}
diff --git a/tests/gdtransformaffinecopy/github_bug_00596.c b/tests/gdtransformaffinecopy/github_bug_00596.c
new file mode 100644
index 0000000..51912e1
--- /dev/null
+++ b/tests/gdtransformaffinecopy/github_bug_00596.c
@@ -0,0 +1,42 @@
+/**
+ * Test gdTransformAffineCopy() run error
+ *
+ * See <https://github.com/libgd/libgd/issues/596>
+ *
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ double matrix[] = {1, 0, 0, 1, 0, 0};
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 16, 16};
+ int white, green;
+ int status = 0;
+ int res;
+ int actual_color = 0;
+ int expected_color = 0x00ff00;
+
+ src = gdImageCreateTrueColor(16, 16);
+ gdTestAssert(src != NULL);
+ white = gdImageColorAllocate(src, 255, 255, 255);
+ gdImageFilledRectangle(src, 0, 0, 16, 16, white);
+
+ dst = gdImageCreateTrueColor(50, 50);
+ gdTestAssert(dst != NULL);
+ green = gdImageColorAllocate(dst, 0, 255, 0);
+ gdImageFilledRectangle(dst, 0, 0, 50, 50, green);
+
+ res = gdTransformAffineCopy(dst, 4, 4, src, &rect, matrix);
+ gdTestAssert(res != GD_FALSE);
+
+ status = gdNumFailures();
+ actual_color = gdImageGetPixel(dst, 20, 5);
+ status = (actual_color == expected_color) ? status : 1;
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+ return status;
+}
diff --git a/tests/gif/.gitignore b/tests/gif/.gitignore
index d18444d..d30118f 100644
--- a/tests/gif/.gitignore
+++ b/tests/gif/.gitignore
@@ -5,5 +5,10 @@
/bug00066
/bug00181
/bug00227
+/bug00499
/gif_im2im
/gif_null
+/gif_nocolormaps
+/ossfuzz5700
+/php_bug_75571
+/uninitialized_memory_read
diff --git a/tests/gif/CMakeLists.txt b/tests/gif/CMakeLists.txt
index 92010c3..d071874 100644
--- a/tests/gif/CMakeLists.txt
+++ b/tests/gif/CMakeLists.txt
@@ -1,13 +1,23 @@
LIST(APPEND TESTS_FILES
- gif_im2im
- gif_null
- bug00005
bug00005_2
+ bug00181
+ bug00227
+ bug00499
+ gif_null
+ gif_nocolormaps
+ ossfuzz5700
+ php_bug_75571
+ uninitialized_memory_read
bug00006
bug00060
+ gif_im2im
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ bug00005
bug00066
- bug00181
- bug00227
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/gif/Makemodule.am b/tests/gif/Makemodule.am
index 50f671f..c616b3e 100644
--- a/tests/gif/Makemodule.am
+++ b/tests/gif/Makemodule.am
@@ -2,15 +2,20 @@ libgd_test_programs += \
gif/bug00005_2 \
gif/bug00181 \
gif/bug00227 \
- gif/gif_null
+ gif/bug00499 \
+ gif/gif_null \
+ gif/gif_nocolormaps \
+ gif/ossfuzz5700 \
+ gif/php_bug_75571 \
+ gif/uninitialized_memory_read \
+ gif/bug00006 \
+ gif/bug00060 \
+ gif/gif_im2im
if HAVE_LIBPNG
libgd_test_programs += \
gif/bug00005 \
- gif/bug00006 \
- gif/bug00060 \
- gif/bug00066 \
- gif/gif_im2im
+ gif/bug00066
endif
EXTRA_DIST += \
@@ -22,4 +27,8 @@ EXTRA_DIST += \
gif/bug00005_3.gif \
gif/bug00060.gif \
gif/bug00066.gif \
- gif/bug00066_exp.png
+ gif/bug00066_exp.png \
+ gif/gif_nocolormaps.gif \
+ gif/ossfuzz5700.gif \
+ gif/php_bug_75571.gif \
+ gif/unitialized_memory_read.gif
diff --git a/tests/gif/bug00006.c b/tests/gif/bug00006.c
index f1a7fe8..95f7620 100644
--- a/tests/gif/bug00006.c
+++ b/tests/gif/bug00006.c
@@ -27,6 +27,10 @@ int main()
gdTestErrorMsg("Cannot open <%s> for writing\n", file);
return 1;
}
+
+ gdImageTrueColorToPaletteSetMethod(im, GD_QUANT_JQUANT, 0);
+ gdImageTrueColorToPalette(im, 1, 256);
+
gdImageGif(im,fp);
fclose(fp);
@@ -60,5 +64,6 @@ int main()
/* Destroy it */
gdImageDestroy(im);
+ free(file);
return error;
}
diff --git a/tests/gif/bug00181.c b/tests/gif/bug00181.c
index 43b9e3b..878537f 100644
--- a/tests/gif/bug00181.c
+++ b/tests/gif/bug00181.c
@@ -92,6 +92,7 @@ int main()
}
error = !im->interlace;
gdImageDestroy(im);
+ free(file);
return error;
}
diff --git a/tests/gif/bug00227.c b/tests/gif/bug00227.c
index e25bd9a..aa20645 100644
--- a/tests/gif/bug00227.c
+++ b/tests/gif/bug00227.c
@@ -65,5 +65,7 @@ int main()
if (buf[PROBE_SIZE-1] & 0x80) return 1;
free(buf);
fclose(fp);
+
+ free(file);
return 0;
}
diff --git a/tests/gif/bug00499.c b/tests/gif/bug00499.c
new file mode 100644
index 0000000..0fedb92
--- /dev/null
+++ b/tests/gif/bug00499.c
@@ -0,0 +1,51 @@
+/**
+ * Test that adding identical images to GIF animations do no double-free
+ *
+ * We are adding two frames to a GIF animation in gdDisposalNone mode, were the
+ * second frame is identical to the first, which result in that image to have
+ * zero extent. This program must not cause any memory issues.
+ *
+ * See also <https://github.com/libgd/libgd/issues/499>.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ int black;
+ int size;
+ void * res;
+
+ im = gdImageCreate(100, 100);
+ black = gdImageColorAllocate(im, 0, 0, 0);
+ gdImageRectangle(im, 0, 0, 10, 10, black);
+
+ res = gdImageGifAnimBeginPtr(im, &size, 1, 3);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimAddPtr(im, &size, 0, 0, 0, 100, gdDisposalNone, NULL);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimAddPtr(im, &size, 0, 0, 0, 100, gdDisposalNone, im);
+ gdTestAssert(res == NULL);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ res = gdImageGifAnimEndPtr(&size);
+ if (res != NULL) {
+ gdFree(res);
+ }
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gif/gif_nocolormaps.c b/tests/gif/gif_nocolormaps.c
new file mode 100644
index 0000000..4419904
--- /dev/null
+++ b/tests/gif/gif_nocolormaps.c
@@ -0,0 +1,25 @@
+/**
+ * Ensure that a GIF without any Global or Local color tables is still decoded
+ *
+ * GIF89a spec indicates conforming image files need not have Global or Local color tables at all
+ *
+ * See also: https://www.w3.org/Graphics/GIF/spec-gif89a.txt
+ * http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gif", "gif_nocolormaps.gif");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGif(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/gif/gif_nocolormaps.gif b/tests/gif/gif_nocolormaps.gif
new file mode 100644
index 0000000..b3aa80d
--- /dev/null
+++ b/tests/gif/gif_nocolormaps.gif
Binary files differ
diff --git a/tests/gif/ossfuzz5700.c b/tests/gif/ossfuzz5700.c
new file mode 100644
index 0000000..8fc9f88
--- /dev/null
+++ b/tests/gif/ossfuzz5700.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp = gdTestFileOpen("gif/ossfuzz5700.gif");
+ im = gdImageCreateFromGif(fp);
+ fclose(fp);
+ gdImageDestroy(im);
+ return 0;
+}
diff --git a/tests/gif/ossfuzz5700.gif b/tests/gif/ossfuzz5700.gif
new file mode 100644
index 0000000..315c5a8
--- /dev/null
+++ b/tests/gif/ossfuzz5700.gif
Binary files differ
diff --git a/tests/gif/php_bug_75571.c b/tests/gif/php_bug_75571.c
new file mode 100644
index 0000000..ec1f37e
--- /dev/null
+++ b/tests/gif/php_bug_75571.c
@@ -0,0 +1,28 @@
+/**
+ * Test that GIF reading does not loop infinitely
+ *
+ * We are reading a crafted GIF image which has been truncated. This would
+ * trigger an infinite loop formerly, but know bails out early, returning
+ * NULL from gdImageCreateFromGif().
+ *
+ * See also https://bugs.php.net/bug.php?id=75571.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("gif", "php_bug_75571.gif");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGif(fp);
+ gdTestAssert(im == NULL);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/gif/php_bug_75571.gif b/tests/gif/php_bug_75571.gif
new file mode 100644
index 0000000..3c30b40
--- /dev/null
+++ b/tests/gif/php_bug_75571.gif
Binary files differ
diff --git a/tests/gif/uninitialized_memory_read.c b/tests/gif/uninitialized_memory_read.c
new file mode 100644
index 0000000..566fc4a
--- /dev/null
+++ b/tests/gif/uninitialized_memory_read.c
@@ -0,0 +1,42 @@
+/**
+ * Test for uninitialized color map entries
+ *
+ * We're reading a crafted GIF which consists of 16x16 color blocks and which
+ * has only two palette entries in the global color map, but uses other palette
+ * indexes as well. We verify whether all undefined palette indexes produce the
+ * color black.
+ *
+ * See also <CAKm_7a-AO++B6cXYWM_DtycPENG5WNWK7NSEvQ5OmZziMY_JyA@mail.gmail.com>
+ * which had been sent to security@libgd.org.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ int i, j, col;
+
+ fp = gdTestFileOpen2("gif", "unitialized_memory_read.gif");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGif(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ for (i = 0; i < gdImageSX(im); i += 16) {
+ for (j = 0; j < gdImageSY(im); j += 16) {
+ if (gdImageGetPixel(im, i, j) >= 2) {
+ col = gdImageGetTrueColorPixel(im, i, j);
+ gdTestAssertMsg(col == 0, "(%d,%d): expected color 0, but got %d\n", i, j, col);
+ }
+ }
+ }
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gif/unitialized_memory_read.gif b/tests/gif/unitialized_memory_read.gif
new file mode 100644
index 0000000..92fbb7f
--- /dev/null
+++ b/tests/gif/unitialized_memory_read.gif
Binary files differ
diff --git a/tests/heif/CMakeLists.txt b/tests/heif/CMakeLists.txt
new file mode 100644
index 0000000..4a41528
--- /dev/null
+++ b/tests/heif/CMakeLists.txt
@@ -0,0 +1,11 @@
+IF(HEIF_FOUND)
+LIST(APPEND TESTS_FILES
+ avif_ptr_double_free
+ heif_im2im
+ heif_null
+ heif_ptr_double_free
+ heif_read
+)
+ENDIF(HEIF_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/heif/Makemodule.am b/tests/heif/Makemodule.am
new file mode 100644
index 0000000..8ab60c4
--- /dev/null
+++ b/tests/heif/Makemodule.am
@@ -0,0 +1,12 @@
+if HAVE_LIBHEIF
+libgd_test_programs += \
+ heif/avif_ptr_double_free \
+ heif/heif_im2im \
+ heif/heif_null \
+ heif/heif_ptr_double_free \
+ heif/heif_read
+endif
+
+EXTRA_DIST += \
+ heif/CMakeLists.txt \
+ heif/label.heic
diff --git a/tests/heif/avif_ptr_double_free.c b/tests/heif/avif_ptr_double_free.c
new file mode 100644
index 0000000..f294929
--- /dev/null
+++ b/tests/heif/avif_ptr_double_free.c
@@ -0,0 +1,31 @@
+/**
+ * Test that failure to convert to AVIF returns NULL
+ *
+ * We are creating an image, set its width to zero, and pass this image to
+ * `gdImageAvifPtr()` which is supposed to fail, and as such should return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ int size;
+
+ src = gdImageCreateTrueColor(1, 10);
+ gdTestAssert(src != NULL);
+
+ src->sx = 0;
+
+ dst = gdImageHeifPtrEx(src, &size, 100, GD_HEIF_CODEC_AV1, GD_HEIF_CHROMA_444);
+ gdTestAssert(dst == NULL);
+
+ gdImageDestroy(src);
+
+ return gdNumFailures();
+}
diff --git a/tests/heif/heif_im2im.c b/tests/heif/heif_im2im.c
new file mode 100644
index 0000000..01abf02
--- /dev/null
+++ b/tests/heif/heif_im2im.c
@@ -0,0 +1,57 @@
+/**
+ * Check if it's any difference between the original bitmap and a encoded and
+ * decoded `4:4:4` HEIF lossless image.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+#include <libheif/heif.h>
+
+int main()
+{
+ gdImagePtr src, dst;
+ int r, g, b;
+ void *p;
+ int size = 0;
+ CuTestImageResult result = {0, 0};
+
+ if (!gdTestAssertMsg(heif_get_version_number_major() == 1 && heif_get_version_number_minor() >= 9, "changing chroma subsampling is not supported in this libheif version\n"))
+ return 77;
+
+ if (!gdTestAssertMsg(heif_have_decoder_for_format(heif_compression_HEVC) && heif_have_encoder_for_format(heif_compression_HEVC), "HEVC codec support missing from libheif\n"))
+ return 77;
+
+ src = gdImageCreateTrueColor(100, 100);
+ gdTestAssertMsg(src != NULL, "could not create src\n");
+ /* libheif seems to have some rounding issues */
+ r = gdImageColorAllocate(src, 0xFE, 0, 0);
+ g = gdImageColorAllocate(src, 0, 0xFE, 0);
+ b = gdImageColorAllocate(src, 0, 0, 0xFE);
+ gdImageFilledRectangle(src, 0, 0, 99, 99, r);
+ gdImageRectangle(src, 20, 20, 79, 79, g);
+ gdImageEllipse(src, 70, 25, 30, 20, b);
+
+ p = gdImageHeifPtrEx(src, &size, 200, GD_HEIF_CODEC_HEVC, GD_HEIF_CHROMA_444);
+ gdTestAssertMsg(p != NULL, "return value of gdImageHeifPtrEx() is null\n");
+ gdTestAssertMsg(size > 0, "gdImageHeifPtrEx() output size is non-positive\n");
+
+ dst = gdImageCreateFromHeifPtr(size, p);
+ gdTestAssertMsg(dst != NULL, "return value of gdImageCreateFromHeifPtr() is null\n");
+
+ if (gdTestAssertMsg(src != NULL && dst != NULL, "cannot compare with NULL buffer"))
+ gdTestImageDiff(src, dst, NULL, &result);
+ else
+ result.pixels_changed = 0;
+ gdTestAssertMsg(result.pixels_changed == 0, "pixels changed: %d\n", result.pixels_changed);
+
+ if (dst != NULL)
+ gdImageDestroy(dst);
+ if (p != NULL)
+ gdFree(p);
+ if (src != NULL)
+ gdImageDestroy(src);
+
+ return gdNumFailures();
+}
diff --git a/tests/heif/heif_null.c b/tests/heif/heif_null.c
new file mode 100644
index 0000000..0b5eac5
--- /dev/null
+++ b/tests/heif/heif_null.c
@@ -0,0 +1,20 @@
+/**
+ * Simple test case that confirms the failure of using `gdImageCreateFromHeif`
+ * with a NULL pointer.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreateFromHeif(NULL);
+ if (!gdTestAssert(im == NULL))
+ gdImageDestroy(im);
+ gdImageHeif(im, NULL); /* noop safely */
+
+ return gdNumFailures();
+}
diff --git a/tests/heif/heif_ptr_double_free.c b/tests/heif/heif_ptr_double_free.c
new file mode 100644
index 0000000..14f1d25
--- /dev/null
+++ b/tests/heif/heif_ptr_double_free.c
@@ -0,0 +1,31 @@
+/**
+ * Test that failure to convert to HEIF returns NULL
+ *
+ * We are creating an image, set its width to zero, and pass this image to
+ * `gdImageHeifPtr()` which is supposed to fail, and as such should return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ int size;
+
+ src = gdImageCreateTrueColor(1, 10);
+ gdTestAssert(src != NULL);
+
+ src->sx = 0;
+
+ dst = gdImageHeifPtrEx(src, &size, 0, GD_HEIF_CODEC_HEVC, GD_HEIF_CHROMA_444);
+ gdTestAssert(dst == NULL);
+
+ gdImageDestroy(src);
+
+ return gdNumFailures();
+}
diff --git a/tests/heif/heif_read.c b/tests/heif/heif_read.c
new file mode 100644
index 0000000..6ecb5f0
--- /dev/null
+++ b/tests/heif/heif_read.c
@@ -0,0 +1,28 @@
+/**
+ * Simple test case that confirms the failure of using `gdImageCreateFromHeif`
+ * with a NULL pointer.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+#include <libheif/heif.h>
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ if (!gdTestAssertMsg(heif_have_decoder_for_format(heif_compression_HEVC), "HEVC codec support missing from libheif\n"))
+ return 77;
+
+ fp = gdTestFileOpen2("heif", "label.heic");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromHeif(fp);
+ if (gdTestAssert(im != NULL))
+ gdImageDestroy(im);
+ fclose(fp);
+
+ return gdNumFailures();
+}
diff --git a/tests/heif/label.avif b/tests/heif/label.avif
new file mode 100644
index 0000000..2e84362
--- /dev/null
+++ b/tests/heif/label.avif
Binary files differ
diff --git a/tests/heif/label.heic b/tests/heif/label.heic
new file mode 100644
index 0000000..12814f7
--- /dev/null
+++ b/tests/heif/label.heic
Binary files differ
diff --git a/tests/jpeg/.gitignore b/tests/jpeg/.gitignore
index 06cc9b2..13bcf04 100644
--- a/tests/jpeg/.gitignore
+++ b/tests/jpeg/.gitignore
@@ -1,6 +1,8 @@
+/bug00338
/bug_github_18
/jpeg_empty_file
/jpeg_im2im
/jpeg_null
+/jpeg_ptr_double_free
/jpeg_read
/jpeg_resolution
diff --git a/tests/jpeg/CMakeLists.txt b/tests/jpeg/CMakeLists.txt
index e8ecf63..ff188a9 100644
--- a/tests/jpeg/CMakeLists.txt
+++ b/tests/jpeg/CMakeLists.txt
@@ -1,12 +1,19 @@
IF(JPEG_FOUND)
LIST(APPEND TESTS_FILES
+ jpeg_empty_file
jpeg_im2im
+ jpeg_ptr_double_free
jpeg_null
- jpeg_read
- jpeg_empty_file
jpeg_resolution
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
bug_github_18
+ jpeg_read
+ bug00338
)
+ENDIF(PNG_FOUND)
ENDIF(JPEG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/jpeg/Makemodule.am b/tests/jpeg/Makemodule.am
index bc196b1..b778470 100644
--- a/tests/jpeg/Makemodule.am
+++ b/tests/jpeg/Makemodule.am
@@ -1,14 +1,16 @@
if HAVE_LIBJPEG
libgd_test_programs += \
- jpeg/bug_github_18 \
jpeg/jpeg_empty_file \
jpeg/jpeg_im2im \
- jpeg/jpeg_null
+ jpeg/jpeg_null \
+ jpeg/jpeg_ptr_double_free \
+ jpeg/jpeg_resolution
if HAVE_LIBPNG
libgd_test_programs += \
- jpeg/jpeg_read \
- jpeg/jpeg_resolution
+ jpeg/bug_github_18 \
+ jpeg/bug00338 \
+ jpeg/jpeg_read
endif
endif
diff --git a/tests/jpeg/bug00338.c b/tests/jpeg/bug00338.c
new file mode 100644
index 0000000..7874df2
--- /dev/null
+++ b/tests/jpeg/bug00338.c
@@ -0,0 +1,46 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/338>
+ *
+ * We're testing that reading a JPEG image with gdImageCreateFromJpeg()
+ * raises a GD_WARNING for the fatal libjpeg error, but not a GD_ERROR.
+ * We also make sure, that the fatal libjpeg error is actually reported.
+ *
+ * See also ../png/bug00338.c
+ */
+
+#include <string.h>
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdtest.h"
+
+#define MSG "gd-jpeg: JPEG library reports unrecoverable error: %s"
+
+static int error_handler_called = 0;
+
+static void error_handler(int priority, const char *format, va_list args)
+{
+ if (!strcmp(format, MSG)) {
+ gdTestAssertMsg(priority == GD_WARNING, "expected priority %d, but got %d", GD_WARNING, priority);
+ error_handler_called = 1;
+ }
+}
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ gdSetErrorMethod(error_handler);
+
+ im = gdImageCreateTrueColor(10, 10);
+ fp = gdTestTempFp();
+ gdImagePng(im, fp);
+ gdImageDestroy(im);
+
+ im = gdImageCreateFromJpeg(fp);
+ gdTestAssert(im == NULL);
+
+ gdTestAssert(error_handler_called);
+
+ return gdNumFailures();
+}
diff --git a/tests/jpeg/jpeg_ptr_double_free.c b/tests/jpeg/jpeg_ptr_double_free.c
new file mode 100644
index 0000000..df5a510
--- /dev/null
+++ b/tests/jpeg/jpeg_ptr_double_free.c
@@ -0,0 +1,31 @@
+/**
+ * Test that failure to convert to JPEG returns NULL
+ *
+ * We are creating an image, set its width to zero, and pass this image to
+ * `gdImageJpegPtr()` which is supposed to fail, and as such should return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr src, dst;
+ int size;
+
+ src = gdImageCreateTrueColor(1, 10);
+ gdTestAssert(src != NULL);
+
+ src->sx = 0; /* this hack forces gdImageJpegPtr() to fail */
+
+ dst = gdImageJpegPtr(src, &size, 0);
+ gdTestAssert(dst == NULL);
+
+ gdImageDestroy(src);
+
+ return gdNumFailures();
+}
diff --git a/tests/png/.gitignore b/tests/png/.gitignore
index 28eb412..d226591 100644
--- a/tests/png/.gitignore
+++ b/tests/png/.gitignore
@@ -3,6 +3,9 @@
/bug00086
/bug00088
/bug00193
+/bug00338
+/bug00381_1
+/bug00381_2
/png_im2im
/png_null
/png_resolution
diff --git a/tests/png/CMakeLists.txt b/tests/png/CMakeLists.txt
index 228474e..6d618a0 100644
--- a/tests/png/CMakeLists.txt
+++ b/tests/png/CMakeLists.txt
@@ -8,7 +8,15 @@ LIST(APPEND TESTS_FILES
bug00086
bug00088
bug00193
+ bug00338
+ bug00381_1
)
+
+IF(ENABLE_GD_FORMATS)
+LIST(APPEND TESTS_FILES
+ bug00381_2
+)
+ENDIF(ENABLE_GD_FORMATS)
ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/png/Makemodule.am b/tests/png/Makemodule.am
index 01c4803..d28253e 100644
--- a/tests/png/Makemodule.am
+++ b/tests/png/Makemodule.am
@@ -5,9 +5,16 @@ libgd_test_programs += \
png/bug00086 \
png/bug00088 \
png/bug00193 \
+ png/bug00338 \
+ png/bug00381_1 \
png/png_im2im \
png/png_null \
png/png_resolution
+
+if ENABLE_GD_FORMATS
+libgd_test_programs += \
+ png/bug00381_2
+endif
endif
EXTRA_DIST += \
@@ -17,4 +24,5 @@ EXTRA_DIST += \
png/bug00088_1_exp.png \
png/bug00088_2.png \
png/bug00088_2_exp.png \
+ png/bug00381_2.gd \
png/emptyfile
diff --git a/tests/png/bug00338.c b/tests/png/bug00338.c
new file mode 100644
index 0000000..f439d8c
--- /dev/null
+++ b/tests/png/bug00338.c
@@ -0,0 +1,44 @@
+/**
+ * Regression test for <https://github.com/libgd/libgd/issues/338>
+ *
+ * We're testing that writing a PNG image with an unsupported quality
+ * raises a GD_WARNING for the fatal libpng error, but not a GD_ERROR.
+ * We also make sure, that the fatal libpng error is actually reported.
+ *
+ * See also ../jpeg/bug00338.c
+ */
+
+#include <string.h>
+#include "gd.h"
+#include "gd_errors.h"
+#include "gdtest.h"
+
+#define MSG "gd-png: fatal libpng error: %s\n"
+
+static int error_handler_called = 0;
+
+static void error_handler(int priority, const char *format, va_list args)
+{
+ if (!strcmp(format, MSG)) {
+ gdTestAssertMsg(priority == GD_WARNING, "expected priority %d, but got %d", GD_WARNING, priority);
+ error_handler_called = 1;
+ }
+}
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+
+ gdSetErrorMethod(error_handler);
+
+ im = gdImageCreateTrueColor(10, 10);
+ fp = gdTestTempFp();
+ gdImagePngEx(im, fp, 100);
+ gdImageDestroy(im);
+ fclose(fp);
+
+ gdTestAssert(error_handler_called);
+
+ return gdNumFailures();
+}
diff --git a/tests/png/bug00381_1.c b/tests/png/bug00381_1.c
new file mode 100644
index 0000000..d8f375b
--- /dev/null
+++ b/tests/png/bug00381_1.c
@@ -0,0 +1,31 @@
+/**
+ * Test that failure to convert to PNG returns NULL
+ *
+ * We are creating a palette image without allocating any colors in the palette,
+ * and pass this image to `gdImagePngPtr()` which is supposed to fail, and as
+ * such should return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ void *data;
+ int size = 0;
+
+ im = gdImageCreate(100, 100);
+ gdTestAssert(im != NULL);
+
+ data = gdImagePngPtr(im, &size);
+ gdTestAssert(data == NULL);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/png/bug00381_2.c b/tests/png/bug00381_2.c
new file mode 100644
index 0000000..84c7bb1
--- /dev/null
+++ b/tests/png/bug00381_2.c
@@ -0,0 +1,35 @@
+/**
+ * Test that failure to convert to PNG returns NULL
+ *
+ * We are reading a palette image without any colors in the palette, and pass
+ * this image to `gdImagePngPtr()` which is supposed to fail, and as such should
+ * return NULL.
+ *
+ * See also <https://github.com/libgd/libgd/issues/381>
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ void *data;
+ int size = 0;
+
+ fp = gdTestFileOpen2("png", "bug00381_2.gd");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromGd(fp);
+ gdTestAssert(im != NULL);
+ fclose(fp);
+
+ data = gdImagePngPtr(im, &size);
+ gdTestAssert(data == NULL);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/png/bug00381_2.gd b/tests/png/bug00381_2.gd
new file mode 100644
index 0000000..c18480a
--- /dev/null
+++ b/tests/png/bug00381_2.gd
Binary files differ
diff --git a/tests/png/png_resolution.c b/tests/png/png_resolution.c
index aed7545..bfc944d 100644
--- a/tests/png/png_resolution.c
+++ b/tests/png/png_resolution.c
@@ -24,7 +24,7 @@ int main()
gdImageDestroy(im);
return 1;
}
-
+
gdImageDestroy(im);
return 0;
}
diff --git a/tests/source/README.md b/tests/source/README.md
new file mode 100644
index 0000000..fce3ac9
--- /dev/null
+++ b/tests/source/README.md
@@ -0,0 +1,3 @@
+These are tests/lints for the source code itself.
+They aren't included in the default `make check` so they aren't run against
+releases, but we run them against Github PRs in Travis.
diff --git a/tests/source/run.sh b/tests/source/run.sh
new file mode 100755
index 0000000..8d7f9c3
--- /dev/null
+++ b/tests/source/run.sh
@@ -0,0 +1,46 @@
+#!/bin/bash -e
+
+if [[ -z "${top_srcdir}" ]] ; then
+ cd "${0%/*}/../.."
+ top_srcdir="${PWD}"
+fi
+TEST_DIR="${top_srcdir}/tests/source"
+
+cd "${top_srcdir}"
+
+ret=0
+
+# Force a basic environment regardless of how we're configured.
+export GIT_PAGER=cat
+export LC_ALL=C
+
+# List all the non-binary files we know about in the tree.
+read -r -d'\n' -a files < <(
+ git ls-tree -r --name-only HEAD | \
+ grep -Ev '\.(avif|bin|bmp|gd|gd2|gif|heic|jpg|jpeg|png|pic|sgi|tga|tiff|ttf|xbm|xpm)$'
+) || :
+
+banner() {
+ echo
+ echo "### $*"
+}
+
+do_grep() {
+ # Use -a so UTF-8 files don't get flagged as binary & skipped.
+ if git grep -aHnE "$@" "${files[@]}" ; then
+ ret=1
+ fi
+}
+
+# Run some tests.
+
+banner "Check for trailing whitespace."
+do_grep '[[:space:]]+$'
+
+banner "Check for Windows line endings."
+do_grep $'\r$'
+
+banner "Checking trailing lines."
+"${TEST_DIR}"/whitespace.py "${files[@]}"
+
+exit ${ret}
diff --git a/tests/source/whitespace.py b/tests/source/whitespace.py
new file mode 100755
index 0000000..2d979fd
--- /dev/null
+++ b/tests/source/whitespace.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""Helper for checking whitespace.
+
+These operations aren't easy to do in pure shell.
+"""
+
+from __future__ import print_function
+
+import sys
+
+
+def check(path):
+ with open(path, 'rb') as fp:
+ # Skip 0 byte files.
+ first_byte = fp.read(1)
+ if not first_byte:
+ return 0
+
+ # Check for leading blank lines.
+ if b'\n' == first_byte:
+ print('%s: trim leading blank lines' % (path,), file=sys.stderr)
+ return 1
+
+ # Check for missing trailing new line.
+ fp.seek(-1, 2)
+ if b'\n' != fp.read(1):
+ print('%s: missing trailing new line' % (path,), file=sys.stderr)
+ return 1
+ elif fp.tell() == 1:
+ print('%s: dummy file' % (path,), file=sys.stderr)
+ return 1
+
+ # Check for trailing blank lines.
+ fp.seek(-2, 2)
+ if b'\n\n' == fp.read(2):
+ print('%s: trim trailing blank lines' % (path,), file=sys.stderr)
+ return 1
+
+ return 0
+
+
+def main(argv):
+ ret = 0
+ for path in argv:
+ ret |= check(path)
+ return ret
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/tests/tga/.gitignore b/tests/tga/.gitignore
index 7a659b1..cf0556b 100644
--- a/tests/tga/.gitignore
+++ b/tests/tga/.gitignore
@@ -3,5 +3,6 @@
/bug00247a
/bug00248
/bug00248a
+/heap_overflow
/tga_null
/tga_read
diff --git a/tests/tga/CMakeLists.txt b/tests/tga/CMakeLists.txt
index 789fb14..ca191a6 100644
--- a/tests/tga/CMakeLists.txt
+++ b/tests/tga/CMakeLists.txt
@@ -1,11 +1,17 @@
LIST(APPEND TESTS_FILES
- tga_null
bug00084
bug00247
bug00247a
bug00248
bug00248a
+ heap_overflow
+ tga_null
+)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
tga_read
)
+ENDIF(PNG_FOUND)
ADD_GD_TESTS()
diff --git a/tests/tga/Makemodule.am b/tests/tga/Makemodule.am
index a1e6af6..091e3be 100644
--- a/tests/tga/Makemodule.am
+++ b/tests/tga/Makemodule.am
@@ -4,8 +4,13 @@ libgd_test_programs += \
tga/bug00247a \
tga/bug00248 \
tga/bug00248a \
- tga/tga_null \
+ tga/heap_overflow \
+ tga/tga_null
+
+if HAVE_LIBPNG
+libgd_test_programs += \
tga/tga_read
+endif
EXTRA_DIST += \
tga/CMakeLists.txt \
@@ -14,6 +19,8 @@ EXTRA_DIST += \
tga/bug00247a.tga \
tga/bug00248.tga \
tga/bug00248a.tga \
+ tga/heap_overflow_1.tga \
+ tga/heap_overflow_2.tga \
tga/tga_read_rgb.png \
tga/tga_read_rgb.tga \
tga/tga_read_rgb_rle.tga
diff --git a/tests/tga/heap_overflow.c b/tests/tga/heap_overflow.c
new file mode 100644
index 0000000..ddd4b63
--- /dev/null
+++ b/tests/tga/heap_overflow.c
@@ -0,0 +1,59 @@
+/**
+ * Test that crafted TGA files don't trigger OOB reads.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void check_file(char *basename);
+static size_t read_test_file(char **buffer, char *basename);
+
+
+int main()
+{
+ check_file("heap_overflow_1.tga");
+ check_file("heap_overflow_2.tga");
+
+ return gdNumFailures();
+}
+
+
+static void check_file(char *basename)
+{
+ gdImagePtr im;
+ char *buffer;
+ size_t size;
+
+ size = read_test_file(&buffer, basename);
+ im = gdImageCreateFromTgaPtr(size, (void *) buffer);
+ gdTestAssert(im == NULL);
+ free(buffer);
+}
+
+
+static size_t read_test_file(char **buffer, char *basename)
+{
+ char *filename;
+ FILE *fp;
+ size_t exp_size, act_size;
+
+ filename = gdTestFilePath2("tga", basename);
+ fp = fopen(filename, "rb");
+ gdTestAssert(fp != NULL);
+
+ fseek(fp, 0, SEEK_END);
+ exp_size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ *buffer = malloc(exp_size);
+ gdTestAssert(*buffer != NULL);
+ act_size = fread(*buffer, sizeof(**buffer), exp_size, fp);
+ gdTestAssert(act_size == exp_size);
+
+ fclose(fp);
+ free(filename);
+
+ return act_size;
+}
diff --git a/tests/tga/heap_overflow.tga b/tests/tga/heap_overflow.tga
new file mode 100644
index 0000000..e9bc0ec
--- /dev/null
+++ b/tests/tga/heap_overflow.tga
Binary files differ
diff --git a/tests/tga/heap_overflow_1.tga b/tests/tga/heap_overflow_1.tga
new file mode 100644
index 0000000..e9bc0ec
--- /dev/null
+++ b/tests/tga/heap_overflow_1.tga
Binary files differ
diff --git a/tests/tga/heap_overflow_2.tga b/tests/tga/heap_overflow_2.tga
new file mode 100644
index 0000000..2b681f2
--- /dev/null
+++ b/tests/tga/heap_overflow_2.tga
Binary files differ
diff --git a/tests/tiff/.gitignore b/tests/tiff/.gitignore
index 7cf35ee..5f4eb55 100644
--- a/tests/tiff/.gitignore
+++ b/tests/tiff/.gitignore
@@ -1,3 +1,5 @@
/tiff_dpi
/tiff_im2im
/tiff_null
+/tiff_invalid_read
+/tiff_read_bw
diff --git a/tests/tiff/CMakeLists.txt b/tests/tiff/CMakeLists.txt
index 03f630c..b1ce8a8 100644
--- a/tests/tiff/CMakeLists.txt
+++ b/tests/tiff/CMakeLists.txt
@@ -1,9 +1,16 @@
IF(TIFF_FOUND)
LIST(APPEND TESTS_FILES
tiff_im2im
+ tiff_invalid_read
tiff_null
tiff_dpi
)
+
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ tiff_read_bw
+)
+ENDIF(PNG_FOUND)
ENDIF(TIFF_FOUND)
ADD_GD_TESTS()
diff --git a/tests/tiff/Makemodule.am b/tests/tiff/Makemodule.am
index fd39699..a136439 100644
--- a/tests/tiff/Makemodule.am
+++ b/tests/tiff/Makemodule.am
@@ -2,8 +2,19 @@ if HAVE_LIBTIFF
libgd_test_programs += \
tiff/tiff_dpi \
tiff/tiff_im2im \
+ tiff/tiff_invalid_read \
tiff/tiff_null
+
+if HAVE_LIBPNG
+libgd_test_programs += \
+ tiff/tiff_read_bw
+endif
endif
EXTRA_DIST += \
- tiff/CMakeLists.txt
+ tiff/CMakeLists.txt \
+ tiff/tiff_invalid_read_1.tiff \
+ tiff/tiff_invalid_read_2.tiff \
+ tiff/tiff_invalid_read_3.tiff \
+ tiff/tiff_read_bw.tiff \
+ tiff/tiff_read_bw_exp.png
diff --git a/tests/tiff/tiff_dpi.c b/tests/tiff/tiff_dpi.c
index d639839..7362646 100644
--- a/tests/tiff/tiff_dpi.c
+++ b/tests/tiff/tiff_dpi.c
@@ -1,16 +1,9 @@
-/*
+/*
* Test that reading and writing image resolution values to/from TIFF files
* works correctly. Set the image resolution, write the file, read the file
* back and test that the image resolution comes back correct.
*/
-#ifdef _WIN32
-#include <stdio.h>
-int main()
-{
- printf("skip");
- return 0;
-}
-#else
+
#include "gd.h"
#include "gdtest.h"
@@ -30,7 +23,7 @@ int main()
r = gdImageColorAllocate(src, 0xFF, 0, 0);
gdImageFilledRectangle(src, 0, 0, 99, 99, r);
- // gd default DPI is 96; libtiff default is 72.
+ // gd default DPI is 96; libtiff default is 72.
// Use something else so we know the value has been
// written / read correctly.
res_x = 100;
@@ -81,4 +74,3 @@ door0:
gdImageDestroy(src);
return status;
}
-#endif
diff --git a/tests/tiff/tiff_im2im.c b/tests/tiff/tiff_im2im.c
index b6b240e..7b6c4cb 100644
--- a/tests/tiff/tiff_im2im.c
+++ b/tests/tiff/tiff_im2im.c
@@ -1,11 +1,3 @@
-#ifdef _WIN32
-#include <stdio.h>
-int main()
-{
- printf("skip");
- return 0;
-}
-#else
#include "gd.h"
#include "gdtest.h"
@@ -70,4 +62,3 @@ door0:
gdImageDestroy(src);
return status;
}
-#endif \ No newline at end of file
diff --git a/tests/tiff/tiff_invalid_read.c b/tests/tiff/tiff_invalid_read.c
new file mode 100644
index 0000000..bed5389
--- /dev/null
+++ b/tests/tiff/tiff_invalid_read.c
@@ -0,0 +1,61 @@
+/*
+We're testing that reading corrupt TIFF files doesn't cause any memory issues,
+and that the operation gracefully fails (i.e. gdImageCreateFromTiffPtr() returns
+NULL).
+*/
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void check_file(char *basename);
+static size_t read_test_file(char **buffer, char *basename);
+
+
+int main()
+{
+ check_file("tiff_invalid_read_1.tiff");
+ check_file("tiff_invalid_read_2.tiff");
+ check_file("tiff_invalid_read_3.tiff");
+
+ return gdNumFailures();
+}
+
+
+static void check_file(char *basename)
+{
+ gdImagePtr im;
+ char *buffer;
+ size_t size;
+
+ size = read_test_file(&buffer, basename);
+ im = gdImageCreateFromTiffPtr(size, (void *) buffer);
+ gdTestAssert(im == NULL);
+ free(buffer);
+}
+
+
+static size_t read_test_file(char **buffer, char *basename)
+{
+ char *filename;
+ FILE *fp;
+ size_t exp_size, act_size;
+
+ filename = gdTestFilePath2("tiff", basename);
+ fp = fopen(filename, "rb");
+ gdTestAssert(fp != NULL);
+
+ fseek(fp, 0, SEEK_END);
+ exp_size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ *buffer = malloc(exp_size);
+ gdTestAssert(*buffer != NULL);
+ act_size = fread(*buffer, sizeof(**buffer), exp_size, fp);
+ gdTestAssert(act_size == exp_size);
+
+ fclose(fp);
+ free(filename);
+
+ return act_size;
+}
diff --git a/tests/tiff/tiff_invalid_read_1.tiff b/tests/tiff/tiff_invalid_read_1.tiff
new file mode 100644
index 0000000..b3877e3
--- /dev/null
+++ b/tests/tiff/tiff_invalid_read_1.tiff
Binary files differ
diff --git a/tests/tiff/tiff_invalid_read_2.tiff b/tests/tiff/tiff_invalid_read_2.tiff
new file mode 100644
index 0000000..f9967e5
--- /dev/null
+++ b/tests/tiff/tiff_invalid_read_2.tiff
Binary files differ
diff --git a/tests/tiff/tiff_invalid_read_3.tiff b/tests/tiff/tiff_invalid_read_3.tiff
new file mode 100644
index 0000000..67ca2a7
--- /dev/null
+++ b/tests/tiff/tiff_invalid_read_3.tiff
Binary files differ
diff --git a/tests/tiff/tiff_null.c b/tests/tiff/tiff_null.c
index 19b64f7..ccaade7 100644
--- a/tests/tiff/tiff_null.c
+++ b/tests/tiff/tiff_null.c
@@ -1,11 +1,3 @@
-#ifdef _WIN32
-#include <stdio.h>
-int main()
-{
- printf("skip");
- return 0;
-}
-#else
#include "gd.h"
int main()
@@ -20,4 +12,3 @@ int main()
gdImageTiff(im, NULL); /* noop safely */
return 0;
}
-#endif \ No newline at end of file
diff --git a/tests/tiff/tiff_read_bw.c b/tests/tiff/tiff_read_bw.c
new file mode 100644
index 0000000..93b646d
--- /dev/null
+++ b/tests/tiff/tiff_read_bw.c
@@ -0,0 +1,25 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("tiff", "tiff_read_bw.tiff");
+ gdTestAssert(fp != NULL);
+ im = gdImageCreateFromTiff(fp);
+ fclose(fp);
+
+ gdTestAssert(im != NULL);
+ gdTestAssert(!gdImageTrueColor(im));
+
+ path = gdTestFilePath2("tiff", "tiff_read_bw_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/tiff/tiff_read_bw.tiff b/tests/tiff/tiff_read_bw.tiff
new file mode 100644
index 0000000..69813f0
--- /dev/null
+++ b/tests/tiff/tiff_read_bw.tiff
Binary files differ
diff --git a/tests/tiff/tiff_read_bw_exp.png b/tests/tiff/tiff_read_bw_exp.png
new file mode 100644
index 0000000..b43daf9
--- /dev/null
+++ b/tests/tiff/tiff_read_bw_exp.png
Binary files differ
diff --git a/tests/wbmp/CMakeLists.txt b/tests/wbmp/CMakeLists.txt
index 787227c..4ec45bd 100644
--- a/tests/wbmp/CMakeLists.txt
+++ b/tests/wbmp/CMakeLists.txt
@@ -1,6 +1,6 @@
LIST(APPEND TESTS_FILES
- wbmp_im2im
wbmp_null
+ wbmp_im2im
)
ADD_GD_TESTS()
diff --git a/tests/wbmp/Makemodule.am b/tests/wbmp/Makemodule.am
index fb12272..37f09e1 100644
--- a/tests/wbmp/Makemodule.am
+++ b/tests/wbmp/Makemodule.am
@@ -1,10 +1,6 @@
libgd_test_programs += \
- wbmp/wbmp_null
-
-if HAVE_LIBPNG
-libgd_test_programs += \
+ wbmp/wbmp_null \
wbmp/wbmp_im2im
-endif
EXTRA_DIST += \
wbmp/CMakeLists.txt
diff --git a/tests/webp/.gitignore b/tests/webp/.gitignore
index f5816bc..b167630 100644
--- a/tests/webp/.gitignore
+++ b/tests/webp/.gitignore
@@ -1,2 +1,4 @@
/bug00111
+/bug_double_free
/webp_ll_im2im
+/gdImageWebpEx
diff --git a/tests/webp/CMakeLists.txt b/tests/webp/CMakeLists.txt
index e114f80..6a4431c 100644
--- a/tests/webp/CMakeLists.txt
+++ b/tests/webp/CMakeLists.txt
@@ -1,8 +1,14 @@
IF(WEBP_FOUND)
LIST(APPEND TESTS_FILES
bug00111
+ gdImageWebpEx
webp_ll_im2im
)
+IF(JPEG_FOUND)
+LIST(APPEND TESTS_FILES
+ bug_double_free
+)
+ENDIF(JPEG_FOUND)
ENDIF(WEBP_FOUND)
ADD_GD_TESTS()
diff --git a/tests/webp/Makemodule.am b/tests/webp/Makemodule.am
index 741e8f2..c6c9528 100644
--- a/tests/webp/Makemodule.am
+++ b/tests/webp/Makemodule.am
@@ -1,8 +1,14 @@
if HAVE_LIBWEBP
libgd_test_programs += \
webp/bug00111 \
+ webp/gdImageWebpEx \
webp/webp_ll_im2im
+if HAVE_LIBJPEG
+libgd_test_programs += \
+ webp/bug_double_free
+endif
endif
EXTRA_DIST += \
- webp/CMakeLists.txt
+ webp/CMakeLists.txt \
+ webp/bug_double_free.jpg
diff --git a/tests/webp/bug_double_free.c b/tests/webp/bug_double_free.c
new file mode 100644
index 0000000..43eecec
--- /dev/null
+++ b/tests/webp/bug_double_free.c
@@ -0,0 +1,29 @@
+/**
+ * Test that a too large image doesn't trigger an double-free when written
+ * to memory.
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im1, im2;
+ FILE *fp;
+ int size;
+
+ fp = gdTestFileOpen2("webp", "bug_double_free.jpg");
+ gdTestAssert(fp != NULL);
+ im1 = gdImageCreateFromJpeg(fp);
+ gdTestAssert(im1 != NULL);
+ fclose(fp);
+
+ im2 = gdImageWebpPtr(im1, &size);
+ gdTestAssert(im2 == NULL);
+
+ gdImageDestroy(im1);
+
+ return gdNumFailures();
+}
diff --git a/tests/webp/bug_double_free.jpg b/tests/webp/bug_double_free.jpg
new file mode 100644
index 0000000..9b792fb
--- /dev/null
+++ b/tests/webp/bug_double_free.jpg
Binary files differ
diff --git a/tests/webp/gdImageWebpEx.c b/tests/webp/gdImageWebpEx.c
new file mode 100644
index 0000000..43011de
--- /dev/null
+++ b/tests/webp/gdImageWebpEx.c
@@ -0,0 +1,26 @@
+/**
+ * Basic testcase for gdImageWebpEx()
+ **/
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp1;
+ int size = 1;
+
+ im = gdImageCreateTrueColor(20, 20);
+ if (!im) {
+ return 1;
+ }
+
+ fp1 = gdTestTempFp();
+ gdImageWebpEx(im, fp1, 8);
+ gdImageWebpPtrEx(im, &size, 9);
+
+ fclose(fp1);
+
+ gdImageDestroy(im);
+ return 0;
+}
diff --git a/tests/xbm/.gitignore b/tests/xbm/.gitignore
index 313d503..8a2565a 100644
--- a/tests/xbm/.gitignore
+++ b/tests/xbm/.gitignore
@@ -1 +1,4 @@
+/github_bug_109
/github_bug_170
+/github_bug_501
+/x10_basic_read
diff --git a/tests/xbm/CMakeLists.txt b/tests/xbm/CMakeLists.txt
index 183cf5e..2447fd5 100644
--- a/tests/xbm/CMakeLists.txt
+++ b/tests/xbm/CMakeLists.txt
@@ -1,5 +1,13 @@
LIST(APPEND TESTS_FILES
+ github_bug_501
github_bug_170
)
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ github_bug_109
+ x10_basic_read
+)
+ENDIF(PNG_FOUND)
+
ADD_GD_TESTS()
diff --git a/tests/xbm/Makemodule.am b/tests/xbm/Makemodule.am
index ba1eabd..4d14916 100644
--- a/tests/xbm/Makemodule.am
+++ b/tests/xbm/Makemodule.am
@@ -1,5 +1,17 @@
libgd_test_programs += \
+ xbm/github_bug_501 \
xbm/github_bug_170
+if HAVE_LIBPNG
+libgd_test_programs += \
+ xbm/github_bug_109 \
+ xbm/x10_basic_read
+endif
+
EXTRA_DIST += \
- xbm/CMakeLists.txt
+ xbm/CMakeLists.txt \
+ xbm/github_bug_109.xbm \
+ xbm/github_bug_109_exp.png \
+ xbm/x10_basic_read.xbm \
+ xbm/x10_basic_read_exp.png \
+ xbm/github_bug_501.xbm
diff --git a/tests/xbm/github_bug_109.c b/tests/xbm/github_bug_109.c
new file mode 100644
index 0000000..70b7937
--- /dev/null
+++ b/tests/xbm/github_bug_109.c
@@ -0,0 +1,33 @@
+/**
+ * Test reading of XBM images with a width that is not a multiple of 8
+ *
+ * We're reading such an XBM image, and check that we got what we've expected,
+ * instead of an error message.
+ *
+ * See also <https://github.com/libgd/libgd/issues/109>.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("xbm", "github_bug_109.xbm");
+ im = gdImageCreateFromXbm(fp);
+ fclose(fp);
+ gdTestAssert(im != NULL);
+ gdTestAssert(gdImageGetTrueColorPixel(im, 0, 0) == 0);
+ gdTestAssert(gdImageGetTrueColorPixel(im, 0, 1) == 0xffffff);
+
+ path = gdTestFilePath2("xbm", "github_bug_109_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/xbm/github_bug_109.xbm b/tests/xbm/github_bug_109.xbm
new file mode 100644
index 0000000..f427d86
--- /dev/null
+++ b/tests/xbm/github_bug_109.xbm
@@ -0,0 +1,5 @@
+#define test_width 10
+#define test_height 10
+static unsigned char test_bits[] = {
+ 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00,
+ 0xFF, 0x03, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00};
diff --git a/tests/xbm/github_bug_109_exp.png b/tests/xbm/github_bug_109_exp.png
new file mode 100644
index 0000000..505b545
--- /dev/null
+++ b/tests/xbm/github_bug_109_exp.png
Binary files differ
diff --git a/tests/xbm/github_bug_170.c b/tests/xbm/github_bug_170.c
index 3900da7..8134fb8 100644
--- a/tests/xbm/github_bug_170.c
+++ b/tests/xbm/github_bug_170.c
@@ -47,4 +47,4 @@ int main()
gdTestAssertMsg(length == 250, "expected to write 250 bytes; %jd bytes written", (intmax_t) length);
return gdNumFailures();
}
-#endif \ No newline at end of file
+#endif
diff --git a/tests/xbm/github_bug_501.c b/tests/xbm/github_bug_501.c
new file mode 100644
index 0000000..5d8bfd7
--- /dev/null
+++ b/tests/xbm/github_bug_501.c
@@ -0,0 +1,39 @@
+/*
+ Test reading an invalid XBM image.
+
+ The pixels of the XBM image are invalid hex which makes the uninitialezed
+ variable be encoded into the output image i.e. information disclosure.
+ The image is 8*2.
+
+ See also <https://github.com/libgd/libgd/issues/501>.
+*/
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+
+ gdImagePtr im;
+ FILE *fp;
+
+ fp = gdTestFileOpen2("xbm", "github_bug_501.xbm");
+ im = gdImageCreateFromXbm(fp);
+
+ gdTestAssert(im == NULL);
+
+ if (im) {
+ gdTestErrorMsg("Info Disclosed\n");
+ int i;
+ for (i = 0; i < 8; i++) {
+ printf("Pixel(%d, 0) %0x\n", i, gdImageGetPixel(im, i, 0));
+ }
+ for (i = 0; i < 8; i++) {
+ printf("Pixel(%d, 1) %0x\n", i, gdImageGetPixel(im, i, 1));
+ }
+ gdImageDestroy(im);
+ }
+
+ fclose(fp);
+ return gdNumFailures();
+}
diff --git a/tests/xbm/github_bug_501.xbm b/tests/xbm/github_bug_501.xbm
new file mode 100644
index 0000000..41ad301
--- /dev/null
+++ b/tests/xbm/github_bug_501.xbm
@@ -0,0 +1,4 @@
+#define width 8
+#define height 2
+static char bits[] ={
+xzzxzz
diff --git a/tests/xbm/x10_basic_read.c b/tests/xbm/x10_basic_read.c
new file mode 100644
index 0000000..f7c505e
--- /dev/null
+++ b/tests/xbm/x10_basic_read.c
@@ -0,0 +1,30 @@
+/**
+ * Test reading of an X10 style XBM file
+ *
+ * X10 style XBMs define a short[] instead of a char[] array. We're testing
+ * that such files are read correctly, particularly regarding the line padding,
+ * which is 2 bytes instead of 1, and the endianess.
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("xbm", "x10_basic_read.xbm");
+ im = gdImageCreateFromXbm(fp);
+ fclose(fp);
+ gdTestAssert(im != NULL);
+
+ path = gdTestFilePath2("xbm", "x10_basic_read_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/xbm/x10_basic_read.xbm b/tests/xbm/x10_basic_read.xbm
new file mode 100644
index 0000000..d8ca2cd
--- /dev/null
+++ b/tests/xbm/x10_basic_read.xbm
@@ -0,0 +1,4 @@
+#define x10_basic_read_width 17
+#define x10_basic_read_height 3
+static unsigned short x10_basic_read_bits[] = {
+ 0xFFFF, 0x0001, 0x0000, 0x0000, 0xFFFF, 0x0001};
diff --git a/tests/xbm/x10_basic_read_exp.png b/tests/xbm/x10_basic_read_exp.png
new file mode 100644
index 0000000..fbcdf0c
--- /dev/null
+++ b/tests/xbm/x10_basic_read_exp.png
Binary files differ
diff --git a/travis/lib.sh b/travis/lib.sh
index 687ed41..7fd0e2c 100644
--- a/travis/lib.sh
+++ b/travis/lib.sh
@@ -13,7 +13,7 @@ if [[ -n ${TRAVIS_OS_NAME} ]] ; then
normal=$(tput sgr0)
else
whitebg=
- blackbg=
+ blackfg=
normal=
fi
v() {
@@ -34,5 +34,5 @@ v() {
ncpus=$(getconf _NPROCESSORS_ONLN)
m() {
- v make -j${ncpus} "$@"
+ v make -j"${ncpus}" "$@"
}
diff --git a/travis/main.sh b/travis/main.sh
index 2169a78..9965c40 100755
--- a/travis/main.sh
+++ b/travis/main.sh
@@ -4,6 +4,7 @@
# TODO: Add support for building/testing w/ASAN/etc... enabled.
+# shellcheck source=travis/lib.sh
. "${0%/*}"/lib.sh
# We have to do this by hand rather than use the coverity addon because of
@@ -29,23 +30,6 @@ coverity_scan() {
curl -s "https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh" | bash || :
}
-update_os() {
- # Note: Linux deps are maintained in .travis.yml.
- case ${TRAVIS_OS_NAME} in
- osx)
- v --fold="brew_update" brew update
- # We have to hack this package due to bugs in Travis CI. See:
- # https://github.com/libgd/libgd/issues/266
- # https://github.com/Homebrew/legacy-homebrew/issues/43874
- v --fold="brew_clean" brew uninstall libtool
- # These packages are already installed in Travis, so omit them or brew fails.
- # autoconf automake pkg-config cmake libpng jpeg libtiff
- v --fold="brew_install" brew install \
- gettext freetype fontconfig libtool webp xz
- ;;
- esac
-}
-
check_git_status() {
local status
@@ -71,6 +55,7 @@ build_autotools() {
--prefix=/usr/local \
--libdir=/usr/local/lib \
--enable-werror \
+ --enable-gd-formats \
--with-fontconfig \
--with-freetype \
--with-jpeg \
@@ -93,37 +78,45 @@ build_autotools() {
m distclean
}
-build_cmake() {
- local args=(
- -DBUILD_SHARED_LIBS=1
- -DBUILD_STATIC_LIBS=1
- -DBUILD_TEST=1
- -DCMAKE_INSTALL_PREFIX=/usr/local
- -DCMAKE_INSTALL_LIBDIR=/usr/local/lib
- -DENABLE_FONTCONFIG=1
- -DENABLE_FREETYPE=1
- -DENABLE_JPEG=1
- -DENABLE_PNG=1
- -DENABLE_TIFF=1
- -DENABLE_WEBP=1
- -DENABLE_XPM=1
- -DENABLE_ZLIB=1
- )
+# TODO: When we switch to Ubuntu 21+ (Hirsute), we can reenable libavif coverage,
+# as Ubuntu 21+ supports libavif 0.8.2+.
+# "-DENABLE_AVIF=1"
+cmake_args=(
+ "-DBUILD_SHARED_LIBS=1"
+ "-DBUILD_STATIC_LIBS=1"
+ "-DBUILD_TEST=1"
+ "-DCMAKE_INSTALL_PREFIX=/usr/local"
+ "-DCMAKE_INSTALL_LIBDIR=/usr/local/lib"
+ "-DENABLE_GD_FORMATS=1"
+ "-DENABLE_FONTCONFIG=1"
+ "-DENABLE_FREETYPE=1"
+ "-DENABLE_JPEG=1"
+ "-DENABLE_PNG=1"
+ "-DENABLE_TIFF=1"
+ "-DENABLE_WEBP=1"
+)
+
+# libxpm-dev is unavaible in brew repo
+# Once it gets available, please modify this code block.
+if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
+ cmake_args+=("-DENABLE_XPM=1")
+fi
+build_cmake() {
# First try building out of tree.
mkdir build
cd build
- v cmake "${args[@]}" ..
+ v cmake "${cmake_args[@]}" ..
m
- v ctest -j${ncpus}
+ v ctest -j"${ncpus}"
cd ..
rm -rf build
# Then build in-tree.
- v cmake "${args[@]}" .
+ v cmake "${cmake_args[@]}" .
m
- v ctest -j${ncpus}
- m install DESTDIR=$PWD/install-cmake
+ v ctest -j"${ncpus}"
+ m install DESTDIR="${PWD}/install-cmake"
}
compare_builds() {
@@ -133,11 +126,43 @@ compare_builds() {
diff -ur install-autotools install-cmake || true
}
+source_tests() {
+ # Run lint/source tests against the codebase.
+ # Reset any files in case the build modified them.
+ git checkout -f
+ ./tests/source/run.sh
+}
+
+build_codecov() {
+ # Only genenrate code coverage report in Linux with gcc
+ if [[ ${TRAVIS_OS_NAME} != "linux" || ${TRAVIS_COMPILER} != "gcc" ]]; then
+ exit 0
+ fi
+
+ # Delete these two files so that we can build out of tree again
+ rm -f CMakeCache.txt
+ rm -rf CMakeFiles
+
+ # Delete test run time limit. Or tests/gdimageline/gdimgaeline_bug5 will run timeout
+ sed -i '/TIMEOUT/d' tests/CMakeLists.txt
+
+ # Build out of tree
+ mkdir build
+ cd build
+ export CFLAGS="-fprofile-arcs -ftest-coverage"
+ v cmake "${cmake_args[@]}" ..
+ m
+ v ctest -j"${ncpus}"
+ bash <(curl -s https://codecov.io/bash)
+}
+
main() {
- update_os
build_autotools
build_cmake
compare_builds
v --fold="coverity_scan" coverity_scan
+ # Run the source tests last.
+ v --fold="source_tests" source_tests
+ build_codecov
}
main "$@"
diff --git a/windows/Makefile.vc b/windows/Makefile.vc
index a3f1a7b..dbec163 100644
--- a/windows/Makefile.vc
+++ b/windows/Makefile.vc
@@ -94,17 +94,35 @@ LIB_OBJS= \
$(LIBGD_OBJ_DIR)\gd_version.obj \
$(LIBGD_OBJ_DIR)\gd_crop.obj \
$(LIBGD_OBJ_DIR)\gd_color_map.obj \
+ $(LIBGD_OBJ_DIR)\gd_heif.obj \
+ $(LIBGD_OBJ_DIR)\gd_avif.obj \
$(LIBGD_OBJ_DIR)\gd_webp.obj
LIBS=kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib Gdi32.Lib
-LIBS_GD=libjpeg_a.lib freetype_a.lib libpng_a.lib libiconv_a.lib zlib_a.lib libwebp_a.lib libxpm_a.lib
-
-INCLUDES=/Isrc /I$(WITH_DEVEL)\include -I$(WITH_DEVEL)\include\libpng16 -I$(WITH_DEVEL)\include\freetype /Itests /Itests\gdtest -I$(WITH_DEVEL)\include\
+LIBS_GD=libjpeg_a.lib freetype_a.lib libpng_a.lib libiconv_a.lib zlib_a.lib libheif_a.lib libwebp_a.lib libxpm_a.lib libavif_a.lib libtiff.lib
+
+PROG_EXES= \
+ $(LIBGD_OBJ_DIR)\gdcmpgif.exe \
+ $(LIBGD_OBJ_DIR)\gdtopng.exe \
+ $(LIBGD_OBJ_DIR)\pngtogd.exe \
+ $(LIBGD_OBJ_DIR)\gdparttopng.exe \
+ $(LIBGD_OBJ_DIR)\gd2topng.exe \
+ $(LIBGD_OBJ_DIR)\pngtogd2.exe \
+ $(LIBGD_OBJ_DIR)\annotate.exe \
+ $(LIBGD_OBJ_DIR)\gd2copypal.exe \
+ $(LIBGD_OBJ_DIR)\gd2togif.exe \
+ $(LIBGD_OBJ_DIR)\giftogd2.exe
+PROG_OBJS=$(PROG_EXES:exe=obj)
+
+INCLUDES=/Isrc /I$(WITH_DEVEL)\include -I$(WITH_DEVEL)\include\libpng16 -I$(WITH_DEVEL)\include\freetype -I$(WITH_DEVEL)\include\freetype2 /Itests /Itests\gdtest -I$(WITH_DEVEL)\include\
LDFLAGS=/nologo /nodefaultlib:libcmt /libpath:$(WITH_DEVEL)\lib /MACHINE:$(PLATFORM)
+!IF $(DEBUG)
+LDFLAGS=$(LDFLAGS) /DEBUG
+!ENDIF
!IF $(DEBUG)
-CFLAGS=/nologo /Qvec-report:1 /MD /TC /Zi /Debug
+CFLAGS=/nologo /Qvec-report:1 /MD /TC /Zi
!ELSE
CFLAGS=/nologo /O2 /Qvec-report:1 /MD /TC
!ENDIF
@@ -114,15 +132,21 @@ CFLAGS= $(CFLAGS) \
/D_WIN32=1\
/DMSWIN32=1\
/DBGDWIN32=1\
+ /DENABLE_GD_FORMATS=1\
/DHAVE_FT2BUILD_H=1\
/DHAVE_GD_H=1\
/DHAVE_ICONV_H=1\
+ /DHAVE_LIBAVIF=1\
/DHAVE_LIBFREETYPE=1\
/DHAVE_LIBJPEG=1\
/DHAVE_LIBPNG=1\
- /DHAVE_LIBWEBP=1\
+ /DHAVE_LIBWEBP=1\
+ /DHAVE_LIBHEIF=1\
+ /DHAVE_LIBAVIF=1\
/DHAVE_LIBZ=1\
- /DHAVE_LIBXPM=1\
+ /DHAVE_LIBXPM=1\
+ /DHAVE_LIBTIFF=1\
+ /DHAVE_CONFIG_H\
$(INCLUDES)
TEST_CFLAGS=$(CFLAGS)
@@ -146,7 +170,8 @@ TEST_OBJS=$(TEST_OBJS:exe=obj)
# pseudotargets
build_libs: make_dirs $(TARGETDLL) $(TARGETLIB)
-all: build_libs build_tests
+build_progs: build_libs $(PROG_OBJS) $(PROG_EXES)
+all: build_libs build_tests build_progs
check: all run_tests
clean:
@@ -165,6 +190,9 @@ make_dirs:
@echo #ifndef HAVE_ICONV_H>> $(GD_CONFIG_H)
@echo #define HAVE_ICONV_H>> $(GD_CONFIG_H)
@echo #endif>> $(GD_CONFIG_H)
+ @echo #ifndef HAVE_LIBAVIF>> $(GD_CONFIG_H)
+ @echo #define HAVE_LIBAVIF>> $(GD_CONFIG_H)
+ @echo #endif>> $(GD_CONFIG_H)
@echo #ifndef HAVE_LIBFREETYPE>> $(GD_CONFIG_H)
@echo #define HAVE_LIBFREETYPE>> $(GD_CONFIG_H)
@echo #endif>> $(GD_CONFIG_H)
@@ -177,6 +205,12 @@ make_dirs:
@echo #ifndef HAVE_LIBWEBP>> $(GD_CONFIG_H)
@echo #define HAVE_LIBWEBP>> $(GD_CONFIG_H)
@echo #endif>> $(GD_CONFIG_H)
+ @echo #ifndef HAVE_LIBHEIF>> $(GD_CONFIG_H)
+ @echo #define HAVE_LIBHEIF>> $(GD_CONFIG_H)
+ @echo #endif>> $(GD_CONFIG_H)
+ @echo #ifndef HAVE_LIBAVIF>> $(GD_CONFIG_H)
+ @echo #define HAVE_LIBAVIF>> $(GD_CONFIG_H)
+ @echo #endif>> $(GD_CONFIG_H)
@echo #ifndef HAVE_LIBZ>> $(GD_CONFIG_H)
@echo #define HAVE_LIBZ>> $(GD_CONFIG_H)
@echo #endif>> $(GD_CONFIG_H)
@@ -188,7 +222,12 @@ make_dirs:
@echo #endif>> $(GD_CONFIG_H)
@echo #ifndef HAVE_SYS_STAT_H>> $(GD_CONFIG_H)
@echo #define HAVE_SYS_STAT_H>> $(GD_CONFIG_H)
- @echo #endif>> $(GD_CONFIG_H)
+ @echo #endif>> $(GD_CONFIG_H)
+ @echo #ifndef HAVE_LIBTIFF>> $(GD_CONFIG_H)
+ @echo #define HAVE_LIBTIFF>> $(GD_CONFIG_H)
+ @echo #endif>> $(GD_CONFIG_H)
+ @echo #define ssize_t SSIZE_T>> $(GD_CONFIG_H)
+ @echo #define SSIZE_MAX MAXSSIZE_T>> $(GD_CONFIG_H)
run_tests: pretest
@cd $(TDR)
@@ -208,29 +247,28 @@ $(TARGETLIB): $(LIB_OBJS)
@$(LB) /OUT:$@ $(LIB_OBJS) $(LDFLAGS)
{$(LIBGD_SRC_DIR)\}.c{$(LIBGD_OBJ_DIR)\}.obj:
- $(CC) $(CFLAGS) /Fo"$@" $<
+ $(CC) $(CFLAGS) /c /Fo"$@" /Fd$*.pdb $<
all: $(LIBGD_OBJ_DIR) $(LIBGD_BIN_DIR) $(LIB_OBJS) $(STATICLIB)
-.SUFFIXES: .c .obj .res
-
-{$(LIBGD_SRC_DIR)\}.c{$(LIBGD_OBJ_DIR)\}.obj:
- $(CC) $(CFLAGS) /Fo"$@" $<
+.SUFFIXES: .c .obj .res .exe
-{src\}.c{$(SDR)}.obj::
- $(CC) $(CFLAGS) /c $< /Fo$(SDR)
-
# tests
!INCLUDE $(TEST_MK)
build_tests: $(TEST_LIST) $(SDR)readdir.obj $(SDR)gdtest.obj $(TEST_EXES)
$(SDR)gdtest.obj: $(TARGETDLL) tests\gdtest\gdtest.c
- @$(CC) $(CFLAGS) /DGDTEST_TOP_DIR=\"$(MAKEDIR:\=\\)\\tests\" /c tests\gdtest\gdtest.c /Fo$(SDR)gdtest.obj
+ @$(CC) $(CFLAGS) /DGDTEST_TOP_DIR=\"$(MAKEDIR:\=\\)\\tests\" /c tests\gdtest\gdtest.c /Fd$(SDR)gdtest.pdb /Fo$(SDR)gdtest.obj
$(SDR)readdir.obj: $(TARGETDLL) tests\gdtest\readdir.c
- @$(CC) $(CFLAGS) /c tests\gdtest\readdir.c /Fo$(SDR)readdir.obj
+ @$(CC) $(CFLAGS) /c tests\gdtest\readdir.c /Fd$(SDR)readdir.pdb /Fo$(SDR)readdir.obj
pretest: $(TARGETDLL)
if not exist $(TDR) mkdir $(TDR)
- copy $(TARGETDLL) $(TDR)$(GD_DLL) \ No newline at end of file
+ copy $(TARGETDLL) $(TDR)$(GD_DLL)
+
+# programs
+
+{$(LIBGD_OBJ_DIR)}.obj{$(LIBGD_OBJ_DIR)}.exe:
+ $(LD) $(LDFLAGS) $** $(BUILD_DIR)\libgd.lib /out:$@
diff --git a/windows/Makefiletest.vc b/windows/Makefiletest.vc
index 827a4e7..6e5d598 100644
--- a/windows/Makefiletest.vc
+++ b/windows/Makefiletest.vc
@@ -1,5 +1,10 @@
TESTS=bmp\bmp_im2im \
bmp\bmp_null \
+avif\avif_ptr_double_free \
+avif\avif_im2im \
+avif\avif_null \
+avif\compare_avif_to_png \
+avif\bad_input \
freetype\bug00132 \
gd\gd_im2im \
gd\gd_null \
diff --git a/windows/gentest.bat b/windows/gentest.bat
index 9c2cbeb..756e0f9 100644
--- a/windows/gentest.bat
+++ b/windows/gentest.bat
@@ -15,21 +15,21 @@ copy NUL !TESTMK! > nul
copy NUL !TESTLIST! > nul
for /D %%d in (!testsdir!/*) do (
- if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
+ if NOT "%%d"=="fontconfig" if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
echo TEST_EXES=!builddir!\tests\%%d_%%~nf.exe ^$^(TEST_EXES^) >> !TESTMK!
)
)
for /D %%d in (!testsdir!/*) do (
- if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
- echo !builddir!\%%d_%%~nf.obj: !testsdir!\%%d\%%f; ^$^(CC^) ^$^(TEST_CFLAGS^) /c ^$** /Fo:$@ >> !TESTMK!
+ if NOT "%%d"=="fontconfig" if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
+ echo !builddir!\%%d_%%~nf.obj: !testsdir!\%%d\%%f; ^$^(CC^) ^$^(TEST_CFLAGS^) /c ^$** /Fd$*.pdb /Fo:$@ >> !TESTMK!
)
)
for /D %%d in (!testsdir!/*) do (
- if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
+ if NOT "%%d"=="fontconfig" if NOT "%%d"=="gdtest" for %%f in (!testsdir!/%%d/*.c) do (
echo !builddir!\tests\%%d_%%~nf.exe: !builddir!\%%d_%%~nf.obj; !LD! !LDFLAGS! $** /out:$@ >> !TESTMK!
echo %%d_%%~nf.exe >> !TESTLIST!
)
)
-ENDLOCAL \ No newline at end of file
+ENDLOCAL
diff --git a/windows/libgd.rc b/windows/libgd.rc
index dfe6ff0..803b346 100755
--- a/windows/libgd.rc
+++ b/windows/libgd.rc
@@ -1,5 +1,4 @@
/* This is a template RC file.
- * $Id$
* Do not edit with MSVC */
#ifdef APSTUDIO_INVOKED
# error dont edit with MSVC
@@ -38,7 +37,7 @@ BEGIN
VALUE "FileDescription", "LIBGD" "\0"
VALUE "FileVersion", GD_VERSION_STRING "\0"
VALUE "InternalName", "bgd.dll" "\0"
- VALUE "LegalCopyright", "Copyright © 1997-2008 Thomas Boutell, Pierre A. Joye and contributors, see COPYING\0"
+ VALUE "LegalCopyright", "Copyright © 1997-2008 Thomas Boutell, Pierre A. Joye and contributors, see COPYING\0"
VALUE "LegalTrademarks", "Thomas Boutell, Pierre A. Joye and contributors\0"
VALUE "OriginalFilename", "bgd.dll" "\0"
VALUE "PrivateBuild", "\0"
@@ -56,4 +55,3 @@ END
#ifdef MC_INCLUDE
#include MC_INCLUDE
#endif
-
diff --git a/windows/msys/Makefile b/windows/msys/Makefile
index 3b1ced4..d183ac2 100644
--- a/windows/msys/Makefile
+++ b/windows/msys/Makefile
@@ -1,4 +1,3 @@
-
# Simple makefile for building and testing libgd under MSYS/MinGW on
# Windows
@@ -7,9 +6,10 @@
LIBVER=3.0.1
# Misc. config flags.
-CDEFS=-DHAVE_ERRNO_H -DHAVE_ICONV -DHAVE_ICONV_H \
--DHAVE_ICONV_T_DEF -DHAVE_INTTYPES_H -DHAVE_LIMITS_H -DHAVE_STDDEF_H \
--DHAVE_STDINT_H -DHAVE_STDLIB_H -DHAVE_VISIBILITY -DICONV_CONST
+CDEFS=-DHAVE_ICONV -DHAVE_ICONV_H \
+-DHAVE_ICONV_T_DEF -DHAVE_INTTYPES_H \
+-DHAVE_STDINT_H -DHAVE_VISIBILITY -DICONV_CONST \
+-DENABLE_GD_FORMATS=1
# GnuWin32 libs should all be installed in one place.
GNUDIR=/c/tools/GnuWin32
@@ -97,8 +97,9 @@ gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c \
gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c \
gdfonts.c gdfontt.c gdft.c gdhelpers.c gdkanji.c gdtables.c gdxpm.c \
wbmp.c gd_filter.c gd_nnquant.c gd_rotate.c gd_matrix.c \
-gd_interpolation.c gd_crop.c gd_webp.c gd_tiff.c gd_tga.c \
-gd_bmp.c gd_xbm.c gd_color_match.c gd_version.c gd_filename.c
+gd_interpolation.c gd_crop.c gd_webp.c gd_heif.c gd_tiff.c gd_tga.c \
+gd_bmp.c gd_xbm.c gd_color_match.c gd_version.c gd_filename.c \
+gd_avif.c
OBJ=$(SRC:.c=.o)
@@ -131,13 +132,3 @@ $(TARGET): $(OBJ)
$(OBJ) $(LIBS)
include deps.mk
-
-
-
-
-
-
-
-
-
-
diff --git a/windows/msys/README.MSYS.md b/windows/msys/README.MSYS.md
index 601802d..e45adc6 100644
--- a/windows/msys/README.MSYS.md
+++ b/windows/msys/README.MSYS.md
@@ -1,4 +1,3 @@
-
# MSYS Fallback Makefile
This is a simple, straightforward Makefile for building LibGD with
@@ -49,6 +48,14 @@ use one of the other build systems (or add them yourself.)
DLLs; it sweeps up all of the DLLs in the directories pointed to
by *_DLLDIR Makefile variables.
+ Before type "make dist", please make sure you have installed
+ zip command in msys. Or you can try:
+ * If you use msys, you can install msys-zip(lib, docs, lic)
+ in MinGW Installation Manager/all package.
+ * If you use msys2, you can install msys/zip by pacman and running:
+
+ pacman -S msys/zip
+
Alternately, you can copy the lib (in src/) to wherever it needs
to go.
@@ -59,7 +66,3 @@ use one of the other build systems (or add them yourself.)
worth.
* LibFontconfig: I couldn't find Windows binaries for it anywhere
reputable.
-
-
-
-
diff --git a/windows/msys/run_tests.sh b/windows/msys/run_tests.sh
index 22de13c..b959afe 100755
--- a/windows/msys/run_tests.sh
+++ b/windows/msys/run_tests.sh
@@ -5,22 +5,27 @@ set -e
# Parameters
DLLPATH_EXTRA=$1 # Path to supporting DLLs
CFLAGS_EXTRA=$2 # Extra C flags
-
+
LOG=run_tests.log
-CFLAGS="-g -Igdtest/ -I. -I../src/ -D_WIN32 $CFLAGS_EXTRA"
-LDFLAGS='-L../src -llibgd'
+CFLAGS=( -g -Igdtest/ -I. -I../src/ -D_WIN32 -DHAVE_SYS_STAT_H )
+if [[ -n "${CFLAGS_EXTRA}" ]]; then
+ # shellcheck disable=SC2206
+ CFLAGS+=( ${CFLAGS_EXTRA} )
+fi
+LDFLAGS=( -L../src -llibgd )
DLLPATH=../src:$DLLPATH_EXTRA
-function run_gcc {
- if msg=`gcc $* 2>&1`; then
- true
- else
- echo "COMMAND: gcc $*" >> $LOG
- echo $msg >> $LOG
- false
- fi
+run_gcc() {
+ local msg
+ if msg=$(gcc "$@" 2>&1); then
+ true
+ else
+ echo "COMMAND: gcc $*" >> "${LOG}"
+ echo "${msg}" >> "${LOG}"
+ false
+ fi
}
# Switch to the working directory
@@ -29,39 +34,36 @@ cd ../../tests
# Initial setup
echo "Setting up..."
-[ -f $LOG ] && rm -f $LOG
+rm -f "${LOG}"
[ -f test_config.h ] || echo '#define GDTEST_TOP_DIR "."' > test_config.h
-run_gcc -c $CFLAGS gdtest/gdtest.c
+run_gcc -c "${CFLAGS[@]}" gdtest/gdtest.c
echo "Running tests:"
count=0
failures=0
compile_failures=0
-for test in `find . -name \*.c | grep -v '^./gdtest'`; do
- count=`expr $count + 1`
+for test in $(find . -name '*.c' | grep -vE '^./(fontconfig|gdtest|gdhelpers|xpm)'); do
+ : $(( count += 1 ))
+
+ exe=${test%.c}.exe
+ if run_gcc -o "${exe}" "${CFLAGS[@]}" "${LDFLAGS[@]}" "${test}" gdtest.o; then
+ true
+ else
+ echo "COMPILE_FAIL: $test"
+ : $(( compile_failures += 1 ))
+ continue
+ fi
- exe=${test%.c}.exe
- if run_gcc -o $exe $CFLAGS $LDFLAGS $test gdtest.o; then
- true;
- else
- echo "COMPILE_FAIL: $test"
- compile_failures=`expr $compile_failures + 1`
- continue
- fi
-
- echo "Running $exe:" >> $LOG
- if $exe 2>&1 >> $LOG; then
- echo "PASS: $test"
- else
- failures=`expr $failures + 1`
- echo "FAIL: $test"
- fi
- echo >> $LOG
+ echo "Running $exe:" >> "${LOG}"
+ if $exe >> "${LOG}" 2>&1; then
+ echo "PASS: $test"
+ else
+ : $(( failures += 1 ))
+ echo "FAIL: $test"
+ fi
+ echo >> "${LOG}"
done
echo "$failures failures and $compile_failures compile failures out of $count tests."
-echo "Error messages in $LOG"
-
-
-
+echo "Error messages in ${LOG}"
diff --git a/windows/readme.md b/windows/readme.md
index 8753b70..dce5202 100644
--- a/windows/readme.md
+++ b/windows/readme.md
@@ -1,11 +1,53 @@
-# Building on Windows with Visual Studio 2013
+# Building on Windows with Visual Studio 2015
-Open the VS2013 x64 Native Tools Command Prompt. 2012 will *not* work.
-Change to the gd-libgd folder.
-git clone https://github.com/imazen/gd-win-dependencies into the folder.
-Run
-nmake /f windows/Makefile.vc all
-nmake /f windows/Makefile.vc check
+* Get the required dependencies from
+ http://windows.php.net/downloads/php-sdk/deps/vc14/ and
+ http://windows.php.net/downloads/pecl/deps/, respectively. Choose the x86 or
+ x64 packages depending on your needs.
-Before rebuilding, run:
-nmake /f windows/Makefile.vc clean \ No newline at end of file
+ * freetype
+ * libiconv
+ * libjpeg
+ * libpng
+ * libtiff
+ * libwebp
+ * libxpm
+ * zlib
+
+* Unpack all dependency packages into the same folder.
+
+* Open the VS2015 x86 or x64 Native Tools Command Prompt.
+
+* Set the environment variable `WITH_DEVEL` to the path where you have unpacked
+ the dependencies. `WITH_DEVEL` defaults to `..\deps`.
+
+* If you want a debug build, do
+````
+set DEBUG=1
+````
+
+* `cd` into the libgd source folder.
+
+* To build the libraries, do:
+```
+nmake /f windows\Makefile.vc
+```
+
+* To build and run the tests, do:
+````
+nmake /f windows\Makefile.vc check
+````
+
+* To build the executable programs, do:
+````
+nmake /f windows\Makefile.vc build_progs
+````
+
+* After a successful build, you find the libraries and test executables in
+ `..\gdbuild`. You can change the build folder by setting the environment
+ variable `WITH_BUILD` to the desired path.
+
+* Before rebuilding, you may have to run:
+```
+nmake /f windows\Makefile.vc clean
+```
diff --git a/windows/run_tests.bat b/windows/run_tests.bat
index 9e9c5e4..097d3b9 100644
--- a/windows/run_tests.bat
+++ b/windows/run_tests.bat
@@ -4,25 +4,40 @@ if [%PLATFORM%]==[] set PLATFORM=x86
if [%PREFERREDTOOLARCHITECTURE%]==[x64] set PLATFORM=x64
set PLATFORM=%PLATFORM:X=x%
+set total=0
+set total_passed=0
+set total_failed=0
+set total_missing=0
+
for /f %%T in (testlist.txt) do (
set test=%%T
set output=test: !test!....................................................................
set target=%%~nT.exe
if not exist !target! SET result=NotFound
call !target! && (SET result=Passed) || (SET result=Failed)
-
+
rem > last_test.out 2> last_test.err
rem set /p testerr=<last_test.err
rem set /p testout=<last_test.out
-
+
echo !output:~0,70!!result!
-
+
rem if defined testerr echo error: !testerr!
rem if defined testout echo msg: !testout!
-
+
+ set /a total=total+1
+ if "!result!"=="Passed" set /a total_passed=total_passed+1
+ if "!result!"=="Failed" set /a total_failed=total_failed+1
+ if "!result!"=="NotFound" set /a total_missing=total_missing+1
+
if defined APPVEYOR (
appveyor AddTest "!test! %PLATFORM%" -Outcome !result! -Framework Custom -Filename %%~nT.exe -Duration 0
)
)
+echo.
+echo Tests: !total!
+echo Passed: !total_passed!
+echo Failed: !total_failed!
+echo Missing: !total_missing!
-exit /b 0 \ No newline at end of file
+exit /b 0