We fix the unintended sign extension issue #150385 by declaring encoded_pixels
as int, and the logical vs. bitwise operator issue #150382 by using the
proper operator.
Otherwise we get artifacts regarding transparency. That happens with the
current implementation of gdImageFilledArc() unless gdChord or gdNoFill
are set. When gdPie is set, however, the filled arc is drawn in wedges,
which are polygons of three points, and so some overlap is natural.
To resolve the issue, we stick with the current algorithm of calculating the
wedges, but instead of drawing each polygon separately, we put the *relevant*
points in a large array, and draw a single polygon. That also is supposed to
improve the performance considerably.
Note that this modification will change the results when gdImageSetStyle()
or gdImageSetBrush() are used, but we believe that this modification is
also an improvement in this regard, even though it still might not make much
sense to use these functions with gdImageFilledArc().
Currently gd_error() forwards to gd_error_ex(). However, both functions
accept a variable number of arguments, and simply forwarding the va_list
isn't portable, see <http://c-faq.com/varargs/handoff.html>. This article
also describes the usual workaround, namely to let the second function
accept a va_list instead of variable number of arguments.
We do so by introducing a static helper, what does not affect API/ABI
compatibility.
This pull request (based on Asma's works) adds support for languages that require [complex text
layout](https://en.wikipedia.org/wiki/Complex_text_layout).
We are using [libraqm](https://github.com/HOST-Oman/libraqm), a small source
code-only library that wraps FriBidi (for bidirectional text support) and
HarfBuzz (for text shaping), and does proper BiDi and script itemization.
The CTL support is enabled by default but can be disabled at compiling time,
and we provide a fallback function that uses your original code without CTL
support.
As reported in <https://bugs.php.net/64641> 1-dimensional horizontal
filled polygons are not drawn at all. That is caused by the scanline
algorithm used for drawing filled polygons which skips the drawing of
horizontal edges, because that is normally not necessary. If, however,
the polygon consists of horizontal edges only, that obviously doesn't
work, so we add a special case handling.
(cherry picked from commit f9f10fa9d4)
As reported in <https://bugs.php.net/64641> 1-dimensional horizontal
filled polygons are not drawn at all. That is caused by the scanline
algorithm used for drawing filled polygons which skips the drawing of
horizontal edges, because that is normally not necessary. If, however,
the polygon consists of horizontal edges only, that obviously doesn't
work, so we add a special case handling.
* GD-2.2:
fix coverity 95857, given the underlying functions, risks to actually have a string overflow seems not possible. However this little safety check costs nothing and puts us on a 100% side.
* GD-2.2:
use unsigned int for index
fix memory leak
add email and quotes (just to be sure)
use 2.2 for now
add key for travis-coverity
Fix 228: gdAssertImageEquals() can't be used
Conflicts:
.travis.yml
Thick lines are drawn by gdImageFilledRectangle(), which iterates over
the x ordinate first (Z order) to apply the style pattern. While this works
fine for vertical and diagonal lines, it obviously fails for horizontal
lines, which have to be iterated over in N order.
To fix this bug, we introduce the helpers gdImageFilled(H|V)Rectangle(),
which may be reused for other purposes as well.
* GD-2.2:
fix#227 drop usage of GD_BILINEAR_FIXED and GD_BICUBIC_FIXED for gdImageRotateInterpolated, the quality does not match expectation. It is also trickier to maintain for little gain. The generic method is used and will be optimized for 2.3 to match fixed pt performance, if necessary. Also use png for comparison to avoid jpeg artifact, making impossible to exactly compare results
fix#227 drop usage of GD_BILINEAR_FIXED and GD_BICUBIC_FIXED for gdImageRotateInterpolated, the quality does not match expectation. It is also trickier to maintain for little gain. The generic method is used and will be optimized for 2.3 to match fixed pt performance, if necessary. Also use png for comparison to avoid jpeg artifact, making impossible to exactly compare results
fix#227 drop usage of GD_BILINEAR_FIXED and GD_BICUBIC_FIXED for gdImageRotateInterpolated, the quality does not match expectation. It is also trickier to maintain for little gain. The generic method is used and will be optimized for 2.3 to match fixed pt performance, if necessary. Also use png for comparison to avoid jpeg artifact, making impossible to exactly compare results
WS
#230 fix crash on fail
gdTestAssert should not accept any message. Also crashes if assert failed
Conflicts:
tests/gdimagerotate/bug00067.c
tests/gdtest/gdtest.c
* GD-2.2:
fix#223 pass coordiates as double to interpolated pixel, simplify edges and bg color checks and correct the calc of the delta between virtual pixels and pixels used for the interpolation. Summary: better quality
gitignore: add missing entries #172#218
clean up new gdTransformAffineBoundingBox tests #221
* GD-2.2:
fix#215 gdImageFillToBorder stack-overflow when invalid color is used
tests: add bug_github_18 to gitignore #18
tests: fix typo in test name #18
These don't seem to ever have been used, but since they follow API
patterns seen by other funcs in here, let's just #if 0 them out for
now. This fixes unused func -Werror failures.
Contrary to gdImageFilledRectangle(), gdImageRectangle() has the
documented limitation that the given points have to be the upper
left and the lower right corner, respectively. However, libgd
already caters to upper right / lower left pairs, and not
catering to the other two combinations seems to be an oversight.
Fixes#177.
The symbol was being set up in cmake but not on the autotools side.
Clean this up to be like other external libraries.
We need to pull in some openmp logic as it's not uncommon for the lib
to be built with openmp support. When we test for it, we need to do
so with openmp flags.
Fixes#137.
We are using GDLIB_REVISION to refer to the gd version string (the "z"
in "x.y.z"), and we are using it to control the libtool revision field.
This leads to problems where the version increases (e.g. "2.1.1") but
the libtool revision doesn't (e.g. "0"). So scripts end up seeing a
revision of "0" in their output instead of "1".
Namespace the libtool version variables with "_LT_" to avoid any more
collisions.
Fixes#140.
Try to standardize the internals a little bit and simplify the read
paths to abort early on when we know we won't actually handle the
input format. Avoid resetting pointers that are on the stack or we
release as it's a waste of code.
First, if the tga input had an ID set, we'd read this into the pointer
itself (and the memory after it in the struct/heap) instead of the memory
allocated to hold it. This bug has been around since the tga code was
first added. We'd basically corrupt memory all the time since most tga
files out there have an ID set up (like a datestamp).
Second, make sure we reject invalid images that would cause overflows in
the allocation path. We tried to check for this already, but we used the
wrong type (we checked uint8_t but allocated int).
Fixes#159.
The use of setjmp in this function was slightly incorrect: we store
pointers to allocated memory in stack variables, but we didn't call
setjmp again afterwards. Optimization might place those in registers
which would clobber their values on the next longjmp. Make sure we
call setjmp after every allocation to update the state.
As part of the cleanup, unify all the error code paths so we don't
have to worry about every if statement being fully correct.
When given invalid inputs, we might be fed the EOF marker before it is
actually the EOF. The gif logic assumes once it sees the EOF marker,
there won't be any more data, so it leaves the cur_bits index possibly
negative. So when we get more data, we underflow the masks array.
Flag it so we don't try to output anything more. The image is invalid,
so we shouldn't be truncating any valid inputs.
This fixes#209.
We use the name passed in to printf into a local stack buffer which is
limited to 4000 bytes. So given a large enough value, lots of stack
data is leaked. Rewrite the code to do simple memory copies with most
of the strings to avoid that issue, and only use stack buffer for small
numbers of constant size.
This closes#211.
Clean up redundant header logic and focus on what we actually care about:
whether specific headers exist.
Update the program list to omit programs when required libs are not found.
The filedata & temp pointers are assigned the same return value, so
trying to free both of them at the end makes no sense and results in
a double free error. Drop one of them.
The Makefile.am has no changes other than sorting & unwrapping the files
to make it a bit more readable (and dropping duplicate entries).
The CMakeLists.txt gains a few files that were added recently but left
out of the cmake build.
Closes#183.
Make sure we do some range checking on corrupted chunks.
Thanks to Hans Jerry Illikainen <hji@dyntopia.com> for indepth report
and reproducer information. Made for easy test case writing :).
We use ceill and ceil in this code, but it's not clear we need the long
double variant of ceill here. The input multiply is already done with
double precision (the 0.1 literal is a double), and not all C libraries
offer long double variants. Change to ceil and see if anyone notices.
Closes issue #123.
* For VS2013 and below, it will compile and additional file `src/snprintf.c`, which contains the fallback implementation. The
function is included with `extern` in other files where required.
* In `src/CMakeLists.txt`, `snprintf.c` is included in sources conditionally; only for
VS2013 and below.
* Note that I have also guarded it with condition inside the `snprintf.c` file, so if any consumer/downstream is not using `cmake` but their own build system (say gyp), this will still prevent them redefining snprintf for VS2015 even if they add `/src/snprintf.c` in to-be-compiled sources unconditionally.
It is the responsibility of the build infrastructure or user to set or
not set NDEBUG. For the time being this is a workaround in the case
where NDEBUG is set by the build infrastructure or user which prevents
the compiler from generating macro redefiniton warnings/errors. A longer
term fix will require changes to booststrap (aka configure) as well as
cmake (aka CMakeLists.txt).
The interpolation_id is an enum that contains only positive
values. As a result, checking if it less than 0 generates a
compiler warning since the conditional check is always false.
Fixing memory leak in gdImageScaleTwoPass, as reported by @cmb69 and
confirmed by @vapier. This bug actually bit me in production and I'm
very thankful that it was reported with an easy fix.
Fixes#173.
In API gdImageLine()
if `dx == 0` Checked and return else if `dy==0` Checked and return.
if ((dx == 0) && (dy == 0)) never TRUE , code has no impact , can be removed.
Issue : gdImageSquareToCircle() may possibly return NULL pointer.
im2 = gdImageCreateTrueColor (radius * 2, radius * 2);
im2 can hold NULL value when 0 returned.
Should be NULL checked.
MAXPATHLEN is set to 256 (on some systems), and DEFAULT_FONTPATH is longer
than this (on some systems). The sprintf() to path[MAXPATHLEN] thus
resulted in a buffer overrun when in some circumstances (also,
fontsearchpath is in the control of the environment, so this could be
triggered on any platform).
Specified calling convention on function pointers. (This matters
under Windows).
Switched from rindex() to strrchr() (oops!).
Tidied the formatting a bit.
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.
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.
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.
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.
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()).
_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.
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.
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.)
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.
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.
_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.