From: Flenser Newsgroups: comp.os.msdos.djgpp Subject: Re: ANDing bitmaps under allegro Date: Fri, 05 Nov 1999 14:41:26 -0600 Organization: Iowa State University, Ames, Iowa, USA Lines: 38 Message-ID: <382340F6.663CFCA1@cs.iastate.edu> References: <381F80A9 DOT 2DE040EB AT cs DOT iastate DOT edu> <38206093 DOT A877DBEC AT cs DOT iastate DOT edu> <3820DF45 DOT D34E8ADC AT cs DOT iastate DOT edu> <370sv7 DOT nm1 DOT ln AT pedos DOT es> 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 Yes, that's what I had in mind. Thanks again. gradha AT iname DOT com wrote: > Flenser wrote: > > 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. > > Well, I think there is (partially). You can reduce the ifs if you > _really_ AND the image. For this, let's say that color 255 is the > one which will show the image, color 0 is the one which will block > the image. > > With this assumption, you first clear your final bitmap to black or > white, and then something like: > > for (y=0;yh;y++) > for (x=0;xh;x++) > putpixel(bmp_final,x,y, > getpixel(bmp_source,x,y) & getpixel(bmp_mask,x,y); > > Since 255 is 1111 1111 in bits, your source image will be shown. > Color 0, which is 0000 0000 in bits, will put color 0 on your > destination bitmap. > > Ok, so this really is ANDING, which you requested in first place. > Sorry for the "way-round" I initially took :-) > > The problem was that I was thinking about an algorithm which you > could feed any image, greyscale it, make it black&white, etc. > > Grzegorz Adam Hankiewicz - gradha AT iname DOT com > Gogosoftware - http://welcome.to/gogosoftware/ > > "She broke my heart. I broke her neck. Now we are even, aren't we?"