We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageActivity.java中替换showImage方法: private void showImage(byte[] data) { Bitmap bitmap; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(data, 0, data.length, opts);
int size = (opts.outWidth * opts.outHeight); int size_limit = 1920 * 1080 * 4; if (size > 1920 * 1080 * 4) { int zoomRate = (int) Math.ceil(size * 1.0 / size_limit); if (zoomRate <= 0) zoomRate = 1; opts.inSampleSize = zoomRate; } if (!Thread.currentThread().isInterrupted()) { opts.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opts); iv.setImageBitmap(bitmap); } }
原因,由于部分图片过大,导致无法显示,因此应该在生成bitmap时做缩放处理(上述代码的作用是将 bitmap限制在1920*1080以内,毕竟大部分电视只支持1080p,分辨率高于这个意义不大,反而极易导致图片内存溢出等各种问题) 更新代码前,测试切换图片时部分图片不能显示的几率较大,更改后为0
The text was updated successfully, but these errors were encountered:
这个项目比较有意义,希望能坚持下去把他做好
Sorry, something went wrong.
更正一下,还是不能杜绝问题,但确实明显有改善,基本上只要真的收到了请求,就能显示出来。尤其是投送高分辨率的图片时改善尤为明显
谢谢楼上的指正……我看一下,修改一下子
No branches or pull requests
ImageActivity.java中替换showImage方法:
private void showImage(byte[] data)
{
Bitmap bitmap;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, opts);
原因,由于部分图片过大,导致无法显示,因此应该在生成bitmap时做缩放处理(上述代码的作用是将
bitmap限制在1920*1080以内,毕竟大部分电视只支持1080p,分辨率高于这个意义不大,反而极易导致图片内存溢出等各种问题)
更新代码前,测试切换图片时部分图片不能显示的几率较大,更改后为0
The text was updated successfully, but these errors were encountered: