Mail Archives: djgpp/1999/11/04/01:29:23
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 -