On Tue, 2007-07-31 at 07:00 -0700, Chandan Pitta wrote:
> I am trying to use kaa.imlib2.Image to create an image that is opaque
> at the top and becomes linearly transparent towards the bottom. My

What you want to do is create an image that is a vertical gradient from
white (top) to black (bottom), which will serve as an image mask.  The
mask image should be the same dimensions as the source image.  Then call
source_image.draw_mask(mask_image, (0, 0))

This will blend the image mask to the alpha channel of the source image.
In the mask image, white means fully opaque, and black means fully
transparent.  It's exactly like working with layer masks in the gimp.

I can show an example if you need.

> plan was to load an image and blend the same image with increasing
> levels of alpha for each scanline. But that is not producing the kind
> effect I want. Actually it is doing nothing. Here is the code I am
> using. Can someone help me please.

Yes, if the source image is fully opaque, that would do exactly
nothing :)

However if the source image had some partial transparency, would it
would do is double the opacity of those pixels.

> What is wrong with the code? The only other solution I can think of is
> to read each pixel and set the alpha level manually with increasing
> levels of alpha as I move down the image. But this is very slow. Is
> there a fast way to do it?

There's really no other way to do it than pixel-by-pixel.  This is what
draw_mask does, except it's implemented in C.  (draw_mask is not part of
Imlib2, it's implemented in C inside kaa.imlib2.)  It could be made
faster with SIMD.  It's probably fast enough for most uses unless you
want to animate with it.

Cheers,
Jason.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to