Trouble with Iris IMG library

Paul Haeberli paul at manray.sgi.com
Tue Mar 20 03:50:11 AEST 1990


The reason you had problems converting a file from Alias QuickPaint is that 
QuickPaint saves its images as colo(u)r index pixels.  To use a QuickPaint
image with the image processing tools or the image library it is best to 
convert it into an RGB image.  

The following script does just that by first saving the current colo(u)r-map, 
and then mapping the color indexed pixels into rgb space.  The programs 
"savemap" and "mapimg" can be found in /usr/people/4Dgifts/iristools/imgtools
if they aren't found in /usr/sbin.


This is fromqp:

#! /bin/sh
if [ $# != 2 ]
then
	echo "usage: fromqp in.qp out.rgb"
	exit 1
fi
savemap /tmp/qp.map
mapimg $1 $2 /tmp/qp.map
rm /tmp/qp.map




To write out an rgb IRIS image from a renderer use a sequence of image
library calls like this:


#include "gl/image.h"
/*
 *	writeiris - 
 *		This function takes three arrays of unsigned characters and 
 *	writes these as pixel data to an IRIS image file that can be ipasted
 *	to the screen.
 *
 */
writeiris(rbuf,gbuf,bbuf,xsize,ysize)
unsigned char *rbuf, *gbuf, *bbuf;
int xsize, ysize;
{
    IMAGE *oimage;
    unsigned short *rs, *gs, *bs;
    int x, y;

    rs = (unsigned short *)malloc(xsize*sizeof(unsigned short));
    gs = (unsigned short *)malloc(xsize*sizeof(unsigned short));
    bs = (unsigned short *)malloc(xsize*sizeof(unsigned short));
    oimage = iopen("render.rgb","w",RLE(1),3,xsize,ysize,3);
    for(y=0; y<ysize; y++) {
	for(x=0; x<xsize; x++) {
	    rs[x] = *rbuf++;
	    gs[x] = *gbuf++;
	    bs[x] = *bbuf++;
	}
	putrow(oimage,rs,y,0);
	putrow(oimage,gs,y,1);
	putrow(oimage,bs,y,2);
    }
    iclose(oimage);
    free(rs);
    free(gs);
    free(bs);
}



Please let me know if you still have problems . . . . .

paul haeberli

paul at sgi.com



More information about the Comp.sys.sgi mailing list