简体   繁体   中英

Merge several images into one


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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM