From: gaw zay (gauze@rifug.org)
Date: Thu 29 Nov 2001 - 04:51:04 IST
hi, I was hacking together something and wanted to do a snapshot of the screen so I hacked up a function which is kludgy at best, basically I was wondering if there was a better way to do this (the switch/case part, ugly!) it looks fairly close to screen output, and luckily I don't use any of the 'in between colors' in this program. (I'm just using the 0-15 color values for vga_setcolor() if it isn't obvious, the color names (LIGHT_RED, etc) are defined by an enum earlier) Are there any functions to get rgb values of these 16 basic colors is my question, I guess. (or a way to decode gl_getpixelrgb() when using these?) thanks in advance, brian code follows /* ze function */ void ppmsnapshot(void) { FILE *file; int x, y, width = 320, height = 200; int color, r=0, g=0, b=0; file = fopen("snapshot.ppm", "w"); fprintf(file, "P3\n%d %d\n255\n", width, height); //ppm header for (y = 0; y < height; y++) { if (y > 0) fprintf(file,"\n"); for (x = 0; x < width; x++) { color = gl_getpixel(x, y); switch (color) { case BLACK: r = g = b = 0; break; case WHITE: r = g = b = 255; break; case RED: r=127; g = b = 0; break; case GREEN: g=127; r = b = 0; break; case BLUE: b=127; r = g = 0; break; case LIGHT_GREEN: g=255; b = r = 0; break; case LIGHT_BLUE: b=255; r = g = 0; break; case LIGHT_RED: r=127; b = g = 0; break; } fprintf(file, "%d %d %d ", r, g, b); } } fclose(file); return; } ------------Rhode Island Free Unix Group---------- http://www.rifug.org mailto:gauze@rifug.org ------------------------------------------------------------------ Unsubscribe: To: listbot@svgalib.org Body: unsubscribe linux-svgalib
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:24 IST