ImageAsResized
ImageAsResized copied to clipboard
RuntimeException: Canvas: trying to use a recycled bitmap
I want to resize and crop a picture in Titanium 3.2, but I ran into a out of memory-error on devices where photos are too big. I was recommended to check this module out. I'm however running into some problems:
var resized_image = e.media;
var rate = 16;
var width = e.cropRect.width / rate;
var height = e.cropRect.height / rate;
resized_image = image_module.cameraImageAsResized(resized_image, width, height, 0);
savedImage = resized_image.imageAsThumbnail(400,0,0);
picture.image = savedImage;
I'm using imageAsThumbnail afterwards to make sure that I'm getting a correctly cropped and sizes image, that will later be sent to an API. However, when I'm doing this I get the following message: RuntimeException: Canvas: trying to use a recycled bitmap
Is there a way to fix this?
how about this?
function resizeAndSave(e){
var image_module = require('org.selfkleptomaniac.ti.imageasresized');
var resized_image = e.media;
var rate = 16;
var width = e.cropRect.width / rate;
var height = e.cropRect.height / rate;
resized_image = image_module.cameraImageAsResized(resized_image, width, height, 0);
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + 'tmp.png');
file.write(resized_image);
var image_to_be_saved = file.read();
//savedImage = resized_image.imageAsThumbnail(400,0,0);
savedImage = image_to_be_saved.imageAsThumbnail(400, 0, 0);
picture.image = savedImage;
}