Bitmap转换为字节码/输出流


主要集中在类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);

你可能感兴趣的:(Android)