Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save scaled/rotated image with full resolution #21

Open
Sub-Zero-1 opened this issue Jun 1, 2017 · 1 comment
Open

Save scaled/rotated image with full resolution #21

Sub-Zero-1 opened this issue Jun 1, 2017 · 1 comment

Comments

@Sub-Zero-1
Copy link

Sub-Zero-1 commented Jun 1, 2017

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

@AladinDridi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants