#if HAVE_GD_BUNDLED # include "gd.h" # include "gdhelpers.h" #else # include <gd.h> # include "libgd/gdhelpers.h" #endif #include "gd_intern.h" #include "php.h" /* bring the palette colors in im2 to be closer to im1 * */ int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2) { unsigned long *buf; /* stores our calculations */ unsigned long *bp; /* buf ptr */ int color, rgb; int x,y; int count; if( !im1->trueColor ) { return -1; /* im1 must be True Color */ } if( im2->trueColor ) { return -2; /* im2 must be indexed */ } if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) { return -3; /* the images are meant to be the same dimensions */ } if (im2->colorsTotal<1) { return -4; /* At least 1 color must be allocated */ } buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * gdMaxColors, 0); memset( buf, 0, sizeof(unsigned long) * 5 * gdMaxColors ); for (x=0; x<im1->sx; x++) { for( y=0; y<im1->sy; y++ ) { color = im2->pixels[y][x]; rgb = im1->tpixels[y][x]; bp = buf + (color * 5); (*(bp++))++; *(bp++) += gdTrueColorGetRed(rgb); *(bp++) += gdTrueColorGetGreen(rgb); *(bp++) += gdTrueColorGetBlue(rgb); *(bp++) += gdTrueColorGetAlpha(rgb); } } bp = buf; for (color=0; color<im2->colorsTotal; color++) { count = *(bp++); if( count > 0 ) { im2->red[color] = *(bp++) / count; im2->green[color] = *(bp++) / count; im2->blue[color] = *(bp++) / count; im2->alpha[color] = *(bp++) / count; } else { bp += 4; } } gdFree(buf); return 0; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
gd.c | File | 72.75 KB | 0644 |
|
gd.h | File | 32.2 KB | 0644 |
|
gd_arc.c | File | 1.66 KB | 0644 |
|
gd_color.c | File | 1.5 KB | 0644 |
|
gd_crop.c | File | 9.04 KB | 0644 |
|
gd_filter.c | File | 10.3 KB | 0644 |
|
gd_gd.c | File | 5.2 KB | 0644 |
|
gd_gd2.c | File | 19.73 KB | 0644 |
|
gd_gif_in.c | File | 13.89 KB | 0644 |
|
gd_gif_out.c | File | 20.54 KB | 0644 |
|
gd_interpolation.c | File | 71.93 KB | 0644 |
|
gd_io.c | File | 2.69 KB | 0644 |
|
gd_io.h | File | 963 B | 0644 |
|
gd_io_dp.c | File | 6.93 KB | 0644 |
|
gd_io_file.c | File | 2.31 KB | 0644 |
|
gd_io_ss.c | File | 2.66 KB | 0644 |
|
gd_jpeg.c | File | 26.21 KB | 0644 |
|
gd_matrix.c | File | 7.78 KB | 0644 |
|
gd_pixelate.c | File | 1.33 KB | 0644 |
|
gd_png.c | File | 22 KB | 0644 |
|
gd_rotate.c | File | 12.98 KB | 0644 |
|
gd_security.c | File | 671 B | 0644 |
|
gd_ss.c | File | 1.08 KB | 0644 |
|
gd_topal.c | File | 63.08 KB | 0644 |
|
gd_transform.c | File | 1.27 KB | 0644 |
|
gd_wbmp.c | File | 5.17 KB | 0644 |
|
gd_webp.c | File | 5.04 KB | 0644 |
|
gdcache.c | File | 4.99 KB | 0644 |
|
gdcache.h | File | 2.68 KB | 0644 |
|
gdfontg.c | File | 113.25 KB | 0644 |
|
gdfontg.h | File | 529 B | 0644 |
|
gdfontl.c | File | 108.5 KB | 0644 |
|
gdfontl.h | File | 527 B | 0644 |
|
gdfontmb.c | File | 79.24 KB | 0644 |
|
gdfontmb.h | File | 495 B | 0644 |
|
gdfonts.c | File | 69.46 KB | 0644 |
|
gdfonts.h | File | 491 B | 0644 |
|
gdfontt.c | File | 38.49 KB | 0644 |
|
gdfontt.h | File | 522 B | 0644 |
|
gdft.c | File | 32.57 KB | 0644 |
|
gdhelpers.c | File | 1.19 KB | 0644 |
|
gdhelpers.h | File | 1.32 KB | 0644 |
|
gdkanji.c | File | 12.11 KB | 0644 |
|
gdtables.c | File | 5.45 KB | 0644 |
|
gdxpm.c | File | 3.21 KB | 0644 |
|
wbmp.c | File | 6.76 KB | 0644 |
|
wbmp.h | File | 1.25 KB | 0644 |
|
webpimg.c | File | 28.33 KB | 0644 |
|
webpimg.h | File | 7.04 KB | 0644 |
|
xbm.c | File | 5.3 KB | 0644 |
|