21#define min(a, b) ((a) < (b) ? (a) : (b))
24#define max(a, b) ((a) > (b) ? (a) : (b))
34static double scale(
double k,
const int src[2],
const int dst[2])
37 (
double)(k - src[0]) * (dst[1] - dst[0]) / (src[1] - src[0]);
40static int scale_fwd_y(
int sy)
42 return (
int)
floor(scale(sy, src[1], dst[1]) + 0.5);
45static int scale_rev_x(
int dx)
47 return (
int)
floor(scale(dx + 0.5, dst[0], src[0]));
50static int next_row(
int sy,
int dy)
55 int y = scale_fwd_y(sy);
63static void alloc_buffers(
void)
69 trans =
G_realloc(trans, nalloc *
sizeof(
int));
84 d[0][0] = (
int)
floor(fd[0][0] + 0.5);
85 d[0][1] = (
int)
floor(fd[0][1] + 0.5);
86 d[1][0] = (
int)
floor(fd[1][0] + 0.5);
87 d[1][1] = (
int)
floor(fd[1][1] + 0.5);
89 ncols = d[0][1] - d[0][0];
91 memcpy(src, s,
sizeof(src));
92 memcpy(dst, d,
sizeof(dst));
97 for (i = 0; i < ncols; i++)
98 trans[i] = scale_rev_x(d[0][0] + i);
111 const unsigned char *grn,
const unsigned char *blu,
112 const unsigned char *
nul)
114 int d_y0 = scale_fwd_y(row + 0);
115 int d_y1 = scale_fwd_y(row + 1);
117 int x0 =
max(
png.clip_left - dst[0][0], 0);
118 int x1 =
min(
png.clip_rite - dst[0][0], ncols);
124 return next_row(row,
d_y1);
126 for (
x = x0;
x < x1;
x++) {
127 int xx = dst[0][0] +
x;
136 for (y =
y0; y < y1; y++) {
145 return next_row(row,
d_y1);
unsigned int png_get_color(int r, int g, int b, int a)
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
void PNG_begin_raster(int mask, int s[2][2], double fd[2][2])
Start drawing raster.
int PNG_raster(int n, int row, const unsigned char *red, const unsigned char *grn, const unsigned char *blu, const unsigned char *nul)
Draw raster row.
GRASS png display driver - header file.