I have an image's Blob and want to convert it into Bitmap image to use android Canvas, Path and Paint in appcelerator Titanium. I went through appcelerator docs but couldn't find any method that allows me to convert directly. I tried converting blob to Base64 string and then create the bitmap object using android native methods through hyperloop but was unsuccessful.
Then I tried converting base64 to byte array and create bitmap using this code by using Hyperloop but bitmap is empty :
var BitmapFactory = require('android.graphics.BitmapFactory');
var ByteArrayInputStream = require("java.io.ByteArrayInputStream");
var stringToSaveInDatabase = Ti.Utils.base64encode(newBlob).toString();
var bytes = [];
for (var k = 0; k < stringToSaveInDatabase.length; k++) {
bytes.push(stringToSaveInDatabase.charCodeAt(k));
}
var arrayInputStream = new ByteArrayInputStream(bytes);
var bitmap = BitmapFactory.decodeStream(arrayInputStream);
Updated examples:
index.xml:
bmpwill be the Bitmap out of theImageViewit will apply a blur and add it to the window again.