[TIMOB-4884] toImage() on device with retina display is pixellated (captured at half resolution)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-02-15T10:30:33.000+0000 |
Affected Version/s | Release 1.6.0 |
Fix Version/s | Sprint 2012-04, Release 2.0.0 |
Components | iOS |
Labels | module_imageview, qe-testadded |
Reporter | Matthew O'Riordan |
Assignee | Vishal Duggal |
Created | 2011-07-22T09:38:01.000+0000 |
Updated | 2012-03-06T11:17:30.000+0000 |
Description
If you call
var a = view.toImage()
on a view, and set an ImageView to that blob i.e. imageView.image = a
on an Iphone with retina display, then the image is displayed at normal resolution and thus is pixelated on an iPhone 4.
There is a very simple fix to this already out there in the wild, see [https://github.com/iamyellow/titanium_mobile/](https://github.com/iamyellow/titanium_mobile/commit/b7ac93e257339e60510a88a5767455f6b1120034#iphone/Classes/TiViewProxy.m)
I would recommend that change is made to all appropriate UI controls which have a toImage() method.
var win = Titanium.UI.createWindow({
backgroundColor: '#FFF'
});
var sourceView = Titanium.UI.createView({
width: 155,
left: 5,
height: 240,
borderWidth: 1,
borderColor: '#000'
});
sourceView.add(Titanium.UI.createLabel({
text: 'Here is some nice smooth antialised text',
font: {
fontSize: 20
}
}));
var targetView = Titanium.UI.createImageView({
width: 155,
right: 5,
height: 240,
borderWidth: 1,
borderColor: '#000'
});
var btn = Titanium.UI.createButton({
title: 'Copy image to target on right',
width: 300,
height: 30,
bottom: 10
});
btn.addEventListener('click', function() {
targetView.image = sourceView.toImage();
});
win.add(btn);
win.add(targetView);
win.add(sourceView);
win.open();
Please remember this issue is only visible when using an iOS 4 Retina Device.
Matthew Thank you for the ticket. In order for us to progress it, we need a proper [usecase](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases) that can be used to demonstrate the issue and also confirm that the subsequent bugfix works. Also, please check the ticket against the [Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist) in order to complete some of the fields. Many thanks
Hi Paul Ok, here goes, think this is all the info you need. Do remember that a fix already exists (which I have tested) at https://github.com/iamyellow/titanium_mobile/commit/b7ac93e257339e60510a88a5767455f6b1120034#iphone/Classes/TiViewProxy.m Environment: Titanium SDK version: 1.7.2 (I don't see where build date / hash comes from, I am using the version that was automatically installed by Titanium Studio when 1.7.2 was released a week or so ago). I see an [INFO] log saying something about 1.7.2.97c3689, is that what you need? Platform & version: iOS 4.3, OSX 10.7 (Lion) Device Details: iOS simulator and iOS device when using RETINA display Host Operating System: OSX 10.7 Titanium Studio version: Titanium Studio, build: 1.0.2.201107130739 Code for app.js example
Please remember this issue is only visible when using an iOS 4 Retina Device. Hope that helps, shout if you need anything else. Matt
Matt It's getting there, but unfortunately the code will not run without modification (it doesn't contain the window creation statement). Please refer to the [Creating Good Use-cases](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases) guide for more info on this. You should be able to edit the ticket itself and enter the new information to the relevant fields. Thanks for your cooperation so far. Once the above is done, I can move the ticket to the correct project.
Come on Paul, you are being very difficult now. I provided perfectly good working code that you can use VERY easily by simply creating a window with this code, and you are just not trying to help. I am contributing to your product to help improve it, and you're not being cooperative. I am really surprised at this attitude from Appcelerator as you have a product that is far from perfect, and you have people like myself who are trying to help improve it with constant resistance and bureaucracy. The reason this code did not run is that because Titanium Mobile has so many bugs, I've created a single project with multiple files in it that are created using a tab system, so that I don't have to create a new project for every bug I come across, I simply add a new tab, and create a new JS file for that tab. So to get my example to work, all you need to do is change the file name of app.js to bug.js, and in app.js use the following code:
I can't believe I had to provide you with that code. Maybe you should read this, http://www.jacquesmattheij.com/How+not+to+handle+open+source+feedback
Thanks for pushing this through
Odd question: What about those of whom who want a non-retina image? As in, I can see someone using the toImage to compose a graphic of a known pixel size. By always using retina scale, it would break their code. I'm thinking we should keep the 1.0 scale for backwards compatibility, but offer that toImage takes an optional argument object property to indicate that things can be made for 2.0 scale.
Use this for testing
Pull pending https://github.com/appcelerator/titanium_mobile/pull/1416
Pull request https://github.com/appcelerator/titanium_mobile/pull/1416 merged.
Closing bug. Verified fix on: SDK build: 2.0.0.v20120305174654 Titanium Studio, build: 1.0.9.201202141208 xcode: 4.2 Device: iphone 4S (5.0.1)