From: gradha AT iname DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: ANDing bitmaps under allegro Date: Wed, 3 Nov 1999 23:53:19 +0100 Organization: Telefonica Transmision de Datos Lines: 41 Message-ID: References: <381F80A9 DOT 2DE040EB AT cs DOT iastate DOT edu> <38206093 DOT A877DBEC AT cs DOT iastate DOT edu> NNTP-Posting-Host: info127.jet.es User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (Linux/2.2.10 (i686)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com >> > I need to AND two bitmaps together, and assign the result to a new >> > bitmap. Does anyone know how to do this? >> >> But what do you mean by ANDing? > > I am running at 8bpp. Basically, I have a bitmap containing an image, > and then another with a silhouette of that image in white on black. Hmmm... I think that's simply "masking". In palette modes, usually black is color 0 and white 255 (or the other way round), so using a bit and wouldn't be very good, IMHO. I think it's better if you create a loop, which reads pixels from the mask bitmap and converts them to grey (if necessary). If the grey you get is more than 50% black, you ignore that pixel. If it's white, you draw the pixel on a third bitmap. In the end you will have a final bitmap with the first image masked by the second one. If you know that you are really using only two palette colors, and that for example, black is 0 and white is 255, then it's just a loop doing something like (pseudo-code): for (y=0;yh;y++) { for (x=0;xh;x++) { color = getpixel(mask_bmp,x,y); /* white could be 0, 255, or other value depending on your palette */ if (color == white) putpixel(final_bmp,x,y,color); else putpixel(final_bmp,x,y,0); } } Grzegorz Adam Hankiewicz - gradha AT iname DOT com Gogosoftware - http://welcome.to/gogosoftware/