Commit Graph

1006 Commits (4b86e06937bc5ff116be969137f8da9d1a7869d5)

Author SHA1 Message Date
Remi Collet 4b86e06937 Fix artefact in gdImageScale using GD_BILINEAR_FIXED
See https://bugs.php.net/66887 for sample image
and examples/resize.c to test.
2014-03-12 17:03:24 +01:00
Remi Collet 1de3b80052 new example "resize" 2014-03-12 17:02:39 +01:00
Remi Collet 5b42b1178c Fix gdImageSetInterpolationMethod with GD_DEFAULT
As we have "im->interpolation_id = id;" after the switch
2014-03-12 15:26:40 +01:00
Chris Reuter 2d5dc2e1cd MSys Makefile now statically links libgd.dll to libiconv.
This reduces dependencies but merges in LGPL code.  You can also
dynamically link it by commenting and uncommenting two lines.
2014-03-07 15:20:59 -05:00
Chris Reuter 01104a2591 MSys Makefile fix
Now adds the -static-libgcc flag.  This removes libgcc as a dependency.
2014-03-05 11:55:59 -05:00
Chris Reuter 7a8e8b2e33 Bug fix: GD DLL rename hadn't been propagated everywhere. 2014-03-01 18:52:12 -05:00
Chris Reuter 6b94f66831 Minor enhancements to the MinGW+Msys build scripts.
Makefile now creates a zipfile containing the DLLs.

Resulting DLL no longer contains a version number in its name.  (The
Windows convention is to ship the DLL with the program using it.
Versioning the name just makes it harder for scripts to find the DLL.)

Tweaked the README a bit.
2014-02-24 17:41:02 -05:00
Chris Reuter 339b17aeff Updated the MSys build files.
The Makefiles and scripts for building under MSYS had rotted a bit.  This
change fixes those things.
2014-02-07 14:17:17 -05:00
Chris Reuter 0cb34fdb31 Got gd_filename.c to work correctly under Windows.
Specified calling convention on function pointers.  (This matters
under Windows).

Switched from rindex() to strrchr() (oops!).

Tidied the formatting a bit.
2014-02-07 14:17:17 -05:00
Chris Reuter 74ad18cc54 Updated .gitignore.
Now ignores all (so far) of the products of the MSys+Windows build
process.
2014-02-07 14:17:17 -05:00
Chris Reuter 275ac17bcc Started importing the old manual into Naturaldocs comments.
This changeset imports documention for gdImage to gdImagePng*() into
Natural Docs.  Documention is based on the text of the original
manual, version 2.0.36 but adapted to better suit the format.
Subsequent changesets will introduce docs for subsequent manual
entries.

naturaldocs, when present, is invoked by bootstrap.sh.  The completed
manual will be in docs/naturaldocs/html/index.html.  It can also be
explicitly invoked by running docs/naturaldocs/run_docs.sh.

This change also removed docs/naturaldocs/project/Menu.txt, since it
currently contains no non-generated content and is prone to introduce
noise into the changeset.
2014-01-07 15:29:06 -05:00
Chris Reuter 3b2caf62b9 Added function 'gdImageGetInterpolationMethod()'.
This retrieves the interpolation method set via
gdImageSetInterpolationMethod().  It is a function instead of a macro
for the benefit of VMs that need a function pointer to call.
2014-01-07 15:19:39 -05:00
Chris Reuter 00cd958324 Added gdnametest and gdCopyBlurred to .gitignore. 2013-12-16 17:38:17 -05:00
Chris Reuter c9d2f89597 Added gdImageFile(), gdImageCreateFromFile() and gdSupportsFileType().
These are convenience functions which load or save image data to a
file.  They are roughly equivalent to opening a file handle with
fopen() and calling gdImageCreateFrom*() or gdImage*() on the FILE
pointer.  However, these functions identify the input or output format
from the filename suffix and call the appropriate read or write
function accordingly.

gdSupportsFileType() can be used to test if a specific file format
is supported.

Most scripting interfaces already do something like this but now
there's support for doing it from C as well.

This change also adds test cases for the code and naturaldocs
documentation.
2013-12-16 17:27:34 -05:00
Chris Reuter e054be7d82 Small code cleanup.
Removed non-exported prototypes from gd.h.  Where possible, made the
functions static and moved the rest of the prototypes to gd_intern.h.

Also removed redundant macros MIN/MAX macros from gd_interpolation.c
(since they're also defined in gd_intern.h) and tidied the formatting
a little.
2013-12-11 18:02:37 -05:00
Chris Reuter b20cdef19f Added a test case for gdImageCopyGaussianBlurred().
This change is relatively thorough.  It confirms that the blurring
process succeeds and that the result is at least somewhat blurry.
2013-12-10 19:17:28 -05:00
Chris Reuter 6febd903b6 Added a new Gaussian blur function.
gdImageCopyGaussianBlurred() returns a blurred copy of its argument.
Blurring is done in two passes to take advantage of the Gaussian
function's separability for.  This makes the algorithm much faster
than single-pass implementations, especially for larger radii.

This change also adds documentation for the new function and the
existing blur (gdImageGaussianBlur()).
2013-12-10 19:17:28 -05:00
Chris Reuter d525680527 Bug fix: gdImageScale() was sometimes messing up transparency.
_gdScaleOneAxis() was clamping the alpha channel to 0..255 when it
should be clamping it to 0..127.  This sometimes caused artifacts.

This change fixes that.
2013-11-19 15:08:55 -05:00
Chris Reuter 549addc327 Added .gitignore lines to exclude naturaldocs by-products. 2013-11-18 19:09:47 -05:00
Chris Reuter bb1d4a044e Added documention for gdImageCreate() and type gdImage.
This change adds naturaldoc comments for the above function and type.
Text was adapted from the 2.0.36 manual.

It also fixes the formatting of the comment for gdInterpolationMethod
so that naturaldoc will extract it.
2013-11-18 18:21:28 -05:00
Chris Reuter 3c1202e5bb Added beginnings of an updated manual
This changeset adds scripts and frontmatter for a user manual
for LibGD.  The manual is written using naturaldoc.  That is, the
actual manual (minus some front-matter taken from the manual for
version 2.0.36) is generated from specially-formatted comments in
the source code.

bootstrap.sh has been modified to also trigger generation of the
manual.
2013-11-18 18:21:27 -05:00
Chris Reuter 769fb1534c Added another Makefile.
This change adds a Makefile and bash script for building and testing
libgd on Windows with MinGW and MSYS.  This was written after I
concluded that it was easier and faster to just write a new Makefile
from scratch than to get autotools or CMake to play nicely with my
Windows installation.
2013-11-11 16:38:58 -05:00
Chris Reuter 0dfd45cdc8 Bug fix: tests didn't (always) return a valid status.
gdImageAALine_thickness.c didn't explicitly return 0 on success.

gdimageline_bug5.c was not an actual test at all.  It now confirms that the
tested operation (a line draw) alters the image it draws on.  (Not ideal
but better than what it did before.)
2013-11-08 19:17:22 -05:00
Chris Reuter 16ccce66a3 Fixed a comment.
getver.pl comment referred to file src/version.h.  It should have
been src/gd.h.  This is now fixed.
2013-11-07 19:52:20 -05:00
Chris Reuter e82b084159 Added new files to CMakeLists.txt.
Added new sources and tests to the relevant CMakeLists.txt files.

NOTE: This works for me but I am not a cmake expert.
2013-11-07 19:44:45 -05:00
Chris Reuter 8cdb1090c3 Updated Netware makefile
Makefile.netware (via an AWK script) used to pull the version numbers
from configure.ac.  Since they are no longer there, 'configure.ac' puts
them into 'configure' for Makefile.netware to find.  This change makes
it look there.

NOTE: This has not been tested on a Netware system.
2013-11-07 19:44:45 -05:00
Chris Reuter 784ffdd01c Test case for new version code.
This adds a simple test of the version API functions.
2013-11-07 19:44:45 -05:00
Chris Reuter 4378b8ded4 gd.h now holds the canonical version number.
Up to now, the version numbers were defined in configure.ac and put
into gd.h by generating it from gd.h.in, replacing the values of
several C macros.  This violates the DRY principle, won't work on a
dumb build system, confuses some dev tools and is just a huge headache
in general.

This change makes gd.h (no longer generated) the home of the version
number and provides a script (config/getver.pl) which can extract the
requested version components from the header file.  configure.ac now
gets the version number from gd.h instead of vice versa.

In addition, there are now C functions that return the values of the
version macros.  This is for the benefit of non-C code using the
library without access to the header file.  It also provides a way to
get the version number of the library currently linked rather than the
header the program was compiled against.  (This could change if the
shared library is updated without recompiling the program using it.)
2013-11-07 19:44:45 -05:00
Chris Reuter 3884557700 Merged in suetanvil/gd-libgd/scale-palette-image-bug (pull request #16)
Fix for #97
2013-10-23 12:40:25 -04:00
Chris Reuter 1a92b2e25e Merged in suetanvil/gd-libgd/interp-precision (pull request #15)
Higher precision in scaling.
2013-10-23 12:37:35 -04:00
Chris Reuter 723ea520be Fix for Issue #97: segfaults when scaling a non-truecolor image
gdImageScaleTwoPass() now converts palette sources to truecolor before
scaling.  This is consistent with the behaviour of the other scale
functions.
2013-10-22 21:22:35 -04:00
Chris Reuter f321961a3c Added test case to exercise all of the gdImageScale() modes.
Creates and shrinks a bunch of images using gdImageScale(), once per
mode in both palette and truecolor.  It does not use GD_DEFAULT (which
is equivalent to one of the others) or GD_WEIGHTED4 (unsupported for
scaling).

Note that this test does not check if the resulting image looks anything
like the source.
2013-10-22 21:22:35 -04:00
Chris Reuter 948bb0a5c2 Higher precision in scaling.
Scaling (i.e. _gdScaleOneAxis()) used to accumulate the weighted
samples in unsigned char variables.  This truncated the floating-point
result toward zero, leading to a darker image and quantization of
colour gradients.

This change switches to keeping the values in doubles and only
coverting the final sums to unsigned char.  In addition to producing a
better result, it is also about 10-15% faster.

The conversion uses a couple of casts for speed.  The behaviour is
defined by ANSI but only correct on computers using twos-complement
arithmetic.  As such, this may break on obscure microcontrollers or
1960's-era minicomputers.
2013-10-15 18:01:05 -04:00
Pierre Joye 916d00c2f0 Merged in suetanvil/gd-libgd/suetanvil-scale-code-cleanup (pull request #14)
Major cleanup of FP scaling code
2013-10-10 08:15:30 +02:00
Pierre Joye 0510b4f099 Merged in suetanvil/gd-libgd/suetanvil-dead-code-removal (pull request #13)
Removed some dead code
2013-10-10 08:13:33 +02:00
Chris Reuter 546b274f27 Bug fix: #92: Bicubic scaling leaves the rightmost and bottom rows black
This turns out to be a simple off-by-one error.

Issue URL: https://bitbucket.org/libgd/gd-libgd/issue/92/bicubic-scaling-leaves-the-rightmost-and
2013-10-09 21:29:06 -04:00
Chris Reuter 16ed1a9a97 Added a test case for gdImageScaleTwoPass().
This testcase does some basic resizing using bicubic
interpolation and ensures the result is sane.  It does
not verify image quality, just that the functions return
acceptible values.
2013-10-09 21:28:20 -04:00
Chris Reuter 65fce84a50 Improved testing code
Assertions in gdtest.c do nothing on failure except print a message.
This change also makes them keep a count of failures which can be
retrieved with the function 'gdNumFailures()', making it easy to
return an error status if an assertion condition fails.

Also added gdMaxPixelDiff(), a function to return the largest
difference between two corresponding pixels.  Used to detect pixels
that are similar except for a little color change.
2013-10-09 21:24:57 -04:00
Chris Reuter be3c8cbbc0 Cleaned up floating-point rescaling code.
These changes improve readability without negatively affecting
correctness or performance.

1) The code to do horizontal and vertical scaling were mostly
identical.  This change merges them.

2) The case where the original and result sizes were identical were
handled inefficiently (and probably incorrectly) by copying the source
to the destination with memcpy.  This change makes a simple copy if
both dimensions are the same (i.e. no resizing is requested) and skips
resizing in the unchanged dimension if only one dimension is
different.

3) Other cleanups: removed dead code, improved variable names, added
assertions to document expections, etc.
2013-10-09 21:24:35 -04:00
Chris Reuter 0d13658b84 More dead code removal.
Missed the typedef.  This patch gets it.
2013-09-27 17:57:14 -04:00
Chris Reuter 5ce14ef47a Removed some dead code.
Removed an unused enum type from gd_interpolation.c. This was the
original version of gdInterpolationMethod in gd.h.
2013-09-27 17:45:51 -04:00
Chris Reuter 08fdff668f Merged libgd/gd-libgd into master 2013-09-25 20:00:15 -04:00
Pierre Joye 3c5c6390c3 Merged in suetanvil/gd-libgd/suetanvil (pull request #12)
Fixed memory overrun bug in gdImageScaleTwoPass
2013-09-25 16:56:05 -07:00
Chris Reuter 4f65a3e4ee Fixed memory overrun bug in gdImageScaleTwoPass
_gdContributionsCalc would compute a window size and then adjust
the left and right positions of the window to make a window within
that size.  However, it was storing the values in the struct *before*
it made the adjustment.  This change fixes that.
2013-09-23 18:03:08 -04:00
Chris Reuter 3e76d309d0 Merged libgd/gd-libgd into master 2013-09-23 17:32:57 -04:00
Pierre Joye de7acbfe3e Merged in suetanvil/gd-libgd (pull request #11)
Fix #86: gdImageScale segfaults with most interpolation types
2013-08-29 08:57:29 +02:00
Chris Reuter 4c70f57fd9 Fix #86: gdImageScale segfaults with most interpolation types
Code fails to propagate the interpolation type to an intermediate
temp image.  This change fixes that.
2013-08-27 21:15:56 -04:00
Pierre Joye a0f58c6abf fix #81, cmake_minimum_required must be the 1st line in 2.8+ 2013-07-14 13:19:13 +02:00
Ondřej Surý 54f80199e1 GD_EXTRA_VERSION and GD_VERSION_STRING needs quotes (Courtesy of Marc Deslauriers) 2013-06-28 15:42:22 +02:00
Ondřej Surý dfea0940ae Add INSTALL notes for Solaris conflicting iconv.h headers (fixes #76) 2013-06-28 08:23:25 +02:00