开发者

How to load BufferedImage in android?

开发者 https://www.devze.com 2023-02-17 09:46 出处:网络
I want to load BufferedImage in my application. For that I am using ImageIO but I am getting java.lang.NoClassDefFoundError:

I want to load BufferedImage in my application. For that I am using ImageIO but I am getting java.lang.NoClassDefFoundError:

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

but i am getting exception:

03-15 18:05:22.051: ERROR/AndroidRuntime(437): java.lang.NoClassDefFoundError: javax.imageio.ImageIO


ImageIO is not supported in Android SDK

Could you achieve the same thing with Bitmap and BitmapFactory?? like so...

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

if tgtImg is not null after this then it was successful.

0

精彩评论

暂无评论...
验证码 换一张
取 消