[TIMOB-19767] iOS: toImage does not honor the scale factor for retina devices
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-11-26T08:54:54.000+0000 |
Affected Version/s | Release 4.0.0, Release 5.1.0, Release 5.0.0 |
Fix Version/s | Release 5.2.0 |
Components | iOS |
Labels | ios, retina, scale, toimage |
Reporter | Hans Knöchel |
Assignee | Hans Knöchel |
Created | 2015-10-22T18:10:55.000+0000 |
Updated | 2016-01-15T18:04:46.000+0000 |
Description
We used to have a
honorScaleFactor
property, that was removed as part of the 4.0.0.GA release in [this PR](https://github.com/appcelerator/titanium_mobile/pull/6302) around changes with non-attached images. The [docs](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ImageView-method-toImage) say, the property was already removed in 3.5.0, but worked until 3.5.1.GA. I would like to get this property back to achieve a proper behavior in the following use case.
*Use case*: Use toImage()
to make an image (blob) of a view, that covers a specified square inside another view.
*Demo:*
var win1 = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
var imageView = Ti.UI.createImageView({
image : "test.jpg"
});
imageView.addEventListener("click", imageViewClicked);
win1.add(imageView);
win1.open();
function imageViewClicked(e) {
imageView.removeEventListener("click", imageViewClicked);
var edgeLength = 100;
var blob = imageView.toImage();
var tempView = Ti.UI.createView({
width : blob.width + edgeLength,
height : blob.height + edgeLength
});
tempView.add(Ti.UI.createImageView({
image : blob,
width : blob.width,
height : blob.height
}));
// No callback -> get blob directly, honorScaleFactor false -> Same size for retina and non-retina
// Default functionality still the same: No callback and secons argument true / undefined -> Different size for retina and non-retina
blob = tempView.toImage(null, false);
var image = blob.imageAsCropped({
width : edgeLength,
height : edgeLength,
x : e.x,
y : e.y
});
var croppedImageView = Ti.UI.createImageView({
image : image,
bottom : 0,
borderWidth : 1,
borderColor : "black",
borderRadius : edgeLength / 2
});
croppedImageView.addEventListener("click", function() {
win1.remove(croppedImageView);
imageView.addEventListener("click", imageViewClicked);
});
win1.add(croppedImageView);
}
*Expected behavior*: The method works same on retina and non-retina devices.
*Actual behavior:* The method uses the wrong scale on creating the image blob.
*Proposal*: Bring back the honorScaleFactor
property, make the default value to true
as the current behavior expects. That would achieve the configuration of the property, but would not break any existing applications.
Attachments
File | Date | Size |
---|---|---|
Actual.png | 2015-10-22T18:30:00.000+0000 | 61508 |
Expected.png | 2015-10-22T18:30:00.000+0000 | 63258 |
test.jpg | 2015-10-22T18:27:29.000+0000 | 18647 |
FT passed , PR approved. Thanks Hans!