www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/05/04:28:12

From: gradha AT iname DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ANDing bitmaps under allegro
Date: Thu, 4 Nov 1999 14:03:31 +0100
Organization: Telefonica Transmision de Datos
Lines: 33
Message-ID: <370sv7.nm1.ln@pedos.es>
References: <381F80A9 DOT 2DE040EB AT cs DOT iastate DOT edu> <tc6pv7 DOT n77 DOT ln AT pedos DOT es> <38206093 DOT A877DBEC AT cs DOT iastate DOT edu> <vceqv7 DOT ps DOT ln AT pedos DOT es> <3820DF45 DOT D34E8ADC AT cs DOT iastate DOT edu>
NNTP-Posting-Host: info583.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

Flenser <flenser AT cs DOT iastate DOT edu> 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;y<bmp_final->h;y++)
	for (x=0;x<bmp_final->h;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?"

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019