JAVA:Java二维数组处理-Bit型转Bitmap
生活随笔
收集整理的這篇文章主要介紹了
JAVA:Java二维数组处理-Bit型转Bitmap
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
詳細介紹Java數組,文鏈:http://c.biancheng.net/view/916.html
雖然使用Java數組效率很低...
代碼段:
import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.RectF;//轉換bit到bitmappublic Bitmap[] convBit2Bitmap( byte[] outputMask,int MAX_RESULTS ){//Bitmap[] bitMask=null;Bitmap[] bitMask=new Bitmap[MAX_RESULTS];//拆分成多個int l = outputMask.length/MAX_RESULTS;double lf = (double)l/3;int width= (int)Math.floor(Math.sqrt(lf));int height= width;height= width=inputSize;//int type = Bitmap.Config.ARGB_8888;byte[][] output =new byte[MAX_RESULTS][l];;for (int i=0;i< MAX_RESULTS;++i){int spos = i*l;output[i] =new byte[l];for ( int j=0;j< l;++j ){output[i][j] = outputMask[spos +j];}if ( output[i].length != 0 ) {//Bitmap bm= BitmapFactory.decodeByteArray(output[i], 0, output[i].length);//bitMask[i] =BitmapFactory.decodeByteArray(output[i], 0, output[i].length);//SkAndroidCodec::NewFromStream returned null//Bitmap.decodeByteArray(outputMask, 0, outputMask.length);//Bitmap stitchBmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);//RGB_565//ARGB_8888//stitchBmp.copyPixelsFromBuffer(ByteBuffer.wrap(output[i]));//bitMask[i] = stitchBmp;Bitmap stitchBmp = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8);stitchBmp.copyPixelsFromBuffer( ByteBuffer.wrap(output[i]) );//bitMask[i] = stitchBmp;//bitMask[i] = stitchBmp.copy(Bitmap.Config.ALPHA_8, true);bitMask.getConfig();bitMask[i] = stitchBmp.copy( stitchBmp.getConfig(), true );int lt = output[i].length;} else {}}return bitMask;}?
Tips:
?
?
總結
以上是生活随笔為你收集整理的JAVA:Java二维数组处理-Bit型转Bitmap的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 勤奋的近义词
- 下一篇: 钟祥最大的混混(钟祥市柴湖镇混混排名)