RuntimeException: Buffer not large enough for pixels
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm receiving a Bitmap in byte array through socket and I read it and then I want to set it os.toByteArray as ImageView in my application. The code I use is: try { //bmp = BitmapFactory.decodeByteArray(result, 0, result.length); bitmap_tmp = Bitmap.createBitmap(540, 719, Bitmap.Config.ARGB_8888); ByteBuffer buffer = ByteBuffer.wrap(os.toByteArray()); bitmap_tmp.copyPixelsFromBuffer(buffer); Log.d("Server",result+"Length:"+result.length); runOnUiThread(new Runnable() { @Override public void run() { imageView.setImageBitmap(bitmap_tmp); } });