31 #include <sys/types.h> 33 #include <w32api/wtypes.h> 41 unsigned short config = PLANARCONFIG_CONTIG;
57 unsigned int xsize, ysize;
58 int mapsize, linebytes;
59 unsigned char *buf, *tmpptr;
60 unsigned char *pixbuf;
63 G_warning(
_(
"Unable to get image of current GL screen"));
67 out = TIFFOpen(name,
"w");
69 G_warning(
_(
"Unable to open file <%s> for writing"), name);
75 TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize);
76 TIFFSetField(out, TIFFTAG_IMAGELENGTH, ysize);
77 TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
78 TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 24 > 8 ? 3 : 1);
79 TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 24 > 1 ? 8 : 1);
80 TIFFSetField(out, TIFFTAG_PLANARCONFIG,
config);
83 TIFFSetField(out, TIFFTAG_PHOTOMETRIC, 24 > 8 ?
84 PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK);
86 linebytes = ((xsize * ysize + 15) >> 3) & ~1;
88 if (TIFFScanlineSize(out) > linebytes) {
89 buf = (
unsigned char *)
G_malloc(linebytes);
92 buf = (
unsigned char *)
G_malloc(TIFFScanlineSize(out));
99 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
103 for (y = 0; y < ysize; y++) {
104 unsigned int yy = ysize - y - 1;
108 for (x = 0; x < (xsize); x++) {
109 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 0];
110 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 1];
111 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 2];
114 if (TIFFWriteScanline(out, buf, y, 0) < 0) {
120 (void)TIFFClose(out);
unsigned short compression
void G_free(void *)
Free allocated memory.
int GS_write_tif(const char *name)
Write data to tif file.
int gsd_getimage(unsigned char **, unsigned int *, unsigned int *)
Get image of current GL screen.
unsigned short rowsperstrip
void G_warning(const char *,...) __attribute__((format(printf