8 int i_width, i_height, maxval;
14 if (fscanf(input,
"P6 %d %d %d", &i_width, &i_height, &maxval) != 3)
21 (
"cairo: input file has incorrect dimensions: expected: %dx%d got: %dx%d",
24 mask_name[strlen(mask_name) - 2] =
'g';
26 mask = fopen(mask_name,
"rb");
28 G_fatal_error(
"cairo: couldn't open input mask file %s", mask_name);
30 if (fscanf(mask,
"P5 %d %d %d", &i_width, &i_height, &maxval) != 3)
31 G_fatal_error(
"cairo: invalid input mask file %s", mask_name);
37 (
"cairo: input mask file has incorrect dimensions: expected: %dx%d got: %dx%d",
42 for (y = 0; y <
height; y++) {
43 unsigned int *row = (
unsigned int *)(
grid + y *
stride);
45 for (x = 0; x <
width; x++) {
56 if (a > 0 && a < 0xFF) {
62 row[x] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
void G_free(void *buf)
Free allocated memory.
char * G_store(const char *s)
Copy string to allocated memory.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.