From: Flenser Newsgroups: comp.os.msdos.djgpp Subject: Re: ANDing bitmaps under allegro Date: Wed, 03 Nov 1999 19:20:05 -0600 Organization: Iowa State University, Ames, Iowa, USA Lines: 49 Message-ID: <3820DF45.D34E8ADC@cs.iastate.edu> References: <381F80A9 DOT 2DE040EB AT cs DOT iastate DOT edu> <38206093 DOT A877DBEC AT cs DOT iastate DOT edu> NNTP-Posting-Host: friley-161-9.res.iastate.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.61 [en] (Win95; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com The operation was called and under Paint Shop's arithmetic operations dialog, that's all I know about it. Your idea works fine, I was just hoping that there was some magic solution that didn't involve going through each pixel and testing it. Thank you for your help. gradha AT iname DOT com wrote: > >> > 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/ > >