[Fxruby-users] Re: Icon transparency (was: Question...)
Status: Inactive
Brought to you by:
lyle
|
From: Lyle J. <ly...@kn...> - 2004-02-27 15:42:53
|
On Feb 26, 2004, at 7:46 AM, Allen Mitchell wrote:
> I want to create an icon on the fly....
>
> I tried:
>
> icon = FXPNGIcon.new( getApp(), nil,
> FXRGB(1,2,3),IMAGE_SHMI|IMAGE_SHMP,
> 24, 24 ) {|png|
>
> png.create
>
> FXDCWindow.new(png) { |dc|
> dc.setForeground(FXRGB(1,2,3))
> dc.fillRectangle(0, 0, 24, 24)
> dc.setForeground(FXRGB(255,0,0))
> dc.fillRectangle(0, 0, 15, 15)
> }
> }
>
> This does give me an icon, but it is not transparent where I want it
> to be.
> Have you ever done this sort of thing?
I have not tried this before, but here are a few guesses:
First, the image flags probably need to include the IMAGE_ALPHA flag so
that the icon object will allocate storage for red, green, blue and
alpha pixel values. I think it may also be necessary to specify
IMAGE_KEEP, to tell FOX to keep the client-side pixel buffer around
after the call to create(). Otherwise, I'm not sure that you can change
the icon's contents after the fact. After you draw into the icon, you
will call render() on the icon to get it to re-render the client-side
pixels to the server-side icon resource.
Second, the FXRGB() module method constructs a color value with no
transparency. If you want specify an alpha component, use the FXRGBA()
method instead, i.e.
color = FXRGBA(255, 0, 0, 128)
where the last value is the alpha, from zero to 255.
Hope this helps,
Lyle
|