Merge several images into one

294 views Asked by At


I have several images, every image placed in writablebitmap. Each images represent one layer, every image contain transparency. I need combine this images into one, combine algorithm: show first image(without changes), after that draw second image, on first, with additional transparency X%, after it third image with additional transparency Y%, etc. For work i use framework 4.5, programming language C# and VS2012.
Thanks for help.

1

There are 1 answers

1
Clemens On

You could dynamically create Image controls in code and add them to the Children collection of a Grid or some other Panel.

Alternatively you may use a Grid as ItemsPanel of an ItemsControl, and bind the ItemsSource property to a collection of objects that have an Image and an Opacity propetrty:

<ItemsControl ItemsSource="{Binding ImageItems}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Image Source="{Binding Image}" Opacity="{Binding Opacity}"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

In either case the Grid will take care for putting all images on top of each other.