dev/graphics/fb0 或许dev/fb0 文件中存储的数据是什么样子的数据?是不是二进制
dev/graphics/fb0 或者dev/fb0 文件中存储的数据是什么样子的数据?是不是二进制
各位高手们,本程序猿写了一程序是从如标题两个文件中读取图像数据,但是用c读取出数据之后返回到java层的数据发现不能正常的转换成bitmap,看来是得到的数据有问题。请问一下高手们,从以上两个文件读取出的数据是不是二进制的数据,还是是别的类型的数据。。求指点。dev/graphics/fb0 或者dev/fb0 里边取出的到底是什么数据。。
------解决方案--------------------
数据是raw数据,里面存储的数据格式和你要转换的格式不一样,我是转成ARGB_8888格式的,贴上我处理的代码
各位高手们,本程序猿写了一程序是从如标题两个文件中读取图像数据,但是用c读取出数据之后返回到java层的数据发现不能正常的转换成bitmap,看来是得到的数据有问题。请问一下高手们,从以上两个文件读取出的数据是不是二进制的数据,还是是别的类型的数据。。求指点。dev/graphics/fb0 或者dev/fb0 里边取出的到底是什么数据。。
------解决方案--------------------
数据是raw数据,里面存储的数据格式和你要转换的格式不一样,我是转成ARGB_8888格式的,贴上我处理的代码
- Java code
获取屏幕大小: DisplayMetrics metrics =new DisplayMetrics(); WindowManager WM = (WindowManager)this.getSystemService(Context.WINDOW_SERVICE); Display display = WM.getDefaultDisplay(); display.getMetrics(metrics); int height = metrics.heightPixels; //屏幕高 int width = metrics.widthPixels; //屏幕的宽 // 获取显示方式 int pixelformat = display.getPixelFormat(); PixelFormat localPixelFormat1 =new PixelFormat(); PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1); int deepth = localPixelFormat1.bytesPerPixel;//位深 InputStream stream =getInputStream(); byte[] piex = new byte[height * width * deepth]; DataInputStream dStream = new DataInputStream(stream); int i=0; while(dStream.read(piex, 0, height * width * deepth) != -1){ // 保存图片 int[] colors = new int[height * width]; for(int m=0;m<piex.length;m++){ if(m%4 == 0){ int r = (piex[m] & 0xFF); int g = (piex[m+1] & 0xFF); int b = (piex[m+2] & 0xFF); int a = (piex[m+3] & 0xFF); colors[m/4]= (a << 24) + (r <<16) + (g <<8) + b; } } // piex生成bitmap Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888); // bitmap保存为png格式: FileOutputStream out = new FileOutputStream("/mnt/sdcard/test"+x+".png"); bitmap.compress(Bitmap.CompressFormat.PNG, 100,out);