{ "id": "115462", "key": "TIMOB-14105", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15499", "description": "2013 Sprint 13 API", "name": "2013 Sprint 13 API", "archived": true, "released": true, "releaseDate": "2013-07-01" }, { "id": "15111", "description": "2013 Sprint 13", "name": "2013 Sprint 13", "archived": true, "released": true, "releaseDate": "2013-07-01" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2013-07-01T21:10:49.000+0000", "created": "2013-06-04T18:49:16.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "SupportTeam", "regression" ], "versions": [], "issuelinks": [ { "id": "29353", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "inwardIssue": { "id": "102764", "key": "TIMOB-11282", "fields": { "summary": "Android TableView with remote images is very slow", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "29354", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "111403", "key": "TIMOB-13115", "fields": { "summary": "Android: ImageView - On Android, ImageView.toBlob returns null", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-30T21:03:39.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h2. Problem description\r\nThe method toImage() does not work if applied to an ImageView. This is also true if the ImageView is child of another view.\r\n\r\nh2. Steps to reproduce\r\nUse the following code to reproduce the issue:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({backgroundColor: 'white'});\r\n \r\nvar img = Ti.UI.createImageView({\r\n image: 'KS_nav_views.png',\r\n backgroundColor: 'transparent',\r\n width: 100,\r\n height: 100\r\n});\r\n \r\nvar tmpImage = img.toImage();\r\ntmpImage.backgroundColor = 'transparent';\r\n \r\nvar imageView = Titanium.UI.createImageView({\r\n width: 100,\r\n height: 100,\r\n image: tmpImage,\r\n top: 10,\r\n backgroundColor: \"transparent\"\r\n});\r\n \r\nwin.add(imageView);\r\nwin.open();\r\n{code}\r\n\r\nh2. Additional notes\r\nThe same code works with SDK 3.0.0.\r\nIf the ImageView is child of another view, and the toImage() is applied to the parent, the ImageView will not be visible as well.", "attachment": [], "flagged": false, "summary": "Android: toImage() does not work if applied to ImageView", "creator": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 3.0.2\r\nSDK 3.1.0\r\nAndroid 4.2", "comment": { "comments": [ { "id": "256008", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ran the test case on 3.0.0.GA and 2.1.4.GA. On 3.0.0.GA, no image showed on the screen. On 2.1.4.GA, a black square showed on the screen. Seems the test case never worked.", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-04T23:32:45.000+0000", "updated": "2013-06-04T23:32:45.000+0000" }, { "id": "256027", "author": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "body": "@Ping I've updated the test code, now I can replicate. The first image was missing width and height.", "updateAuthor": { "name": "dcassenti", "key": "dcassenti", "displayName": "Davide Cassenti", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-06-05T00:29:12.000+0000", "updated": "2013-06-05T00:29:12.000+0000" }, { "id": "256310", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "There is a behavior change in imageview in 3.0.2. Before 3.0.2, if the image is local, it will be loaded synchronously; if the image is remote, it will be loaded asynchronously. After 3.0.2, all the images are loaded asynchronously no matter local images or remote images. The toImage() method is to give a snapshot of the view. Therefore, if the image is loaded asynchronously, the snapshot will be empty because the image is not ready yet.\r\nThe above test case works in 3.0.0 because it uses a local image. If we modify Line 4 to\r\n{code}\r\nimage: \"https://raw.github.com/appcelerator/titanium_mobile/master/android/templates/app/default/Resources/android/appicon.png\",\r\n{code}\r\nit will not work even in 3.0.0.", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-05T23:10:43.000+0000", "updated": "2013-06-05T23:14:29.000+0000" }, { "id": "256470", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Here are two workarounds for this issue:\n1. Set the \"backgroundImage\" or \"defaultImage\" property to the imageview.\nSample code:\n{code}\nvar win = Ti.UI.createWindow({backgroundColor: 'white'});\n \nvar img = Ti.UI.createImageView({\n image: 'KS_nav_views.png',\n //backgroundImage: 'KS_nav_views.png',\n defaultImage: 'KS_nav_views.png',\n backgroundColor: 'transparent',\n width: 100,\n height: 100\n});\n \nvar tmpImage = img.toImage();\ntmpImage.backgroundColor = 'transparent';\n \nvar imageView = Titanium.UI.createImageView({\n width: 100,\n height: 100,\n image: tmpImage,\n top: 10,\n backgroundColor: \"transparent\"\n});\n \nwin.add(imageView);\nwin.open();\n{code}\n2. Add listener to the [\"load\"|http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ImageView-event-load] event. In this case we are sure that the toImage() method is called after the image finishes loading. *Note:* in order to fire the \"load\" event, the imageview must be added to the window.\nSample code:\n{code}\nvar win = Ti.UI.createWindow({backgroundColor: 'white'});\n\nvar img = Ti.UI.createImageView({\n image: 'KS_nav_views.png',\n backgroundColor: 'transparent',\n width: 100,\n height: 100,\n bottom: 10\n});\n\n\nimg.addEventListener(\"load\", function() {\n\tvar tmpImage = img.toImage();\n\ttmpImage.backgroundColor = 'transparent';\n\n\tvar imageView = Titanium.UI.createImageView({\n\t\twidth : 100,\n\t\theight : 100,\n\t\timage : tmpImage,\n\t\ttop : 10,\n\t\tbackgroundColor : \"transparent\"\n\t});\n\n\twin.add(imageView);\n}); \n\nwin.add(img);\nwin.open();\n{code}", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-06T18:54:11.000+0000", "updated": "2013-06-06T18:54:11.000+0000" }, { "id": "260570", "author": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "body": "People are watching this ticket. Closing an issue people are interested in a resolution of as Resolved/Won't Fix without comment leaves people hanging and deteriorates hope in the platform. Could you provide a short explanation of why this won't be fixed? At the very least the documentation should be updated to explain the asynchronous nature of the \"image\" property and the available workarounds.", "updateAuthor": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-02T05:52:25.000+0000", "updated": "2013-07-02T05:52:25.000+0000" }, { "id": "416380", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as \"Won't Fix\". There has been no update for quite a while. If there is any problem, please open a new ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-30T21:03:39.000+0000", "updated": "2017-03-30T21:03:39.000+0000" } ], "maxResults": 16, "total": 16, "startAt": 0 } } }