Converting byte array from camera to argb_8888 int array.

All your problems with Audio, Video and Images.

Converting byte array from camera to argb_8888 int array.

Postby kubecz3k » Tue Jan 12, 2010 7:46 pm

Hello.
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:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. parameters.setPictureFormat(PixelFormat.RGB_565);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

and push it to Camera.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mCamera.setParameters(parameters);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Then I implement:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. onPictureTaken(byte[] imageData, Camera c)
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

method in Camera.PictureCallback

After I use my own method like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. convert2ArgbArray(imageData, imageData.length);
Parsed in 0.035 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:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private synchronized void convert2ArgbArray(byte[] imageData, int arraySize){
  2.  
  3.                
  4.  
  5.                 int argbArray[] = new int[CameraView.PICTURE_HEIGHT*CameraView.PICTURE_WIDTH];
  6.  
  7.                 int argbCounter = 0;
  8.  
  9.                
  10.  
  11.                 int r = 0x00,
  12.  
  13.                         g = 0x00,
  14.  
  15.                         b = 0x00;
  16.  
  17.                
  18.  
  19.                 for (int i = 0 ; i < arraySize; i++){
  20.  
  21.                        
  22.  
  23.                         if (i%2==0){
  24.  
  25.                                 r = (imageData[i] >> 3 & 0x0000001F) << 19;
  26.  
  27.                                 g = (imageData[i] & 0x00000007) << 3;
  28.  
  29.                                
  30.  
  31.                         } else {
  32.  
  33.                                 g = (((imageData[i] >> 5) & 0x7) | g ) << 10 ;
  34.  
  35.                                 b = (imageData[i] & 0x1f)  << 3;
  36.  
  37.                                
  38.  
  39.                                 //insert into new array
  40.  
  41.                                 argbArray[argbCounter] = 0xff000000 | r | g| b;
  42.  
  43.                                 argbCounter = argbCounter + 1;                                   
  44.  
  45.                         }
  46.  
  47.                 }                      
  48.  
  49.                 mPhotoPicture2 = Bitmap.createBitmap(argbArray, CameraView.PICTURE_WIDTH, CameraView.PICTURE_HEIGHT, Bitmap.Config.ARGB_8888);
  50.  
  51.         }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4

I simply display mPhotoPicture2 on the screen after this method, and all I get is nice hype.
kubecz3k
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Nov 17, 2009 7:31 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google Feedfetcher and 22 guests