delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/04/01:29:23

From: Flenser <flenser AT cs DOT iastate DOT edu>
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> <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>
NNTP-Posting-Host: friley-161-9.res.iastate.edu
Mime-Version: 1.0
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;y<bmp_source->h;y++)
> {
>         for (x=0;x<bmp_source->h;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/
>
> <You moved the mouse. You must restart WindowsNT to see the changes.>

- Raw text -


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