-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add "scalingMode" property to Ti.UI.ImageView #12753
Conversation
Fixes TIMOB-24313
|
This is huge. Basically makes the 3rd-party dependency to av.imageview obsolete (although the caching was better there a while ago - not sure if that changed in Titanium) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: PASS
TEST CASE
const window = Ti.UI.createWindow({
layout: 'vertical',
backgroundColor: 'white'
});
const picker = Ti.UI.createPicker({ top: 10 });
const image = Ti.UI.createImageView({
top: 10,
image: 'https://garymathews.com/droid.gif',
width: 256,
height: 144,
borderWidth: 1,
borderColor: 'gray',
autorotate: true
});
const gallery_button = Ti.UI.createButton({ title: 'Select Photo' });
picker.add(Ti.UI.createPickerRow({ title: 'IMAGE_SCALING_AUTO' }));
picker.add(Ti.UI.createPickerRow({ title: 'IMAGE_SCALING_NONE' }));
picker.add(Ti.UI.createPickerRow({ title: 'IMAGE_SCALING_FILL' }));
picker.add(Ti.UI.createPickerRow({ title: 'IMAGE_SCALING_ASPECT_FILL' }));
picker.add(Ti.UI.createPickerRow({ title: 'IMAGE_SCALING_ASPECT_FIT' }));
picker.addEventListener('change', e => {
switch (e.rowIndex) {
case 0:
image.scalingMode = Ti.Media.IMAGE_SCALING_AUTO;
break;
case 1:
image.scalingMode = Ti.Media.IMAGE_SCALING_NONE;
break;
case 2:
image.scalingMode = Ti.Media.IMAGE_SCALING_FILL;
break;
case 3:
image.scalingMode = Ti.Media.IMAGE_SCALING_ASPECT_FILL;
break;
case 4:
image.scalingMode = Ti.Media.IMAGE_SCALING_ASPECT_FIT;
break;
}
});
gallery_button.addEventListener('click', _ => {
Ti.Media.openPhotoGallery({
mediaTypes: Ti.Media.MEDIA_TYPE_PHOTO,
success: e => image.image = e.media
});
});
window.add([ picker, image, gallery_button ]);
window.open();
@hansemannn, @m1ga, @garymathews, |
In my opinion it should be |
@jquick-axway I think it should be |
…fault to true Fixes TIMOB-28432
@jquick-axway , I am seeing an issue on IOS, when |
Fix for TIMOB-28432 looks good. |
Would love to see this merged for 10.1.0! It will reduce the number of external required modules (in this case av.imageview for us) |
@lokeshchdhry , what we're seeing is a clipping issue on iOS. By default an So, it's not really a bug, but maybe we should change the default behavior to clip the image by default unless the |
Updated PR to always clip the image within the ImageView, because it was always scaled within the view's bounds before. |
FR Passed. |
@ewanharris Build passing, go go go! 😄 |
JIRA:
Summary:
Ti.UI.ImageView
.Ti.Media.IMAGE_SCALING_AUTO
// Legacy behaviorTi.Media.IMAGE_SCALING_NONE
// No scalingTi.Media.IMAGE_SCALING_FILL
// Stretches disproportionallyTi.Media.IMAGE_SCALING_ASPECT_FILL
// Crops proportionallyTi.Media.IMAGE_SCALING_ASPECT_FIT
// Letterbox/Pillarbox scales proportionallytrue
like iOS.ImageView
to correctly handle EXIF mirroring if "autorotate" property istrue
.Image Scaling Test:
ImageScalingChangeTest.js
attached to TIMOB-24313 on Android.Android EXIF Test:
ImageExifTest.js
attached to TIMOB-28432 on Android.autorotate: false
line in the JS file. (This will ignored EXIF orientation.)