سؤال

How do i convert Image format from within my android application activity.

I have the code to convert image format using Java, but it doesn't output the image with good quality and also similar code is not working in Android's Java.

هل كانت مفيدة؟

المحلول

You didn't post any of your code, so i have no idea what is wrong with your code. but you can convert a image to PNG or JPEG like this:

try {
   FileOutputStream out = new FileOutputStream(filename);
   bmp.compress(Bitmap.CompressFormat.PNG, 100, out); //100-best quality
   out.close();
} catch (Exception e) {
   e.printStackTrace();
}

نصائح أخرى

For example, from Bitmap to JPG:

Bitmap bmp;
JPEG_QUALITY = 80;
bmp.compress(Bitmap.CompressFormat.JPEG, JPEG_QUALITY, out);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top