"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gd_filter.c" between
libgd-2.2.4.tar.gz and libgd-2.2.5.tar.gz

About: LibGD is a library for the dynamic creation of images by programmers (PNG, JPEG, GIF, WebP, XPM, BMP support).

gd_filter.c  (libgd-2.2.4):gd_filter.c  (libgd-2.2.5)
skipping to change at line 238 skipping to change at line 238
} }
} }
return 1; return 1;
} }
/** /**
* Function: gdImageGrayScale * Function: gdImageGrayScale
* *
* Convert an image to grayscale * Convert an image to grayscale
* *
* The red, green and blue components of each pixel are replaced by their
* weighted sum using the same coefficients as the REC.601 luma (Y')
* calculation. The alpha components are retained.
*
* For palette images the result may differ due to palette limitations.
*
* Parameters: * Parameters:
* src - The image. * src - The image.
* *
* Returns: * Returns:
* Non-zero on success, zero on failure. * Non-zero on success, zero on failure.
*/ */
BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src) BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src)
{ {
int x, y; int x, y;
int r,g,b,a; int r,g,b,a;
int new_pxl, pxl; int new_pxl, pxl;
FuncPtr f; FuncPtr f;
int alpha_blending;
if (src==NULL) { if (src==NULL) {
return 0; return 0;
} }
alpha_blending = src->alphaBlendingFlag;
gdImageAlphaBlending(src, gdEffectReplace);
f = GET_PIXEL_FUNCTION(src); f = GET_PIXEL_FUNCTION(src);
for (y=0; y<src->sy; ++y) { for (y=0; y<src->sy; ++y) {
for (x=0; x<src->sx; ++x) { for (x=0; x<src->sx; ++x) {
pxl = f (src, x, y); pxl = f (src, x, y);
r = gdImageRed(src, pxl); r = gdImageRed(src, pxl);
g = gdImageGreen(src, pxl); g = gdImageGreen(src, pxl);
b = gdImageBlue(src, pxl); b = gdImageBlue(src, pxl);
a = gdImageAlpha(src, pxl); a = gdImageAlpha(src, pxl);
r = g = b = (int) (.299 * r + .587 * g + .114 * b); r = g = b = (int) (.299 * r + .587 * g + .114 * b);
new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a); new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
if (new_pxl == -1) { if (new_pxl == -1) {
new_pxl = gdImageColorClosestAlpha(src, r, g, b, a); new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
} }
gdImageSetPixel (src, x, y, new_pxl); gdImageSetPixel (src, x, y, new_pxl);
} }
} }
gdImageAlphaBlending(src, alpha_blending);
return 1; return 1;
} }
/** /**
* Function: gdImageBrightness * Function: gdImageBrightness
* *
* Change the brightness of an image * Change the brightness of an image
* *
* Parameters: * Parameters:
* src - The image. * src - The image.
 End of changes. 4 change blocks. 
0 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)