Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6908] Android: png image file transparency problem

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2017-04-21T01:30:16.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterRune Lund-Hermansen
AssigneeIngo Muschenetz
Created2011-10-24T12:50:25.000+0000
Updated2017-04-21T01:30:16.000+0000

Description

Problem

On Android, PNGs containing transparency/semi-transparency (such as shadows and glow) look very bad compared to both the iPhone version and the Photoshop reference mockup (see attached screenshots). The PNGs are normal 32bit (RGBA) straight from Photoshop and looks fine in iPhone simulator. On Android both the emulator and device (HTC Legend) are affected.

Test case

The test is made up of a Window with a background PNG, and two child views with unscaled background PNG's with both solid and semi-transparent content. Assets are attached
var win = Ti.UI.createWindow({
    backgroundImage:'bg.png',
});
 
var shadow = Ti.UI.createView({
    backgroundImage:'shadow.png',
    width:'179dp',
    height:'179dp',
    top:'25dp',
});
 
var glow = Ti.UI.createView({
    backgroundImage:'glow.png',
    width:'189dp',
    height:'189dp',
    bottom:'15dp',
});
 
win.add(shadow);
win.add(glow);
win.open();

Discussions

Q&A: [severe android png rendering bug](http://developer.appcelerator.com/question/127038/severe-android-png-rendering-bug)

Attachments

FileDateSize
png_assets.zip2011-10-24T12:50:25.000+000025919
TI_android_PNG_Bug.jpg2011-10-24T12:50:25.000+0000289754

Comments

  1. Max Stepanov 2012-12-11

    http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/ {quote} Simple performance test shows very clearly that using a compatible format (32 bits bitmap on a 32 bits window or 16 bits/565 bitmap on a 16 bits window) is the most efficient way to draw bitmaps. For this reason, you should always check the format of your bitmaps and windows and try to make them compatible with each other. {quote} This code in onCreate() may work:
       // set 32 bit window (draw correctly transparent images)
       getWindow().getAttributes().format = android.graphics.PixelFormat.RGBA_8888;
       
    Workaround: ship 16-bit PNGs for android
  2. Joshua Quick 2017-04-21

    Closing because it is a duplicate of [TIMOB-24465] which will be resolved soon.

JSON Source