Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE : [platform-swt-dev] Loading PNG file with alpha channel

Title: RE : [platform-swt-dev] Loading PNG file with alpha channel

Hello everyone,

A Label object does not [yet, I guess] support alpha channel transparency  just by throwing a PNG image at it.  But a GC (Graphical context) does.

Gc is accessible through paint event so you can do sth like this :

final Image splash = new Image( display ,       testSplash.class.getResourceAsStream( "Lax_splash.png" ) ) ;

Shell shell = new Shell( display , SWT.NO_TRIM | SWT.NO_BACKGROUND ) ;
// ... layout..
shell.addPaintListener( new PaintListener() {
        public void paintControl (PaintEvent e)         {
                e.gc.drawImage( splash , 0 , 0 ) ; } } ) ;

You can generalise this for buttons and hover labels acting as labels...

Hope this helps.

A.

-----Message d'origine-----
De : Mohsen Saboorian [mailto:mohsen_s@xxxxxxxxxxxxx]
Envoyé : 31 August 2004 19:00
À : platform-swt-dev@xxxxxxxxxxx
Objet : [platform-swt-dev] Loading PNG file with alpha channel

Hi,
I have a 32 bit png file (sure with alpha channel properties).
Now when I try to open it as a form icon (using shell.setImage(...),
the result is not as the image should be. It seems to be 256color
or may alpha channel values are ignored.
As far as I know the only image format with alpha channel enabled is png,
so it seems that there is no alternative way.

Thanks in advance.
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top