i have this machine that i have to capture the product's image and fill other data to upload them to the server. i've been using the image capture intent but the image was being downsized by the system to 150*200 but thanks to you now i'm having the full size image. the problem is the size of the image is a big one (2-5mbs) i tried the shrink bitmap method and the picasso library but the image file is still having the same size. can you give me guidelines on how to reduce it's size (and even resolution if necessary). what i tried:
public void grabImage(ImageView imageView) {
this.getContentResolver().notifyChange(mImageUri, null);
ContentResolver cr = this.getContentResolver();
Bitmap bitmap;
try
{
bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, mImageUri);
//ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Bitmap bm = ShrinkBitmap(fullpath, bitmap.getWidth(), bitmap.getHeight());
imageView.setImageBitmap(bm);
}
catch (Exception e)
{
Log.d("This", "Failed to load", e);
}
}
Bitmap ShrinkBitmap(String file, int width, int height){
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
int heightRatio = (int)Math.ceil(bmpFactoryOptions.outHeight/(float)height);
int widthRatio = (int)Math.ceil(bmpFactoryOptions.outWidth/(float)width);
if (heightRatio > 1 || widthRatio > 1)
{
if (heightRatio > widthRatio)
{
bmpFactoryOptions.inSampleSize = 4;
} else {
bmpFactoryOptions.inSampleSize = 4;
}
}
bmpFactoryOptions.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
return bitmap;
}
regards,