mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
Merge branch 'PHP-5.6'
* PHP-5.6: updated NEWS Fix #67447: imagecrop() adds a black line when cropping
This commit is contained in:
commit
930a9910d7
2 changed files with 29 additions and 3 deletions
|
@ -80,14 +80,14 @@ printf("rect->x: %i\nrect->y: %i\nrect->width: %i\nrect->height: %i\n", crop->x,
|
|||
y = crop->y;
|
||||
if (src->trueColor) {
|
||||
unsigned int dst_y = 0;
|
||||
while (y < (crop->y + (crop->height - 1))) {
|
||||
while (y < (crop->y + crop->height)) {
|
||||
/* TODO: replace 4 w/byte per channel||pitch once available */
|
||||
memcpy(dst->tpixels[dst_y++], src->tpixels[y++] + crop->x, crop->width * 4);
|
||||
}
|
||||
} else {
|
||||
int x;
|
||||
for (y = crop->y; y < (crop->y + (crop->height - 1)); y++) {
|
||||
for (x = crop->x; x < (crop->x + (crop->width - 1)); x++) {
|
||||
for (y = crop->y; y < (crop->y + crop->height); y++) {
|
||||
for (x = crop->x; x < (crop->x + crop->width); x++) {
|
||||
dst->pixels[y - crop->y][x - crop->x] = src->pixels[y][x];
|
||||
}
|
||||
}
|
||||
|
|
26
ext/gd/tests/bug67447.phpt
Normal file
26
ext/gd/tests/bug67447.phpt
Normal file
|
@ -0,0 +1,26 @@
|
|||
--TEST--
|
||||
Bug #67447 (imagecrop() adds a black line when cropping)
|
||||
--FILE--
|
||||
<?php
|
||||
// true color
|
||||
$image = imagecreatetruecolor(500, 500);
|
||||
$red = imagecolorallocate($image, 255, 0, 0);
|
||||
imagefill($image, 0, 0, $red);
|
||||
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
|
||||
var_dump(imagecolorat($cropped, 249, 249) === $red);
|
||||
imagedestroy($image);
|
||||
imagedestroy($cropped);
|
||||
|
||||
// palette
|
||||
$image = imagecreate(500, 500);
|
||||
imagecolorallocate($image, 0, 0, 255); // first palette color = background
|
||||
$red = imagecolorallocate($image, 255, 0, 0);
|
||||
imagefill($image, 0, 0, $red);
|
||||
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
|
||||
var_dump(imagecolorat($cropped, 249, 249) === $red);
|
||||
imagedestroy($image);
|
||||
imagedestroy($cropped);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue