/* *************************************************************************** * Scan_sample.c * *************************************************************************** * This program demonstrates how to use the edge library commands to write* * out images in scanline order. The image can either be written to a file * * or to the screen. To display the rle file on the Hps use * * getX11 or * * get24 * * On the Suns, use getX11 * * For more information on the functions and on the Utah Raster Toolkit * * routines, do a man on the command, or "man -k rle" for a listing of all * * the utah raster toolkit function names. * * * * The call to ct_gen sets up a color table on the 8-bit HPs and sets the * * 24-bit HPs to use all 24 bits. For further explanation on this routine, * * edge_open, or write_buffer, see the online man pages. * *************************************************************************** */ #include #define FNAMELEN 256 #define MAX_X_RES 1024 main() { edge_td *buffer; rgb_td pixel_data[MAX_X_RES], background, colors[2]; char image_filename[FNAMELEN]; int vt=499, vb=0, vl=0,vr=499, height,width, i,j, count =2; /* med blue background (great for photographing the screen) */ background.r = background.g =0; background.b = .5; /* set up the colors for the objects for the call to ct_gen */ colors[0].r = 1.0; colors[0].g = 1.0; colors[0].b = 0.0; colors[1].r = 1.0; colors[1].g = colors[1].b = 0.0; printf("Enter filename for the file or 0 to draw to the screen\n"); scanf("%s", image_filename); height = vt - vb +1; width = vr - vl +1; /* Open the buffer */ if(strcmp("0",image_filename)!=0) { buffer = edge_open(RLE_FILE,height, width, image_filename); } else { buffer = edge_open(X11_DISPLAY,height, width,""); edge_clear(buffer); } /* set up the color table */ ct_gen(buffer,background,count,colors); /* write out a very simple scanline image */ for(i=0; i < height; i++) { init_scanline(pixel_data,background, width); if(i > 124 && i < 375) { for(j=125; j < 375; j++) { pixel_data[j] =colors[0]; } } else { for(j=125; j < 375; j++) { pixel_data[j] = colors[1]; } } write_buffer(pixel_data,i,vl,width,buffer); } edge_close(buffer); } init_scanline(pixel_data, background,width) rgb_td pixel_data[], background; int width; { int i; for(i=0; i < width; i++) pixel_data[i]=background; }