Often I need to display a user-provided picture in an ImageView in such a way that the whole ImageView is filled with as much of the picture possible.
This is how I do it:
var image = require('image');
Ti.Media.showCamera({
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: function (e) {
myImageView.image = image.crop(e.media, myImageView.rect);
}
});
Take a look at the next image.js
file to learn how it works.
blob
: TheTi.Blob
containing the image.options
: Either anobject
(or Dimension) containing the targetwidth
andheight
and the other options listed below, or a Number representing only thewidth
.height
: The targetheight
.
width
: See above.height
: See above.pixels
: Set toFALSE
to disable converting target dimensions to actual pixels needed for either Retina or Android variable DPI.fix
: Set toFALSE
to disable the workaround for bug TIMOB-4865.