Skip to content
Permalink
Browse files

fix #223 pass coordiates as double to interpolated pixel, simplify ed…

…ges and bg color checks and correct the calc of the delta between virtual pixels and pixels used for the interpolation. Summary: better quality
  • Loading branch information...
pierrejoye committed Jun 11, 2016
1 parent b30fdbf commit 2b26be874d0c0987c4906a40ef8f0e8fee04ae8f
Showing with 4 additions and 15 deletions.
  1. +4 −15 src/gd_interpolation.c
@@ -816,8 +816,8 @@ static int getPixelInterpolateWeight(gdImagePtr im, const double x, const double
*/
int getPixelInterpolated(gdImagePtr im, const double x, const double y, const int bgColor)
{
const int xi=(int)((x) < 0 ? x - 1: x);
const int yi=(int)((y) < 0 ? y - 1: y);
const int xi=(int)(x);
const int yi=(int)(y);
int yii;
int i;
double kernel, kernel_cache_y;
@@ -1748,12 +1748,6 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
unsigned int i;
gdImagePtr dst;

const gdFixed f_slop_y = f_sin;
const gdFixed f_slop_x = f_cos;
const gdFixed f_slop = f_slop_x > 0 && f_slop_y > 0 ?
f_slop_x > f_slop_y ? gd_divfx(f_slop_y, f_slop_x) : gd_divfx(f_slop_x, f_slop_y)
: 0;

if (bgColor < 0) {
return NULL;
}
@@ -1782,15 +1776,10 @@ gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor)
long m = gd_fxtoi(f_m);
long n = gd_fxtoi(f_n);

if ((n <= 0) || (m <= 0) || (m >= src_h) || (n >= src_w)) {
if (m < -1 || n < -1 || m >= src_h || n >= src_w ) {
dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor;
} else if ((n <= 1) || (m <= 1) || (m >= src_h - 1) || (n >= src_w - 1)) {
register int c = getPixelInterpolated(src, n, m, bgColor);
c = c | (( gdTrueColorGetAlpha(c) + ((int)(127* gd_fxtof(f_slop)))) << 24);

dst->tpixels[dst_offset_y][dst_offset_x++] = _color_blend(bgColor, c);
} else {
dst->tpixels[dst_offset_y][dst_offset_x++] = getPixelInterpolated(src, n, m, bgColor);
dst->tpixels[dst_offset_y][dst_offset_x++] = getPixelInterpolated(src, gd_fxtod(f_n), gd_fxtod(f_m), bgColor);
}
}
dst_offset_y++;

0 comments on commit 2b26be8

Please sign in to comment.
You can’t perform that action at this time.