29 #include <grass/gis.h> 30 #include <grass/glocale.h> 31 #include <grass/ogsf.h> 45 unsigned int xsize, ysize;
47 unsigned char *pixbuf;
51 if (
NULL == (fp = fopen(name,
"w"))) {
52 G_warning(_(
"Unable to open file <%s> for writing"), name);
56 fprintf(fp,
"P6\n%d %d\n255\n", xsize, ysize);
58 for (y = ysize - 1; y >= 0; y--) {
59 for (x = 0; x < xsize; x++) {
60 unsigned char r = pixbuf[(y * xsize +
x) * 4 + 0];
61 unsigned char g = pixbuf[(y * xsize +
x) * 4 + 1];
62 unsigned char b = pixbuf[(y * xsize +
x) * 4 + 2];
90 unsigned char *pixbuf;
94 if (
NULL == (fp = fopen(name,
"w"))) {
95 G_warning(_(
"Unable to open file <%s> for writing"), name);
99 fprintf(fp,
"P6\n%d %d\n255\n", xsize, ysize);
101 for (y = ysize - 1; y >= 0; y--) {
102 for (x = 0; x < xsize; x++) {
103 unsigned char r = pixbuf[(y * xsize +
x) * 4 + 0];
104 unsigned char g = pixbuf[(y * xsize +
x) * 4 + 1];
105 unsigned char b = pixbuf[(y * xsize +
x) * 4 + 2];
int GS_write_zoom(const char *name, unsigned int xsize, unsigned int ysize)
Write zoom to file.
int GS_write_ppm(const char *name)
Save current GL screen to ppm file.
int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize, unsigned int *ysize)
Get image of current GL screen.
int gsd_writeView(unsigned char **pixbuf, unsigned int xsize, unsigned int ysize)
Write view.
void G_free(void *buf)
Free allocated memory.
void G_warning(const char *msg,...)
Print a warning message to stderr.