Hi there,
I need to draw a basic shapes on my bitmap (Bgra32). However, RenderTargetBitmap works with Pbgra32 bitmaps. What is the most elegant way of dealing with bitmaps in WPF?
Thank you in advance for the reply!
Cheers
Hi there,
I need to draw a basic shapes on my bitmap (Bgra32). However, RenderTargetBitmap works with Pbgra32 bitmaps. What is the most elegant way of dealing with bitmaps in WPF?
Thank you in advance for the reply!
Cheers
You can define a BitmapSource with any format you like in the constructor itself and then send a byte array with the drawing you want. For example:
byte[] pixelData = DrawYourPicture();
int stride = width * PixelFormats.Pbgra32.BitsPerPixel/8;
BitmapSource bmpSource = BitmapSource.Create(width, height, 96, 96,
PixelFormats.Pbgra32, null, pixelData, stride);
The bmpSource can then be directly assigned to the Source property of an Image.