Bitmap assetsRead(String file) {
InputStream is;
Bitmap bitmap = Bitmap.createBitmap(previewWidth, previewHeight, Config.ARGB_8888);
try {
is = getAssets().open(file);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
bitmap = BitmapFactory.decodeByteArray( buffer, 0, buffer.length ) ;
bitmap = Bitmap.createScaledBitmap(bitmap, 720, 720, false);
} catch (IOException e) {
e.printStackTrace();
}
return bitmap ;
}
int width = canvas.getWidth();
int height = canvas.getHeight() / 2;
Bitmap resize_bitmap = Bitmap.createScaledBitmap(assetsRead("image.png"), width, height, false);
canvas.drawBitmap(resize_bitmap, 0, 0, null);