GOOGLE对于图像的读取处理,已经封装了Bitmap类和BitmapFactory类,可以说囊括了许多种读取图片数据的方式,但是如果我们只有纯RGB数据(byte[])和位图宽和高又如何将数据上屏显示呢? 查看SDK文档,虽然没有关于byte[]数组的构建BITMAP对象的API 但是有[url=file:///C:/Program%20Files/android-sdk-windows/docs/reference/android/graphics/Bitmap.html#createBitmap(int[], int, int, android.graphics.Bitmap.Config)]createBitmap[/url](int[] colors, int width, int height, Bitmap.Config config) 这个方法 于是就有了思路,就是将byte[]数组转化为int[]数组,以下是本人封装的一个类用以实现通过byte[]数据流构建BITMAP的对象: public class MyBitmap{
static public Bitmap createMyBitmap(byte[] data, int width, int height){ int []colors = convertByteToColor(data); if (colors == null){ return null; }