ceti (ceti++at++worldnet.net)
Tue, 18 Jun 1996 08:57:27 +0100
Here is a tool I ve done to mix a rgb file containning image and an other
(black and white saved in rgb ) containning the alpha mask to create a rgba
file that you can check using the import image option of showcase.
/*
*
* To compile: cc addalpha.c -o addalpha -limage
* BILLARD Olivier ceti++at++worldnet.net
* Thanks to Paul Haerbli for readimage.c
*/
#include <gl/image.h>
main(argc,argv)
int argc;
char **argv;
{
IMAGE *imagergb;
IMAGE *imagea;
IMAGE *imagergba;
int x, y, z;
short *rbuf, *gbuf, *bbuf,*abuf;
/* print usage message */
if( argc<4 )
{
fprintf(stderr,"usage: readimage rgbinfile alphainfile outfile\n");
exit(1);
}
/* open the image file */
if( (imagergb=iopen(argv[1],"r")) == NULL )
{
fprintf(stderr,"readimage: can't open input file %s\n",argv[1]);
exit(1);
}
if( (imagea=iopen(argv[2],"r")) == NULL )
{
fprintf(stderr,"readimage: can't open input file %s\n",argv[2]);
exit(1);
}
if(
(imagergba=iopen(argv[3],"w",RLE(1),3,imagergb->xsize,imagergb->ysize,4)) ==
NULL )
{
fprintf(stderr,"readimage: can't open input file %s\n",argv[3]);
exit(1);
}
/* print a little info about the image */
printf("Image x and y size in pixels: %d %d\n",imagergb->xsize,imagergb->ysize);
printf("Image zsize in channels: %d\n",imagergb->zsize);
printf("Image pixel min and max: %d %d\n",imagergb->min,imagergb->max);
/* allocate buffers for image data */
rbuf = (short *)malloc(imagergb->xsize*sizeof(short));
gbuf = (short *)malloc(imagergb->xsize*sizeof(short));
bbuf = (short *)malloc(imagergb->xsize*sizeof(short));
abuf = (short *)malloc(imagergb->xsize*sizeof(short));
imagergba->zsize >= 4;
for(y=0; y<imagergb->ysize; y++)
{
printf("row %d: \n",y);
getrow(imagergb,rbuf,y,0);
getrow(imagergb,gbuf,y,1);
getrow(imagergb,bbuf,y,2);
getrow(imagea,abuf,y,0);
putrow(imagergba,rbuf,y,0);
putrow(imagergba,gbuf,y,1);
putrow(imagergba,bbuf,y,2);
putrow(imagergba,abuf,y,3);
}
iclose(imagergb);
iclose(imagea);
iclose(imagergba);
}
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
< _/_/ _/ _/_/_/ _/ _/ _/_/_/ _/_/_/ _/_/_/ >
< _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ >
< _/ _/ _/ _/ _/ _/ _/ _/_/_/ _/ _/ >
< _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/ >
< _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ >
< _/_/ _/_/_/ _/_/_/ _/ _/_/_/ _/_/_/ _/ _/ >
< >
< BILLARD Olivier - Ingeneer R&D ++at++ C&I Software >
< 1 avenue de la mer - 44380 PORNICHET - FRANCE >
< Tel: +33 40 11 68 72 Fax: +33 140 61 68 14 >
< Email: ceti++at++worldnet.net >
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer.html
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:01 PDT