Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!sgi!shinobu!odin!dave From: dave@sgi.com (dave "who can do? ratmandu!" ratcliffe) Newsgroups: comp.sys.sgi Subject: Re: Creating Image Files Keywords: SGI imagelib image file format--creating one's own images of this kind Message-ID: <1990Oct4.143609.6981@odin.corp.sgi.com> Date: 4 Oct 90 14:36:09 GMT References: <4671@tahoe.unr.edu> Sender: news@odin.corp.sgi.com (Net News) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 186 In article <4671@tahoe.unr.edu> dahl@tahoe.unr.edu (Michael Dahl) writes: > >I want to produce, from within my application, image files of the format >produced by snapshot(1). Can anyone tell me the file format? hi Michael- a boatload o' worms you sail in w/here with but i'll try to give it a go: so snapshot uses the ubiquitous gl_readscreen (see the post i just sent out before this one responding to a query about wanting more info on this un- documented GL call) to go read, scanline by scanline, whatever area of the screen is specified and, returns RGB triples for each pixel into the three red green and blue arrays gl_readscreen gets called with. unfortunately the request for information on the format of the equally ubiquitous "SGI imagelib image" -type files betrays the dangling embarrassment that this information has never been adequately documented... without being able to give you a blow-blow, technically inclusive specification of this format, here are some of the most salient points. (please know that i am, at this moment engaged in trying to work with those in the know, to once and for all create the ultimate document on the iris image libraries which *will* contain the details about the creation and manipulation of "SGI imagelib image" files. regretably, i am unable at this time to tell you when this will be completed.) refer to the IMAGE structure in /usr/include/gl/image.h this is the meat of what you are asking about. the IMAGE structure *is* the header for every file created by snapshot/icut/scrsave which calls gl_readscreen. if you haven't already found it, see /usr/people/4Dgifts/iristools. this subtree under the 4Dgifts sample source code user account contains all the source you are wondering about (~4Dgifts/iristools/libimage/* contains all the source that builds the library /usr/lib/libimage.a, ~4Dgifts/iristools/libgutil contains all the source that builds the library /usr/lib/libgutil.a). this subtree is still in a process of "evolvement" and its lack of documentation is an area we in support engineering are painfully aware of and are trying to correct. (if you can't find /usr/people/4Dgifts on yer machine it's because no one has ever gone into manual mode while running the installation tool and explicitly tagged "dev.sw.giftssrc" for loading. see the description in the Release and Installation Notes document for how to do this from the DEVelopment tape.) in essence you want to fold the guts of ~4Dgifts/iristools/imgtools/writeimg.c into yer own code. this standalone "lobotomized" example program creates the SGI imagelib image file format you are seeking. lets briefly examine writeimg.c: ----------------------------------------------------- /* * writeimg - * Write out an RGB image file. This example uses three functions * from the image library: * * iopen, putrow, and iclose. * * The function iopen is called to describe the xsize and ysize of the * RGB image to be written out. * * The function putrow writes a row of image data to the image file. It is * called with an array of shorts with values in the range [0..255]. * * The function iclose is called to close the image file. * * Why not modify this program to be a filter that converts from your own * image file format to IRIS images? * * Paul Haeberli - 1987 * */ #include "image.h" unsigned short rbuf[4096]; unsigned short gbuf[4096]; unsigned short bbuf[4096]; main(argc,argv) int argc; char **argv; { int y; int xsize, ysize; IMAGE *image; if(argc<4) { fprintf(stderr,"usage writeimg name xsize ysize\n"); exit(1); } xsize = atoi(argv[2]); ysize = atoi(argv[3]); image = iopen(argv[1],"w",RLE(1),3,xsize,ysize,3); for(y=0; y