Re: Editing bitmaps with transparency

New Message Reply Date view Thread view Subject view Author view

ceti (ceti++at++worldnet.net)
Tue, 18 Jun 1996 08:57:27 +0100


>Hi everybody,
>
>We want to create textures (RGBA files) to use with performer. we
>need to use
>transparency for the background of the texture. We did not find any
>tool in the
>standard installation of our high impact machine. Tring to convert
>TIFF with alpha channel does not work. Is there some tools available
>to edit bitmaps ?

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


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:01 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.