summaryrefslogtreecommitdiff
path: root/src/gd_rotate.c
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2016-06-19 15:16:58 +0700
committerPierre Joye <pierre.php@gmail.com>2016-06-19 15:16:58 +0700
commitbb09a211d3ba32e95a086fca4d1376ada54a3426 (patch)
treee9ba3299fed87cea2b9e8366915a09dc6dbf5680 /src/gd_rotate.c
parent489e90f7aa7476a31a6f09045ea42be878bc73d1 (diff)
downloadlibgd-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.c56
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 */
-
-