#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;}
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
}
+#if 0
/*
* This is not actually used, but is here for completeness, in case someone wants to
* use the HWB stuff for anything else...
}
return RGB;
-
}
+#endif /* 0 */
int
gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b)
}
}
+static int
+gdImageGetTrueColorPixel (gdImagePtr im, int x, int y)
+{
+ int p = gdImageGetPixel (im, x, y);
+ if (!im->trueColor)
+ {
+ return gdTrueColorAlpha (im->red[p], im->green[p], im->blue[p],
+ (im->transparent == p) ? gdAlphaTransparent :
+ gdAlphaOpaque);
+ }
+ else
+ {
+ return p;
+ }
+}
+
static void
gdImageBrushApply (gdImagePtr im, int x, int y)
{
}
}
-int
-gdImageGetTrueColorPixel (gdImagePtr im, int x, int y)
-{
- int p = gdImageGetPixel (im, x, y);
- if (!im->trueColor)
- {
- return gdTrueColorAlpha (im->red[p], im->green[p], im->blue[p],
- (im->transparent == p) ? gdAlphaTransparent :
- gdAlphaOpaque);
- }
- else
- {
- return p;
- }
-}
-
/* Bresenham as presented in Foley & Van Dam */
void
gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
int dashStep = 0;
int on = 1;
int wid;
- int w, wstart, vert;
+ int vert;
int thick = im->thick;
dx = abs (x2 - x1);
}
if (dst->trueColor)
{
- int d;
mapTo = gdImageGetTrueColorPixel (src, x, y);
/* Added 7/24/95: support transparent copies */
if (gdImageGetTransparent (src) == mapTo)
int srcW, int srcH)
{
int x, y;
- float sx, sy;
if (!dst->trueColor)
{
gdImageCopyResized (
{
for (x = dstX; (x < dstX + dstW); x++)
{
- int pd = gdImageGetPixel (dst, x, y);
+ /*int pd = gdImageGetPixel (dst, x, y);*/
float sy1, sy2, sx1, sx2;
float sx, sy;
float spixels = 0;
- float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
+ float red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
sy1 = ((float) y - (float) dstY) * (float) srcH /
(float) dstH;
sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH /
float yportion;
if (floor (sy) == floor (sy1))
{
- yportion = 1.0 - (sy - floor (sy));
+ yportion = 1.0f - (sy - floor (sy));
if (yportion > sy2 - sy1)
{
yportion = sy2 - sy1;
_gdPutColors (gdImagePtr im, gdIOCtx * out)
{
int i;
- int trans;
gdPutC (im->trueColor, out);
if (!im->trueColor)
int i;
int ncx, ncy, nc, cs, cx, cy;
int x, y, ylo, yhi, xlo, xhi;
- int ch, vers, fmt;
+ int vers, fmt;
t_chunk_info *chunkIdx = NULL; /* So we can gdFree it with impunity. */
unsigned char *chunkBuf = NULL; /* So we can gdFree it with impunity. */
int chunkNum = 0;
{
if (im->trueColor)
{
- ch = chunkBuf[chunkPos++] << 24 +
- chunkBuf[chunkPos++] << 16 +
- chunkBuf[chunkPos++] << 8 +
- chunkBuf[chunkPos++];
+ ch = (chunkBuf[chunkPos++] << 24)
+ + (chunkBuf[chunkPos++] << 16)
+ + (chunkBuf[chunkPos++] << 8)
+ + (chunkBuf[chunkPos++]);
}
else
{
/* 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. */
}
}
jpeg_finish_compress (&cinfo);
-error:
+/*error:*/
jpeg_destroy_compress (&cinfo);
gdFree (row);
}
volatile JSAMPROW row = 0;
volatile gdImagePtr im = 0;
JSAMPROW rowptr[1];
- int i, j, retval;
+ JDIMENSION i, j;
JDIMENSION nrows;
+ int retval;
#ifdef JPEG_DEBUG
printf ("gd-jpeg: gd JPEG version %s\n", GD_JPEG_VERSION);
png_bytepp row_pointers = NULL;
gdImagePtr im = NULL;
int i, j, *open;
+ png_uint_32 ui, uj;
volatile int transparent = -1;
volatile int palette_allocated = FALSE;
}
/* set the individual row_pointers to point at the correct offsets */
- for (j = 0; j < height; ++j)
+ for (uj = 0; uj < height; ++uj)
{
- row_pointers[j] = image_data + j * rowbytes;
+ row_pointers[uj] = image_data + uj * 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 (uj = 0; uj < height; uj++)
{
int boffset = 0;
- for (i = 0; i < width; i++)
+ for (ui = 0; ui < width; ui++)
{
- 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[uj][boffset++];
+ register png_byte g = row_pointers[uj][boffset++];
+ register png_byte b = row_pointers[uj][boffset++];
+ im->tpixels[uj][ui] = gdTrueColor (r, g, b);
}
}
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
- for (j = 0; j < height; j++)
+ for (uj = 0; uj < height; uj++)
{
int boffset = 0;
- for (i = 0; i < width; i++)
+ for (ui = 0; ui < width; ui++)
{
- 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[uj][boffset++];
+ register png_byte g = row_pointers[uj][boffset++];
+ register png_byte b = row_pointers[uj][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[uj][boffset++] >> 1);
+ im->tpixels[uj][ui] = gdTrueColorAlpha (r, g, b, a);
}
}
break;
default:
/* Palette image, or something coerced to be one */
- for (j = 0; j < height; ++j)
+ for (uj = 0; uj < height; ++uj)
{
- for (i = 0; i < width; ++i)
+ for (ui = 0; ui < width; ++ui)
{
- register png_byte idx = row_pointers[j][i];
- im->pixels[j][i] = idx;
+ register png_byte idx = row_pointers[uj][ui];
+ im->pixels[uj][ui] = idx;
open[idx] = 0;
}
}
int i;
int j;
int k;
- int highTrans = -1;
for (i = 0; (i < im->colorsTotal); i++)
{
if ((!im->open[i]) &&
#include "gd.h"
#include "gdhelpers.h"
+#include <string.h>
/*
* This module implements the well-known Heckbert paradigm for color
void
gd_putout (int i, void *out)
{
- gdPutC (i, (gdIOCtx *) out);
+ gdPutC ((unsigned char)i, (gdIOCtx *) out);
}
#ifndef MSWIN32
#include <unistd.h>
+extern int access(const char *pathname, int mode);
#else
#define R_OK 2
#endif
gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
- gdImageStringFT (im, brect, fg, fontlist, ptsize,
+ return gdImageStringFT (im, brect, fg, fontlist, ptsize,
angle, x, y, string);
}
int n;
int font_found = 0;
unsigned short platform, encoding;
- char *fontsearchpath, *fontpath, *fontlist;
+ char *fontsearchpath, *fontlist;
char *fullname = NULL;
char *name, *path, *dir;
char *strtok_ptr;
gdft_draw_bitmap (gdImage * im, int fg, FT_Bitmap bitmap, int pen_x, int pen_y)
{
unsigned char *pixel;
- int *tpixel;
int x, y, row, col, pc;
tweencolor_t *tc_elem;
return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, NULL);
}
+static int
+gdroundupdown (FT_F26Dot6 v1, int updown)
+{
+ return (!updown)
+ ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6)
+ : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
+}
+
char *
gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string,
if (ch == '\r')
{
penf.x = 0;
- x1 = (penf.x * cos_a - penf.y * sin_a + 32) / 64;
- y1 = (penf.x * sin_a + penf.y * cos_a + 32) / 64;
+ x1 = (int)(penf.x * cos_a - penf.y * sin_a + 32) / 64;
+ y1 = (int)(penf.x * sin_a + penf.y * cos_a + 32) / 64;
pen.x = pen.y = 0;
previous = 0; /* clear kerning flag */
next++;
/* newlines */
if (ch == '\n')
{
- penf.y -= face->size->metrics.height * linespace;
+ penf.y -= (long)(face->size->metrics.height * linespace);
penf.y = (penf.y - 32) & -64; /* round to next pixel row */
- x1 = (penf.x * cos_a - penf.y * sin_a + 32) / 64;
- y1 = (penf.x * sin_a + penf.y * cos_a + 32) / 64;
+ x1 = (int)(penf.x * cos_a - penf.y * sin_a + 32) / 64;
+ y1 = (int)(penf.x * sin_a + penf.y * cos_a + 32) / 64;
pen.x = pen.y = 0;
previous = 0; /* clear kerning flag */
next++;
return (char *) NULL;
}
-int
-gdroundupdown (FT_F26Dot6 v1, int updown)
-{
- return (!updown)
- ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6)
- : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
-}
-
#endif /* HAVE_LIBFREETYPE */
#include "gd.h"
#include "gdhelpers.h"
#include <stdlib.h>
+#include <string.h>
/* TBB: gd_strtok_r is not portable; provide an implementation */
i = getin (in);
if (i < 0)
return (-1);
- mbi = mbi << 7 | i & 0x7f;
+ mbi = (mbi << 7) | (i & 0x7f);
}
while (i & 0x80);