Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7586] iOS: image saved to filesystem using toImage() loses it's transparency

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-08T14:34:00.000+0000
Affected Version/sn/a
Fix Version/sSprint 2012-05, Release 2.0.0
ComponentsiOS
Labelsmodule_media, qe-testadded
ReporterFederico Casali
AssigneeMax Stepanov
Created2012-02-09T10:41:56.000+0000
Updated2012-07-05T15:16:27.000+0000

Description

Problem

Saving an image to the filesystem using toImage() method, does not keep the transparent property of the image

Steps to reproduce

See attached code
var window = Ti.UI.createWindow({
    backgroundColor:'#ff0'
});

var view = Ti.UI.createImageView({
    image:'KS_nav_ui.png',
// var view = Ti.UI.createView({
    backgroundColor:'transparent',
    borderWidth:2,
    borderColor:'#f00',
    width:100,
    height:100,
    top:10
});

window.add(view);

var image = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'tst.png');
image.write(view.toImage());

var img = Ti.UI.createImageView({
    width:200,
    height:200,
    bottom:10,
    image:image.nativePath
});

window.add(img);
window.open();

Link

Ticket : http://support-admin.appcelerator.com/display/APP-785915

Comments

  1. Dan Tamas 2012-02-09

    I'm thinking on 2 cases: 1. The image is saved jpg as the background color goes always white. 2. It can be fixed as I specified in the ticket by altering the write method in ToBlob.m
  2. Wilson Luu 2012-03-15

    Closing bug. Verified fix on: SDK build: 2.0.0.v20120315140247 Titanium Studio, build: 2.0.0.201203142055 xcode: 4.2 Device: iphone 4s (5.0.1)

JSON Source