Re: [AD] masked blits - transparent color

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Lennart Steinke wrote:
> I just wondered if it's possible to make the transparent color user
> adjustable.

draw_sprite() is much faster if the transparent color can be hard-coded,
so I think it's not worth the slowdown.

> So I could say I want bright green as trans color. The
> reason for this is that sometimes I'd like to do apply an effect only
> to the non-transparent parts of a sprite. This can be applying the
> effect to the complete sprite, and then blitting only the transparent
> part ontop of it.

Maybe you can make your effect aware of the transparent color.

> Hm... guess it would be ok if a blitting function would be added which
> only blits the transparent color.

You can do this easily yourself:

   do_effect(from source to dest)
   mask = bitmap_mask_color(source);
   for (y=0; y<source->h; y++)
      for (x=0; x<source->w; x++)
         if (getpixel(source, x, y) == mask)
            putpixel(dest, x, y, mask);

If you know that source and/or dest are memory bitmaps, and know their
color depths in advance, it's much more efficient to use the
bmp->line[y][x] pointer than getpixel()/putpixel().

> Is something like this possible in one of the future releases?

IMHO it's a bit too specialized to be included in the main lib, but I
think it can be very useful as an add-on.

-- 
Sven Sandberg    svsa1977@xxxxxxxxxx    home.student.uu.se/svsa1977



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/