setRGB2YUV => setYUV2RGB problem

Put your problem here if it does not fit any of the other categories.

setRGB2YUV => setYUV2RGB problem

Postby Vince » Thu Apr 29, 2010 8:07 am

Hello everyone, I have this code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. float[] mx = {
  5.  
  6.                      1.0f,  0.0f,  0.0f,  0.0f,  0.0f,
  7.  
  8.                      0.0f,  1.0f,  0.0f,  0.0f,  0.0f,
  9.  
  10.                      0.0f,  0.0f,  1.0f,  0.0f,  0.0f,
  11.  
  12.                      0.0f,  0.0f,  0.0f,  1.0f,  0.0f
  13.  
  14.                     };
  15.  
  16.  
  17.  
  18. ColorMatrix ms = new ColorMatrix(mx);
  19.  
  20.  
  21.  
  22. ms.setRGB2YUV();
  23.  
  24. ms.setYUV2RGB();
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


When I set the matrix to a Drawable without doing any RGB2YUV/YUV2RGB, no color change happens, since indeed the color matrix makes every rgb value be multiplied by 1, leaving the rgb color unchanged.

However, when I do these two simple conversion something goes wrong:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ms.setRGB2YUV();
  2.  
  3. ms.setYUV2RGB();
Parsed in 0.062 seconds, using GeSHi 1.0.8.4


Supposedly the first conversion should convert RGB to YUV and the second one should convert YUV to RGB. In my case I'm not changing any values between the conversions and I would expect to get the very same initial color matrix (mx). This doesn't happen and I get a totally different matrix values and if I apply the matrix to my image i get some weird result.

What am I doing wrong? Or is that a bug?
Vince
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 27, 2010 3:59 pm

Top

Postby Vince » Fri Apr 30, 2010 7:41 am

Could anyone at least tell me how I can access online the source code of android.graphics.ColorMatrix to check both methods (setRGB2YUV/setYUV2RGB)?
Vince
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 27, 2010 3:59 pm

Postby pskink » Fri Apr 30, 2010 8:00 am

Vince wrote:Could anyone at least tell me how I can access online the source code of android.graphics.ColorMatrix to check both methods (setRGB2YUV/setYUV2RGB)?


https://android.git.kernel.org/?p=platf ... e6;hb=HEAD
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby Vince » Fri Apr 30, 2010 10:09 am

Thanks!

That explains a lot. I don't know if it's intended, but the matrix gets reset every time you call the setRGB2YUV/setYUV2RGB function. So the conversion is done on the default matrix not a matrix you've set, which is weird. I thought that for example setRGB2YUV would convert the current matrix to YUV, instead of returning a YUV ''standard'' matrix...

I don't know why that would be so, maybe I'm not interpreting the code correctly, but anyway looking at the code gave me an insight into what I'm trying to do and I've solved the issue.
Vince
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 27, 2010 3:59 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests