9 #define min(a,b) ((a)<(b)?(a):(b))
12 #define max(a,b) ((a)>(b)?(a):(b))
22 static double scale(
double k,
const int src[2],
const int dst[2])
24 return dst[0] + (double)(k - src[0]) * (dst[1] - dst[0]) / (src[1] -
28 static int scale_fwd_y(
int sy)
30 return (
int)floor(scale(sy, src[1], dst[1]) + 0.5);
33 static int scale_rev_x(
int dx)
35 return (
int)floor(scale(dx + 0.5, dst[0], src[0]));
38 static int next_row(
int sy,
int dy)
43 int y = scale_fwd_y(sy);
51 static void alloc_buffers(
void)
57 trans = G_realloc(trans, nalloc *
sizeof(
int));
64 ncols = d[0][1] - d[0][0];
66 memcpy(src, s,
sizeof(src));
67 memcpy(dst, d,
sizeof(dst));
72 for (i = 0; i < ncols; i++)
73 trans[i] = scale_rev_x(d[0][0] + i);
77 const unsigned char *red,
const unsigned char *grn,
78 const unsigned char *blu,
const unsigned char *nul)
80 int d_y0 = scale_fwd_y(row + 0);
81 int d_y1 = scale_fwd_y(row + 1);
82 int d_rows = d_y1 - d_y0;
90 return next_row(row, d_y0);
92 for (x = x0; x < x1; x++) {
93 int xx = dst[0][0] + x;
97 if (masked && nul && nul[j])
100 c =
get_color(red[j], grn[j], blu[j], 0);
102 for (y = y0; y < y1; y++) {
111 return next_row(row, d_y1);
void PNG_begin_scaled_raster(int, int[2][2], int[2][2])
int PNG_scaled_raster(int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
unsigned int get_color(int r, int g, int b, int a)