Fixed #369: fix new_a init error in gdImageConvolution()

master
willson-chen 2019-12-13 04:26:40 +01:00 committed by Christoph M. Becker
parent b9004db6a2
commit 4b0f372402
5 changed files with 35 additions and 0 deletions

View File

@ -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++) {

View File

@ -1 +1,2 @@
/basic
/bug00369

View File

@ -1,3 +1,5 @@
LIST(APPEND TESTS_FILES bug00369)
IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
basic

View File

@ -1,3 +1,6 @@
libgd_test_programs += \
gdimageconvolution/bug00369
if HAVE_LIBPNG
libgd_test_programs += \
gdimageconvolution/basic

View File

@ -0,0 +1,28 @@
/**
* Test Issue #369 for gdImageConvolution()
*/
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr im;
float matrix[3][3] = {
{1, 0, 1},
{0, 5, 0},
{1, 0, 0}
};
im = gdImageCreateTrueColor(40, 40);
gdImageAlphaBlending(im, gdEffectReplace);
gdImageFilledRectangle(im, 0, 0, 39, 39, 0x7FFFFFFF);
gdImageFilledEllipse(im, 19, 19, 20, 20, 0x00FF00);
gdImageConvolution(im, matrix, 9, 1);
gdTestAssert(0x7F010101 == gdImageGetPixel(im, 0, 0));
gdImageDestroy(im);
return gdNumFailures();
}