3 static int src_t, src_b, src_l, src_r, src_w, src_h;
4 static int dst_t, dst_b, dst_l, dst_r, dst_w, dst_h;
6 static cairo_surface_t *src_surf;
7 static unsigned char *src_data;
14 G_debug(1,
"Cairo_begin_scaled_raster: %d %d %d %d %d %d %d %d %d",
15 mask, s[0][0], s[0][1], s[1][0], s[1][1], d[0][0], d[0][1],
27 src_w = src_r - src_l;
28 src_h = src_b - src_t;
35 dst_w = dst_r - dst_l;
36 dst_h = dst_b - dst_t;
38 G_debug(1,
" src (TBLR): %d %d %d %d, dst (TBLR) %d %d %d %d",
39 src_t, src_b, src_l, src_r, dst_t, dst_b, dst_l, dst_r);
42 src_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, src_w, src_h);
43 if (cairo_surface_status(src_surf) != CAIRO_STATUS_SUCCESS)
44 G_fatal_error(
"Cairo_begin_scaled_raster: Failed to create surface");
46 src_data = cairo_image_surface_get_data(src_surf);
47 src_stride = cairo_image_surface_get_stride(src_surf);
51 const unsigned char *red,
const unsigned char *grn,
52 const unsigned char *blu,
const unsigned char *nul)
55 (
unsigned int *)(src_data + (row - src_t) * src_stride);
58 G_debug(3,
"Cairo_scaled_raster: %d %d", n, row);
60 for (i = 0; i <
n; i++) {
61 if (masked && nul && nul[i])
64 unsigned int r = red[i];
65 unsigned int g = grn[i];
66 unsigned int b = blu[i];
67 unsigned int a = 0xFF;
69 *dst++ = (a << 24) + (r << 16) + (g << 8) + (b << 0);
78 G_debug(1,
"Cairo_end_scaled_raster");
82 cairo_translate(
cairo, dst_l, dst_t);
83 cairo_scale(
cairo, (
double)dst_w / (
double)src_w,
84 (
double)dst_h / (
double)src_h);
85 cairo_surface_mark_dirty(src_surf);
86 cairo_set_source_surface(
cairo, src_surf, 0, 0);
91 cairo_surface_destroy(src_surf);
void Cairo_begin_scaled_raster(int, int[2][2], int[2][2])
int Cairo_scaled_raster(int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
void Cairo_end_scaled_raster(void)
int G_debug(int level, const char *msg,...)
Print debugging message.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.