diff options
author | Pierre Joye <pierre.php@gmail.com> | 2016-06-19 15:16:58 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2016-06-19 15:16:58 +0700 |
commit | bb09a211d3ba32e95a086fca4d1376ada54a3426 (patch) | |
tree | e9ba3299fed87cea2b9e8366915a09dc6dbf5680 /src/gd_rotate.c | |
parent | 489e90f7aa7476a31a6f09045ea42be878bc73d1 (diff) | |
download | libgd-bb09a211d3ba32e95a086fca4d1376ada54a3426.tar.gz |
simplify, no need to allocate color here as it always true color
Diffstat (limited to 'src/gd_rotate.c')
-rw-r--r-- | src/gd_rotate.c | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/src/gd_rotate.c b/src/gd_rotate.c index eb057e1..e590b3f 100644 --- a/src/gd_rotate.c +++ b/src/gd_rotate.c @@ -55,16 +55,28 @@ void gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double b = (int)(gdImageBlue(src,pxlSrc) * dWeight); a = (int)(gdImageAlpha(src,pxlSrc) * dWeight); - pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a); + if (r>255) { + r = 255; + } - if (pxlLeft == -1) { - pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a); + if (g>255) { + g = 255; } - r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft)); - g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft)); - b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft)); - a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft)); + if (b>255) { + b = 255; + } + + if (a>127) { + a = 127; + } + + pxlLeft = gdTrueColorAlpha(r, g, b, a); + + r = gdImageRed(src,pxlSrc) - (r - gdImageRed(src,pxlOldLeft)); + g = gdImageGreen(src,pxlSrc) - (g - gdImageGreen(src,pxlOldLeft)); + b = gdImageBlue(src,pxlSrc) - (b - gdImageBlue(src,pxlOldLeft)); + a = gdImageAlpha(src,pxlSrc) - (a - gdImageAlpha(src,pxlOldLeft)); if (r>255) { r = 255; @@ -145,19 +157,31 @@ void gdImageSkewY (gdImagePtr dst, gdImagePtr src, int uCol, int iOffset, double b = (int)((double)gdImageBlue(src,pxlSrc) * dWeight); a = (int)((double)gdImageAlpha(src,pxlSrc) * dWeight); - pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a); + if (r>255) { + r = 255; + } + + if (g>255) { + g = 255; + } + + if (b>255) { + b = 255; + } - if (pxlLeft == -1) { - pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a); + if (a>127) { + a = 127; } - r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft)); - g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft)); - b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft)); - a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft)); + pxlLeft = gdTrueColorAlpha(r, g, b, a); + + r = gdImageRed(src,pxlSrc) - (r - gdImageRed(src,pxlOldLeft)); + g = gdImageGreen(src,pxlSrc) - (g - gdImageGreen(src,pxlOldLeft)); + b = gdImageBlue(src,pxlSrc) - (b - gdImageBlue(src,pxlOldLeft)); + a = gdImageAlpha(src,pxlSrc) - (a - gdImageAlpha(src,pxlOldLeft)); if (r>255) { - r = 255; + r = 255; } if (g>255) { @@ -529,5 +553,3 @@ gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignore return rotatedImg; } /* End Rotate function */ - - |