Merge branch 'master' into webp-lossless

# Conflicts:
#	tests/webp/.gitignore
#	tests/webp/CMakeLists.txt
#	tests/webp/Makemodule.am
master
Adam Silverstein 2021-05-05 09:30:02 -06:00
commit a2b3ba08ef
481 changed files with 8503 additions and 6206 deletions

21
.github/workflows/shellcheck.yml vendored Normal file
View File

@ -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

2
.gitignore vendored
View File

@ -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

View File

@ -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

164
CHANGELOG.md Normal file
View File

@ -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

View File

@ -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}")
MACRO(GV VER VAR)
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.sh ${VER}
OUTPUT_VARIABLE ${VAR}
)
ENDMACRO(GV)
SET(GD_VERSION_INT "20101")
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}")
SET(CMAKE_REQUIRED_INCLUDES "/usr/include" "/usr/local/include")
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/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 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 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)

46
CODE_OF_CONDUCT.md Normal file
View File

@ -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/

View File

@ -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.

View File

@ -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ý

View File

@ -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.

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -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()

View File

@ -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"

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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
)
)

View File

@ -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)

View File

@ -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 )

View File

@ -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}")

View File

@ -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()

View File

@ -1,14 +1,14 @@
# - Find JPEG
# Find the native JPEG 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.
# - Find the native RAQM includes and library
#
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
# This module defines
# 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)

View File

@ -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)

View File

@ -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

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2006 Alan W. Irwin
*
* This file is part of PLplot.

View File

@ -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)

View File

@ -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)

View File

@ -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

13
config/gdlib.pc.cmake Normal file
View File

@ -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

View File

@ -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

42
config/getlib.sh Executable file
View File

@ -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

View File

@ -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

48
config/getver.sh Executable file
View File

@ -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

View File

@ -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
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)))
AC_SUBST(GDLIB_MAJOR)
AC_SUBST(GDLIB_MINOR)
AC_SUBST(GDLIB_REVISION)
AC_SUBST(GDLIB_EXTRA)
AC_SUBST(GDLIB_VERSION)
GDLIB_LT_CURRENT=gd_LT_CURRENT
GDLIB_LT_REVISION=gd_LT_REVISION
GDLIB_LT_AGE=gd_LT_AGE
# 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
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
])

View File

@ -367,4 +367,3 @@ operates.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -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)

View File

@ -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 .

View File

@ -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 を優先するようになります。

View File

@ -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:

View File

@ -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.

View File

@ -55,4 +55,3 @@ sub unslurp {
or die "Error writing file '$filename'\n";
close ($fh);
}

View File

@ -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. */

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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);

55
examples/avif2jpeg.c Normal file
View File

@ -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;
}

View File

@ -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));

View File

@ -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;
}

View File

@ -1,4 +1,3 @@
/* $Id$ */
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>

View File

@ -49,4 +49,4 @@ int main(void)
fclose(out);
return 0;
}
}

57
examples/jpeg2avif.c Normal file
View File

@ -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;
}

98
examples/jpeg2avifex.c Normal file
View File

@ -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);
}

View File

@ -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;
}

58
examples/png2avif.c Normal file
View File

@ -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;
}

View File

@ -56,4 +56,4 @@ int main (int argc, char *argv[]) {
gdImageDestroy(out);
return 0;
}
}

View File

@ -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);
}

View File

@ -1,4 +1,3 @@
/* $Id$ */
/*
* You can fetch a set of samples TIFF images here:
* ftp://ftp.remotesensing.org/pub/libtiff/

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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], [

View File

@ -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?])])

View File

@ -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)

View File

@ -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 ",";
}
}

View File

@ -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 "";
}

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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")

View File

@ -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.

View File

@ -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
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 entities.h gd_color_map.h gd_errors.h gdpp.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)

View File

@ -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 */
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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 */

View File

@ -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>
</body></html>

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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 */

172
src/gd.h
View File

@ -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 */

View File

@ -1,4 +1,3 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -43,4 +43,3 @@ int main(int argc, char **argv)
return 0;
}

View File

@ -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);

688
src/gd_avif.c Normal file
View File

@ -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 */

View File

@ -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;
}
@ -141,6 +145,11 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
compression - whether to apply RLE or not.
*/
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;
@ -148,6 +157,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
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 */

View File

@ -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);

View File

@ -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];

View File

@ -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;
}

View File

@ -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*/

Some files were not shown because too many files have changed in this diff Show More