getting a byte[] from the JPEG or RAW Colorclient

Mar 23, 2012 at 12:45 AM

Hi great software really helpfull

Im just a bit stuck trying to get a byte[] from the e.ColorFrame in  

client_ColorFrameReady(object sender, ColorFrameReadyEventArgs e) 

 

I tried a couple of solutions for decoding i found on the web but non of them seem to work.

I also tried to use the RAW image just to make sure i got the data but it size it returned was a bit larger than expected

Could someone please give me a hint how to properly do this? 

any help would be much appreciated.

kind regards  Bill

Mar 23, 2012 at 7:38 AM

Hi Bill,

Are you using WPF or Windows Phone?

Mar 23, 2012 at 12:21 PM

Hi Peekb

Im using the Windowsclient, Listeners and Common and at the client side I need a byte[] to fill a windows XNA texture.

Thanks for responding so quickly.  

Mar 23, 2012 at 4:22 PM

You should be able to use the CopyPixels method that lives on the BitmapImage object.  That will copy the pixels into a byte[] array which you can pass over to XNA.

Mar 23, 2012 at 6:36 PM

Oww thanks !!!

It works fine and so simple too.

You really made my day have a nice weekend.

Mar 23, 2012 at 6:57 PM

You too, thanks. :)

Apr 3, 2012 at 9:28 PM

Hi, it seems that the CopyPixels methods works for WindowsClient but How can I reach the same in a Windows Phone, I tried to usted the e.ColorFrame.BitmapImage but it does not have the CopyPixels method.

Thanks. 

Apr 3, 2012 at 10:19 PM
Edited Apr 3, 2012 at 10:21 PM

On the phone side, just create a new WriteableBitmap using the BitmapImage. From there you can use the Pixels property to get access to the pixel data.

 

WriteableBitmap bmp = new WriteableBitmap(e.ColorFrame.BitmapImage);
bmp.Pixels[0] = 0;
int pixel = bmp.Pixels[1];