I have three BitmapImages that I would like to stitch together to create a composite image. The three images to be stitched together are aligned in the following way:
The images are of a type System.Windows.Media.Imaging.BitmapImage. I have looked at the following solution, but it uses System.Drawing.Graphics to perform stitching. I find it unintuitive to convert my BitmapImage to System.Drawing.Bitmap everytime I want to stich them together.
Is there a simple way to stitch three images of type System.Windows.Media.Imaging.BitmapImage together?
It really depends on what output type you want. Here are some options.
DrawingVisual
If you just need to render them to a visual, you could use a
DrawingVisual
and render the three images. You could then render the visual in various ways depending on your use case (for example, using aVisualBrush
).Custom Element
If you need an element that you can place in your UI directly, you can make a custom element that extends
FrameworkElement
.You could then use it like this:
Images in a Grid
You always have the option of putting three
Image
controls in aGrid
.Creating an ImageSource
If you need the three images combined into a single
ImageSource
for some reason, you could render into aDrawingVisual
(mentioned above) and then render that visual into aRenderTargetBitmap
.In addition to the options described in the other answer, the code below stitches three BitmapSource together into a single WriteableBitmap: