Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient bitmap manipulation in WPF (C#)

the problem is as follows:

I have got a rendered bitmap in a byte array (together with the bitmap header). Now I want to manipulate the content of a bitmap. For that purpose I need to wrap this array with some high-level class, say BitmapImage . I want to avoid copying the array, or its data part etc. I want just to force .NET to interpret my byte array as the BitmapImage .

I want to change the content by rendering some stuff to RenderTargetBitmap , and then interpret its data bits as the bits of my image. For rendering I am to use standard DrawingContext, DrawingVisual pair. Thus, it would be great if I could WORK on the data part of my byte array and render my final image to this subarray. Then I did not need to perform any copying and the performance would be great.

How to speedup the calculation and get breathtaking results? :-)

Thank you in advance for the replies!

Cheers

like image 377
Jamie Avatar asked Feb 02 '26 14:02

Jamie


1 Answers

I would use Writeablebitmap , manipulate it in the code and then show it in the Image. Depending on the context some caching could do a great job.

like image 121
Lukasz Madon Avatar answered Feb 05 '26 04:02

Lukasz Madon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!