I am trying to convert BufferedImage
into bitmap to set bitmap in ImageView
but I am getting an error. Is there any way to set java.awt.Image
in ImageView
?
BufferedImage bImageFromConvert = null;
InputStream in = new ByteArrayInputStream(byt);
try {
bImageFromConvert = ImageIO.read(in);
Image ima = bImageFromConvert;
Bitmap bmp = Bitmap.;
img.setImageBitmap(bmp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Is there any way to set
java.awt.Image
inImageView
?
Short answer: No.
You can't use Image
, BufferedImage
( java.awt
package) or ImageIO
( javax.imageio
package) from Android. So I'm guessing the error you see is related to that.
Maybe if you try to ask how to achieve your goal, rather than this specific implementation issue, maybe we could help you further. :-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.