imageButtonEx question

JB7TS

Member
Licensed User
Hello,

I'm trying to use transparent png images as buttons.

I'm working with basci4ppc 6.80.

I searched the forum for some help and i came across imageButtonEx.

But when i try to compile i get the following error:

Error CS0117: System.Windows.Forms.PictureBox does not have a definition for "BackgroundImage"


I need tranparent png button for an application on device. Is this lib only for desktop? if true, how can i make a transparent png button?


Thanks
 

JB7TS

Member
Licensed User
i used icons with an acid green as background color.

Tried with png, jpg and bmp but i always see a gray background into the image...

these imagebuttons are positioned over a dzHTMLView object that display a web page.

:sign0085:

Thanks
 

mjcoon

Well-Known Member
Licensed User
Unfortunately the ImageButton picks up the Form background for its' transparent areas, not any control it is superimposed on.

Hmm, my ImageButtons seem to have the colour of the panel they are sitting on showing through OK, as in attachment. It hadn't occurred to me that it would be otherwise...

But on the other hand the rightmost of those five blue buttons does not show as expected. The central area is meant to be black, but is (0, 0, 1) instead of (0, 0, 0) because real black is the colour of pixel(0, 0) for transparency, just like the other buttons. In the desktop IDE Designer it shows as I intended, but not on my WM5.0 device. Could it be that the transparency calculation is being done differently, perhaps not checking all three colours?

Mike.
 

Attachments

  • ScreenShot-2009-11-25.jpg
    15.2 KB · Views: 214

agraham

Expert
Licensed User
Longtime User
my ImageButtons seem to have the colour of the panel they are sitting on showing through OK
Yes. An ImageButton exxpects to sit on either a Panel or a Form and copies the background for its' transparent bits.

Could it be that the transparency calculation is being done differently, perhaps not checking all three colours?
As Klaus indicates most devices only support a maximum of 65536 colours with a colour depth of 5 pixels for red and blue and six pixels for green. This means that, unlike the desktop, many colours are approximations of what you expect. If possible it is best to set and then read back the colour of a pixel with the colour that you want to use as transparent - then you get the actual colour the device will render.
 

mjcoon

Well-Known Member
Licensed User
Try to use a color like 10,10,10 instead of 0,0,1 some devices don't recognize all colors.

Thanks Klaus, I'll try that. (Just as an experiment; I'm not sure that a black, or dark grey, centre is the best way to indicate that the button is for turning off the backlight to save power while the device gets on with playing the MP3 file(s) that the program is playing!)

Certainly the IDE Designer on the device shows the centre as transparent, like the run-time, and unlike the PC Designer.

Mike.
 

eww245

Member
Licensed User
In the desktop IDE Designer it shows as I intended, but not on my WM5.0 device. Could it be that the transparency calculation is being done differently, perhaps not checking all three colours?

Mike.

It looks like, from your picture, that the images have an alpha channel.
.Net Compact Framework does not support true transparency.
Unless the images are edited to remove the alpha areas it will not show properly in any control.

Although if the correct back color is used for the ImageButton, it may look OK.
This would depend on what the color of the alpha layer is.

If you can't figure it out I have written a library http://www.b4x.com/forum/additional-libraries/4952-alpha-image-device.html that supports the alpha channel of a png.
It can be used with an ImageButton or any control.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…