StickerView
StickerView copied to clipboard
Save scaled/rotated image with full resolution
Hi!
I am loading an image from my gallery into StickerView and rotate and scale it there.
Bitmap bitmap = Bitmap.createBitmap(mContentRootView.getWidth(), mContentRootView.getHeight() , Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); mContentRootView.draw(canvas);
My mContentRootView has just a height of 335 and a width of 238, which is equivalent on my phone with a resolution of 1340 x 952. On other phones the resoltution is mostly smaller, because of lower resolution Display. With your method given in the example and listed above, you just take a screenshot of the mContentRootView and the resulting image has only the resolution of the mContentRootView. In my case 1340*952. Since I load an image with a higher resolution to my Stickerview/mContentRootView (e.g. 1717 x 1217))and scale it that it exactly matches the mContentRootView I want to get that full resolution image saved? Is there a way to achive that? I see that my scaled/rotated image within the StickerView/mContentRootview has the desired resoluton of 1717 x 1217, but then it gets reduced by the size of the mContentRootView, because you only make a "Screenshot" of it.
Thanks,
Sub-Zero-1
public void onsave(ImageView imageView){
this.imageView=imageView;
BitmapDrawable draw=(BitmapDrawable)imageView.getDrawable();
Bitmap bitmap=draw.getBitmap();
FileOutputStream outputStream=null;
File sdcard= Environment.getExternalStorageDirectory();
File file=new File(sdcard.getAbsolutePath()+"/StickersimgApp");
file.mkdir();
String filname=String.format("%d.jpg",System.currentTimeMillis());
File outputfile=new File(file,filname);
try {
outputStream=new FileOutputStream(outputfile);
bitmap.compress(Bitmap.CompressFormat.JPEG,100,outputStream);
try {
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
stickerView.save(outputfile);
}
this code may helps you