解决方案如下:
BufferedImage在Java端使用并将其转换为字节数组,然后在Android端,获取字节数组并将其转换为
Bitmap。
Java方面:
public static byte[] imageToByteArray(BufferedImage image) throws IOException{ ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "png", baos); return baos.toByteArray();}
Android方面:
BitmapFactory.Options opt = new BitmapFactory.Options();opt.inDither = true;opt.inPreferredConfig = Bitmap.Config.ARGB_8888;byte[] imageByteArray = getImageByteArray();Bitmap bitmap = BitmapFactory.depreByteArray(imageByteArray, 0, imageByteArray.length, opt);imageView.setImageBitmap(bitmap);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)