add gdImageClone, use gdImageClone for 0 degree rotation, fix expected images for bug00067 test
95
src/gd.c
|
@ -2258,6 +2258,101 @@ BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2,
|
|||
}
|
||||
}
|
||||
|
||||
BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
|
||||
gdImagePtr dst;
|
||||
register int i, x;
|
||||
|
||||
if (src->trueColor) {
|
||||
dst = gdImageCreateTrueColor(src->sx , src->sy);
|
||||
} else {
|
||||
dst = gdImageCreate(src->sx , src->sy);
|
||||
}
|
||||
|
||||
if (dst == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (src->trueColor == 0) {
|
||||
dst->colorsTotal = src->colorsTotal;
|
||||
for (i = 0; i < gdMaxColors; i++) {
|
||||
dst->red[gdMaxColors] = src->red[gdMaxColors];
|
||||
dst->green[gdMaxColors] = src->green[gdMaxColors];
|
||||
dst->blue[gdMaxColors] = src->blue[gdMaxColors];
|
||||
dst->alpha[gdMaxColors] = src->alpha[gdMaxColors];
|
||||
dst->open[gdMaxColors] = src->open[gdMaxColors];
|
||||
}
|
||||
for (i = 0; i < src->sy; i++) {
|
||||
for (x = 0; x < src->sx; x++) {
|
||||
dst->pixels[i][x] = dst->pixels[i][x];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < src->sy; i++) {
|
||||
for (x = 0; x < src->sx; x++) {
|
||||
dst->tpixels[i][x] = src->tpixels[i][x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (src->styleLength > 0) {
|
||||
dst->styleLength = src->styleLength;
|
||||
dst->stylePos = src->stylePos;
|
||||
for (i = 0; i < src->styleLength; i++) {
|
||||
dst->style[i] = src->style[i];
|
||||
}
|
||||
}
|
||||
|
||||
dst->interlace = src->interlace;
|
||||
|
||||
dst->alphaBlendingFlag = src->alphaBlendingFlag;
|
||||
dst->saveAlphaFlag = src->saveAlphaFlag;
|
||||
dst->AA = src->AA;
|
||||
dst->AA_color = src->AA_color;
|
||||
dst->AA_dont_blend = src->AA_dont_blend;
|
||||
|
||||
dst->cx1 = src->cx1;
|
||||
dst->cy1 = src->cy1;
|
||||
dst->cx2 = src->cx2;
|
||||
dst->cy2 = src->cy2;
|
||||
|
||||
dst->res_x = src->res_x;
|
||||
dst->res_y = src->res_x;
|
||||
|
||||
dst->paletteQuantizationMethod = src->paletteQuantizationMethod;
|
||||
dst->paletteQuantizationSpeed = src->paletteQuantizationSpeed;
|
||||
dst->paletteQuantizationMinQuality = src->paletteQuantizationMinQuality;
|
||||
dst->paletteQuantizationMinQuality = src->paletteQuantizationMinQuality;
|
||||
|
||||
dst->interpolation_id = src->interpolation_id;
|
||||
dst->interpolation = src->interpolation;
|
||||
|
||||
if (src->brush) {
|
||||
dst->brush = gdImageClone(src->brush);
|
||||
}
|
||||
|
||||
if (src->tile) {
|
||||
dst->tile = gdImageClone(src->tile);
|
||||
}
|
||||
|
||||
if (src->style) {
|
||||
gdImageSetStyle(dst, src->style, src->styleLength);
|
||||
}
|
||||
|
||||
for (i = 0; i < gdMaxColors; i++) {
|
||||
dst->brushColorMap[i] = src->brushColorMap[i];
|
||||
dst->tileColorMap[i] = src->tileColorMap[i];
|
||||
}
|
||||
|
||||
if (src->polyAllocated > 0) {
|
||||
dst->polyAllocated = src->polyAllocated;
|
||||
for (i = 0; i < src->polyAllocated; i++) {
|
||||
dst->polyInts[i] = src->polyInts[i];
|
||||
}
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
|
||||
int srcY, int w, int h)
|
||||
{
|
||||
|
|
2
src/gd.h
|
@ -889,6 +889,8 @@ BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,
|
|||
int srcX, int srcY,
|
||||
int srcWidth, int srcHeight, int angle);
|
||||
|
||||
BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src);
|
||||
|
||||
BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
|
||||
BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
|
||||
BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);
|
||||
|
|
|
@ -2199,6 +2199,19 @@ BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const fl
|
|||
|
||||
/* no interpolation needed here */
|
||||
switch (angle_rounded) {
|
||||
|
||||
case 0: {
|
||||
gdImagePtr dst = gdImageClone(src);
|
||||
|
||||
if (dst == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (dst->trueColor == 0) {
|
||||
gdImagePaletteToTrueColor(dst);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
case 9000:
|
||||
return gdImageRotate90(src, 0);
|
||||
case 18000:
|
||||
|
|
|
@ -46,7 +46,7 @@ int main()
|
|||
exp = gdImageRotateInterpolated(im, angle, color);
|
||||
|
||||
if (!exp) {
|
||||
gdTestErrorMsg("rotating image failed.\n");
|
||||
gdTestErrorMsg("rotating image failed for %03d.\n", angle);
|
||||
gdImageDestroy(im);
|
||||
return 1;
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 34 KiB |