主要集中在类Bitmap、BitmapFactory中:
(1)Bitmap转换为字节码
ByteBuffer buf = ByteBuffer.allocate(bitmap.getWidth() * bitmap.getHeight() * 4);
bitmap.copyPixelsToBuffer(buf);
byte[] bytesOfBitmap = buf.array();
(2)Bitmap转换为输出流
bitmap.compress(CompressFormat format, int quality, OutputStream stream);
(3)从byte[]中获取Bitmap
BitmapFactory.decodeByteArray(byte[] data, int offset, int length, Options opts);
(4)从输入流中获得Bitmap
BitmapFactory.decodeStream(InputStream is, Rect outPadding, Options opts);
Bitmap转换为字节码/输出流
最新推荐文章于 2023-10-19 23:10:07 发布