ImageButton Background Transparent Issue

Discussion in 'Questions (Windows Mobile)' started by gs4322, Dec 26, 2007.

  1. gs4322

    gs4322 Member Licensed User

    I have a Image button loaded with a PNG image 64x64 pix. At run time the image will show a gray background. Transparent property is set to TRUE.

    When I click the image Button the Image background is then transparent, which should it been when the program started.

    What do I need to set in order in the imageButton property (if any) so it does not have a gray background at start up?

    You help will be appreciated.

    Thank You.
     
  2. Cableguy

    Cableguy Expert Licensed User

    Hi,

    PNG images have an alpha cannel, wich control their transparencie...
    Try to use a BMP version of the same image...
    As I understand, the transparency feature works by getting the o,o (x,y)pixel color, and then set them all to the same collor as the background...
     
  3. klaus

    klaus Expert Licensed User

    Hello gs4322
    You must know that the upper left pixel determines the transparency color.
    If you have placed your button with the Designer you can select or unselect the Tranparent property which defines the state at programm start.
    If you have placed the control by code in the App_Start routine you should set the Transparent property to true or false depending on what you need.
    I have used this method with buttons with white as transparency color and a black frame around but white pixels in the corner because it determines the transparency color with bitmaps.

    Klaus
    Switzerland
     
  4. gs4322

    gs4322 Member Licensed User

    Guys thanks for the quick response, you guys are great..

    I converted the image to BMP, same problem. Can you share some code example here:

    How to set the pixel transparency (X,Y) pixel in the image property.

    I do have transparency set to TRUE.

    I have the same issue with (PNG, GIF and now BMP), I want to use PNG because they smaller, these are converted ICON to PNG..

    :sign0085:

    Thanks
     
  5. Cableguy

    Cableguy Expert Licensed User

    Can u upload the project as is...?
    could then help more efectively...
     
  6. gs4322

    gs4322 Member Licensed User

    I found the problem, when I resized the PNG images I must lost some property format or did not save correctly. The original PNG was 128x128 pix. Anyway, I used the original and resize the ImageBtn to 48x48pix and the image looks fine now.

    This problem started wanting to display ICONS (ico) formats.

    Thanks for all your help..
     
  7. gs4322

    gs4322 Member Licensed User

    well guys, I thought I had the problem fixed with the images resizing, still have the same issue.

    Attached is the sample code with the images, you can see the edges of the image in gray..

    I need to have a panel on top of the form because I may have different panels.

    Thanks..

    gs4322
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The ImageButton transparent parts show the forms colors.
    You will need to remove the image and the panel and draw the image on the form.
    See the attached file.
     

    Attached Files:

  9. dennishea

    dennishea Active Member Licensed User

    Erel your show2.sbp is just a blank template.
     
  10. klaus

    klaus Expert Licensed User

    I have modified your program with 4 ImageButtons.
    The upper two's parent control is Form1
    the lower two's parent control is Panel1
    the left two with .png images
    the right two with .bmp images
    And Button1 to toggle between transparent ant not transparent.

    As you can see, the upper two buttons show the Form1 background color
    the lower two show the Panel1 background color.

    An image control can not be a parent control so the image button cannot show it's image.

    A panel control can be a parent control but doesn't have an image property.

    So, as Erel told, you must put the image on Form1 ant the image buttons parent control must also be Form1.

    The top right buttons transparent color is almost the same as the Form1 background color that's why there seems not be any change in toggling.

    Hope this explains how this works.

    Klaus
    Switzerland
     

    Attached Files:

  11. Erel

    Erel Administrator Staff Member Licensed User

    Did you unzip the image files and run it?
     
  12. dennishea

    dennishea Active Member Licensed User

    Ok, you got me, how do you get it to post an image file with only form1.show? :sign0148:
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    You should check the form's Image property in the Visual Designer ;)
     
  14. dennishea

    dennishea Active Member Licensed User

    I can't even claim :sign0144:.
     
  15. gs4322

    gs4322 Member Licensed User

    Erel, and Klaus,

    Thank you for U help.

    Just a curiosity question: I found the note below in IMAGEBUTTON Help

    When the Transparent property is set to True the control Transparent color will be the color of pixel (0,0) of the image.

    If thats true, then the IMAGE should not matter where its placed. Do I see a bug ..

    GS4322:sign0144:
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    By design the ImageButton transparent areas show the form's background.
    It is a technical limitation.
     
Loading...