diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src/gd_rotate.c')
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_rotate.c | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/gd_rotate.c b/Build/source/libs/gd/libgd-src/src/gd_rotate.c index e590b3f2114..3d7025001bf 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_rotate.c +++ b/Build/source/libs/gd/libgd-src/src/gd_rotate.c @@ -362,194 +362,3 @@ gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent) return dst; } - -gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent) -{ - gdImagePtr dst1,dst2,dst3; - double dRadAngle, dSinE, dTan, dShear; - double dOffset; /* Variable skew offset */ - int u, iShear, newx, newy; - int clrBackR, clrBackG, clrBackB, clrBackA; - - /* See GEMS I for the algorithm details */ - dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */ - dSinE = sin (dRadAngle); - dTan = tan (dRadAngle / 2.0); - - newx = (int)(src->sx + src->sy * fabs(dTan)); - newy = src->sy; - - /* 1st shear */ - dst1 = gdImageCreateTrueColor(newx, newy); - /******* Perform 1st shear (horizontal) ******/ - if (dst1 == NULL) { - return NULL; - } -#ifdef HAVE_GD_BUNDLED - dst1->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst1, 0); -#endif - if (dAngle == 0.0) { - /* Returns copy of src */ - gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy); - return dst1; - } - - gdImagePaletteCopy (dst1, src); - - if (ignoretransparent) { - if (gdImageTrueColor(src)) { - dst1->transparent = src->transparent; - } else { - - dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127); - } - } - - for (u = 0; u < dst1->sy; u++) { - if (dTan >= 0.0) { - dShear = ((double)(u + 0.5)) * dTan; - } else { - dShear = ((double)(u - dst1->sy) + 0.5) * dTan; - } - - iShear = (int)floor(dShear); - gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent); - } - - /* - The 1st shear may use the original clrBack as color index - Convert it once here - */ - if(!src->trueColor) { - clrBackR = gdImageRed(src, clrBack); - clrBackG = gdImageGreen(src, clrBack); - clrBackB = gdImageBlue(src, clrBack); - clrBackA = gdImageAlpha(src, clrBack); - clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA); - } - /* 2nd shear */ - newx = dst1->sx; - - if (dSinE > 0.0) { - dOffset = (src->sx-1) * dSinE; - } else { - dOffset = -dSinE * (src->sx - newx); - } - - newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1; - - dst2 = gdImageCreateTrueColor(newx, newy); - if (dst2 == NULL) { - gdImageDestroy(dst1); - return NULL; - } - -#ifdef HAVE_GD_BUNDLED - dst2->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst2, 0); -#endif - - if (ignoretransparent) { - dst2->transparent = dst1->transparent; - } - - for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) { - iShear = (int)floor (dOffset); - gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent); - } - - /* 3rd shear */ - gdImageDestroy(dst1); - - newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1; - newy = dst2->sy; - - dst3 = gdImageCreateTrueColor(newx, newy); - if (dst3 == NULL) { - gdImageDestroy(dst2); - return NULL; - } - -#ifdef HAVE_GD_BUNDLED - dst3->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst3, 0); -#endif - - if (ignoretransparent) { - dst3->transparent = dst2->transparent; - } - - if (dSinE >= 0.0) { - dOffset = (double)(src->sx - 1) * dSinE * -dTan; - } else { - dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy)); - } - - for (u = 0; u < dst3->sy; u++, dOffset += dTan) { - int iShear = (int)floor(dOffset); - gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent); - } - - gdImageDestroy(dst2); - - return dst3; -} - -gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent) -{ - gdImagePtr pMidImg; - gdImagePtr rotatedImg; - - if (src == NULL) { - return NULL; - } - - if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) { - return NULL; - } - - while (dAngle >= 360.0) { - dAngle -= 360.0; - } - - while (dAngle < 0) { - dAngle += 360.0; - } - - if (dAngle == 90.00) { - return gdImageRotate90(src, ignoretransparent); - } - if (dAngle == 180.00) { - return gdImageRotate180(src, ignoretransparent); - } - if(dAngle == 270.00) { - return gdImageRotate270 (src, ignoretransparent); - } - - if ((dAngle > 45.0) && (dAngle <= 135.0)) { - pMidImg = gdImageRotate90 (src, ignoretransparent); - dAngle -= 90.0; - } else if ((dAngle > 135.0) && (dAngle <= 225.0)) { - pMidImg = gdImageRotate180 (src, ignoretransparent); - dAngle -= 180.0; - } else if ((dAngle > 225.0) && (dAngle <= 315.0)) { - pMidImg = gdImageRotate270 (src, ignoretransparent); - dAngle -= 270.0; - } else { - return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent); - } - - if (pMidImg == NULL) { - return NULL; - } - - rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent); - gdImageDestroy(pMidImg); - - return rotatedImg; -} -/* End Rotate function */ |