Hi can anyone please clear my doubt. am trying to display an image which is captured from camera in imageview which is in 2nd activity. but image quality is becoming very poor. an anyone tell me why is that and how to resolve it. This is my code please see
Activity 1 (MainActivity)
And now am retriving image from sd card to imageview .
Activity 2(Main2Activity)
Am compressing the image but the image is becoming from 60KB to 121 KB and when i check in sd card it is 22.4 KB Why is that please explain.And even if it is becoming from 60KB to 121KB it is blurry in imageview Why is that ?
Activity 1 (MainActivity)
Code:
if(requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK )
{
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get( "data" );
long height = imageBitmap.getHeight(); // the height is 204
long width = imageBitmap.getWidth(); //the width is 153
long filesizeinBytes1 = imageBitmap.getByteCount();
long fileSizeInKB1 = filesizeinBytes1 / 1024; // 60KB
Log.d( TAG, "Textview message :" + height + " , " + width + " , " + fileSizeInKB1 );
System.out.print( fileSizeInKB1 );
File destination = new File( Environment.getExternalStorageDirectory(), "temp.jpg" );
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
imageBitmap.compress( Bitmap.CompressFormat.JPEG,100,bytes );
FileOutputStream fo;
try {
fo = new FileOutputStream( destination );
fo.write( bytes.toByteArray());
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
Intent intent = new Intent( this, Main2Activity.class );
startActivity( intent );
And now am retriving image from sd card to imageview .
Activity 2(Main2Activity)
Code:
File destination = new File( Environment.getExternalStorageDirectory(), "temp.jpg" );
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Bitmap bmp= BitmapFactory.decodeFile( destination.getAbsolutePath() );
bmp.compress( Bitmap.CompressFormat.JPEG,50,bytes );
image.setImageBitmap( bmp);
long height = bmp.getHeight(); // the height is 204
long width = bmp.getWidth(); // the width is 153
long filesizeinBytes1 = bmp.getByteCount();
long fileSizeInKB1 = filesizeinBytes1 / 1024; // 121KB
textview1.setText( " Height:" + height + "Width" + width + "size in KB: " + fileSizeInKB1 );
Log.d( TAG, "Textview message :" + height + " , " + width + " , " + fileSizeInKB1 );
System.out.print( fileSizeInKB1 );
Am compressing the image but the image is becoming from 60KB to 121 KB and when i check in sd card it is 22.4 KB Why is that please explain.And even if it is becoming from 60KB to 121KB it is blurry in imageview Why is that ?