Commit Graph

18 Commits (6013c7bcf6eb795dba584f92d3824ebd3ae60202)

Author SHA1 Message Date
Mike Frysinger e697147788 revert unneeded test change in previous commit
GH does not make it easy to edit PRs.
2021-03-03 02:19:32 -05:00
az6667 fc38677e80
Allow GIFs missing both Global and Local Colormaps to still decode (#494)
Ensure that a GIF without any Global or Local color tables is still
decoded by libgd.

GIF89a spec indicates conforming image files need not have
Global or Local color tables at all.

Spec recommends creating custom color map in that situation, and
that at least Black+White as first two entries, to ensure B&W images
are decoded.

Some commonly used single-pixel GIFs found around the web are
undecoded by libgd otherwise. Test case has been included.

References:
https://www.w3.org/Graphics/GIF/spec-gif89a.txt
http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
2021-03-03 02:17:51 -05:00
wilson chen 08238a0ac2 Fix some memory leakage in test cases
Fix the memory leakage in following test cases: tests/bug_overflow_lagre_new_size.c, tests/gdimagecrop/bug00486.c, tests/bmp/bug00450.c
2020-03-21 10:59:33 +08:00
wilson chen b1151dedb1
tests: Correct some test depend errors 2020-01-02 20:27:29 +08:00
Andrew Burley e5502c7a3f tests: cmake: list appending instead of set(
Consistent use of LIST(APPEND over SET(
2019-02-09 13:17:25 -05:00
Andrew Burley 2d1c4ba01b tests: cmake: feature enable lists - building w/o libpng enabled failing again. #382 2019-02-09 13:17:25 -05:00
Christoph M. Becker 6613094e5d Fix #486: gdImageCropAuto(…, GD_CROP_SIDES) crops left but not right
`gdGuessBackgroundColorFromCorners()` is supposed to handle *all* cases
where an image has exactly two equal colors in the same way.
2018-11-25 17:58:41 +01:00
Christoph M. Becker bda85aaeeb Fix #485: auto cropping has insufficient precision
After calculating the top crop amount, we bail out if the whole image
was going to be cropped away.  The condition to check this
is off-by-one, though, since `y` would be equal to `height` in this
case.  However, `y` would be equal to `height` also in case only the
last row of the image would have to be retained.  We instead check for
`match` which indicates whether all pixels have the same color.

After calculating the bottom crop amount, we must never calculate the
`crop.height` based on the image height, since its irrelevant.

When calculating the left and right crop amount, we must not ignore the
last row of the image.

The partially identical implementation of `gdImageCropThreshold()` has
exactly the same issues, so we fix it as well.

Future scope for *improvements*:

- Replace the `match` flag with respective `goto`s (basically, `break
  2`) is supposed to yield clearer code.
- Don't check the rows which will be top-cropped anyway, when
  calculating the left and right crop amount, for efficiency.
- Join the implementations of calculating the crop rectangle of
  `gdImageCropAuto()` and `gdImageCropThreshold()`.
2018-11-25 14:39:09 +01:00
Mike Frysinger fd06f7f83c clean up trailing whitespace/newlines
This is preparation for adding some linting checks for new commits from
people.  Shouldn't be any functional changes here (tests still pass!).
2018-06-21 22:47:42 -04:00
Christoph M. Becker a15130c6bb Fix #432: gdImageCrop neglecting transparency
When using `gdImageCopy()` for image cropping, we have to make sure
that it doesn't use alpha blending (the current default), but rather
`gdEffectReplace`.  We reset the `alphaBlendingFlag` after finishing
the copy operation.
2018-02-02 16:36:00 +01:00
Christoph M. Becker d2bc56737d Replace GNU old-style field designators with C89 compatible initializers 2016-09-11 16:40:42 +02:00
Christoph M. Becker a59523038d Fix #297: gdImageCrop() converts palette image to truecolor image
When just cropping an image, we want to stick with the same image type.
2016-09-11 16:17:49 +02:00
Pierre Joye fd62302550 fix php 72494, CID 149753, color is unsigned int, remove useless <0 comparison 2016-06-27 12:05:37 +07:00
Pierre Joye 907115fbb9 fix php 72494, CID 149753, color is unsigned int, remove useless <0 comparison 2016-06-27 11:52:43 +07:00
Pierre Joye 6ff72ae40c fix php 72494, invalid color index not handled, can lead to crash 2016-06-27 11:42:44 +07:00
Pierre Joye bca12e4e11 fix php 72494, invalid color index not handled, can lead to crash 2016-06-27 11:42:29 +07:00
Pierre Joye 8de370b7b6 fix php 72494, invalid color index not handled, can lead to crash 2016-06-27 11:42:10 +07:00
Pierre Joye 8c9f39c7cb fix php 72494, invalid color index not handled, can lead to crash 2016-06-27 11:41:55 +07:00