سؤال

How can I combine a list of RenderTargetBitmaps into single large RenderTargetBitmap?

I create a list of RenderTargetBitmaps by rendering multiple visuals. Then all these RenderTargetBitmaps need to be combined into one large texture atlas (sprite sheet).

هل كانت مفيدة؟

المحلول 2

I have found there is WriteableBitmap class in WPF with WritePixels method that could be used in combination with RenderTargetBitmaps's CopyPixels method. WritePixels method allows to specify a region where pixels are copied to on WriteableBitmap, so I think that should work in theory at least.

Before I have found about WriteableBitmap class I have already moved packing logic. Visuals are already positioned (at rendering) on one large RenderTargetBitmap, so that I do not need to combine multiple RenderTargetBitmap anymore.

نصائح أخرى

I'm not sure how extensive WPF's direct imaging methods are, there's methods for CopyPixels on a BitmapSource, in theory you could use CopyPixel on all your bitmapsource's, merge them and create a new bitmapsource passing the new pixeldata. I'm not sure how to do the actual merging though.

Another way would be to convert the BitmapSources to GDI+ instead, merge them using it's imaging features and convert the result back to an BitmapSource

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top