How to load BufferedImage in android?

I want to load BufferedImage into my application. For this, I use ImageIO , but I get java.lang.NoClassDefFoundError :

 BufferedImage tgtImg = loadImage("ImageD2.jpg"); public static BufferedImage loadImage(String ref) { BufferedImage bimg = null; try { bimg = ImageIO.read(new File(ref)); } catch (Exception e) { e.printStackTrace(); } return bimg; } 

but I get an exception:

 03-15 18:05:22.051: ERROR/AndroidRuntime(437): java.lang.NoClassDefFoundError: javax.imageio.ImageIO 
+5
android bufferedimage
source share
1 answer

ImageIO is not supported in Android SDK

Could you do the same with Bitmap and BitmapFactory ?? like this...

 Bitmap tgtImg = BitmapFactory.decodeFile("ImageD2.jpg"); 

if tgtImg not null after this, it was successful.

+11
source share

All Articles