Problem with BitmapFrame rendering (created from byte array) in C#

359 views Asked by At

Here is the situation:

I have got the array of bytes containing the bitmap header together with the bitmap data. I know the offset of data, and I need to generate BitmapFrame for later rendering. I wanted to avoid array cells copying and created a wrapper for a part of the array ( ArraySegment ).

Then I render this bitmap together with a primitive into the RenderTargetBitmap, which is, in turn, saved to the same array (in place of data) using CopyPixels.

I have noticed, that if I work on the original data, with an array wrapper I get the wrong final image. However if I copy the same data to another array and provide it to static Create method of BitmapFrame class, the result is correct.

Do you have any ideas what happens?

Thank you in advance for the replies!

Cheers

1

There are 1 answers

0
Jamie On BEST ANSWER

OK, I have identified the problem - a property of ArraySegment returns the original array - no the subarray...