I try to write method to make converion from rgb_565 byte array to argb_8888 array.
I need this becouse I want to make a lot of image processing from taken photo and I get image data in byte array rgb_565 format (as I believe).
Firstly after creating reference to Camera i do:
Using java Syntax Highlighting
- parameters.setPictureFormat(PixelFormat.RGB_565);
Parsed in 0.029 seconds, using GeSHi 1.0.8.4
and push it to Camera.
Using java Syntax Highlighting
- mCamera.setParameters(parameters);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Then I implement:
Using java Syntax Highlighting
- onPictureTaken(byte[] imageData, Camera c)
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
method in Camera.PictureCallback
After I use my own method like this:
Using java Syntax Highlighting
- convert2ArgbArray(imageData, imageData.length);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Result is a little crapy
Maybe someone has ever try to do this, have the same problem or just can help or have another idea for image processing??
Here is my method:
Using java Syntax Highlighting
- private synchronized void convert2ArgbArray(byte[] imageData, int arraySize){
- int argbArray[] = new int[CameraView.PICTURE_HEIGHT*CameraView.PICTURE_WIDTH];
- int argbCounter = 0;
- int r = 0x00,
- g = 0x00,
- b = 0x00;
- for (int i = 0 ; i < arraySize; i++){
- if (i%2==0){
- r = (imageData[i] >> 3 & 0x0000001F) << 19;
- g = (imageData[i] & 0x00000007) << 3;
- } else {
- g = (((imageData[i] >> 5) & 0x7) | g ) << 10 ;
- b = (imageData[i] & 0x1f) << 3;
- //insert into new array
- argbArray[argbCounter] = 0xff000000 | r | g| b;
- argbCounter = argbCounter + 1;
- }
- }
- mPhotoPicture2 = Bitmap.createBitmap(argbArray, CameraView.PICTURE_WIDTH, CameraView.PICTURE_HEIGHT, Bitmap.Config.ARGB_8888);
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
I simply display mPhotoPicture2 on the screen after this method, and all I get is nice hype.


