helly Thu Nov 28 17:48:20 2002 EDT Modified files: /php4/ext/gd/libgd gd.c gd_gd2.c gd_jpeg.c gd_png.c /php4/ext/gd gd.c Log: Conversion fixes
Index: php4/ext/gd/libgd/gd.c diff -u php4/ext/gd/libgd/gd.c:1.28 php4/ext/gd/libgd/gd.c:1.29 --- php4/ext/gd/libgd/gd.c:1.28 Sun Nov 24 20:51:52 2002 +++ php4/ext/gd/libgd/gd.c Thu Nov 28 17:48:19 2002 @@ -244,7 +244,7 @@ #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)) @@ -319,7 +319,7 @@ } 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 */ @@ -878,7 +878,7 @@ 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; } @@ -948,7 +948,7 @@ 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; @@ -1033,7 +1033,7 @@ 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; @@ -1880,12 +1880,12 @@ { 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); @@ -1930,19 +1930,19 @@ 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); @@ -2123,22 +2123,22 @@ 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; @@ -2150,22 +2150,22 @@ 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 ( @@ -3444,9 +3444,9 @@ 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) { @@ -3504,35 +3504,35 @@ 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; } } @@ -3567,9 +3567,9 @@ } } - 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); Index: php4/ext/gd/libgd/gd_gd2.c diff -u php4/ext/gd/libgd/gd_gd2.c:1.6 php4/ext/gd/libgd/gd_gd2.c:1.7 --- php4/ext/gd/libgd/gd_gd2.c:1.6 Mon Nov 25 09:25:52 2002 +++ php4/ext/gd/libgd/gd_gd2.c Thu Nov 28 17:48:19 2002 @@ -763,7 +763,7 @@ /* The zlib notes say output buffer size should be (input size) * 1.01 * 12 */ /* - we'll use 1.02 to be paranoid. */ /* */ - compMax = cs * bytesPerPixel * cs * 1.02 + 12; + compMax = (int)(cs * bytesPerPixel * cs * 1.02f) + 12; /* */ /* Allocate the buffers. */ Index: php4/ext/gd/libgd/gd_jpeg.c diff -u php4/ext/gd/libgd/gd_jpeg.c:1.6 php4/ext/gd/libgd/gd_jpeg.c:1.7 --- php4/ext/gd/libgd/gd_jpeg.c:1.6 Sun Nov 24 20:51:53 2002 +++ php4/ext/gd/libgd/gd_jpeg.c Thu Nov 28 17:48:19 2002 @@ -281,7 +281,8 @@ volatile JSAMPROW row = 0; volatile gdImagePtr im = 0; JSAMPROW rowptr[1]; - int i, j, retval; + unsigned int i, j; + int retval; JDIMENSION nrows; #ifdef JPEG_DEBUG Index: php4/ext/gd/libgd/gd_png.c diff -u php4/ext/gd/libgd/gd_png.c:1.6 php4/ext/gd/libgd/gd_png.c:1.7 --- php4/ext/gd/libgd/gd_png.c:1.6 Sun Nov 24 20:51:53 2002 +++ php4/ext/gd/libgd/gd_png.c Thu Nov 28 17:48:19 2002 @@ -116,7 +116,7 @@ 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; @@ -319,9 +319,9 @@ } /* 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... */ @@ -352,44 +352,44 @@ 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; } } Index: php4/ext/gd/gd.c diff -u php4/ext/gd/gd.c:1.228 php4/ext/gd/gd.c:1.229 --- php4/ext/gd/gd.c:1.228 Sat Nov 23 19:59:41 2002 +++ php4/ext/gd/gd.c Thu Nov 28 17:48:20 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.228 2002/11/24 00:59:41 moriyoshi Exp $ */ +/* $Id: gd.c,v 1.229 2002/11/28 22:48:20 helly Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -3988,7 +3988,7 @@ if (im_src==NULL) { RETURN_FALSE; } - if (gdImageSmooth(im_src, weight)==1) { + if (gdImageSmooth(im_src, (float)weight)==1) { RETURN_TRUE; } RETURN_FALSE;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php