This project is read-only.

Mixing PixelFormats.Bgr32 and PixelFormats.Bgra32

Jan 27, 2013 at 3:14 PM
Edited Jan 27, 2013 at 4:50 PM

I'm missing something in the API:

1. I have an XAML Image source targeting  a WriteableBitmap:

new WriteableBitmap(kinect.ColorW, kinect.ColorH, 96.0, 96.0, PixelFormats.Bgr32, null);

2. Because I want to draw on it I have to convert it to Bgra:


 this.colorBitmap.DrawRectangle(r.Left, r.Top, r.Width + r.Left, r.Height + r.Top, Colors.Green);

3. But I also have to write next kinect image:

WritePixels(new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),            this.colorPixels, this.colorBitmap.PixelWidth * sizeof(int), 0);

How can I write the bgr pixel array to bgra WriteableBitmapEx ?

Thanks !


Ok so I loop on ColorPixels to set Alpha to 255

for (int i = 3; i < ColorPixels.Length; i += 4) {        ColorPixels[i] = 255;      }



Jan 28, 2013 at 10:53 AM

This lib only supports ARGB and an auto conversation is performed if you use the BitmapFactory to create a new Bitmap.

After you have the right values, use the Blit method where one bitmap has set the alpha values to 0.