31 #include <sys/types.h>
33 #include <w32api/wtypes.h>
41 unsigned short config = PLANARCONFIG_CONTIG;
57 unsigned int xsize, ysize;
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");
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);
82 TIFFSetField(out, TIFFTAG_PHOTOMETRIC,
83 24 > 8 ? PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK);
85 linebytes = ((xsize * ysize + 15) >> 3) & ~1;
87 if (TIFFScanlineSize(out) > linebytes) {
88 buf = (
unsigned char *)
G_malloc(linebytes);
91 buf = (
unsigned char *)
G_malloc(TIFFScanlineSize(out));
98 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
102 for (y = 0; y < ysize; y++) {
103 unsigned int yy = ysize - y - 1;
107 for (
x = 0;
x < (xsize);
x++) {
108 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 0];
109 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 1];
110 *tmpptr++ = pixbuf[(yy * xsize +
x) * 4 + 2];
113 if (TIFFWriteScanline(out, buf, y, 0) < 0) {
120 (void)TIFFClose(out);
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int gsd_getimage(unsigned char **, unsigned int *, unsigned int *)
Get image of current GL screen.
unsigned short rowsperstrip
int GS_write_tif(const char *name)
Write data to tif file.
unsigned short compression