#define RETURN_HWB(h, w, b) {HWB->H = h; HWB->W = w; HWB->B = b; return HWB;}
#define RETURN_RGB(r, g, b) {RGB->R = r; RGB->G = g; RGB->B = b; return RGB;}
#define HWB_UNDEFINED -1
-#define SETUP_RGB(s, r, g, b) {s.R = r/255.0; s.G = g/255.0; s.B = b/255.0;}
+#define SETUP_RGB(s, r, g, b) {s.R = r/255.0f; s.G = g/255.0f; s.B = b/255.0f;}
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
}
else
{
- diff = abs (HWB1.H - HWB2.H);
+ diff = fabsf(HWB1.H - HWB2.H);
if (diff > 3)
{
diff = 6 - diff; /* Remember, it's a colour circle */
if ((dx == 0) && (dy == 0)) {
wid = 1;
} else {
- wid = thick * cos (atan2 (dy, dx));
+ wid = (int)(thick * cos (atan2 (dy, dx)));
if (wid == 0) {
wid = 1;
}
else
{
/* More-or-less vertical. use wid for horizontal stroke */
- wid = thick * sin (atan2 (dy, dx));
+ wid = (int)(thick * sin (atan2 (dy, dx)));
if (wid == 0)
wid = 1;
if (dy <= dx)
{
/* More-or-less horizontal. use wid for vertical stroke */
- wid = thick * sin (atan2 (dy, dx));
+ wid = (int)(thick * sin (atan2 (dy, dx)));
vert = 1;
d = 2 * dy - dx;
{
dc = gdImageGetPixel (dst, tox, toy);
- ncR = gdImageRed (src, c) * (pct / 100.0)
- + gdImageRed (dst, dc) * ((100 - pct) / 100.0);
- ncG = gdImageGreen (src, c) * (pct / 100.0)
- + gdImageGreen (dst, dc) * ((100 - pct) / 100.0);
- ncB = gdImageBlue (src, c) * (pct / 100.0)
- + gdImageBlue (dst, dc) * ((100 - pct) / 100.0);
+ ncR = (int)(gdImageRed (src, c) * (pct / 100.0f)
+ + gdImageRed (dst, dc) * ((100 - pct) / 100.0f));
+ ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f)
+ + gdImageGreen (dst, dc) * ((100 - pct) / 100.0f));
+ ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f)
+ + gdImageBlue (dst, dc) * ((100 - pct) / 100.0f));
/* Find a reasonable color */
nc = gdImageColorResolve (dst, ncR, ncG, ncB);
else
{
dc = gdImageGetPixel (dst, tox, toy);
- g = 0.29900 * dst->red[dc]
- + 0.58700 * dst->green[dc]
- + 0.11400 * dst->blue[dc];
+ g = (0.29900f * dst->red[dc])
+ + (0.58700f * dst->green[dc])
+ + (0.11400f * dst->blue[dc]);
- ncR = gdImageRed (src, c) * (pct / 100.0)
+ ncR = (int)(gdImageRed (src, c) * (pct / 100.0f)
+ gdImageRed (dst, dc) * g *
- ((100 - pct) / 100.0);
- ncG = gdImageGreen (src, c) * (pct / 100.0)
+ ((100 - pct) / 100.0f));
+ ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f)
+ gdImageGreen (dst, dc) * g *
- ((100 - pct) / 100.0);
- ncB = gdImageBlue (src, c) * (pct / 100.0)
+ ((100 - pct) / 100.0f));
+ ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f)
+ gdImageBlue (dst, dc) * g *
- ((100 - pct) / 100.0);
+ ((100 - pct) / 100.0f));
/* First look for an exact match */
nc = gdImageColorExact (dst, ncR, ncG, ncB);
do
{
float yportion;
- if (floor (sy) == floor (sy1))
+ if (floorf (sy) == floorf (sy1))
{
- yportion = 1.0 - (sy - floor (sy));
+ yportion = 1.0f - (sy - floorf (sy));
if (yportion > sy2 - sy1)
{
yportion = sy2 - sy1;
}
- sy = floor (sy);
+ sy = floorf (sy);
}
- else if (sy == floor (sy2))
+ else if (sy == floorf (sy2))
{
- yportion = sy2 - floor (sy2);
+ yportion = sy2 - floorf (sy2);
}
else
{
- yportion = 1.0;
+ yportion = 1.0f;
}
sx1 = ((float) x - (float) dstX) * (float) srcW /
dstW;
float xportion;
float pcontribution;
int p;
- if (floor (sx) == floor (sx1))
+ if (floorf (sx) == floorf (sx1))
{
- xportion = 1.0 - (sx - floor (sx));
+ xportion = 1.0f - (sx - floorf (sx));
if (xportion > sx2 - sx1)
{
xportion = sx2 - sx1;
}
- sx = floor (sx);
+ sx = floorf (sx);
}
- else if (sx == floor (sx2))
+ else if (sx == floorf (sx2))
{
- xportion = sx2 - floor (sx2);
+ xportion = sx2 - floorf (sx2);
}
else
{
- xportion = 1.0;
+ xportion = 1.0f;
}
pcontribution = xportion * yportion;
p = gdImageGetTrueColorPixel (
new_g = (new_g/filter_div)+offset;
new_b = (new_b/filter_div)+offset;
- new_r = (new_r > 255.0)? 255.0 : ((new_r < 0.0)? 0.0:new_r);
- new_g = (new_g > 255.0)? 255.0 : ((new_g < 0.0)? 0.0:new_g);
- new_b = (new_b > 255.0)? 255.0 : ((new_b < 0.0)? 0.0:new_b);
+ new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
+ new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
+ new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
if (new_pxl == -1) {
new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));
- if (new_r < 0.0) {
+ if (new_r < 0.0f) {
new_r = -new_r;
}
if (new_r != 0) {
- flt_r[j][i] = 1.0/new_r;
+ flt_r[j][i] = 1.0f/new_r;
} else {
- flt_r[j][i] = 1.0;
+ flt_r[j][i] = 1.0f;
}
new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));
- if (new_g < 0.0) {
+ if (new_g < 0.0f) {
new_g = -new_g;
}
if (new_g != 0) {
- flt_g[j][i] = 1.0/new_g;
+ flt_g[j][i] = 1.0f/new_g;
} else {
- flt_g[j][i] = 1.0;
+ flt_g[j][i] = 1.0f;
}
new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));
- if (new_b < 0.0) {
+ if (new_b < 0.0f) {
new_b = -new_b;
}
if (new_b != 0) {
- flt_b[j][i] = 1.0/new_b;
+ flt_b[j][i] = 1.0f/new_b;
} else {
- flt_b[j][i] = 1.0;
+ flt_b[j][i] = 1.0f;
}
}
}
}
- new_r = (new_r > 255.0)? 255.0 : ((new_r < 0.0)? 0.0:new_r);
- new_g = (new_g > 255.0)? 255.0 : ((new_g < 0.0)? 0.0:new_g);
- new_b = (new_b > 255.0)? 255.0 : ((new_b < 0.0)? 0.0:new_b);
+ new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
+ new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
+ new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
if (new_pxl == -1) {
new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
png_byte sig[8];
png_structp png_ptr;
png_infop info_ptr;
- png_uint_32 width, height, rowbytes;
+ png_uint_32 width, height, rowbytes, w, h;
int bit_depth, color_type, interlace_type;
int num_palette, num_trans;
png_colorp palette;
}
/* set the individual row_pointers to point at the correct offsets */
- for (j = 0; j < height; ++j)
+ for (h = 0; h < height; ++h)
{
- row_pointers[j] = image_data + j * rowbytes;
+ row_pointers[h] = image_data + h * rowbytes;
}
png_read_image (png_ptr, row_pointers); /* read whole image... */
switch (color_type)
{
case PNG_COLOR_TYPE_RGB:
- for (j = 0; j < height; j++)
+ for (h = 0; h < height; h++)
{
int boffset = 0;
- for (i = 0; i < width; i++)
+ for (w = 0; w < width; w++)
{
- register png_byte r = row_pointers[j][boffset++];
- register png_byte g = row_pointers[j][boffset++];
- register png_byte b = row_pointers[j][boffset++];
- im->tpixels[j][i] = gdTrueColor (r, g, b);
+ register png_byte r = row_pointers[h][boffset++];
+ register png_byte g = row_pointers[h][boffset++];
+ register png_byte b = row_pointers[h][boffset++];
+ im->tpixels[h][w] = gdTrueColor (r, g, b);
}
}
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
- for (j = 0; j < height; j++)
+ for (h = 0; h < height; h++)
{
int boffset = 0;
- for (i = 0; i < width; i++)
+ for (w = 0; w < width; w++)
{
- register png_byte r = row_pointers[j][boffset++];
- register png_byte g = row_pointers[j][boffset++];
- register png_byte b = row_pointers[j][boffset++];
+ register png_byte r = row_pointers[h][boffset++];
+ register png_byte g = row_pointers[h][boffset++];
+ register png_byte b = row_pointers[h][boffset++];
/* gd has only 7 bits of alpha channel resolution, and
127 is transparent, 0 opaque. A moment of convenience,
a lifetime of compatibility. */
register png_byte a = gdAlphaMax -
- (row_pointers[j][boffset++] >> 1);
- im->tpixels[j][i] = gdTrueColorAlpha (r, g, b, a);
+ (row_pointers[h][boffset++] >> 1);
+ im->tpixels[h][w] = gdTrueColorAlpha (r, g, b, a);
}
}
break;
default:
/* Palette image, or something coerced to be one */
- for (j = 0; j < height; ++j)
+ for (h = 0; h < height; ++h)
{
- for (i = 0; i < width; ++i)
+ for (w = 0; w < width; ++w)
{
- register png_byte idx = row_pointers[j][i];
- im->pixels[j][i] = idx;
+ register png_byte idx = row_pointers[h][w];
+ im->pixels[h][w] = idx;
open[idx] = 0;
}
}