我已经查了一下,但不能清楚地看到它。我怎样才能将一个图像的字节数组设置为一个图像视图?我得到了字符串在java中尝试BufferedImage img = ImageIO.read(new ByteArrayInputStream(bytes));
,但不能:(任何人都可以帮助我?对不起,如果问题就像一个小白菜:)图像字节数组到imageview
22
A
回答
52
尝试下面的代码转换位图为bytearray和bytearray到位图,它会解决你的问题。
转换位图的ByteArray: -
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
转换ByteArray的位图: -
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(Bitmap.createScaledBitmap(bmp, image.getWidth(),
image.getHeight(), false)));
-1
获得字节从位图
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
byte[] bytearray = stream.toByteArray();
return bytearray;
+0
这是你给的错误答案。 –
相关问题
- 1. 图像到字节数组
- 2. 字节数组图像到位图
- 3. 字节数组到位图图像
- 4. 字节数组到图像转换
- 5. JavaFx图像到字节[]数组(闭合)
- 6. 字节数组到WriteableBitmap图像IValueConverter WP7
- 7. Silverlight 4,图像到字节数组
- 8. .NET核心字节数组到图像
- 9. 字节数组到图像显示
- 10. 图像到字节数组不一致
- 11. 字节数组到图像对象
- 12. 字节数组图像
- 13. 图像的字节数组
- 14. 如何将图像(字节数组)从JSON显示到imageView ...工厂返回null
- 15. 转换字节数组图像并返回到字节数组,值改变
- 16. 图像到字节数组到字符串(反之亦然)
- 17. 将图像从字节数组加载到图形视图中
- 18. 从imageview可绘制到字节数组(数据库)
- 19. Java字节数组比JPG图像
- 20. 动态显示图像(字节数组)
- 21. 用OpenGL读取图像字节数组
- 22. SQL图像 - >字节数组
- 23. DataTemplate图像标识与字节数组
- 24. 字节数组Base64String(图像转换)
- 25. 从字节数组中裁剪图像
- 26. 转换字节数组图像
- 27. 字节数组输出为图像
- 28. 如何解析图像字节[]数组
- 29. 的SqlDataSource - UpdateParameters与图像字节数组
- 30. GSP,从数组字节图像
感谢名单的队友,将检查和电话你 –
权在钱:) thanx很多 –
可能有任何OutOfMemoryError与此? –