0

I'm developing an app in which I take image from camera or Gallery and apply filters to it.

When I send this image from one activity to other i have to reduce the image size, and this make the image resolution low.

Here's My Code:

private Bitmap scaleBitmap(Bitmap bm) {
        int width = bm.getWidth();
        int height = bm.getHeight();
        Log.v("Pictures", "Width and height are " + width + "--" + height);

        int maxwidth,maxhieght;

        if(width >2400) {
            maxwidth= width/2;
        } else{maxwidth =1200;}

        if(height>2800){
            maxhieght=height/2;
        } else {
            maxhieght=1400;
        }

        if (width > height) {
            // landscape
            float ratio = (float) width / maxwidth;
            width = maxwidth;
            height = (int)(height / ratio);
        } else if (height > width) {
            // portrait
            float ratio = (float) height / maxhieght;
            height = maxhieght;
            width = (int)(width / ratio);
        } else {
            // square
            height = 1200;
            width = 1200;
        }

        Log.v("Pictures", "after scaling Width and height are " + width + "--" + height);

        bm = Bitmap.createScaledBitmap(bm, width, height, true);
        return bm;
}

Is there any possible way to send the image with it's actual size?

Thank you in advance.

I.G. Pascual
  • 5,818
  • 5
  • 42
  • 58
rgl
  • 45
  • 8

0 Answers0