Hi, I am tring to get a image from the images stored on the sdcard of my Android
but i am getting a skia error using BitmapFactory When I just take the image directly without using BitmapFactory class I get the image. But the purpose of using BitmapFactory is scaling down the image size by using inSample =4; but I get skia as the error Here is my code after which the logcat details are also given Java: public class bitD extends Activity { private int SELECT_IMAGE = 200; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == SELECT_IMAGE) { if (resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); System.out.println("Uri of the selected img is " + selectedImage); try { InputStream is = getContentResolver ().openInputStream( selectedImage); BitmapFactory.Options opts = new BitmapFactory.Options(); Bitmap bm; opts.inJustDecodeBounds = true; bm = BitmapFactory.decodeStream(is, null, opts); System.out.println("ht" + opts.outHeight); System.out.println("wt" + opts.outWidth); System.out.println("mime" + opts.outMimeType); opts.inJustDecodeBounds = false; opts.inDither = true; opts.inPreferredConfig = Bitmap.Config.RGB_565; // this will resize the bm opts.inSampleSize = 4; // scaled down by 4 bm = BitmapFactory.decodeStream(is, null, opts); setContentView(R.layout.main); ImageView iv1 = (ImageView) findViewById (R.id.ImageView01); iv1.setImageBitmap(bm); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } Here is the ouput of my logcat 06-19 12:01:21.140: DEBUG/SurfaceFlinger(56): Screen about to return, flinger = 0x127c58 06-19 12:01:21.350: DEBUG/dalvikvm(316): GC freed 875 objects / 48416 bytes in 89ms 06-19 12:01:21.450: DEBUG/dalvikvm(316): GC freed 148 objects / 5720 bytes in 88ms 06-19 12:01:21.560: DEBUG/dalvikvm(316): GC freed 23 objects / 1064 bytes in 87ms 06-19 12:01:21.780: DEBUG/KeyguardViewMediator(56): pokeWakelock(5000) 06-19 12:01:22.870: VERBOSE/ImageGallery2(316): / ImageBlockManager.onPause 06-19 12:01:22.890: INFO/System.out(2551): Uri of the selected img is content://media/external/images/media/34 06-19 12:01:22.960: INFO/System.out(2551): ht1536 06-19 12:01:22.960: INFO/System.out(2551): wt2048 06-19 12:01:22.970: INFO/System.out(2551): mimeimage/jpeg 06-19 12:01:22.970: DEBUG/skia(2551): xxxxxxxxxxx jpeg error 53 Not a JPEG file: starts with 0x%02x 0x%02x 06-19 12:01:23.080: INFO/ActivityManager(56): Displayed activity co.pad.BD/.bitD: 14010 ms 06-19 12:01:28.200: DEBUG/dalvikvm(163): GC freed 1543 objects / 79424 bytes in 108ms 06-19 12:01:33.170: DEBUG/dalvikvm(180): GC freed 91 objects / 4840 bytes in 77ms 06-19 12:01:38.200: DEBUG/dalvikvm(316): GC freed 790 objects / 35944 bytes in 103ms Please someone help me out ........ Is there a work around / can i do this differently without consuming a lot of memory(I do not want to end up with Out of Memory Error.) Thanks in Advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---