summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/src
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-04-10 03:40:48 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-04-10 03:40:48 +0000
commit503c0227622254c0ae3209a1fa72bcb68bb450bc (patch)
tree48df20533f300f819504c15af33cdc03fc386a93 /Build/source/libs/gd/libgd-src/src
parenta9d86b73ecf95b83666e16c4d90e348c4958a63b (diff)
libgd 2.3.0
git-svn-id: svn://tug.org/texlive/trunk@54636 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src')
-rw-r--r--Build/source/libs/gd/libgd-src/src/CMakeLists.txt42
-rw-r--r--Build/source/libs/gd/libgd-src/src/COPYING28
-rw-r--r--Build/source/libs/gd/libgd-src/src/Makefile.am17
-rw-r--r--Build/source/libs/gd/libgd-src/src/annotate.c46
-rw-r--r--Build/source/libs/gd/libgd-src/src/bdftogd15
-rw-r--r--Build/source/libs/gd/libgd-src/src/bmp.h11
-rw-r--r--Build/source/libs/gd/libgd-src/src/circletexttest.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/config.h.cmake21
-rw-r--r--Build/source/libs/gd/libgd-src/src/config.hin15
-rw-r--r--Build/source/libs/gd/libgd-src/src/entities.html26
-rw-r--r--Build/source/libs/gd/libgd-src/src/fontconfigtest.c4
-rw-r--r--Build/source/libs/gd/libgd-src/src/fontsizetest.c13
-rw-r--r--Build/source/libs/gd/libgd-src/src/fontwheeltest.c6
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd.c103
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd.h94
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd2copypal.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd2togif.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd2topng.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_bmp.c57
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_color_match.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_crop.c51
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_filename.c21
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_filter.c14
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_gd.c76
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_gd2.c45
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_gif_in.c24
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_gif_out.c54
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_intern.h4
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_interpolation.c139
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_io.c4
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_io.h22
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_io_dp.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_io_stream.cxx15
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_io_stream.h5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_jpeg.c91
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_matrix.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_nnquant.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_nnquant.h3
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_png.c67
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_tga.c3
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_tiff.c48
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_topal.c17
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_transform.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_wbmp.c23
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_webp.c58
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_xbm.c8
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdcache.c15
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdcache.h4
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdcmpgif.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gddemo.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfontg.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfontl.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfontmb.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfontt.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdft.c272
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfx.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdfx.h11
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdhelpers.c2
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdhelpers.h10
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdkanji.c24
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdparttopng.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdpp.cxx85
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdpp.h22
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdtables.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdtest.c10
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdtestft.c14
-rw-r--r--Build/source/libs/gd/libgd-src/src/gdtopng.c5
-rw-r--r--Build/source/libs/gd/libgd-src/src/getopt.c129
-rw-r--r--Build/source/libs/gd/libgd-src/src/gifanimtest.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/giftogd2.c1
-rw-r--r--Build/source/libs/gd/libgd-src/src/jisx0208.h8
-rw-r--r--Build/source/libs/gd/libgd-src/src/msinttypes/inttypes.h18
-rw-r--r--Build/source/libs/gd/libgd-src/src/msinttypes/stdint.h18
-rw-r--r--Build/source/libs/gd/libgd-src/src/pngtogd.c4
-rw-r--r--Build/source/libs/gd/libgd-src/src/pngtogd2.c6
-rw-r--r--Build/source/libs/gd/libgd-src/src/snprintf.c25
-rw-r--r--Build/source/libs/gd/libgd-src/src/testac.c9
-rw-r--r--Build/source/libs/gd/libgd-src/src/testtr.c14
-rw-r--r--Build/source/libs/gd/libgd-src/src/wbmp.c3
-rw-r--r--Build/source/libs/gd/libgd-src/src/wbmp.h12
-rw-r--r--Build/source/libs/gd/libgd-src/src/webpng.c6
81 files changed, 1307 insertions, 761 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/CMakeLists.txt b/Build/source/libs/gd/libgd-src/src/CMakeLists.txt
index 08fd6991bbe..629e0fc745e 100644
--- a/Build/source/libs/gd/libgd-src/src/CMakeLists.txt
+++ b/Build/source/libs/gd/libgd-src/src/CMakeLists.txt
@@ -1,4 +1,3 @@
-
SET (LIBGD_SRC_FILES
bmp.h
gd.c
@@ -69,17 +68,27 @@ 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)
+ if(MSVC_VERSION LESS 1900)
+ set(LIBGD_SRC_FILES ${LIBGD_SRC_FILES}
+ snprintf.c
+ )
+ endif(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 +101,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 +134,7 @@ SET(LIBGD_DEP_LIBS
${XPM_LIBRARIES}
${FONTCONFIG_LIBRARY}
${WEBP_LIBRARIES}
+ ${RAQM_LIBRARIES}
)
if (BUILD_SHARED_LIBS)
target_link_libraries(${GD_LIB} ${LIBGD_DEP_LIBS})
@@ -132,7 +152,7 @@ if (PNG_FOUND)
endif()
endif()
-if (FREETYPE_FOUND)
+if (FREETYPE_FOUND AND JPEG_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} annotate)
endif()
@@ -147,6 +167,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})
@@ -177,3 +200,6 @@ install(FILES
gdfx.h
gdpp.h
DESTINATION include)
+
+CONFIGURE_FILE(../config/gdlib.pc.cmake gdlib.pc @ONLY)
+INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/gdlib.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
diff --git a/Build/source/libs/gd/libgd-src/src/COPYING b/Build/source/libs/gd/libgd-src/src/COPYING
index 90ef1c867ef..a1e4c78485c 100644
--- a/Build/source/libs/gd/libgd-src/src/COPYING
+++ b/Build/source/libs/gd/libgd-src/src/COPYING
@@ -1,25 +1,24 @@
-
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.
+ P41-RR02188 by the National Institutes of Health.
Portions copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 by
- Boutell.Com, Inc.
+ 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.
+ Roelofs.
- Portions relating to gdttf.c copyright 1999, 2000, 2001, 2002 John
+ 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 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).
+ 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,
@@ -35,19 +34,18 @@
provided that this notice is present in user-accessible supporting
documentation.
- This does not affect your ownership of the derived work itself, and
+ 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
+ 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
+ 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
+ particular purpose, with respect to this code and accompanying
documentation.
Although their code does not appear in gd, the authors wish to thank
David Koblas, David Rowley, and Hutchison Avenue Software Corporation
for their prior contributions.
-
diff --git a/Build/source/libs/gd/libgd-src/src/Makefile.am b/Build/source/libs/gd/libgd-src/src/Makefile.am
index 93e8838c366..377acc078d0 100644
--- a/Build/source/libs/gd/libgd-src/src/Makefile.am
+++ b/Build/source/libs/gd/libgd-src/src/Makefile.am
@@ -23,7 +23,9 @@ check_PROGRAMS += fontconfigtest
endif
if HAVE_LIBFREETYPE
+if HAVE_LIBJPEG
bin_PROGRAMS += annotate
+endif
check_PROGRAMS += gdtestft testtr
endif
@@ -37,7 +39,19 @@ 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 \
+ snprintf.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
@@ -114,4 +128,3 @@ libgd_la_LDFLAGS = -version-info $(GDLIB_LT_CURRENT):$(GDLIB_LT_REVISION):$(GDLI
libgd_la_LIBADD = $(LTLIBICONV)
LDADD = libgd.la $(LIBICONV)
-
diff --git a/Build/source/libs/gd/libgd-src/src/annotate.c b/Build/source/libs/gd/libgd-src/src/annotate.c
index 00aaf496bbd..35724b0658a 100644
--- a/Build/source/libs/gd/libgd-src/src/annotate.c
+++ b/Build/source/libs/gd/libgd-src/src/annotate.c
@@ -16,38 +16,28 @@ enum { left, center, right };
int main(int argc, char *argv[])
{
-#ifndef HAVE_LIBFREETYPE
- (void)argc;
- (void)argv;
-
- /* 2.0.12 */
- fprintf(stderr, "annotate is not useful without freetype.\n"
- "Install freetype, then './configure; make clean; make install'\n"
- "the gd library again.\n"
- );
- return 1;
-#else
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
- char s[1024];
+ char *s;
+ size_t len;
int bounds[8];
int lines = 1;
int color = gdTrueColor(0, 0, 0);
- char font[1024];
+ char *font;
int size = 12;
int align = left;
int x = 0, y = 0;
char *fontError;
- strcpy(font, "times");
+ font = strdup("times");
if(argc != 3) {
fprintf(stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
fprintf(stderr, "Standard input should consist of\n");
fprintf(stderr, "lines in the following formats:\n");
fprintf(stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
- fprintf(stderr, "font fontname (max name length 1024)\n");
+ fprintf(stderr, "font fontname\n");
fprintf(stderr, "size pointsize\n");
fprintf(stderr, "align (left|right|center)\n");
fprintf(stderr, "move x y\n");
@@ -70,12 +60,7 @@ int main(int argc, char *argv[])
exit(2);
}
-#ifdef HAVE_LIBJPEG
im = gdImageCreateFromJpeg(in);
-#else
- fprintf(stderr, "No JPEG library support available.\n");
- exit(1);
-#endif
fclose(in);
@@ -84,7 +69,9 @@ int main(int argc, char *argv[])
exit(3);
}
- while(fgets(s, sizeof(s), stdin)) {
+ s = NULL;
+ len = 0;
+ while (getline(&s, &len, stdin) != -1) {
char *st;
char *text;
@@ -99,12 +86,12 @@ int main(int argc, char *argv[])
if(!st) {
goto badLine;
} else {
- const unsigned int font_len = strlen(st);
- if (font_len >= 1024) {
- fprintf(stderr, "Font maximum length is 1024, %d given\n", font_len);
+ free(font);
+ font = strdup(st);
+ if (font == NULL) {
+ perror("Font failed");
goto badLine;
}
- strncpy(font, st, font_len);
}
} else if(!strcmp(st, "align")) {
char *st = strtok(0, " \t\r\n");
@@ -178,7 +165,7 @@ int main(int argc, char *argv[])
fontError = gdImageStringFT(im, 0, color, font, size, 0, rx, y, text);
if(fontError) {
- fprintf(stderr, "font error at line %d: %s\n", lines, fontError);
+ fprintf(stderr, "Font error at line %d: %s\n", lines, fontError);
exit(7);
}
@@ -194,19 +181,16 @@ badLine:
fprintf(stderr, "Bad syntax, line %d\n", lines);
exit(4);
}
+ free(font);
+ free(s);
out = fopen(iout, "wb");
if(!out) {
fprintf(stderr, "Cannot create %s\n", iout);
exit(5);
}
-#ifdef HAVE_LIBJPEG
gdImageJpeg(im, out, 95);
-#else
- fprintf(stderr, "No JPEG library support available.\n");
-#endif
gdImageDestroy(im);
fclose(out);
return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/Build/source/libs/gd/libgd-src/src/bdftogd b/Build/source/libs/gd/libgd-src/src/bdftogd
index 66ffcc9ae88..a9500039301 100644
--- a/Build/source/libs/gd/libgd-src/src/bdftogd
+++ b/Build/source/libs/gd/libgd-src/src/bdftogd
@@ -46,18 +46,18 @@ while (<>)
my ($tag, $value) = split / /, $_, 2;
die "Font is not fixed width\n"
if $tag eq 'SPACING' and not $value =~ /[CM]/i;
-
+
$currentchar = $value if $tag eq 'ENCODING';
$minchar = $currentchar if not defined $minchar
or $currentchar < $minchar;
$maxchar = $currentchar if not defined $maxchar
or $currentchar > $maxchar;
-
+
if ($tag eq 'ENDCHAR')
{
$gobitmap = 0;
my $bottom = $globaltop - $bottom[$currentchar];
-
+
if ($bottom > 0)
{ $data[$currentchar] = substr $data[$currentchar], 0, length($data[$currentchar]) - $bottom * $width; }
@@ -80,7 +80,7 @@ while (<>)
{ $fontdef = $value; }
if ($tag eq 'COPYRIGHT' and not defined $copyright)
{ $copyright = $value; }
-
+
if ($tag eq 'BBX')
{
my ($tag, $wid, $hei, $left, $bottom) = split / /;
@@ -100,7 +100,7 @@ while (<>)
$bits = substr $bits, 0, $width;
$data[$currentchar] .= $bits;
}
-
+
if ($tag eq 'BITMAP')
{
$gobitmap = 1;
@@ -150,7 +150,7 @@ for (my $i = $minchar; $i <= $maxchar; $i++)
{
$data[$i] = '' unless defined $data[$i];
$data[$i] = '0' x ($width * $height - length $data[$i]) . $data[$i];
-
+
print FILEC "/* Char $i */\n";
for my $line (0 .. $height - 1)
{ print FILEC join ',', split(//, substr($data[$i], $line * $width, $width)), "\n"; }
@@ -158,7 +158,7 @@ for (my $i = $minchar; $i <= $maxchar; $i++)
print FILEC "\n";
next;
-
+
for my $line (0 .. $height - 1)
{ print substr($data[$i], $line * $width, $width), "\n"; }
}
@@ -202,4 +202,3 @@ extern gdFontPtr $gdname;
EOF
1;
-
diff --git a/Build/source/libs/gd/libgd-src/src/bmp.h b/Build/source/libs/gd/libgd-src/src/bmp.h
index cecde0383f5..5644fab982d 100644
--- a/Build/source/libs/gd/libgd-src/src/bmp.h
+++ b/Build/source/libs/gd/libgd-src/src/bmp.h
@@ -1,4 +1,6 @@
-/* $Id$ */
+#ifndef BMP_H
+#define BMP_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -19,9 +21,6 @@ extern "C" {
----------------------------------------------------------------------------
*/
-#ifndef BMP_H
-#define BMP_H 1
-
#define BMP_PALETTE_3 1
#define BMP_PALETTE_4 2
@@ -105,8 +104,8 @@ extern "C" {
} bmp_info_t;
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/Build/source/libs/gd/libgd-src/src/circletexttest.c b/Build/source/libs/gd/libgd-src/src/circletexttest.c
index 0f20a34d9b8..53451517acb 100644
--- a/Build/source/libs/gd/libgd-src/src/circletexttest.c
+++ b/Build/source/libs/gd/libgd-src/src/circletexttest.c
@@ -8,10 +8,6 @@
int main(void)
{
/* 2.0.22: can't depend on PNG either */
-#ifndef HAVE_LIBPNG
- fprintf(stderr, "Requires PNG support, gd was compiled without it\n");
- return 0;
-#else
char *error;
#ifdef HAVE_LIBJPEG
FILE *in = 0;
@@ -64,6 +60,5 @@ int main(void)
gdImagePng(im, out);
fclose(out);
gdImageDestroy(im);
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/Build/source/libs/gd/libgd-src/src/config.h.cmake b/Build/source/libs/gd/libgd-src/src/config.h.cmake
index 26cf22ff549..54f3a528907 100644
--- a/Build/source/libs/gd/libgd-src/src/config.h.cmake
+++ b/Build/source/libs/gd/libgd-src/src/config.h.cmake
@@ -3,15 +3,15 @@
/* Define is you are building for Win32 API */
#cmakedefine BGDWIN32
+/* Whether to support gd image formats */
+#define ENABLE_GD_FORMATS @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
@@ -45,6 +45,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 +60,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,21 +72,12 @@
/* 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
-/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine HAVE_STDLIB_H
-
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H
-/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine HAVE_STRING_H
-
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
diff --git a/Build/source/libs/gd/libgd-src/src/config.hin b/Build/source/libs/gd/libgd-src/src/config.hin
index d2777209b45..56df3dabf72 100644
--- a/Build/source/libs/gd/libgd-src/src/config.hin
+++ b/Build/source/libs/gd/libgd-src/src/config.hin
@@ -3,15 +3,15 @@
/* Define is you are building for Win32 API */
#undef BGDWIN32
+/* Whether to support gd image formats */
+#undef ENABLE_GD_FORMATS
+
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
-/* Define to 1 if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
/* Define if you have the ft2build.h header. */
#undef HAVE_FT2BUILD_H
@@ -45,6 +45,9 @@
/* Define if you have png */
#undef HAVE_LIBPNG
+/* Define if you have raqm */
+#undef HAVE_LIBRAQM
+
/* Define if you have tiff */
#undef HAVE_LIBTIFF
@@ -57,9 +60,6 @@
/* Define if you have zlib */
#undef HAVE_LIBZ
-/* Define to 1 if you have the <limits.h> header file. */
-#undef HAVE_LIMITS_H
-
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
@@ -72,9 +72,6 @@
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
-/* Define to 1 if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
-
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
diff --git a/Build/source/libs/gd/libgd-src/src/entities.html b/Build/source/libs/gd/libgd-src/src/entities.html
index 5c5d7b65a32..f3e99097e4d 100644
--- a/Build/source/libs/gd/libgd-src/src/entities.html
+++ b/Build/source/libs/gd/libgd-src/src/entities.html
@@ -11,7 +11,7 @@
<body>
<div class="navbar" align="center">&nbsp;<a href="http://www.w3.org/TR/REC-html40/sgml/framesetdtd.html">
previous</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/appendix/changes.html">next</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/cover.html#minitoc">contents</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/elements.html">
-elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a>
+elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a>
<hr></div>
@@ -26,7 +26,7 @@ references in HTML 4</a></h1>
references</a></li>
<li><a class="tocxref" href="#h-24.2">Character entity references for ISO
-8859-1 characters</a>
+8859-1 characters</a>
<ol>
<li><a class="tocxref" href="#h-24.2.1">The list of characters</a></li>
@@ -34,7 +34,7 @@ references</a></li>
</li>
<li><a class="tocxref" href="#h-24.3">Character entity references for symbols,
-mathematical symbols, and Greek letters</a>
+mathematical symbols, and Greek letters</a>
<ol>
<li><a class="tocxref" href="#h-24.3.1">The list of characters</a></li>
@@ -42,7 +42,7 @@ mathematical symbols, and Greek letters</a>
</li>
<li><a class="tocxref" href="#h-24.4">Character entity references for
-markup-significant and internationalization characters</a>
+markup-significant and internationalization characters</a>
<ol>
<li><a class="tocxref" href="#h-24.4.1">The list of characters</a></li>
@@ -55,7 +55,7 @@ markup-significant and internationalization characters</a>
A <a href="http://www.w3.org/TR/REC-html40/charset.html#entities">character entity reference</a> is an SGML
construct that references a character of the <a href="http://www.w3.org/TR/REC-html40/charset.html">document
-character set.</a>
+character set.</a>
<p>This version of HTML supports several sets of character entity
references:</p>
@@ -345,7 +345,7 @@ occasional Greek letters used in technical and mathematical works.</em></p>
existing ISO 8879 entity names. ISO 10646 character numbers
are given for each character, in hex. CDATA values are decimal
conversions of the ISO 10646 values and refer to the document
- character set. Names are ISO 10646 names.
+ character set. Names are ISO 10646 names.
--&gt;
@@ -472,7 +472,7 @@ occasional Greek letters used in technical and mathematical works.</em></p>
&lt;!ENTITY uArr CDATA "&amp;#8657;" -- upwards double arrow, U+21D1 ISOamsa --&gt;
&lt;!ENTITY rArr CDATA "&amp;#8658;" -- rightwards double arrow,
U+21D2 ISOtech --&gt;
-&lt;!-- ISO 10646 does not say this is the 'implies' character but does not have
+&lt;!-- ISO 10646 does not say this is the 'implies' character but does not have
another character with this function so ?
rArr can be used for 'implies' as ISOtech suggests --&gt;
&lt;!ENTITY dArr CDATA "&amp;#8659;" -- downwards double arrow, U+21D3 ISOamsa --&gt;
@@ -525,9 +525,9 @@ occasional Greek letters used in technical and mathematical works.</em></p>
U+2265 ISOtech --&gt;
&lt;!ENTITY sub CDATA "&amp;#8834;" -- subset of, U+2282 ISOtech --&gt;
&lt;!ENTITY sup CDATA "&amp;#8835;" -- superset of, U+2283 ISOtech --&gt;
-&lt;!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
+&lt;!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
font encoding and is not included. Should it be, for symmetry?
- It is in ISOamsn --&gt;
+ It is in ISOamsn --&gt;
&lt;!ENTITY nsub CDATA "&amp;#8836;" -- not a subset of, U+2284 ISOamsn --&gt;
&lt;!ENTITY sube CDATA "&amp;#8838;" -- subset of or equal to, U+2286 ISOtech --&gt;
&lt;!ENTITY supe CDATA "&amp;#8839;" -- superset of or equal to,
@@ -550,11 +550,11 @@ occasional Greek letters used in technical and mathematical works.</em></p>
&lt;!ENTITY rfloor CDATA "&amp;#8971;" -- right floor, U+230B ISOamsc --&gt;
&lt;!ENTITY lang CDATA "&amp;#9001;" -- left-pointing angle bracket = bra,
U+2329 ISOtech --&gt;
-&lt;!-- lang is NOT the same character as U+003C 'less than'
+&lt;!-- lang is NOT the same character as U+003C 'less than'
or U+2039 'single left-pointing angle quotation mark' --&gt;
&lt;!ENTITY rang CDATA "&amp;#9002;" -- right-pointing angle bracket = ket,
U+232A ISOtech --&gt;
-&lt;!-- rang is NOT the same character as U+003E 'greater than'
+&lt;!-- rang is NOT the same character as U+003E 'greater than'
or U+203A 'single right-pointing angle quotation mark' --&gt;
&lt;!-- Geometric Shapes --&gt;
@@ -614,7 +614,7 @@ that contains the requisite glyphs.</p>
existing ISO 8879 entity names. ISO 10646 character numbers
are given for each character, in hex. CDATA values are decimal
conversions of the ISO 10646 values and refer to the document
- character set. Names are ISO 10646 names.
+ character set. Names are ISO 10646 names.
--&gt;
@@ -679,4 +679,4 @@ that contains the requisite glyphs.</p>
<div class="navbar" align="center">
<hr><a href="http://www.w3.org/TR/REC-html40/sgml/framesetdtd.html">previous</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/appendix/changes.html">next</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/cover.html#minitoc">
contents</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/elements.html">elements</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/attributes.html">attributes</a> &nbsp; <a href="http://www.w3.org/TR/REC-html40/index/list.html">index</a></div>
-</body></html> \ No newline at end of file
+</body></html>
diff --git a/Build/source/libs/gd/libgd-src/src/fontconfigtest.c b/Build/source/libs/gd/libgd-src/src/fontconfigtest.c
index 47c484922db..eda5c959a83 100644
--- a/Build/source/libs/gd/libgd-src/src/fontconfigtest.c
+++ b/Build/source/libs/gd/libgd-src/src/fontconfigtest.c
@@ -9,7 +9,6 @@ int main (int argc, char *argv[])
gdImagePtr im;
int green, blue;
gdFTStringExtra se;
- FILE *out;
im = gdImageCreateTrueColor(300, 100);
green = gdImageColorAllocate(im, 128, 255, 128);
gdImageFilledRectangle(im, 0, 0, 300, 100, green);
@@ -33,7 +32,7 @@ int main (int argc, char *argv[])
gdImageStringFTEx(im, 0, blue, "arial",
12, 0, 20, 80, "plain pathname", &se);
#ifdef HAVE_LIBPNG
- out = fopen("fontconfigtest.png", "wb");
+ FILE *out = fopen("fontconfigtest.png", "wb");
gdImagePng(im, out);
fclose(out);
#else
@@ -41,4 +40,3 @@ int main (int argc, char *argv[])
#endif /* HAVE_LIBPNG */
return 0;
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/fontsizetest.c b/Build/source/libs/gd/libgd-src/src/fontsizetest.c
index 55b9209d051..c32c77728ab 100644
--- a/Build/source/libs/gd/libgd-src/src/fontsizetest.c
+++ b/Build/source/libs/gd/libgd-src/src/fontsizetest.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -19,29 +18,17 @@ dosizes (gdImagePtr im, int color, char *fontfile,
sprintf (buf, "%d: %s", cursize, string);
/* The case of newlines is taken care of in the gdImageStringTTF call */
-#if defined(OLDER_GD)
- cp =
- gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
- buf);
-#else
cp =
gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
buf);
-#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
/* render the same fontsize with antialiasing turned off */
-#if defined(OLDER_GD)
- cp =
- gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
- y, buf);
-#else
cp =
gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
y, buf);
-#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
diff --git a/Build/source/libs/gd/libgd-src/src/fontwheeltest.c b/Build/source/libs/gd/libgd-src/src/fontwheeltest.c
index b2bb258fdad..a225810db56 100644
--- a/Build/source/libs/gd/libgd-src/src/fontwheeltest.c
+++ b/Build/source/libs/gd/libgd-src/src/fontwheeltest.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -37,13 +36,8 @@ dowheel (gdImagePtr im, int color, char *fontfile, int fontsize,
y0 = y - sin (curangrads) * offset;
/* The case of newlines is taken care of in the gdImageStringTTF call */
-#if defined(OLDER_GD)
- cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
- curangrads, x0, y0, string);
-#else
cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
curangrads, x0, y0, string);
-#endif
if (cp)
doerr (err, cp);
diff --git a/Build/source/libs/gd/libgd-src/src/gd.c b/Build/source/libs/gd/libgd-src/src/gd.c
index 7f0a258f800..4eb2c351c30 100644
--- a/Build/source/libs/gd/libgd-src/src/gd.c
+++ b/Build/source/libs/gd/libgd-src/src/gd.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include <stdio.h>
#include <math.h>
#include <string.h>
@@ -177,7 +175,7 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
See Also:
- <gdImageCreateTrueColor>
+ <gdImageCreateTrueColor>
*/
BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
@@ -192,7 +190,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
if (overflow2(sizeof (unsigned char *), sy)) {
return NULL;
}
- if (overflow2(sizeof (unsigned char *), sx)) {
+ if (overflow2(sizeof (unsigned char), sx)) {
return NULL;
}
@@ -285,7 +283,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy)
See Also:
- <gdImageCreateTrueColor>
+ <gdImageCreateTrueColor>
*/
BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy)
@@ -296,12 +294,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy)
if (overflow2(sx, sy)) {
return NULL;
}
-
if (overflow2(sizeof (int *), sy)) {
return 0;
}
-
- if (overflow2(sizeof(int *), sx)) {
+ if (overflow2(sizeof(int), sx)) {
return NULL;
}
@@ -418,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
@@ -910,15 +906,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;
}
@@ -1491,7 +1485,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)
@@ -1544,7 +1538,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)
@@ -1589,7 +1583,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));
@@ -1942,7 +1936,7 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c
/**
* Function: gdImageString
- *
+ *
* Draws a character string.
*
* Parameters:
@@ -2068,6 +2062,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;
@@ -2097,8 +2092,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) {
@@ -2124,8 +2119,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;
@@ -2154,6 +2149,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);
@@ -2167,7 +2180,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;
@@ -2214,7 +2227,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;
@@ -2281,7 +2294,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;
}
}
@@ -2301,7 +2314,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;
@@ -2616,16 +2629,12 @@ skip:
*
* Parameters:
* im - The image.
- * x1 - The x-coordinate of the upper left corner.
- * y1 - The y-coordinate of the upper left corner.
- * x2 - The x-coordinate of the lower right corner.
- * y2 - The y-coordinate of the lower right corner.
+ * x1 - The x-coordinate of one of the corners.
+ * y1 - The y-coordinate of one of the corners.
+ * x2 - The x-coordinate of another corner.
+ * y2 - The y-coordinate of another corner.
* color - The color.
*
- * Note that x1,y1 and x2,y2 may be swapped, i.e. the former may designate the
- * lower right corner and the latter the upper left corner. The behavior for
- * specifying other corners is undefined.
- *
* See also:
* - <gdImageFilledRectangle>
*/
@@ -2639,12 +2648,13 @@ BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y
}
if (y2 < y1) {
- int t;
- t = y1;
+ int t = y1;
y1 = y2;
y2 = t;
+ }
- t = x1;
+ if (x2 < x1) {
+ int t = x1;
x1 = x2;
x2 = t;
}
@@ -2855,14 +2865,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;
@@ -2897,6 +2899,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++) {
@@ -3099,7 +3102,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.
@@ -3180,7 +3183,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.
@@ -3437,7 +3440,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.
@@ -4345,8 +4348,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 */
@@ -4365,7 +4368,7 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co
if (dx == 0 && dy == 0) {
/* TBB: allow setting points */
- gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
+ gdImageSetPixel(im, x1, y1, col);
return;
} else {
double ag;
diff --git a/Build/source/libs/gd/libgd-src/src/gd.h b/Build/source/libs/gd/libgd-src/src/gd.h
index 219b2240357..27c663edad8 100644
--- a/Build/source/libs/gd/libgd-src/src/gd.h
+++ b/Build/source/libs/gd/libgd-src/src/gd.h
@@ -1,20 +1,20 @@
-#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 2 /*version605b5d1778*/
-#define GD_RELEASE_VERSION 5 /*version605b5d1778*/
-#define GD_EXTRA_VERSION "" /*version605b5d1778*/
+#define GD_MINOR_VERSION 3 /*version605b5d1778*/
+#define GD_RELEASE_VERSION 0 /*version605b5d1778*/
+#define GD_EXTRA_VERSION "" /*version605b5d1778*/
/* End parsable section. */
/* The version string. This is constructed from the version number
@@ -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,19 @@ 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, snprintf, 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
+# endif
#if _MSC_VER < 1900
extern int snprintf(char*, size_t, const char*, ...);
#endif
-#endif
-
-#ifdef __cplusplus
- extern "C"
- {
#endif
/* gd.h: declarations file for the graphic-draw module.
@@ -131,9 +126,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 +204,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 +281,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
@@ -346,7 +341,7 @@ typedef double (* interpolation_method )(double);
/*
Group: Types
-
+
typedef: gdImage
typedef: gdImagePtr
@@ -513,7 +508,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
@@ -710,7 +705,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 +763,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 +803,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 +812,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 +852,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);
/*
@@ -977,16 +972,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.
*/
@@ -1092,7 +1087,7 @@ BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantiza
/**
* Group: GifAnim
- *
+ *
* Legal values for Disposal. gdDisposalNone is always used by
* the built-in optimizer if previm is passed.
*
@@ -1318,7 +1313,7 @@ BGD_DECLARE(gdImagePtr) gdImageCopyGaussianBlurred(gdImagePtr src, int radius,
* Macro: gdImageSX
*
* Gets the width (in pixels) of an image.
- *
+ *
* Parameters:
* im - The image.
*/
@@ -1536,11 +1531,11 @@ 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:
* - <gdImageCropAuto>
@@ -1634,16 +1629,11 @@ BGD_DECLARE(int) gdReleaseVersion(void);
BGD_DECLARE(const char *) gdExtraVersion(void);
BGD_DECLARE(const char *) gdVersionString(void);
-
-#ifdef __cplusplus
-}
-#endif
-
/* newfangled special effects */
#include "gdfx.h"
-#endif /* GD_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GD_H */
diff --git a/Build/source/libs/gd/libgd-src/src/gd2copypal.c b/Build/source/libs/gd/libgd-src/src/gd2copypal.c
index eaa67b55e6f..5a4675585d3 100644
--- a/Build/source/libs/gd/libgd-src/src/gd2copypal.c
+++ b/Build/source/libs/gd/libgd-src/src/gd2copypal.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/Build/source/libs/gd/libgd-src/src/gd2togif.c b/Build/source/libs/gd/libgd-src/src/gd2togif.c
index 5a0be19b378..5b15994d01c 100644
--- a/Build/source/libs/gd/libgd-src/src/gd2togif.c
+++ b/Build/source/libs/gd/libgd-src/src/gd2togif.c
@@ -43,4 +43,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd2topng.c b/Build/source/libs/gd/libgd-src/src/gd2topng.c
index 6c0626f3b30..5e8ca8740db 100644
--- a/Build/source/libs/gd/libgd-src/src/gd2topng.c
+++ b/Build/source/libs/gd/libgd-src/src/gd2topng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -52,11 +51,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support available.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/Build/source/libs/gd/libgd-src/src/gd_bmp.c b/Build/source/libs/gd/libgd-src/src/gd_bmp.c
index 7b29c1a5a3a..5bef2d2ab29 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_bmp.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_bmp.c
@@ -19,12 +19,12 @@
* Read and write BMP images.
*/
-/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
+#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
@@ -47,6 +47,8 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info);
+static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression);
+
#define BMP_DEBUG(s)
static int gdBMPPutWord(gdIOCtx *out, int w)
@@ -87,8 +89,10 @@ BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageBmpCtx(im, out, compression);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageBmpCtx(im, out, compression))
+ rv = gdDPExtractData(out, size);
+ else
+ rv = NULL;
out->gd_free(out);
return rv;
}
@@ -142,12 +146,18 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
*/
BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
{
+ _gdImageBmpCtx(im, out, compression);
+}
+
+static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
+{
int bitmap_size = 0, info_size, total_size, padding;
int i, row, xpos, pixel;
int error = 0;
unsigned char *uncompressed_row = NULL, *uncompressed_row_start = NULL;
FILE *tmpfile_for_compression = NULL;
gdIOCtxPtr out_original = NULL;
+ int ret = 1;
/* No compression if its true colour or we don't support seek */
if (im->trueColor) {
@@ -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,7 +781,7 @@ 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 */
if (!gdSeek(infile, header->off)) {
@@ -855,7 +878,7 @@ 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 */
if (!gdSeek(infile, header->off)) {
@@ -863,8 +886,8 @@ static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp
}
}
- /* 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;
}
@@ -925,7 +948,7 @@ 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 */
if (!gdSeek(infile, header->off)) {
@@ -1012,7 +1035,7 @@ 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 */
if (!gdSeek(infile, header->off)) {
diff --git a/Build/source/libs/gd/libgd-src/src/gd_color_match.c b/Build/source/libs/gd/libgd-src/src/gd_color_match.c
index f0842b69ed7..f0194302ee1 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_color_match.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_color_match.c
@@ -31,9 +31,8 @@ BGD_DECLARE(int) gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
return -4; /* At least 1 color must be allocated */
}
- buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * im2->colorsTotal);
- memset (buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
-
+ buf = (unsigned long *)gdMalloc(sizeof(unsigned long) * 5 * gdMaxColors);
+ memset (buf, 0, sizeof(unsigned long) * 5 * gdMaxColors );
for (x=0; x < im1->sx; x++) {
for( y=0; y<im1->sy; y++ ) {
color = im2->pixels[y][x];
diff --git a/Build/source/libs/gd/libgd-src/src/gd_crop.c b/Build/source/libs/gd/libgd-src/src/gd_crop.c
index 1a6a11f73ca..68f58c695cc 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_crop.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_crop.c
@@ -6,7 +6,7 @@
* 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);
@@ -48,6 +48,7 @@ static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color);
BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop)
{
gdImagePtr dst;
+ int alphaBlendingFlag;
if (gdImageTrueColor(src)) {
dst = gdImageCreateTrueColor(crop->width, crop->height);
@@ -55,7 +56,10 @@ 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;
}
@@ -126,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));
}
}
@@ -157,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));
}
}
@@ -179,7 +177,7 @@ BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode)
* im - The image.
* color - The crop color.
* threshold - The crop threshold.
- *
+ *
* Returns:
* The newly created cropped image, or NULL on failure.
*
@@ -221,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;
}
}
@@ -253,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;
}
}
@@ -290,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) {
diff --git a/Build/source/libs/gd/libgd-src/src/gd_filename.c b/Build/source/libs/gd/libgd-src/src/gd_filename.c
index fd61677d581..d668b01ddf3 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_filename.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_filename.c
@@ -28,7 +28,7 @@ static void BGD_STDCALL writejpeg(gdImagePtr im, FILE *out) {
static void BGD_STDCALL writewbmp(gdImagePtr im, FILE *out) {
int fg = gdImageColorClosest(im, 0, 0, 0);
-
+
gdImageWBMP(im, fg, out);
}/* writejpeg*/
@@ -61,7 +61,7 @@ static struct FileType {
{".jpeg", gdImageCreateFromJpeg, writejpeg, NULL},
#endif
-#ifdef HAVE_LIBTIFF
+#ifdef HAVE_LIBTIFF
{".tiff", gdImageCreateFromTiff, gdImageTiff, NULL},
{".tif" , gdImageCreateFromTiff, gdImageTiff, NULL},
#endif
@@ -90,7 +90,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 +103,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),
@@ -145,7 +145,7 @@ 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);
return !!entry && (!writing || !!entry->writer);
@@ -159,7 +159,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 +179,12 @@ gdSupportsFileType(const char *filename, int writing) {
*/
-BGD_DECLARE(gdImagePtr)
+BGD_DECLARE(gdImagePtr)
gdImageCreateFromFile(const char *filename) {
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 +193,7 @@ gdImageCreateFromFile(const char *filename) {
if (!fh) return NULL;
result = entry->reader(fh);
-
+
fclose(fh);
return result;
@@ -235,7 +235,7 @@ gdImageCreateFromFile(const char *filename) {
*/
-BGD_DECLARE(int)
+BGD_DECLARE(int)
gdImageFile(gdImagePtr im, const char *filename) {
struct FileType *entry = ftype(filename);
FILE *fh;
@@ -251,4 +251,3 @@ gdImageFile(gdImagePtr im, const char *filename) {
return GD_TRUE;
}/* gdImageFile*/
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_filter.c b/Build/source/libs/gd/libgd-src/src/gd_filter.c
index c81e1c177e5..7855190f090 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_filter.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_filter.c
@@ -537,6 +537,7 @@ BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float fi
for ( y=0; y<src->sy; y++) {
for(x=0; x<src->sx; x++) {
new_r = new_g = new_b = 0;
+ pxl = f(srcback, x, y);
new_a = gdImageAlpha(srcback, pxl);
for (j=0; j<3; j++) {
@@ -898,7 +899,7 @@ applyCoeffsLine(gdImagePtr src, gdImagePtr dst, int line, int linelen,
const int srcpx = (axis == HORIZONTAL) ?
src->tpixels[line][rndx] :
src->tpixels[rndx][line];
-
+
r += coeff * (double)gdTrueColorGetRed(srcpx);
g += coeff * (double)gdTrueColorGetGreen(srcpx);
b += coeff * (double)gdTrueColorGetBlue(srcpx);
@@ -912,7 +913,7 @@ applyCoeffsLine(gdImagePtr src, gdImagePtr dst, int line, int linelen,
static void
-applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
+applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
gdAxis axis)
{
int line, numlines, linelen;
@@ -939,7 +940,7 @@ applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
_radius_ is a radius, not a diameter so a radius of 2 (for
example) will blur across a region 5 pixels across (2 to the
center, 1 for the center itself and another 2 to the other edge).
-
+
_sigma_ represents the "fatness" of the curve (lower == fatter).
If _sigma_ is less than or equal to 0,
<gdImageCopyGaussianBlurred> ignores it and instead computes an
@@ -987,10 +988,10 @@ applyCoeffs(gdImagePtr src, gdImagePtr dst, double *coeffs, int radius,
FILE *in;
gdImagePtr result, src;
-
+
in = fopen("foo.png", "rb");
src = gdImageCreateFromPng(in);
-
+
result = gdImageCopyGaussianBlurred(im, src->sx / 10, -1.0);
(end code)
@@ -1034,7 +1035,7 @@ gdImageCopyGaussianBlurred(gdImagePtr src, int radius, double sigma)
gdFree(coeffs);
return NULL;
}/* if */
-
+
freeSrc = 1;
}/* if */
@@ -1059,4 +1060,3 @@ gdImageCopyGaussianBlurred(gdImagePtr src, int radius, double sigma)
return result;
}/* gdImageCopyGaussianBlurred*/
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_gd.c b/Build/source/libs/gd/libgd-src/src/gd_gd.c
index a1e9ebf343b..0771fd37cbe 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_gd.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_gd.c
@@ -12,21 +12,34 @@
* - color header (either truecolor or palette)
* - image data
*
- * All numbers are stored in big-endian format.
+ * All numbers are stored in big-endian format. Note that all GD output is done
+ * in the GD 2.x format (not to be confused with the GD2 format), but input may
+ * also be in the GD 1.x format.
*
- * File header structure:
+ * GD 1.x file header structure:
+ * width - 1 word
+ * height - 1 word
+ *
+ * GD 1.x color header (palette only):
+ * count - 1 byte (the number of used palette colors)
+ * transparent - 1 word (257 signals no transparency)
+ * palette - 256×3 bytes (RGB triplets)
+ *
+ * GD 2.x file header structure:
* signature - 1 word ("\xFF\xFE" for truecolor, "\xFF\xFF" for palette)
* width - 1 word
* height - 1 word
*
- * Truecolor image color header:
+ * GD 2.x truecolor image color header:
* truecolor - 1 byte (always "\001")
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (ARGB color); "\377\377\377\377" means that no
+ * transparent color is set
*
- * Palette image color header:
+ * GD 2.x palette image color header:
* truecolor - 1 byte (always "\0")
* count - 1 word (the number of used palette colors)
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (palette index); "\377\377\377\377" means that no
+ * transparent color is set
* palette - 256 dwords (RGBA colors)
*
* Image data:
@@ -44,6 +57,10 @@
#include <string.h>
#include <stdlib.h>
#include "gd.h"
+#include "gd_errors.h"
+
+/* 2.3: gd is no longer mandatory */
+#if ENABLE_GD_FORMATS
#define TRUE 1
#define FALSE 0
@@ -91,9 +108,10 @@ _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
if (!gdGetWord (&im->transparent, in)) {
goto fail1;
}
- if (im->transparent == 257) {
- im->transparent = (-1);
- }
+ }
+ /* Make sure transparent index is within bounds of the palette. */
+ if (!(im->trueColor) && (im->transparent >= im->colorsTotal || im->transparent < 0)) {
+ im->transparent = (-1);
}
GD2_DBG (printf
("Palette had %d colours (T=%d)\n", im->colorsTotal,
@@ -216,7 +234,7 @@ fail1:
> in = fopen("mygd.gd", "rb");
> im = gdImageCreateFromGd(in);
> fclose(in);
- > // ... Use the image ...
+ > // ... Use the image ...
> gdImageDestroy(im);
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * inFile)
@@ -387,3 +405,41 @@ BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size)
out->gd_free (out);
return rv;
}
+
+#else /* no HAVE_LIBZ or !ENABLE_GD_FORMATS */
+
+static void _noGdError (void)
+{
+ gd_error("GD image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * inFile)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in)
+{
+ _noGdError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * outFile)
+{
+ _noGdError();
+}
+
+BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size)
+{
+ _noGdError();
+ return NULL;
+}
+
+#endif /* ENABLE_GD_FORMATS */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_gd2.c b/Build/source/libs/gd/libgd-src/src/gd_gd2.c
index 85106bc9273..760e85b9fd9 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_gd2.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_gd2.c
@@ -47,16 +47,18 @@
* offset - 1 dword
* size - 1 dword
*
- * There are x_chunk_count * y_chunk_count chunk headers.
+ * There are x_chunk_count * y_chunk_count chunk headers.
*
* Truecolor image color header:
* truecolor - 1 byte (always "\001")
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (ARGB color); "\377\377\377\377" means that no
+ * transparent color is set
*
* Palette image color header:
* truecolor - 1 byte (always "\0")
* count - 1 word (the number of used palette colors)
- * transparent - 1 dword (ARGB color)
+ * transparent - 1 dword (palette index); "\377\377\377\377" means that no
+ * transparent color is set
* palette - 256 dwords (RGBA colors)
*
* Chunk structure:
@@ -83,7 +85,7 @@
/* 2.03: gd2 is no longer mandatory */
/* JCE - test after including gd.h so that HAVE_LIBZ can be set in
* a config.h file included by gd.h */
-#ifdef HAVE_LIBZ
+#if defined(HAVE_LIBZ) && ENABLE_GD_FORMATS
#include <zlib.h>
#define TRUE 1
@@ -210,7 +212,7 @@ _gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy,
GD2_DBG (printf ("%d Chunks vertically\n", *ncy));
if (gd2_compressed (*fmt)) {
- if (*ncx <= 0 || *ncy <= 0 || *ncx > INT_MAX / *ncy) {
+ if (overflow2(*ncx, *ncy)) {
GD2_DBG(printf ("Illegal chunk counts: %d * %d\n", *ncx, *ncy));
goto fail1;
}
@@ -236,7 +238,7 @@ _gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy,
if (gdGetInt (&cidx[i].size, in) != 1) {
goto fail2;
};
- if (cidx[i].offset < 0 || cidx[i].size < 0)
+ if (cidx[i].offset < 0 || cidx[i].size < 0 || cidx[i].size == INT_MAX)
goto fail2;
};
*chunkIdx = cidx;
@@ -405,7 +407,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data)
Function: gdImageCreateFromGd2Ctx
Reads in a GD2 image via a <gdIOCtx> struct. See
- <gdImageCreateFromGd2>.
+ <gdImageCreateFromGd2>.
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
{
@@ -436,8 +438,13 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
}
bytesPerPixel = im->trueColor ? 4 : 1;
+ if (overflow2(ncx, ncy))
+ goto fail;
nc = ncx * ncy;
+ if (overflow2(ncy, cs) || overflow2(ncx, cs) || overflow2(bytesPerPixel, cs))
+ goto fail;
+
if (gd2_compressed (fmt)) {
/* Find the maximum compressed chunk size. */
compMax = 0;
@@ -1127,57 +1134,61 @@ BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
return rv;
}
-#else /* no HAVE_LIBZ */
-static void _noLibzError (void)
+#else /* no HAVE_LIBZ or !ENABLE_GD_FORMATS */
+static void _noGd2Error (void)
{
+#if !ENABLE_GD_FORMATS
+ gd_error("GD2 image support has been disabled\n");
+#else
gd_error("GD2 support is not available - no libz\n");
+#endif
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * inFile)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * inFile, int srcx, int srcy, int w, int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy, int w,
int h)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * outFile, int cs, int fmt)
{
- _noLibzError();
+ _noGd2Error();
}
BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
{
- _noLibzError();
+ _noGd2Error();
return NULL;
}
#endif /* HAVE_LIBZ */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_gif_in.c b/Build/source/libs/gd/libgd-src/src/gd_gif_in.c
index c1954480143..1ae0e32b23f 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_gif_in.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_gif_in.c
@@ -53,7 +53,7 @@ static int set_verbose(void)
#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
-#define ReadOK(file, buffer, len) (gdGetBuf(buffer, len, file) > 0)
+#define ReadOK(file, buffer, len) (gdGetBuf(buffer, len, file) == len)
#define LM_to_uint(a, b) (((b)<<8)|(a))
@@ -149,7 +149,7 @@ static void ReadImage (gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned
> in = fopen("mygif.gif", "rb");
> im = gdImageCreateFromGif(in);
> fclose(in);
- > // ... Use the image ...
+ > // ... Use the image ...
> gdImageDestroy(im);
*/
@@ -335,11 +335,6 @@ terminated:
return 0;
}
- if(!im->colorsTotal) {
- gdImageDestroy(im);
- return 0;
- }
-
/* Check for open colors at the end, so
* we can reduce colorsTotal and ultimately
* BitsPerPixel */
@@ -351,6 +346,11 @@ terminated:
}
}
+ if(!im->colorsTotal) {
+ gdImageDestroy(im);
+ return 0;
+ }
+
return im;
}
@@ -447,7 +447,7 @@ static int
GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP)
{
int i, j, ret;
- unsigned char count;
+ int count;
if(flag) {
scd->curbit = 0;
@@ -601,6 +601,10 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i
/* Bad compressed data stream */
return -1;
}
+ if(code >= (1 << MAX_LWZ_BITS)) {
+ /* Corrupted code */
+ return -1;
+ }
*sd->sp++ = sd->table[1][code];
@@ -610,6 +614,10 @@ LWZReadByte_(gdIOCtx *fd, LZW_STATIC_DATA *sd, char flag, int input_code_size, i
code = sd->table[0][code];
}
+ if(code >= (1 << MAX_LWZ_BITS)) {
+ /* Corrupted code */
+ return -1;
+ }
*sd->sp++ = sd->firstcode = sd->table[1][code];
diff --git a/Build/source/libs/gd/libgd-src/src/gd_gif_out.c b/Build/source/libs/gd/libgd-src/src/gd_gif_out.c
index 6fe707d8423..2dd866a74a6 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_gif_out.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_gif_out.c
@@ -99,6 +99,11 @@ static void char_init(GifCtx *ctx);
static void char_out(int c, GifCtx *ctx);
static void flush_char(GifCtx *ctx);
+static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out);
+static int _gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
+ int LocalCM, int LeftOfs, int TopOfs,
+ int Delay, int Disposal,
+ gdImagePtr previm);
@@ -131,8 +136,11 @@ BGD_DECLARE(void *) gdImageGifPtr(gdImagePtr im, int *size)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageGifCtx(im, out);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageGifCtx(im, out)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -221,6 +229,12 @@ BGD_DECLARE(void) gdImageGif(gdImagePtr im, FILE *outFile)
*/
BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
{
+ _gdImageGifCtx(im, out);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
+{
gdImagePtr pim = 0, tim = im;
int interlace, BitsPerPixel;
interlace = im->interlace;
@@ -231,7 +245,7 @@ BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
based temporary image. */
pim = gdImageCreatePaletteFromTrueColor(im, 1, 256);
if(!pim) {
- return;
+ return 1;
}
tim = pim;
}
@@ -247,6 +261,8 @@ BGD_DECLARE(void) gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
/* Destroy palette based temporary image. */
gdImageDestroy( pim);
}
+
+ return 0;
}
@@ -475,8 +491,11 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -546,18 +565,18 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
gdImagePtr im, im2, im3;
int black, white, trans;
FILE *out;
-
+
im = gdImageCreate(100, 100); // Create the image
white = gdImageColorAllocate(im, 255, 255, 255); // Allocate background
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
trans = gdImageColorAllocate(im, 1, 1, 1); // trans clr for compression
gdImageRectangle(im, 0, 0, 10, 10, black); // Draw rectangle
-
+
out = fopen("anim.gif", "wb");// Open output file in binary mode
gdImageGifAnimBegin(im, out, 1, 3);// Write GIF hdr, global clr map,loops
// Write the first frame. No local color map. Delay = 1s
gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
-
+
// construct the second frame
im2 = gdImageCreate(100, 100);
(void)gdImageColorAllocate(im2, 255, 255, 255); // White background
@@ -566,7 +585,7 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
// Allow animation compression with transparent pixels
gdImageColorTransparent (im2, trans);
gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im); // Add second frame
-
+
// construct the third frame
im3 = gdImageCreate(100, 100);
(void)gdImageColorAllocate(im3, 255, 255, 255); // white background
@@ -578,7 +597,7 @@ BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM,
gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
gdImageGifAnimEnd(out); // End marker, same as putc(';', out);
fclose(out); // Close file
-
+
// Destroy images
gdImageDestroy(im);
gdImageDestroy(im2);
@@ -637,6 +656,15 @@ BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
int Delay, int Disposal,
gdImagePtr previm)
{
+ _gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
+ int LocalCM, int LeftOfs, int TopOfs,
+ int Delay, int Disposal,
+ gdImagePtr previm)
+{
gdImagePtr pim = NULL, tim = im;
int interlace, transparent, BitsPerPixel;
interlace = im->interlace;
@@ -653,7 +681,7 @@ BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtxPtr out,
based temporary image. */
pim = gdImageCreatePaletteFromTrueColor(im, 1, 256);
if (!pim) {
- return;
+ return 1;
}
tim = pim;
}
@@ -826,12 +854,14 @@ break_right:
out, tim->sx, tim->sy, LeftOfs, TopOfs, interlace, transparent,
Delay, Disposal, BitsPerPixel,
LocalCM ? tim->red : 0, tim->green, tim->blue, tim);
+ return 0;
fail_end:
if(pim) {
/* Destroy palette based temporary image. */
gdImageDestroy(pim);
}
+ return 1;
}
@@ -1374,7 +1404,7 @@ static void compress(int init_bits, gdIOCtxPtr outfile, gdImagePtr im, GifCtx *c
output((code_int)ctx->ClearCode, ctx);
#ifdef SIGNED_COMPARE_SLOW
- while((c = GIFNextPixel(im)) != (unsigned) EOF) {
+ while((c = GIFNextPixel(im, ctx)) != (unsigned) EOF) {
#else /* SIGNED_COMPARE_SLOW */
while((c = GIFNextPixel(im, ctx)) != EOF) {
#endif /* SIGNED_COMPARE_SLOW */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_intern.h b/Build/source/libs/gd/libgd-src/src/gd_intern.h
index 86d817e6d4a..3bf1fa884b7 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_intern.h
+++ b/Build/source/libs/gd/libgd-src/src/gd_intern.h
@@ -1,10 +1,7 @@
#ifndef GD_INTERN_H
#define GD_INTERN_H
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
-
#ifndef MAXPATHLEN
# ifdef PATH_MAX
@@ -87,4 +84,3 @@ gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
#endif
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_interpolation.c b/Build/source/libs/gd/libgd-src/src/gd_interpolation.c
index b9a206551dc..21f7315f10a 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_interpolation.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_interpolation.c
@@ -41,8 +41,8 @@
downscaling using the fixed point implementations are usually much faster
than the existing gdImageCopyResampled while having a similar or better
quality.
-
- For image rotations, the optimized versions have a lazy antialiasing for
+
+ For image rotations, the optimized versions have a lazy antialiasing for
the edges of the images. For a much better antialiased result, the affine
function is recommended.
*/
@@ -78,7 +78,7 @@ TODO:
# include <emmintrin.h>
#endif
-static gdImagePtr gdImageScaleBilinear(gdImagePtr im,
+static gdImagePtr gdImageScaleBilinear(gdImagePtr im,
const unsigned int new_width,
const unsigned int new_height);
static gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src,
@@ -278,7 +278,7 @@ static double KernelBessel_Q1(const double x)
static double KernelBessel_Order1(double x)
{
double p, q;
-
+
if (x == 0.0)
return (0.0f);
p = x;
@@ -617,7 +617,7 @@ static double filter_welsh(const double x)
#if defined(_MSC_VER) && !defined(inline)
# define inline __inline
-#endif
+#endif
/* keep it for future usage for affine copy over an existing image, targetting fix for 2.2.2 */
#ifdef FUNCTION_NOT_USED_YET
@@ -654,7 +654,7 @@ static inline int _color_blend (const int dst, const int src)
}
}
-static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
+static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor)
{
const gdFixed f_127 = gd_itofx(127);
register int c = src->tpixels[y][x];
@@ -948,8 +948,8 @@ _gdScaleOneAxis(gdImagePtr pSrc, gdImagePtr dst,
double r = 0, g = 0, b = 0, a = 0;
const int left = contrib->ContribRow[ndx].Left;
const int right = contrib->ContribRow[ndx].Right;
- int *dest = (axis == HORIZONTAL) ?
- &dst->tpixels[row][ndx] :
+ int *dest = (axis == HORIZONTAL) ?
+ &dst->tpixels[row][ndx] :
&dst->tpixels[ndx][row];
int i;
@@ -958,7 +958,7 @@ _gdScaleOneAxis(gdImagePtr pSrc, gdImagePtr dst,
for (i = left; i <= right; i++) {
const int left_channel = i - left;
const int srcpx = (axis == HORIZONTAL) ?
- pSrc->tpixels[row][i] :
+ pSrc->tpixels[row][i] :
pSrc->tpixels[i][row];
r += contrib->ContribRow[ndx].Weights[left_channel]
@@ -1313,8 +1313,8 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
gdFixed f_j = gd_itofx(j);
gdFixed f_a = gd_mulfx(f_i, f_dy);
gdFixed f_b = gd_mulfx(f_j, f_dx);
- const gdFixed m = gd_fxtoi(f_a);
- const gdFixed n = gd_fxtoi(f_b);
+ const long m = gd_fxtoi(f_a);
+ const long n = gd_fxtoi(f_b);
gdFixed f_f = f_a - gd_itofx(m);
gdFixed f_g = f_b - gd_itofx(n);
@@ -1686,7 +1686,7 @@ static int gdRotatedImageSize(gdImagePtr src, const float angle, gdRectPtr bbox)
return GD_TRUE;
}
-static gdImagePtr
+static gdImagePtr
gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees,
const int bgColor)
{
@@ -1799,7 +1799,7 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
return dst;
}
-/**
+/**
* Function: gdImageRotateInterpolated
*
* Rotate an image
@@ -1821,7 +1821,7 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
*/
BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)
{
- /* round to two decimals and keep the 100x multiplication to use it in the common square angles
+ /* round to two decimals and keep the 100x multiplication to use it in the common square angles
case later. Keep the two decimal precisions so smaller rotation steps can be done, useful for
slow animations, f.e. */
const int angle_rounded = fmod((int) floorf(angle * 100), 360 * 100);
@@ -1953,7 +1953,7 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
if (!src->trueColor) {
gdImagePaletteToTrueColor(src);
}
-
+
/* Translate to dst origin (0,0) */
gdAffineTranslate(m, -bbox.x, -bbox.y);
gdAffineConcat(m, affine, m);
@@ -1975,6 +1975,51 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
}
}
+/** Function: getPixelRgbInterpolated
+ * get the index of the image's colors
+ *
+ * Parameters:
+ * im - Image to draw the transformed image
+ * tcolor - TrueColor
+ *
+ * Return:
+ * index of colors
+ */
+static int getPixelRgbInterpolated(gdImagePtr im, const int tcolor)
+{
+ unsigned char r, g, b, a;
+ int ct, i;
+
+ b = (unsigned char)tcolor;
+ g = (unsigned char)(tcolor >> 8);
+ r = (unsigned char)(tcolor >> 16);
+ a = (unsigned char)(tcolor >> 24);
+
+ b = CLAMP(b, 0, 255);
+ g = CLAMP(g, 0, 255);
+ r = CLAMP(r, 0, 255);
+ a = CLAMP(a, 0, 127);
+
+ for (i = 0; i < im->colorsTotal; i++) {
+ if (im->red[i] == r && im->green[i] == g && im->blue[i] == b && im->alpha[i] == a) {
+ return i;
+ }
+ }
+
+ ct = im->colorsTotal;
+ if (ct == gdMaxColors) {
+ return -1;
+ }
+
+ im->colorsTotal++;
+ im->red[ct] = r;
+ im->green[ct] = g;
+ im->blue[ct] = b;
+ im->alpha[ct] = a;
+ im->open[ct] = 0;
+
+ return ct;
+}
/**
* Function: gdTransformAffineCopy
* Applies an affine transformation to a region and copy the result
@@ -1988,7 +2033,7 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst,
* src_area - Rectangular region to rotate in the src image
*
* Returns:
- * GD_TRUE if the affine is rectilinear or GD_FALSE
+ * GD_TRUE on success or GD_FALSE on failure
*/
BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
int dst_x, int dst_y,
@@ -2001,21 +2046,21 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
int backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2;
register int x, y, src_offset_x, src_offset_y;
double inv[6];
- int *dst_p;
gdPointF pt, src_pt;
gdRect bbox;
int end_x, end_y;
- gdInterpolationMethod interpolation_id_bak = GD_DEFAULT;
+ gdInterpolationMethod interpolation_id_bak = src->interpolation_id;
/* These methods use special implementations */
if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) {
- interpolation_id_bak = src->interpolation_id;
-
gdImageSetInterpolationMethod(src, GD_BICUBIC);
}
-
gdImageClipRectangle(src, src_region);
+ c1x = src_region->x;
+ c1y = src_region->y;
+ c2x = src_region->x + src_region->width -1;
+ c2y = src_region->y + src_region->height -1;
if (src_region->x > 0 || src_region->y > 0
|| src_region->width < gdImageSX(src)
@@ -2039,13 +2084,14 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
return GD_FALSE;
}
- gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y);
-
end_x = bbox.width + abs(bbox.x);
end_y = bbox.height + abs(bbox.y);
/* Get inverse affine to let us work with destination -> source */
- gdAffineInvert(inv, affine);
+ if (gdAffineInvert(inv, affine) == GD_FALSE) {
+ gdImageSetInterpolationMethod(src, interpolation_id_bak);
+ return GD_FALSE;
+ }
src_offset_x = src_region->x;
src_offset_y = src_region->y;
@@ -2053,28 +2099,51 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
if (dst->alphaBlendingFlag) {
for (y = bbox.y; y <= end_y; y++) {
pt.y = y + 0.5;
- for (x = 0; x <= end_x; x++) {
+ for (x = bbox.x; x <= end_x; x++) {
pt.x = x + 0.5;
gdAffineApplyToPointF(&src_pt, &pt, inv);
- gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0));
+ if (floor(src_offset_x + src_pt.x) < c1x
+ || floor(src_offset_x + src_pt.x) > c2x
+ || floor(src_offset_y + src_pt.y) < c1y
+ || floor(src_offset_y + src_pt.y) > c2y) {
+ continue;
+ }
+ gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), 0));
}
}
} else {
- for (y = 0; y <= end_y; y++) {
- pt.y = y + 0.5 + bbox.y;
+ for (y = bbox.y; y <= end_y; y++) {
+ unsigned char *dst_p = NULL;
+ int *tdst_p = NULL;
+
+ pt.y = y + 0.5;
if ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) {
continue;
}
- dst_p = dst->tpixels[dst_y + y] + dst_x;
+ if (dst->trueColor) {
+ tdst_p = dst->tpixels[dst_y + y] + dst_x;
+ } else {
+ dst_p = dst->pixels[dst_y + y] + dst_x;
+ }
- for (x = 0; x <= end_x; x++) {
- pt.x = x + 0.5 + bbox.x;
+ for (x = bbox.x; x <= end_x; x++) {
+ pt.x = x + 0.5;
gdAffineApplyToPointF(&src_pt, &pt, inv);
if ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) {
break;
}
- *(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1);
+ if (floor(src_offset_x + src_pt.x) < c1x
+ || floor(src_offset_x + src_pt.x) > c2x
+ || floor(src_offset_y + src_pt.y) < c1y
+ || floor(src_offset_y + src_pt.y) > c2y) {
+ continue;
+ }
+ if (dst->trueColor) {
+ *(tdst_p + dst_x + x) = getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), -1);
+ } else {
+ *(dst_p + dst_x + x) = getPixelRgbInterpolated(dst, getPixelInterpolated(src, (int)(src_offset_x + src_pt.x), (int)(src_offset_y + src_pt.y), -1));
+ }
}
}
}
@@ -2137,8 +2206,8 @@ BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine
}
bbox->x = (int) min.x;
bbox->y = (int) min.y;
- bbox->width = (int) ceil((max.x - min.x)) + 1;
- bbox->height = (int) ceil(max.y - min.y) + 1;
+ bbox->width = (int) ceil((max.x - min.x));
+ bbox->height = (int) ceil(max.y - min.y);
return GD_TRUE;
}
@@ -2236,9 +2305,9 @@ BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMet
case GD_DEFAULT:
id = GD_LINEAR;
im->interpolation = filter_linear;
+ break;
default:
return 0;
- break;
}
im->interpolation_id = id;
return 1;
diff --git a/Build/source/libs/gd/libgd-src/src/gd_io.c b/Build/source/libs/gd/libgd-src/src/gd_io.c
index 03b83472120..4cb1adefcdb 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_io.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_io.c
@@ -129,7 +129,7 @@ int gdGetWordLSB(signed short int *result, gdIOCtx *ctx)
int gdGetInt(int *result, gdIOCtx *ctx)
{
- int r;
+ unsigned int r;
r = (ctx->getC)(ctx);
if(r == EOF) {
@@ -164,7 +164,7 @@ int gdGetInt(int *result, gdIOCtx *ctx)
int gdGetIntLSB(signed int *result, gdIOCtx *ctx)
{
- int c = 0;
+ unsigned int c;
unsigned int r = 0;
c = (ctx->getC) (ctx);
diff --git a/Build/source/libs/gd/libgd-src/src/gd_io.h b/Build/source/libs/gd/libgd-src/src/gd_io.h
index 1039d597dc8..c7a5025591f 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_io.h
+++ b/Build/source/libs/gd/libgd-src/src/gd_io.h
@@ -1,12 +1,12 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef GD_IO_H
#define GD_IO_H 1
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifdef VMS
# define Putchar gdPutchar
#endif
@@ -17,7 +17,7 @@ extern "C" {
typedef: gdIOCtx
gdIOCtx structures hold function pointers for doing image IO.
-
+
Most of the gd functions that read and write files, such as
<gdImagePng> also have variants that accept a <gdIOCtx> structure;
see <gdImagePngCtx> and <gdImageCreateFromJpegCtx>.
@@ -45,14 +45,14 @@ extern "C" {
> {
> int (*getC) (struct gdIOCtx *);
> int (*getBuf) (struct gdIOCtx *, void *, int wanted);
- >
+ >
> void (*putC) (struct gdIOCtx *, int);
> int (*putBuf) (struct gdIOCtx *, const void *, int wanted);
- >
- > // seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ >
+ > // seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
> int (*seek) (struct gdIOCtx *, const int);
> long (*tell) (struct gdIOCtx *);
- >
+ >
> void (*gd_free) (struct gdIOCtx *);
> } gdIOCtx;
@@ -93,8 +93,8 @@ int gdGetIntLSB(signed int *result, gdIOCtx *ctx);
int gdSeek(gdIOCtx *ctx, const int offset);
long gdTell(gdIOCtx *ctx);
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/Build/source/libs/gd/libgd-src/src/gd_io_dp.c b/Build/source/libs/gd/libgd-src/src/gd_io_dp.c
index 25c0980a9b3..ec259e7a69f 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_io_dp.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_io_dp.c
@@ -6,7 +6,7 @@
* Based on GD.pm code by Lincoln Stein for interfacing to libgd.
* Added support for reading as well as support for 'tell' and 'seek'.
*
- * As will all I/O modules, most functions are for local use only (called
+ * As with all I/O modules, most functions are for local use only (called
* via function pointers in the I/O context).
*
* gdDPExtractData is the exception to this: it will return the pointer to
diff --git a/Build/source/libs/gd/libgd-src/src/gd_io_stream.cxx b/Build/source/libs/gd/libgd-src/src/gd_io_stream.cxx
index 28021afc1ae..0d64c72c2b7 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_io_stream.cxx
+++ b/Build/source/libs/gd/libgd-src/src/gd_io_stream.cxx
@@ -1,12 +1,11 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
*******************************************************************************/
/** \file gd_io_stream.cxx
\brief Implementation of the methods of the gdIOCtx std stream specialization.
-
+
Implements the derived specializations of gdIOCtx.
These methods are not called by users of libgd, they
are internal implementation.
@@ -22,7 +21,7 @@
#include "gd_io_stream.h"
/** Read into buffer from stream
- Return the number of bytes successfully read.
+ Return the number of bytes successfully read.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -33,7 +32,7 @@ int istreamIOCtx::Getbuf (struct gdIOCtx * ctx, void * buf, int size)
return _str->gcount();
}
/** Write from buffer to stream
- Return the number of bytes successfully written.
+ Return the number of bytes successfully written.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -58,7 +57,7 @@ void istreamIOCtx::Putchar (struct gdIOCtx * , int )
}
/** Seek to position offset from the beginning of the stream
- must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
*/
int istreamIOCtx::Seek (struct gdIOCtx * ctx, const int pos)
{
@@ -82,7 +81,7 @@ void istreamIOCtx::FreeCtx (struct gdIOCtx * ctx)
}
/** Read into buffer from stream
- Return the number of bytes successfully read.
+ Return the number of bytes successfully read.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -91,7 +90,7 @@ int ostreamIOCtx::Getbuf (struct gdIOCtx * , void * , int )
return 0;
}
/** Write from buffer to stream
- Return the number of bytes successfully written.
+ Return the number of bytes successfully written.
If an error occurs, or the end-of-file is reached, the return value
is a short byte count (or zero).
*/
@@ -119,7 +118,7 @@ void ostreamIOCtx::Putchar (struct gdIOCtx * ctx, int c)
}
/** Seek to position offset from the beginning of the stream
- must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
+ must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek!
*/
int ostreamIOCtx::Seek (struct gdIOCtx * ctx, const int pos)
{
diff --git a/Build/source/libs/gd/libgd-src/src/gd_io_stream.h b/Build/source/libs/gd/libgd-src/src/gd_io_stream.h
index 703548fec26..dd76d7786a0 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_io_stream.h
+++ b/Build/source/libs/gd/libgd-src/src/gd_io_stream.h
@@ -1,5 +1,4 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
@@ -27,9 +26,9 @@
}
gdImageDestroy(im_in);
*/
-#ifdef __cplusplus
#ifndef _gd_io_stream_h
#define _gd_io_stream_h
+#ifdef __cplusplus
#include "gd.h"
#include <iostream>
@@ -122,5 +121,5 @@ inline gdIOCtx * gdNewOstreamCtx (std::ostream * __stream)
return new ostreamIOCtx(* __stream);
}
-#endif /* _gd_io_stream_h */
#endif /* __cplusplus */
+#endif /* _gd_io_stream_h */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_jpeg.c b/Build/source/libs/gd/libgd-src/src/gd_jpeg.c
index 271ef46e003..f2dd329aac0 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_jpeg.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_jpeg.c
@@ -47,12 +47,6 @@
# define HAVE_BOOLEAN
#endif
-/* JCE undef two symbols that we don't need anymore but which are
- may be defined in config.h from ./configure but which are
- redefined incompatibly in jpeglib.h */
-#undef HAVE_STDDEF_H
-#undef HAVE_STDLIB_H
-
/* 1.8.1: remove dependency on jinclude.h */
#include "jpeglib.h"
#include "jerror.h"
@@ -123,6 +117,8 @@ static void fatal_jpeg_error(j_common_ptr cinfo)
exit(99);
}
+static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality);
+
/*
* Write IM to OUTFILE as a JFIF-formatted JPEG image, using quality
* QUALITY. If QUALITY is in the range 0-100, increasing values
@@ -237,8 +233,11 @@ BGD_DECLARE(void *) gdImageJpegPtr(gdImagePtr im, int *size, int quality)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageJpegCtx(im, out, quality);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageJpegCtx(im, out, quality)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
@@ -255,11 +254,17 @@ void jpeg_gdIOCtx_dest(j_compress_ptr cinfo, gdIOCtx *outfile);
im - The image to write.
outfile - The output sink.
- quality - Image quality.
+ quality - Image quality.
*/
BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
{
+ _gdImageJpegCtx(im, outfile, quality);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
+{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
int i, j, jidx;
@@ -293,7 +298,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
if(row) {
gdFree(row);
}
- return;
+ return 1;
}
cinfo.err->emit_message = jpeg_emit_message;
@@ -334,7 +339,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
if(row == 0) {
gd_error("gd-jpeg: error: unable to allocate JPEG row structure: gdCalloc returns NULL\n");
jpeg_destroy_compress(&cinfo);
- return;
+ return 1;
}
rowptr[0] = row;
@@ -411,6 +416,7 @@ BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
gdFree(row);
+ return 0;
}
@@ -496,7 +502,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning
Function: gdImageCreateFromJpegPtr
Parameters:
-
+
size - size of JPEG data in bytes.
data - pointer to JPEG data.
@@ -511,7 +517,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr(int size, void *data)
Function: gdImageCreateFromJpegPtrEx
Parameters:
-
+
size - size of JPEG data in bytes.
data - pointer to JPEG data.
ignore_warning - if true, ignore recoverable warnings
@@ -1198,4 +1204,63 @@ void jpeg_gdIOCtx_dest(j_compress_ptr cinfo, gdIOCtx *outfile)
dest->outfile = outfile;
}
+#else /* !HAVE_LIBJPEG */
+
+static void _noJpegError(void)
+{
+ gd_error("JPEG image support has been disabled\n");
+}
+
+BGD_DECLARE(void) gdImageJpeg(gdImagePtr im, FILE *outFile, int quality)
+{
+ _noJpegError();
+}
+
+BGD_DECLARE(void *) gdImageJpegPtr(gdImagePtr im, int *size, int quality)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageJpegCtx(gdImagePtr im, gdIOCtx *outfile, int quality)
+{
+ _noJpegError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg(FILE *inFile)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx(FILE *inFile, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr(int size, void *data)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx(int size, void *data, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx(gdIOCtx *infile)
+{
+ _noJpegError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx(gdIOCtx *infile, int ignore_warning)
+{
+ _noJpegError();
+ return NULL;
+}
+
#endif /* HAVE_LIBJPEG */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_matrix.c b/Build/source/libs/gd/libgd-src/src/gd_matrix.c
index b7827a07034..ada63e694ca 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_matrix.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_matrix.c
@@ -57,13 +57,13 @@ BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src,
* <gdAffineIdentity>
*
* Returns:
- * GD_TRUE if the affine is rectilinear or GD_FALSE
+ * GD_TRUE on success or GD_FALSE on failure
*/
BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6])
{
double r_det = (src[0] * src[3] - src[1] * src[2]);
- if (r_det <= 0.0) {
+ if (fabs(r_det) <= 0.0) {
return GD_FALSE;
}
@@ -333,4 +333,3 @@ BGD_DECLARE(int) gdAffineEqual (const double m1[6], const double m2[6])
fabs (m1[4] - m2[4]) < GD_EPSILON &&
fabs (m1[5] - m2[5]) < GD_EPSILON);
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_nnquant.c b/Build/source/libs/gd/libgd-src/src/gd_nnquant.c
index 19190b7ed84..9129d84f354 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_nnquant.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_nnquant.c
@@ -464,7 +464,7 @@ int verbose;
radius = initradius;
rad = radius >> radiusbiasshift;
-
+
for (i=0; i<rad; i++)
nnq->radpower[i] = alpha*(((rad*rad - i*i)*radbias)/(rad*rad));
diff --git a/Build/source/libs/gd/libgd-src/src/gd_nnquant.h b/Build/source/libs/gd/libgd-src/src/gd_nnquant.h
index b054fb1da44..11643b7d622 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_nnquant.h
+++ b/Build/source/libs/gd/libgd-src/src/gd_nnquant.h
@@ -1,4 +1,3 @@
-
/* maximum number of colours that can be used.
actual number is now passed to initcolors */
#define MAXNETSIZE 256
@@ -15,5 +14,3 @@
#define prime4 503
#define minpicturebytes (4*prime4) /* minimum size for input image */
-
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_png.c b/Build/source/libs/gd/libgd-src/src/gd_png.c
index c9e3545de86..8119cf39c05 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_png.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_png.c
@@ -1,4 +1,3 @@
-/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -592,7 +591,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
gdImagePtr im;
int black, white;
FILE *out;
-
+
im = gdImageCreate(100, 100); // Create the image
white = gdImageColorAllocate(im, 255, 255, 255); // Alloc background
black = gdImageColorAllocate(im, 0, 0, 0); // Allocate drawing color
@@ -772,6 +771,7 @@ static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level)
png_color palette[gdMaxColors];
png_structp png_ptr;
png_infop info_ptr;
+ png_bytep *row_pointers = NULL;
volatile int transparent = im->transparent;
volatile int remap = FALSE;
#ifdef PNG_SETJMP_SUPPORTED
@@ -806,6 +806,13 @@ static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level)
if (setjmp(jbw.jmpbuf)) {
gd_error("gd-png error: setjmp returns error condition\n");
png_destroy_write_struct (&png_ptr, &info_ptr);
+
+ if (row_pointers) {
+ for (i = 0; i < height; ++i)
+ gdFree(row_pointers[i]);
+ gdFree(row_pointers);
+ }
+
return 1;
}
#endif
@@ -981,7 +988,6 @@ static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level)
/* performance optimizations by Phong Tran */
int channels = im->saveAlphaFlag ? 4 : 3;
/* Our little 7-bit alpha channel trick costs us a bit here. */
- png_bytep *row_pointers;
unsigned char *pOutputRow;
int **ptpixels = im->tpixels;
int *pThisRow;
@@ -993,7 +999,8 @@ static int _gdImagePngCtxEx(gdImagePtr im, gdIOCtx * outfile, int level)
ret = 1;
goto bail;
}
- row_pointers = gdMalloc (sizeof (png_bytep) * height);
+ /* Need to use calloc so we can clean it up sanely in the error handler. */
+ row_pointers = gdCalloc(height, sizeof (png_bytep));
if (row_pointers == NULL) {
gd_error("gd-png error: unable to allocate row_pointers\n");
ret = 1;
@@ -1082,5 +1089,57 @@ bail:
return ret;
}
+#else /* !HAVE_LIBPNG */
+
+static void _noPngError(void)
+{
+ gd_error("PNG image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * inFile)
+{
+ _noPngError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data)
+{
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtx * infile)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * outFile, int level)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * outFile)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level)
+{
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
+{
+ _noPngError();
+}
+
+BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level)
+{
+ _noPngError();
+}
#endif /* HAVE_LIBPNG */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_tga.c b/Build/source/libs/gd/libgd-src/src/gd_tga.c
index f80f0b16fb8..cae9428da50 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_tga.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_tga.c
@@ -206,7 +206,7 @@ int read_header_tga(gdIOCtx *ctx, oTga *tga)
int read_image_tga( gdIOCtx *ctx, oTga *tga )
{
int pixel_block_size = (tga->bits / 8);
- int image_block_size = (tga->width * tga->height) * pixel_block_size;
+ int image_block_size;
int* decompression_buffer = NULL;
unsigned char* conversion_buffer = NULL;
int buffer_caret = 0;
@@ -223,6 +223,7 @@ int read_image_tga( gdIOCtx *ctx, oTga *tga )
return -1;
}
+ image_block_size = (tga->width * tga->height) * pixel_block_size;
if(overflow2(image_block_size, sizeof(int))) {
return -1;
}
diff --git a/Build/source/libs/gd/libgd-src/src/gd_tiff.c b/Build/source/libs/gd/libgd-src/src/gd_tiff.c
index ae65ed7d5e2..4020a6f7054 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_tiff.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_tiff.c
@@ -27,7 +27,6 @@
----------------------------------------------------------------------------
*/
-/* $Id$ */
/**
* File: TIFF IO
@@ -790,7 +789,7 @@ static int createFromTiffRgba(TIFF * tif, gdImagePtr im)
rgba = buffer[(y * width + x)];
a = (0xff - TIFFGetA(rgba)) / 2;
color = gdTrueColorAlpha(TIFFGetR(rgba), TIFFGetG(rgba), TIFFGetB(rgba), a);
-
+
/* set pixel colour to this colour */
gdImageSetPixel(im, x, height - y - 1, color);
}
@@ -993,10 +992,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
goto error;
}
- if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &res_float)) {
+ if (TIFFGetField(tif, TIFFTAG_XRESOLUTION, &res_float)) {
im->res_x = (unsigned int)res_float; //truncate
}
- if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &res_float)) {
+ if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &res_float)) {
im->res_y = (unsigned int)res_float; //truncate
}
@@ -1070,4 +1069,45 @@ BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size)
return rv;
}
+#else
+
+static void _noTiffError(void)
+{
+ gd_error("TIFF image support has been disabled\n");
+}
+
+BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out)
+{
+ _noTiffError();
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data)
+{
+ _noTiffError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile)
+{
+ _noTiffError();
+}
+
+BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size)
+{
+ _noTiffError();
+ return NULL;
+}
+
#endif
diff --git a/Build/source/libs/gd/libgd-src/src/gd_topal.c b/Build/source/libs/gd/libgd-src/src/gd_topal.c
index 3419512eee2..5ac226ae8fd 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_topal.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_topal.c
@@ -1383,7 +1383,7 @@ zeroHistogram (hist3d histogram)
* method - The quantization method, see <gdPaletteQuantizationMethod>.
* speed - The quantization speed between 1 (highest quality) and
* 10 (fastest). 0 selects a method-specific default (recommended).
- *
+ *
* Returns:
* Zero if the given method is invalid or not available; non-zero otherwise.
*
@@ -1451,7 +1451,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
*
* Returns:
* A newly create palette image; NULL on failure.
- *
+ *
* See also:
* - <gdImageCreatePaletteFromTrueColor>
* - <gdImageTrueColorToPaletteSetMethod>
@@ -1523,6 +1523,15 @@ static void free_truecolor_image_data(gdImagePtr oim)
oim->tpixels = 0;
}
+#ifdef HAVE_LIBIMAGEQUANT
+/* liq requires 16 byte aligned heap memory */
+static void *malloc16(size_t size)
+{
+ void *p;
+ return posix_memalign(&p, 16, size) == 0 ? p : NULL;
+}
+#endif
+
/*
* Module initialization routine for 2-pass color quantization.
*/
@@ -1586,7 +1595,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
nim = gdImageNeuQuant(oim, colorsWanted, oim->paletteQuantizationSpeed ? oim->paletteQuantizationSpeed : 2);
if (cimP) {
*cimP = nim;
- }
+ }
if (!nim) {
return FALSE;
} else {
@@ -1601,7 +1610,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors
#ifdef HAVE_LIBIMAGEQUANT
if (oim->paletteQuantizationMethod == GD_QUANT_DEFAULT ||
oim->paletteQuantizationMethod == GD_QUANT_LIQ) {
- liq_attr *attr = liq_attr_create_with_allocator(gdMalloc, gdFree);
+ liq_attr *attr = liq_attr_create_with_allocator(malloc16, free);
liq_image *image;
liq_result *remap;
int remapped_ok = 0;
diff --git a/Build/source/libs/gd/libgd-src/src/gd_transform.c b/Build/source/libs/gd/libgd-src/src/gd_transform.c
index 1a96daaf438..fae1a5851ff 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_transform.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_transform.c
@@ -120,5 +120,3 @@ BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im)
gdImageFlipVertical(im);
gdImageFlipHorizontal(im);
}
-
-
diff --git a/Build/source/libs/gd/libgd-src/src/gd_wbmp.c b/Build/source/libs/gd/libgd-src/src/gd_wbmp.c
index 0028273d656..a49bdbecbb1 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_wbmp.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_wbmp.c
@@ -88,6 +88,8 @@ int gd_getin(void *in)
return (gdGetC((gdIOCtx *)in));
}
+static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
+
/*
Function: gdImageWBMPCtx
@@ -101,13 +103,19 @@ int gd_getin(void *in)
*/
BGD_DECLARE(void) gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
{
+ _gdImageWBMPCtx(image, fg, out);
+}
+
+/* returns 0 on success, 1 on failure */
+static int _gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
+{
int x, y, pos;
Wbmp *wbmp;
/* create the WBMP */
if((wbmp = createwbmp(gdImageSX(image), gdImageSY(image), WBMP_WHITE)) == NULL) {
gd_error("Could not create WBMP\n");
- return;
+ return 1;
}
/* fill up the WBMP structure */
@@ -123,18 +131,22 @@ BGD_DECLARE(void) gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out)
/* write the WBMP to a gd file descriptor */
if(writewbmp(wbmp, &gd_putout, out)) {
+ freewbmp(wbmp);
gd_error("Could not save WBMP\n");
+ return 1;
}
/* des submitted this bugfix: gdFree the memory. */
freewbmp(wbmp);
+
+ return 0;
}
/*
Function: gdImageCreateFromWBMPCtx
Reads in a WBMP image via a <gdIOCtx> struct. See
- <gdImageCreateFromWBMP>.
+ <gdImageCreateFromWBMP>.
*/
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx(gdIOCtx *infile)
{
@@ -271,8 +283,11 @@ BGD_DECLARE(void *) gdImageWBMPPtr(gdImagePtr im, int *size, int fg)
void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) return NULL;
- gdImageWBMPCtx(im, fg, out);
- rv = gdDPExtractData(out, size);
+ if (!_gdImageWBMPCtx(im, fg, out)) {
+ rv = gdDPExtractData(out, size);
+ } else {
+ rv = NULL;
+ }
out->gd_free(out);
return rv;
}
diff --git a/Build/source/libs/gd/libgd-src/src/gd_webp.c b/Build/source/libs/gd/libgd-src/src/gd_webp.c
index b5ee2642634..ab15109d548 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_webp.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_webp.c
@@ -9,7 +9,6 @@
#endif /* HAVE_CONFIG_H */
-#ifdef HAVE_LIBWEBP
#include <stdio.h>
#include <math.h>
#include <string.h>
@@ -17,6 +16,8 @@
#include "gd.h"
#include "gd_errors.h"
#include "gdhelpers.h"
+
+#ifdef HAVE_LIBWEBP
#include "webp/decode.h"
#include "webp/encode.h"
@@ -212,7 +213,7 @@ static int _gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
}
*(p++) = gdTrueColorGetRed(c);
*(p++) = gdTrueColorGetGreen(c);
- *(p++) = gdTrueColorGetBlue(c);
+ *(p++) = gdTrueColorGetBlue(c);
*(p++) = a;
}
}
@@ -360,4 +361,57 @@ BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
out->gd_free(out);
return rv;
}
+
+#else /* !HAVE_LIBWEBP */
+
+static void _noWebpError(void)
+{
+ gd_error("WEBP image support has been disabled\n");
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quality)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)
+{
+ _noWebpError();
+}
+
+BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size)
+{
+ _noWebpError();
+ return NULL;
+}
+
+BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
+{
+ _noWebpError();
+ return NULL;
+}
+
#endif /* HAVE_LIBWEBP */
diff --git a/Build/source/libs/gd/libgd-src/src/gd_xbm.c b/Build/source/libs/gd/libgd-src/src/gd_xbm.c
index 29bc5c2e8d5..cf0545efdb4 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_xbm.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_xbm.c
@@ -169,7 +169,11 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm(FILE * fd)
}
h[3] = ch;
}
- sscanf(h, "%x", &b);
+ if (sscanf(h, "%x", &b) != 1) {
+ gd_error("invalid XBM");
+ gdImageDestroy(im);
+ return 0;
+ }
for (bit = 1; bit <= max_bit; bit = bit << 1) {
gdImageSetPixel(im, x++, y, (b & bit) ? 1 : 0);
if (x == im->sx) {
@@ -220,7 +224,7 @@ static void gdCtxPrintf(gdIOCtx * out, const char *format, ...)
* gd - Which color to use as forground color. All pixels with another
* color are unset.
* out - The <gdIOCtx> to write the image file to.
- *
+ *
*/
BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out)
{
diff --git a/Build/source/libs/gd/libgd-src/src/gdcache.c b/Build/source/libs/gd/libgd-src/src/gdcache.c
index b264d6ef859..3aad153dc04 100644
--- a/Build/source/libs/gd/libgd-src/src/gdcache.c
+++ b/Build/source/libs/gd/libgd-src/src/gdcache.c
@@ -25,7 +25,9 @@
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c -lgd
+ * or
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c libgd.a
*
* The cache is implemented by a singly-linked list of elements
* each containing a pointer to a user struct that is being managed by
@@ -137,8 +139,13 @@ void * gdCacheGet(gdCache_head_t *head, void *keydata)
}
} else {
/* cache full - replace least-recently-used */
- /* preveprev becomes new end of list */
- prevprev->next = NULL;
+ if(!prevprev) {
+ /* cache size is 1 */
+ head->mru = NULL;
+ } else {
+ /* prevprev becomes new end of list */
+ prevprev->next = NULL;
+ }
elem = prev;
(*(head->gdCacheRelease))(elem->userdata);
}
@@ -192,7 +199,7 @@ static void cacheRelease(void *map)
gdFree((char *)map);
}
-int main(char *argv[], int argc)
+int main(int argc, char **argv)
{
gdCache_head_t *cacheTable;
int elem, key;
diff --git a/Build/source/libs/gd/libgd-src/src/gdcache.h b/Build/source/libs/gd/libgd-src/src/gdcache.h
index bf451dc6cc3..751a842154c 100644
--- a/Build/source/libs/gd/libgd-src/src/gdcache.h
+++ b/Build/source/libs/gd/libgd-src/src/gdcache.h
@@ -12,7 +12,9 @@ extern "C" {
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c -lgd
+ * or
+ * gcc -o gdcache -g -Wall -DTEST -DNEED_CACHE gdcache.c libgd.a
*
* The cache is implemented by a singly-linked list of elements
* each containing a pointer to a user struct that is being managed by
diff --git a/Build/source/libs/gd/libgd-src/src/gdcmpgif.c b/Build/source/libs/gd/libgd-src/src/gdcmpgif.c
index 737f7ba90b8..d440f717276 100644
--- a/Build/source/libs/gd/libgd-src/src/gdcmpgif.c
+++ b/Build/source/libs/gd/libgd-src/src/gdcmpgif.c
@@ -89,5 +89,3 @@ void CompareImages(char *msg, gdImagePtr im1, gdImagePtr im2)
printf("-%s: INFO actual colours of pixels differ\n",msg);
}
}
-
-
diff --git a/Build/source/libs/gd/libgd-src/src/gddemo.c b/Build/source/libs/gd/libgd-src/src/gddemo.c
index 28afd3c1d12..69d9d35ddd3 100644
--- a/Build/source/libs/gd/libgd-src/src/gddemo.c
+++ b/Build/source/libs/gd/libgd-src/src/gddemo.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -16,7 +15,6 @@
int
main (void)
{
-#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
FILE *out;
@@ -181,8 +179,5 @@ main (void)
if (im_in) {
gdImageDestroy (im_in);
}
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/Build/source/libs/gd/libgd-src/src/gdfontg.c b/Build/source/libs/gd/libgd-src/src/gdfontg.c
index 2adf6da7995..2fe71662cf9 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfontg.c
+++ b/Build/source/libs/gd/libgd-src/src/gdfontg.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.51 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/Build/source/libs/gd/libgd-src/src/gdfontl.c b/Build/source/libs/gd/libgd-src/src/gdfontl.c
index 97f7a65863d..f7ce2726375 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfontl.c
+++ b/Build/source/libs/gd/libgd-src/src/gdfontl.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/Build/source/libs/gd/libgd-src/src/gdfontmb.c b/Build/source/libs/gd/libgd-src/src/gdfontmb.c
index debee4e3105..ed0f1ace780 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfontmb.c
+++ b/Build/source/libs/gd/libgd-src/src/gdfontmb.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/Build/source/libs/gd/libgd-src/src/gdfontt.c b/Build/source/libs/gd/libgd-src/src/gdfontt.c
index e7bb3458e16..1fb96e14e25 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfontt.c
+++ b/Build/source/libs/gd/libgd-src/src/gdfontt.c
@@ -1,5 +1,3 @@
-
-
/*
This is a header file for gd font, generated using
bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
diff --git a/Build/source/libs/gd/libgd-src/src/gdft.c b/Build/source/libs/gd/libgd-src/src/gdft.c
index d989ecc3873..98e74fa346c 100644
--- a/Build/source/libs/gd/libgd-src/src/gdft.c
+++ b/Build/source/libs/gd/libgd-src/src/gdft.c
@@ -1,4 +1,3 @@
-
/********************************************/
/* gd interface to freetype library */
/* */
@@ -72,9 +71,7 @@ static char *font_path(char **fontpath, char *name_list);
*/
#ifndef DEFAULT_FONTPATH
-# ifdef NETWARE
-# define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;."
-# elif defined(_WIN32)
+# if defined(_WIN32)
# define DEFAULT_FONTPATH "C:\\WINDOWS\\FONTS;C:\\WINNT\\FONTS"
# elif defined(__APPLE__) || (defined(__MWERKS__) && defined(macintosh))
# define DEFAULT_FONTPATH "/usr/share/fonts/truetype:/System/Library/Fonts:/Library/Fonts"
@@ -85,7 +82,7 @@ static char *font_path(char **fontpath, char *name_list);
#endif
#ifndef PATHSEPARATOR
-# if defined(NETWARE) || defined(_WIN32)
+# if defined(_WIN32)
# define PATHSEPARATOR ";"
# else
# define PATHSEPARATOR ":"
@@ -103,8 +100,8 @@ static char *font_path(char **fontpath, char *name_list);
*
* Alias of <gdImageStringFT>.
*/
-BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
/* 2.0.6: valid return */
return gdImageStringFT (im, brect, fg, fontlist, ptsize,
@@ -112,8 +109,8 @@ BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fo
}
#ifndef HAVE_LIBFREETYPE
-BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string,
+BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string,
gdFTStringExtraPtr strex)
{
(void)im;
@@ -130,8 +127,8 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
return "libgd was not built with FreeType font support\n";
}
-BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
(void)im;
(void)brect;
@@ -184,7 +181,7 @@ typedef struct {
font_t;
typedef struct {
- char *fontlist; /* key */
+ const char *fontlist; /* key */
int flags; /* key */
FT_Library *library;
}
@@ -260,7 +257,7 @@ static int comp_entities(const void *e1, const void *e2)
return strcmp(en1->name, en2->name);
}
-extern int any2eucjp (char *, char *, unsigned int);
+extern int any2eucjp (char *, const char *, unsigned int);
/* Persistent font cache until explicitly cleared */
/* Fonts can be used across multiple images */
@@ -273,7 +270,7 @@ static FT_Library library;
#define Tcl_UniChar int
#define TCL_UTF_MAX 3
static int
-gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
+gdTcl_UtfToUniChar (const char *str, Tcl_UniChar * chPtr)
/* str is the UTF8 next character pointer */
/* chPtr is the int for the result */
{
@@ -432,6 +429,107 @@ gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
return 1;
}
+#ifdef HAVE_LIBRAQM
+#include <raqm.h>
+#endif
+
+typedef struct {
+ unsigned int index;
+ FT_Pos x_advance;
+ FT_Pos x_offset;
+ FT_Pos y_offset;
+ uint32_t cluster;
+} glyphInfo;
+
+static size_t
+textLayout(uint32_t *text, int len,
+ FT_Face face, gdFTStringExtraPtr strex,
+ glyphInfo **glyph_info)
+{
+ size_t count;
+ glyphInfo *info;
+
+#ifdef HAVE_LIBRAQM
+ size_t i;
+ raqm_glyph_t *glyphs;
+ raqm_t *rq = raqm_create ();
+
+ if (!rq || !raqm_set_text (rq, text, len) ||
+ !raqm_set_freetype_face (rq, face) ||
+ !raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) ||
+ !raqm_layout (rq)) {
+ raqm_destroy (rq);
+ return 0;
+ }
+
+ glyphs = raqm_get_glyphs (rq, &count);
+ if (!glyphs) {
+ raqm_destroy (rq);
+ return 0;
+ }
+
+ info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count);
+ if (!info) {
+ raqm_destroy (rq);
+ return 0;
+ }
+
+ for (i = 0; i < count; i++) {
+ info[i].index = glyphs[i].index;
+ info[i].x_offset = glyphs[i].x_offset;
+ info[i].y_offset = glyphs[i].y_offset;
+ info[i].x_advance = glyphs[i].x_advance;
+ info[i].cluster = glyphs[i].cluster;
+ }
+
+ raqm_destroy (rq);
+#else
+ FT_UInt glyph_index = 0, previous = 0;
+ FT_Vector delta;
+ FT_Error err;
+ info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len);
+ if (!info) {
+ return 0;
+ }
+ for (count = 0; count < len; count++) {
+ /* Convert character code to glyph index */
+ glyph_index = FT_Get_Char_Index (face, text[count]);
+
+ /* retrieve kerning distance */
+ if (! (strex && (strex->flags & gdFTEX_DISABLE_KERNING))
+ && ! FT_IS_FIXED_WIDTH(face)
+ && FT_HAS_KERNING(face)
+ && previous
+ && glyph_index)
+ FT_Get_Kerning (face, previous, glyph_index, ft_kerning_default, &delta);
+ else
+ delta.x = delta.y = 0;
+
+ err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
+ if (err) {
+ gdFree (info);
+ return 0;
+ }
+ info[count].index = glyph_index;
+ info[count].x_offset = 0;
+ info[count].y_offset = 0;
+ if (delta.x != 0)
+ info[count - 1].x_advance += delta.x;
+ info[count].x_advance = face->glyph->metrics.horiAdvance;
+ info[count].cluster = count;
+
+ /* carriage returns or newlines */
+ if (text[count] == '\r' || text[count] == '\n')
+ previous = 0; /* clear kerning flag */
+ else
+ previous = glyph_index;
+ }
+#endif
+
+ *glyph_info = info;
+ return count;
+}
+
/********************************************************************/
/* font cache functions */
@@ -475,7 +573,7 @@ fontFetch (char **error, void *key)
gdFree(a);
return "could not alloc full list of fonts";
}
- strncpy(a->fontlist, b->fontlist, b_font_list_len);
+ memcpy(a->fontlist, b->fontlist, b_font_list_len);
a->fontlist[b_font_list_len] = 0;
a->flags = b->flags;
@@ -824,8 +922,8 @@ BGD_DECLARE(void) gdFontCacheShutdown ()
* See also:
* - <gdImageString>
*/
-BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string)
+BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string)
{
return gdImageStringFTEx (im, brect, fg, fontlist,
ptsize, angle, x, y, string, 0);
@@ -872,13 +970,13 @@ BGD_DECLARE(int) gdFontCacheSetup (void)
typedef struct {
// logical OR of gdFTEX_ values
int flags;
-
+
// fine tune line spacing for '\n'
double linespacing;
-
+
// Preferred character mapping
int charmap;
-
+
// Rendering resolution
int hdpi;
int vdpi;
@@ -982,32 +1080,35 @@ BGD_DECLARE(int) gdFontCacheSetup (void)
> flags | gdFTEX_FONTPATHNAME;
- For more information, see <gdImageStringFT>.
+ For more information, see <gdImageStringFT>.
*/
/* the platform-independent resolution used for size and position calculations */
/* the size of the error introduced by rounding is affected by this number */
#define METRIC_RES 300
-BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y, char *string,
+BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
+ double ptsize, double angle, int x, int y, const char *string,
gdFTStringExtraPtr strex)
{
FT_Matrix matrix;
- FT_Vector penf, oldpenf, delta, total_min = {0,0}, total_max = {0,0}, glyph_min, glyph_max;
+ FT_Vector penf, oldpenf, total_min = {0,0}, total_max = {0,0}, glyph_min, glyph_max;
FT_Face face;
FT_CharMap charmap = NULL;
FT_Glyph image;
FT_GlyphSlot slot;
FT_Error err;
- FT_UInt glyph_index, previous;
+ FT_UInt glyph_index;
double sin_a = sin (angle);
double cos_a = cos (angle);
- int len, i, ch;
+ int i, ch;
font_t *font;
fontkey_t fontkey;
- char *next;
+ const char *next;
char *tmpstr = 0;
+ uint32_t *text;
+ glyphInfo *info = NULL;
+ size_t count;
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
FT_BitmapGlyph bm;
/* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing
@@ -1100,7 +1201,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
gdMutexUnlock(gdFontCacheMutex);
return "could not alloc full list of fonts";
}
- strncpy(strex->fontpath, font->fontpath, fontpath_len);
+ memcpy(strex->fontpath, font->fontpath, fontpath_len);
strex->fontpath[fontpath_len] = 0;
}
}
@@ -1220,31 +1321,11 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
oldpenf.x = oldpenf.y = 0; /* for postscript xshow operator */
penf.x = penf.y = 0; /* running position of non-rotated glyphs */
- previous = 0; /* index of previous glyph for kerning calculations */
- for (i=0; *next; i++) {
- FT_Activate_Size (platform_independent);
-
+ text = (uint32_t*) gdCalloc (sizeof (uint32_t), strlen(next));
+ i = 0;
+ while (*next) {
+ int len;
ch = *next;
-
- /* carriage returns */
- if (ch == '\r') {
- penf.x = 0;
- previous = 0; /* clear kerning flag */
- next++;
- continue;
- }
- /* newlines */
- if (ch == '\n') {
- /* 2.0.13: reset penf.x. Christopher J. Grayce */
- penf.x = 0;
- penf.y += linespace * ptsize * 64 * METRIC_RES / 72;
- penf.y &= ~63; /* round down to 1/METRIC_RES */
- previous = 0; /* clear kerning flag */
- next++;
- continue;
- }
-
-
switch (encoding) {
case gdFTEX_Unicode: {
/* use UTF-8 mapping from ASCII */
@@ -1320,22 +1401,43 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
next++;
break;
}
+ text[i] = ch;
+ i++;
+ }
- /* Convert character code to glyph index */
- glyph_index = FT_Get_Char_Index (face, ch);
+ FT_Activate_Size (platform_independent);
- /* retrieve kerning distance */
- if ( ! (strex && (strex->flags & gdFTEX_DISABLE_KERNING))
- && ! FT_IS_FIXED_WIDTH(face)
- && FT_HAS_KERNING(face)
- && previous
- && glyph_index)
- FT_Get_Kerning (face, previous, glyph_index, ft_kerning_default, &delta);
- else
- delta.x = delta.y = 0;
+ count = textLayout (text , i, face, strex, &info);
- penf.x += delta.x;
+ if (!count) {
+ gdFree (text);
+ gdFree (tmpstr);
+ gdCacheDelete (tc_cache);
+ gdMutexUnlock (gdFontCacheMutex);
+ return "Problem doing text layout";
+ }
+ for (i = 0; i < count; i++) {
+ FT_Activate_Size (platform_independent);
+
+ ch = text[info[i].cluster];
+
+ /* carriage returns */
+ if (ch == '\r') {
+ penf.x = 0;
+ continue;
+ }
+
+ /* newlines */
+ if (ch == '\n') {
+ /* 2.0.13: reset penf.x. Christopher J. Grayce */
+ penf.x = 0;
+ penf.y += linespace * ptsize * 64 * METRIC_RES / 72;
+ penf.y &= ~63; /* round down to 1/METRIC_RES */
+ continue;
+ }
+
+ glyph_index = info[i].index;
/* When we know the position of the second or subsequent character,
save the (kerned) advance from the preceeding character in the
xshow vector */
@@ -1348,6 +1450,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
if (!strex->xshow) {
if (tmpstr)
gdFree (tmpstr);
+ gdFree(text);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem allocating memory";
@@ -1359,6 +1462,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
if (!strex->xshow) {
if (tmpstr)
gdFree (tmpstr);
+ gdFree(text);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem allocating memory";
@@ -1374,12 +1478,13 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
if (err) {
if (tmpstr)
gdFree (tmpstr);
+ gdFree(text);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem loading glyph";
}
- horiAdvance = slot->metrics.horiAdvance;
+ horiAdvance = info[i].x_advance;
if (brect) {
/* only if need brect */
@@ -1414,6 +1519,8 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
}
if (render) {
+ FT_Pos pen_x;
+ FT_Pos pen_y;
FT_Activate_Size (platform_specific);
/* load glyph again into the slot (erase previous one) - this time with scaling */
@@ -1421,6 +1528,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
if (err) {
if (tmpstr)
gdFree (tmpstr);
+ gdFree(text);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem loading glyph";
@@ -1435,6 +1543,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
FT_Done_Glyph(image);
if (tmpstr)
gdFree (tmpstr);
+ gdFree(text);
gdCacheDelete (tc_cache);
gdMutexUnlock (gdFontCacheMutex);
return "Problem rendering glyph";
@@ -1445,19 +1554,22 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
bm = (FT_BitmapGlyph) image;
/* position rounded down to nearest pixel at current dpi
(the estimate was rounded up to next 1/METRIC_RES, so this should fit) */
+ pen_x = penf.x + info[i].x_offset;
+ pen_y = penf.y - info[i].y_offset;
gdft_draw_bitmap (tc_cache, im, fg, bm->bitmap,
- (int)(x + (penf.x * cos_a + penf.y * sin_a)*hdpi/(METRIC_RES*64) + bm->left),
- (int)(y - (penf.x * sin_a - penf.y * cos_a)*vdpi/(METRIC_RES*64) - bm->top));
+ (int)(x + (pen_x * cos_a + pen_y * sin_a)*hdpi/(METRIC_RES*64) + bm->left),
+ (int)(y - (pen_x * sin_a - pen_y * cos_a)*vdpi/(METRIC_RES*64) - bm->top));
FT_Done_Glyph (image);
}
- /* record current glyph index for kerning */
- previous = glyph_index;
penf.x += horiAdvance;
}
+ gdFree(text);
+ gdFree(info);
+
/* Save the (unkerned) advance from the last character in the xshow vector */
if (strex && (strex->flags & gdFTEX_XSHOW) && strex->xshow) {
sprintf(strex->xshow + xshow_pos, "%g",
@@ -1469,12 +1581,6 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *f
double scalex = (double)hdpi / (64 * METRIC_RES);
double scaley = (double)vdpi / (64 * METRIC_RES);
- /* increase by 1 pixel to allow for rounding */
- total_min.x -= METRIC_RES;
- total_min.y -= METRIC_RES;
- total_max.x += METRIC_RES;
- total_max.y += METRIC_RES;
-
/* rotate bounding rectangle, scale and round to int pixels, and translate */
brect[0] = x + (total_min.x * cos_a + total_max.y * sin_a)*scalex;
brect[1] = y - (total_min.x * sin_a - total_max.y * cos_a)*scaley;
@@ -1656,7 +1762,7 @@ static char * font_pattern(char **fontpath, char *fontpattern)
if (*fontpath == NULL) {
return "could not alloc font path";
}
- strncpy(*fontpath, (const char *)file, file_len);
+ memcpy(*fontpath, (const char *)file, file_len);
(*fontpath)[file_len] = 0;
}
FcPatternDestroy(font);
@@ -1685,11 +1791,11 @@ static char * font_path(char **fontpath, char *name_list)
fontsearchpath = getenv ("GDFONTPATH");
#ifdef _WIN32
if (!fontsearchpath) {
- char *ffptr = getenv ("SYSTEMROOT");
+ char *ffptr = getenv ("WINDIR");
if (ffptr) {
- fontsearchpath = malloc (strlen(ffptr) + strlen("\\fonts") + 1);
+ fontsearchpath = malloc (strlen(ffptr) + strlen("\\Fonts") + 1);
strcpy(fontsearchpath, ffptr);
- strcat(fontsearchpath, "\\fonts");
+ strcat(fontsearchpath, "\\Fonts");
}
}
#endif
@@ -1706,7 +1812,7 @@ static char * font_path(char **fontpath, char *name_list)
gdFree(path);
return "could not alloc full list of fonts";
}
- strncpy(fontlist, name_list, name_list_len);
+ memcpy(fontlist, name_list, name_list_len);
fontlist[name_list_len] = 0;
/*
@@ -1731,14 +1837,9 @@ static char * font_path(char **fontpath, char *name_list)
return "could not alloc full path of font";
}
/* if name is an absolute or relative pathname then test directly */
-#ifdef NETWARE
- /* netware uses the format "volume:/path" or the standard "/path" */
- if (name[0] != 0 && (strstr(name, ":/") || name[0] == '/'))
-#else
if (strchr (name, '/')
|| (name[0] != 0 && name[1] == ':'
&& (name[2] == '/' || name[2] == '\\')))
-#endif
{
sprintf (fullname, "%s", name);
if (access (fullname, R_OK) == 0) {
@@ -1820,4 +1921,3 @@ BGD_DECLARE(int) gdFTUseFontConfig(int flag)
return 0;
#endif /* HAVE_LIBFONTCONFIG */
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/gdfx.c b/Build/source/libs/gd/libgd-src/src/gdfx.c
index d71a3421b2c..557f51c4653 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfx.c
+++ b/Build/source/libs/gd/libgd-src/src/gdfx.c
@@ -522,4 +522,3 @@ gdImageSharpen (gdImagePtr im, int pct)
}
}
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/gdfx.h b/Build/source/libs/gd/libgd-src/src/gdfx.h
index dbd74984ebe..b00f573a609 100644
--- a/Build/source/libs/gd/libgd-src/src/gdfx.h
+++ b/Build/source/libs/gd/libgd-src/src/gdfx.h
@@ -1,10 +1,10 @@
+#ifndef GDFX_H
+#define GDFX_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef GDFX_H
-#define GDFX_H 1
-
BGD_DECLARE(gdImagePtr) gdImageSquareToCircle(gdImagePtr im, int radius);
BGD_DECLARE(char *) gdImageStringFTCircle(
@@ -22,9 +22,8 @@ BGD_DECLARE(char *) gdImageStringFTCircle(
BGD_DECLARE(void) gdImageSharpen (gdImagePtr im, int pct);
-#endif /* GDFX_H */
-
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GDFX_H */
diff --git a/Build/source/libs/gd/libgd-src/src/gdhelpers.c b/Build/source/libs/gd/libgd-src/src/gdhelpers.c
index 20fff5c0356..de7a0a39c8e 100644
--- a/Build/source/libs/gd/libgd-src/src/gdhelpers.c
+++ b/Build/source/libs/gd/libgd-src/src/gdhelpers.c
@@ -114,5 +114,3 @@ BGD_DECLARE(void) gdFree (void *ptr)
{
free (ptr);
}
-
-
diff --git a/Build/source/libs/gd/libgd-src/src/gdhelpers.h b/Build/source/libs/gd/libgd-src/src/gdhelpers.h
index 2a96b8b4e55..9c7ef104c28 100644
--- a/Build/source/libs/gd/libgd-src/src/gdhelpers.h
+++ b/Build/source/libs/gd/libgd-src/src/gdhelpers.h
@@ -1,10 +1,10 @@
+#ifndef GDHELPERS_H
+#define GDHELPERS_H 1
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef GDHELPERS_H
-#define GDHELPERS_H 1
-
/* sys/types.h is needed for size_t on Sparc-SunOS-4.1 */
#ifndef _WIN32_WCE
#include <sys/types.h>
@@ -69,8 +69,8 @@ extern "C" {
#define DPI2DPCM(dpi) (unsigned int)((dpi)/2.54 + 0.5)
#define DPI2DPM(dpi) (unsigned int)((dpi)/0.0254 + 0.5)
-#endif /* GDHELPERS_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* GDHELPERS_H */
diff --git a/Build/source/libs/gd/libgd-src/src/gdkanji.c b/Build/source/libs/gd/libgd-src/src/gdkanji.c
index f05187e4580..c670d986433 100644
--- a/Build/source/libs/gd/libgd-src/src/gdkanji.c
+++ b/Build/source/libs/gd/libgd-src/src/gdkanji.c
@@ -11,11 +11,7 @@
#include "gd.h"
#include "gdhelpers.h"
#include "gd_errors.h"
-
-#ifdef HAVE_ERRNO_H
#include <errno.h>
-#endif
-
#include <stdarg.h>
#if defined(HAVE_ICONV_H)
#include <iconv.h>
@@ -98,7 +94,7 @@ iconv_close (iconv_t cd)
/* DetectKanjiCode() derived from DetectCodeType() by Ken Lunde. */
static int
-DetectKanjiCode (unsigned char *str)
+DetectKanjiCode (const unsigned char *str)
{
static int whatcode = ASCII;
int oldcode = ASCII;
@@ -146,7 +142,7 @@ DetectKanjiCode (unsigned char *str)
whatcode = EUCORSJIS;
else if (c >= 224 && c <= 239) {
whatcode = EUCORSJIS;
- while (c >= 64 && c != '\0' && whatcode == EUCORSJIS) {
+ while (c >= 64 && whatcode == EUCORSJIS) {
if (c >= 129) {
if (c <= 141 || (c >= 143 && c <= 159))
whatcode = SJIS;
@@ -334,20 +330,20 @@ han2zen (int *p1, int *p2)
#define ustrncpy(A,B, maxsize) (strncpy((char*)(A),(const char*)(B), maxsize))
static void
-do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
+do_convert (unsigned char **to_p, const unsigned char **from_p, const char *code)
{
unsigned char *to = *to_p;
- unsigned char *from = *from_p;
+ const unsigned char *from = *from_p;
#ifdef HAVE_ICONV
iconv_t cd;
size_t from_len, to_len;
if ((cd = iconv_open (EUCSTR, code)) == (iconv_t) - 1) {
gd_error ("iconv_open() error");
-#ifdef HAVE_ERRNO_H
+
if (errno == EINVAL)
gd_error ("invalid code specification: \"%s\" or \"%s\"", EUCSTR, code);
-#endif
+
ustrcpy (to, from);
return;
}
@@ -357,7 +353,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
if ((int) (iconv (cd, (char **)from_p, &from_len, (char **)to_p, &to_len))
== -1) {
-#ifdef HAVE_ERRNO_H
+
if (errno == EINVAL)
gd_error ("invalid end of input string");
else if (errno == EILSEQ)
@@ -365,7 +361,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
else if (errno == E2BIG)
gd_error ("output buffer overflow at do_convert()");
else
-#endif
+
gd_error ("something happen");
ustrcpy (to, from);
return;
@@ -436,7 +432,7 @@ do_convert (unsigned char **to_p, unsigned char **from_p, const char *code)
}
static int
-do_check_and_conv (unsigned char *to, unsigned char *from)
+do_check_and_conv (unsigned char *to, const unsigned char *from)
{
static unsigned char tmp[BUFSIZ];
unsigned char *tmp_p = &tmp[0];
@@ -527,7 +523,7 @@ do_check_and_conv (unsigned char *to, unsigned char *from)
}
int
-any2eucjp (unsigned char *dest, unsigned char *src, unsigned int dest_max)
+any2eucjp (unsigned char *dest, const unsigned char *src, unsigned int dest_max)
{
static unsigned char tmp_dest[BUFSIZ];
int ret;
diff --git a/Build/source/libs/gd/libgd-src/src/gdparttopng.c b/Build/source/libs/gd/libgd-src/src/gdparttopng.c
index 42d6df20368..4bf2fc82778 100644
--- a/Build/source/libs/gd/libgd-src/src/gdparttopng.c
+++ b/Build/source/libs/gd/libgd-src/src/gdparttopng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -49,11 +48,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/Build/source/libs/gd/libgd-src/src/gdpp.cxx b/Build/source/libs/gd/libgd-src/src/gdpp.cxx
index a8101fca29f..5e579da1fb3 100644
--- a/Build/source/libs/gd/libgd-src/src/gdpp.cxx
+++ b/Build/source/libs/gd/libgd-src/src/gdpp.cxx
@@ -1,12 +1,11 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
*******************************************************************************/
/** \file gdpp.cxx
\brief Implements the non-trivial methods of GD::Image.
-
+
Implementation of the more complex methods defined
in gdpp.h.
Notably includes the methods which determine the image file
@@ -19,13 +18,13 @@ namespace GD
{
/**
Load an image from a file, after attempting to
- determine it's image file format.
+ determine it's image file format.
Invoke CreateFrom with an already opened
- pointer to a file containing the desired image.
+ pointer to a file containing the desired image.
CreateFrom does not close the file.
\param[in] in An opened FILE * pointer.
- \return true for success, or false if unable to load the image (most often because the
- file is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ file is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
*/
bool Image::CreateFrom(FILE * in)
@@ -40,50 +39,47 @@ namespace GD
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
== .PNG\r\n.\n
*/
-#ifdef HAVE_LIBPNG
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
-#endif
+
/* GIF
0x47 0x49 0x46
*/
case 0x47: // GIF
rtn = CreateFromGif(in);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(in);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(in);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
/* XBM
#define test_width 16
#define test_height 7
- */
+ */
case 0x23: // XBM
rtn = CreateFromXbm(in);
break;
@@ -91,18 +87,18 @@ namespace GD
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
/**
Load an image from a standard input stream, after attempting to
- determine it's image file format.
+ determine it's image file format.
Invoke CreateFrom with an already opened stream
- containing the desired image.
+ containing the desired image.
CreateFrom does not close the stream.
\param[in] in An opened standard library input stream.
- \return true for success, or false if unable to load the image (most often because the
- file is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ file is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
Example usage, convert anything to gif:
#include <fstream>
@@ -122,7 +118,6 @@ namespace GD
bool rtn;
switch (in.peek())
{
-#ifdef HAVE_LIBPNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@@ -131,7 +126,6 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(in);
break;
-#endif
/* GIF
0x47 0x49 0x46
@@ -140,51 +134,49 @@ namespace GD
rtn = CreateFromGif(in);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(in);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(in);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(in);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
default:
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
/**
Load an image from an in-RAM memory block, after attempting to
- determine it's image format.
+ determine it's image format.
CreateFrom does not de-allocate the memory.
\param[in] size The byte count of the memory block.
\param[in] data A pointer to the memory block.
- \return true for success, or false if unable to load the image (most often because the
- formatting is corrupt or does not contain a recognized image format).
+ \return true for success, or false if unable to load the image (most often because the
+ formatting is corrupt or does not contain a recognized image format).
You can call Width() and Height() member functions of the image to determine its size.
*/
bool Image::CreateFrom(int size, void * data)
@@ -193,7 +185,6 @@ namespace GD
switch (((unsigned char * )data)[0])
{
-#ifdef HAVE_LIBPNG
/* PNG
The first eight bytes of a PNG file always contain the following (decimal) values:
0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A
@@ -202,7 +193,7 @@ namespace GD
case 0x89: // PNG
rtn = CreateFromPng(size, data);
break;
-#endif
+
/* GIF
0x47 0x49 0x46
*/
@@ -210,45 +201,43 @@ namespace GD
rtn = CreateFromGif(size, data);
break;
-#ifdef HAVE_LIBJPEG
/* JPEG
A JFIF-standard file will start with the four bytes (hex) FF D8 FF E0,
- followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
+ followed by two variable bytes (often hex 00 10), followed by 'JFIF'.
*/
case 0xFF: // JPEG
rtn = CreateFromJpeg(size, data);
break;
-#endif
/* WBMP
- WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
+ WBMP Type 0: B/W, Uncompressed bitmap is the only gd supported type
*/
case 0x00: // WBMP
rtn = CreateFromWBMP(size, data);
break;
/* GD2
- 0x67 0x64 0x32 0x00
+ 0x67 0x64 0x32 0x00
== GD2\0
- Starts with gd2
+ Starts with gd2
*/
case 0x67: // GD2
rtn = CreateFromGd2(size, data);
break;
/* GD
0xFF 0xFE
- or
- 0xFF 0xFF
+ or
+ 0xFF 0xFF
Conflicts with Jpeg
*/
default:
rtn = false;
break;
}
- return rtn;
+ return rtn;
}
} // namespace GD
/**
- Load an image from a standard input stream, regardless of it's image file format.
+ Load an image from a standard input stream, regardless of it's image file format.
You can call Width() and Height() member functions of the image to determine its size.
Example usage, convert anything to gif:
#include <fstream>
diff --git a/Build/source/libs/gd/libgd-src/src/gdpp.h b/Build/source/libs/gd/libgd-src/src/gdpp.h
index 2ebda162e1c..3d58d899eed 100644
--- a/Build/source/libs/gd/libgd-src/src/gdpp.h
+++ b/Build/source/libs/gd/libgd-src/src/gdpp.h
@@ -1,5 +1,4 @@
/* *****************************************************************************
-** $Id$
** Initial file written and documented by:
** Kevin Shepherd <kshepherd@php.net> December 2007
** of Scarlet Line http://www.scarletline.com/
@@ -20,13 +19,9 @@
im.Gif(out);
}
*/
-#ifdef __cplusplus
#ifndef _gdpp_h
#define _gdpp_h
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#ifdef __cplusplus
#include "gd_io_stream.h"
#include <string>
@@ -292,7 +287,7 @@ public:
:im(0) {
CreateFrom(size, data);
}
-#ifdef HAVE_LIBPNG
+
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
@@ -330,7 +325,6 @@ public:
:im(0) {
CreateFromPng(size, data);
}
-#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@@ -408,7 +402,6 @@ public:
CreateFromWBMP(size, data);
}
-#ifdef HAVE_LIBJPEG
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
@@ -446,7 +439,6 @@ public:
:im(0) {
CreateFromJpeg(size, data);
}
-#endif
/** Construct an image by reading from \p in.
The tag is an empty struct which simply tells the compiler which image read function to use.
@@ -608,7 +600,6 @@ public:
/// Read an image from a memory block, after determining the image format
bool CreateFrom(int size, void * data);
-#ifdef HAVE_LIBPNG
// Png
bool CreateFromPng(FILE * in) {
clear();
@@ -627,7 +618,6 @@ public:
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
}
-#endif
// Gif
bool CreateFromGif(FILE * in) {
@@ -666,7 +656,6 @@ public:
return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
}
-#ifdef HAVE_LIBJPEG
// Jpeg
/**
Load a truecolor image from a JPEG format file.
@@ -720,7 +709,6 @@ public:
istreamIOCtx _in_ctx(in);
return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
}
-#endif
// Gd
bool CreateFromGd(FILE * in) {
@@ -1089,7 +1077,6 @@ public:
gdImageGifCtx(im, & _out_ctx);
}
-#ifdef HAVE_LIBPNG
/**
Write out this image in PNG file format to \p out.
\param out A FILE * handle
@@ -1154,7 +1141,6 @@ public:
ostreamIOCtx _out_ctx(out);
gdImagePngCtxEx(im, & _out_ctx, level);
}
-#endif
/**
Write out this image in WBMP file format ( black and white only ) to \p out.
@@ -1191,7 +1177,6 @@ public:
gdImageWBMPCtx(im, fg, & _out_ctx);
}
-#ifdef HAVE_LIBJPEG
/**
Write out this image in JPEG file format to \p out.
\param out A FILE * handle
@@ -1226,7 +1211,6 @@ public:
ostreamIOCtx _out_ctx(out);
gdImageJpegCtx(im, & _out_ctx, quality);
}
-#endif
void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const {
gdImageGifAnimBegin(im, out, GlobalCM, Loops);
@@ -1542,5 +1526,5 @@ protected:
/// Read in an image from a standard library input stream
std::istream & operator>> (std::istream & in, GD::Image & img);
-#endif /* _gdpp_h */
#endif /* __cplusplus */
+#endif /* _gdpp_h */
diff --git a/Build/source/libs/gd/libgd-src/src/gdtables.c b/Build/source/libs/gd/libgd-src/src/gdtables.c
index 7753b21a4b3..d368b8d9b78 100644
--- a/Build/source/libs/gd/libgd-src/src/gdtables.c
+++ b/Build/source/libs/gd/libgd-src/src/gdtables.c
@@ -1,4 +1,3 @@
-
const int gdCosT[] = {
1024,
1023,
diff --git a/Build/source/libs/gd/libgd-src/src/gdtest.c b/Build/source/libs/gd/libgd-src/src/gdtest.c
index 0f8febe077a..cf0eff5477c 100644
--- a/Build/source/libs/gd/libgd-src/src/gdtest.c
+++ b/Build/source/libs/gd/libgd-src/src/gdtest.c
@@ -24,7 +24,6 @@ static int fwriteWrapper (void *context, const char *buffer, int len);
int
main (int argc, char **argv)
{
-#ifdef HAVE_LIBPNG
gdImagePtr im, ref, im2, im3;
FILE *in, *out;
void *iptr;
@@ -87,12 +86,12 @@ main (int argc, char **argv)
}
im2 = gdImageCreateFromPng (in);
fclose (in);
-
+
if (!im2) {
fprintf(stderr, "gdImageCreateFromPng failed.\n");
exit (1);
}
-
+
CompareImages ("GD->PNG File->GD", ref, im2);
unlink (of);
@@ -196,7 +195,7 @@ main (int argc, char **argv)
fprintf(stderr, "gdImageCreateFromGdPtr failed.\n");
exit (1);
}
-
+
CompareImages ("GD->GD ptr->GD", ref, im2);
gdImageDestroy (im2);
@@ -409,9 +408,6 @@ main (int argc, char **argv)
}
gdImageDestroy (im);
gdImageDestroy (ref);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif /* HAVE_LIBPNG */
return 0;
}
diff --git a/Build/source/libs/gd/libgd-src/src/gdtestft.c b/Build/source/libs/gd/libgd-src/src/gdtestft.c
index 53945a636cf..f50b17491ba 100644
--- a/Build/source/libs/gd/libgd-src/src/gdtestft.c
+++ b/Build/source/libs/gd/libgd-src/src/gdtestft.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -26,13 +25,6 @@
int
main (int argc, char *argv[])
{
-#ifndef HAVE_LIBFREETYPE
- fprintf(stderr, "gd was not compiled with HAVE_LIBFREETYPE defined.\n");
- fprintf(stderr, "Install the FreeType library, including the\n");
- fprintf(stderr, "header files. Then edit the gd Makefile, type\n");
- fprintf(stderr, "make clean, and type make again.\n");
- return 1;
-#else
gdImagePtr im;
int blue;
int blueAlpha;
@@ -40,7 +32,6 @@ main (int argc, char *argv[])
int brect[8];
int x, y, sx, sy;
char *err;
- FILE *out;
#ifdef JISX0208
char *s = "Hello. ‚±‚ñ‚É‚¿‚Í Qyjpqg,"; /* String to draw. */
#else
@@ -155,7 +146,7 @@ main (int argc, char *argv[])
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
if (im->trueColor) {
#ifdef HAVE_LIBJPEG
- out = fopen ("test/fttest.jpg", "wb");
+ FILE *out = fopen ("test/fttest.jpg", "wb");
if (!out) {
fprintf(stderr, "Can't create test/fttest.jpg\n");
exit (1);
@@ -169,7 +160,7 @@ main (int argc, char *argv[])
#endif
} else {
#ifdef HAVE_LIBPNG
- out = fopen ("test/fttest.png", "wb");
+ FILE *out = fopen ("test/fttest.png", "wb");
if (!out) {
fprintf(stderr, "Can't create test/fttest.png\n");
exit (1);
@@ -186,5 +177,4 @@ main (int argc, char *argv[])
gdImageDestroy (im);
return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/Build/source/libs/gd/libgd-src/src/gdtopng.c b/Build/source/libs/gd/libgd-src/src/gdtopng.c
index d3341b43cad..c937558eb19 100644
--- a/Build/source/libs/gd/libgd-src/src/gdtopng.c
+++ b/Build/source/libs/gd/libgd-src/src/gdtopng.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -38,11 +37,7 @@ main (int argc, char **argv)
gdImageDestroy (im);
exit (1);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im, out);
-#else
- fprintf(stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im);
diff --git a/Build/source/libs/gd/libgd-src/src/getopt.c b/Build/source/libs/gd/libgd-src/src/getopt.c
new file mode 100644
index 00000000000..8651b87de74
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/src/getopt.c
@@ -0,0 +1,129 @@
+/* $NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt(int nargc, char * const nargv[], const char *ostr)
+{
+ static const char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || *place == 0) { /* update scanning pointer */
+ optreset = 0;
+ place = nargv[optind];
+ if (optind >= nargc || *place++ != '-') {
+ /* Argument is absent or is not an option */
+ place = EMSG;
+ return (-1);
+ }
+ optopt = *place++;
+ if (optopt == '-' && *place == 0) {
+ /* "--" => end of options */
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ if (optopt == 0) {
+ /* Solitary '-', treat as a '-' option
+ if the program (eg su) is looking for it. */
+ place = EMSG;
+ if (strchr(ostr, '-') == NULL)
+ return -1;
+ optopt = '-';
+ }
+ } else
+ optopt = *place++;
+
+ /* See if option letter is one the caller wanted... */
+ if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
+ if (*place == 0)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: unknown option -- %c\n", nargv[0],
+ optopt);
+ return (BADCH);
+ }
+
+ /* Does this option need an argument? */
+ if (oli[1] != ':') {
+ /* don't need argument */
+ optarg = NULL;
+ if (*place == 0)
+ ++optind;
+ } else {
+ /* Option-argument is either the rest of this argument or the
+ entire next argument. */
+ if (*place)
+ optarg = (char *)place;
+ else if (oli[2] == ':')
+ /*
+ * GNU Extension, for optional arguments if the rest of
+ * the argument is empty, we return NULL
+ */
+ optarg = NULL;
+ else if (nargc > ++optind)
+ optarg = nargv[optind];
+ else {
+ /* option-argument absent */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ nargv[0], optopt);
+ return (BADCH);
+ }
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* return option letter */
+}
diff --git a/Build/source/libs/gd/libgd-src/src/gifanimtest.c b/Build/source/libs/gd/libgd-src/src/gifanimtest.c
index da17b9e24f5..28b7d27381b 100644
--- a/Build/source/libs/gd/libgd-src/src/gifanimtest.c
+++ b/Build/source/libs/gd/libgd-src/src/gifanimtest.c
@@ -32,4 +32,3 @@ int main(void)
gdImageDestroy(im);
return 0;
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/giftogd2.c b/Build/source/libs/gd/libgd-src/src/giftogd2.c
index e7d0c6b8250..68c82a1e3fd 100644
--- a/Build/source/libs/gd/libgd-src/src/giftogd2.c
+++ b/Build/source/libs/gd/libgd-src/src/giftogd2.c
@@ -49,4 +49,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/Build/source/libs/gd/libgd-src/src/jisx0208.h b/Build/source/libs/gd/libgd-src/src/jisx0208.h
index d49dddc010a..118c23e0aac 100644
--- a/Build/source/libs/gd/libgd-src/src/jisx0208.h
+++ b/Build/source/libs/gd/libgd-src/src/jisx0208.h
@@ -1,9 +1,9 @@
+#ifndef JISX0208_H
+#define JISX0208_H
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef JISX0208_H
-#define JISX0208_H
/* This file was derived from "src/VF_Ftype.c" in VFlib2-2.24.2
by Dr. Kakugawa */
@@ -1299,8 +1299,8 @@ extern "C" {
}
};
-#endif /* JISX0208_H */
-
#ifdef __cplusplus
}
#endif
+
+#endif /* JISX0208_H */
diff --git a/Build/source/libs/gd/libgd-src/src/msinttypes/inttypes.h b/Build/source/libs/gd/libgd-src/src/msinttypes/inttypes.h
index 4b3828a2162..ead903f78e4 100644
--- a/Build/source/libs/gd/libgd-src/src/msinttypes/inttypes.h
+++ b/Build/source/libs/gd/libgd-src/src/msinttypes/inttypes.h
@@ -1,32 +1,32 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
// Copyright (c) 2006 Alexander Chemeris
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
+//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
diff --git a/Build/source/libs/gd/libgd-src/src/msinttypes/stdint.h b/Build/source/libs/gd/libgd-src/src/msinttypes/stdint.h
index d02608a5972..c66fbb817c0 100644
--- a/Build/source/libs/gd/libgd-src/src/msinttypes/stdint.h
+++ b/Build/source/libs/gd/libgd-src/src/msinttypes/stdint.h
@@ -1,32 +1,32 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
-//
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
// Copyright (c) 2006-2008 Alexander Chemeris
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
-//
+//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-//
+//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
+//
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER // [
diff --git a/Build/source/libs/gd/libgd-src/src/pngtogd.c b/Build/source/libs/gd/libgd-src/src/pngtogd.c
index f00fe8f7ac9..4f9804d177a 100644
--- a/Build/source/libs/gd/libgd-src/src/pngtogd.c
+++ b/Build/source/libs/gd/libgd-src/src/pngtogd.c
@@ -25,11 +25,7 @@ main (int argc, char **argv)
fprintf (stderr, "Input file does not exist!\n");
exit (1);
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
-#else
- fprintf (stderr, "No PNG library support available.\n");
-#endif
fclose (in);
if (!im) {
fprintf (stderr, "Input is not in PNG format!\n");
diff --git a/Build/source/libs/gd/libgd-src/src/pngtogd2.c b/Build/source/libs/gd/libgd-src/src/pngtogd2.c
index e474afb6612..20fbee25daa 100644
--- a/Build/source/libs/gd/libgd-src/src/pngtogd2.c
+++ b/Build/source/libs/gd/libgd-src/src/pngtogd2.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -30,12 +29,7 @@ main (int argc, char **argv)
fprintf(stderr, "Input file does not exist!\n");
exit (1);
}
-#ifdef HAVE_LIBPNG
im = gdImageCreateFromPng (in);
-#else
- im = NULL;
- fprintf(stderr, "No PNG library support available.\n");
-#endif
fclose (in);
if (!im) {
fprintf(stderr, "Input is not in PNG format!\n");
diff --git a/Build/source/libs/gd/libgd-src/src/snprintf.c b/Build/source/libs/gd/libgd-src/src/snprintf.c
new file mode 100644
index 00000000000..33d1b42c81d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-src/src/snprintf.c
@@ -0,0 +1,25 @@
+/* Provide a snprintf on Windows for older Visual Studio builds.
+ * VS2013 and older do not support C99 snprintf(). The subsitute _snprintf()
+ * does not correctly NUL-terminate buffers in case of overflow.
+ * This implementation emulates the ISO C99 snprintf() for VS2013 and older.
+ */
+
+#if defined(_MSC_VER) && _MSC_VER < 1900
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int snprintf(char* buf, size_t len, const char* fmt, ...)
+{
+ int n;
+ va_list ap;
+ va_start(ap, fmt);
+
+ n = _vscprintf(fmt, ap);
+ vsnprintf_s(buf, len, _TRUNCATE, fmt, ap);
+
+ va_end(ap);
+ return n;
+}
+
+#endif
diff --git a/Build/source/libs/gd/libgd-src/src/testac.c b/Build/source/libs/gd/libgd-src/src/testac.c
index 0d200f0630c..bea4308f082 100644
--- a/Build/source/libs/gd/libgd-src/src/testac.c
+++ b/Build/source/libs/gd/libgd-src/src/testac.c
@@ -1,4 +1,3 @@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -17,7 +16,6 @@ void testDrawing (gdImagePtr im_in,
int
main (int argc, char *argv[])
{
-#ifdef HAVE_LIBPNG
/* Input and output files */
FILE *in;
@@ -55,9 +53,6 @@ main (int argc, char *argv[])
testDrawing (im_in, 2.0, 0, 1, "noblending-doublesize-palette.png");
testDrawing (im_in, 2.0, 1, 1, "blending-doublesize-palette.png");
gdImageDestroy (im_in);
-#else
- fprintf (stderr, "No PNG library support.\n");
-#endif
return 0;
}
@@ -116,11 +111,7 @@ testDrawing (gdImagePtr im_in,
gdImageTrueColorToPalette (im_out, 1, 256);
}
-#ifdef HAVE_LIBPNG
gdImagePng (im_out, out);
-#else
- fprintf (stderr, "No PNG library support.\n");
-#endif
fclose (out);
gdImageDestroy (im_out);
diff --git a/Build/source/libs/gd/libgd-src/src/testtr.c b/Build/source/libs/gd/libgd-src/src/testtr.c
index b7b419f96c0..ed1b374a8e8 100644
--- a/Build/source/libs/gd/libgd-src/src/testtr.c
+++ b/Build/source/libs/gd/libgd-src/src/testtr.c
@@ -11,8 +11,6 @@
int
main(void)
{
-#ifdef HAVE_LIBFREETYPE
- FILE *out;
int transparent, green, black;
gdImagePtr im;
@@ -37,17 +35,15 @@ main(void)
gdImageSaveAlpha (im, TRUE);
#ifdef HAVE_LIBPNG
- out = fopen ("testtr.png", "wb");
- gdImagePng (im, out);
- fclose (out);
+ {
+ FILE *out = fopen("testtr.png", "wb");
+ gdImagePng(im, out);
+ fclose(out);
+ }
#else
fprintf(stderr, "Compiled without libpng support\n");
#endif /* HAVE_LIBPNG */
gdImageDestroy (im);
return 0;
-#else
- fprintf(stderr, "Compiled without freetype support\n");
- return 0;
-#endif /* HAVE_LIBFREETYPE */
}
diff --git a/Build/source/libs/gd/libgd-src/src/wbmp.c b/Build/source/libs/gd/libgd-src/src/wbmp.c
index 6be39410c55..6f187f9b1c5 100644
--- a/Build/source/libs/gd/libgd-src/src/wbmp.c
+++ b/Build/source/libs/gd/libgd-src/src/wbmp.c
@@ -38,7 +38,8 @@
*/
int getmbi(int (*getin) (void *in), void *in)
{
- int i, mbi = 0;
+ unsigned int mbi = 0;
+ int i;
do {
i = getin(in);
diff --git a/Build/source/libs/gd/libgd-src/src/wbmp.h b/Build/source/libs/gd/libgd-src/src/wbmp.h
index f163b4be410..9a93d6ebf09 100644
--- a/Build/source/libs/gd/libgd-src/src/wbmp.h
+++ b/Build/source/libs/gd/libgd-src/src/wbmp.h
@@ -1,7 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* WBMP
* ----
* WBMP Level 0: B/W, Uncompressed
@@ -16,6 +12,10 @@ extern "C" {
#ifndef __WBMP_H
#define __WBMP_H 1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* WBMP struct
* -----------
* A Wireless bitmap structure
@@ -44,8 +44,8 @@ extern "C" {
void freewbmp(Wbmp *wbmp);
void printwbmp(Wbmp *wbmp);
-#endif
-
#ifdef __cplusplus
}
#endif
+
+#endif
diff --git a/Build/source/libs/gd/libgd-src/src/webpng.c b/Build/source/libs/gd/libgd-src/src/webpng.c
index 2dff83294cf..b376253def9 100644
--- a/Build/source/libs/gd/libgd-src/src/webpng.c
+++ b/Build/source/libs/gd/libgd-src/src/webpng.c
@@ -4,16 +4,10 @@
/* Bring in standard I/O and string manipulation functions */
#include <stdarg.h>
-#ifdef HAVE_ERRNO_H
#include <errno.h>
-#endif
#include <stdio.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif