JPG ICON w/ Transparency

I have a couple icons in my Data Field. My icons have a white background and they look great with a white device background (daytime). But at night, when the device background is black, the icons' background shows up. Ideally I'd like to specify a color to be treated as transparent. Then these icons will look great at night as well.

It seems there is a way to handle transparent colors in the resource XML file. But it didn't work for me. It seems like the resources file is looking for the colors to display (many), not the one color to be treated as transparent?

Also, I save the icons as JPG at an 80% quality level (which looks fine and the size is only 2KB), the color palette for my 3 color graphic expands to a dozen or more colors. If I save that same icon as a bitmap, it is over 20KB.

I could create a 2nd set of icons with a black background and use those when I detect the devices has a black background. But I'd like to get the transparency working. Any issues or tricks to get this working?
  • Are you saving the image with the background transparent?
    In the XML, do you have disableTransparency="false"? (it looks to be the default)
    The palette will determine the size, and transparent counts as a color if I recall, and the number of colors determines how many bits per pixel, and therefore the size..


  • Try using a PNG with alpha channel instead of JPG.

    I don’t think there’s any reason to use JPG since (correct me if I’m wrong anyone), the resource compiler would just convert it to an uncompressed bitmap anyway, and you’re not going to save memory at run time.
  • Thx! I'll try these ideas tonight and report on the runtime size implications.
  • Ok, tried it quickly before heading out for my ride. PNG with Alpha worked! Thank you!!!!
  • Former Member
    Former Member over 6 years ago
    Flowstate is correct. It does not matter what format your images are in. The resource compiler will convert them to the native format used by the target device. The only compression available for device formats is restricting the device palette as you are doing.