0


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.

Andriy Mytroshyn
  • 221
  • 1
  • 5
  • 14
  • What is the desired result? Do you want to shows this on screen only, or also save it to an image file? Did you yet try anything? – Clemens Jul 19 '13 at 13:15
  • result need display only, i found only one hardcore way, calculate color result from program, but i think wpf can do it better and faster – Andriy Mytroshyn Jul 19 '13 at 13:20
  • Couldn't you just overlay three Image controls with appropriate `Opacity` values? – Clemens Jul 19 '13 at 13:25
  • yes i could do it, it is normal way if i have three images, but in case if i work with many images i can have problem with managing this additional images vector – Andriy Mytroshyn Jul 19 '13 at 13:30

1 Answers1

1

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.

Clemens
  • 123,504
  • 12
  • 155
  • 268