Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Manage image size (hires and not) from blob

$
0
0

Hi, I have to show a imageView 130x100 and my image is in db as blob data. How have I manage hires dimensions? In hires devices, can I directly convert blob in img.jpg 260x200 ? or do I have convert blob in two image img.jpg and img@2x.jpg with relative size 130x200 and 260x200?

My code

var image_url = Titanium.Filesystem.applicationDataDirectory + '/'+name+'.jpg';
var f = Titanium.Filesystem.getFile(image_url);
 
if(rows2.fieldByName('image') && !f.exists()){
 
    var blob = Ti.Utils.base64decode(rows2.fieldByName('image')); // 260x200
 
    if(deviceHiRes){
 
        f.write(blob);
 
    }else{
 
        var halfblob = blob.imageAsResized(blob.width/2, blob.height/2);
        f.write(halfblob);
    }
 
}
 
var im = Ti.UI.createImageView({
    image: image_url,
    width: 130,
    height: 100
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>