I develop app in WPF. I have a bmp images I merge together and final image bind as a source to image control. The bmp images are same size. The image control I need as a part of treeview.
Binding of images, treeviewitem.
<StackPanel Orientation="Horizontal">
<Image Margin="0,0,4,0" Source="{Binding ImgHeader}" Width="16" Height="16" />
<TextBlock Text="{Binding Header}"></TextBlock>
</StackPanel>
This is a code I merge bmp together with another bmp.
Bitmap oSource = LoadImage(imageName); - image from resource
oSource.MakeTransparent(System.Drawing.Color.White);
using (Graphics oGraphics = Graphics.FromImage(dest))
{
oGraphics.PageUnit = GraphicsUnit.Pixel;
oGraphics.DrawImage(oSource, new Rectangle(0, 0, dest.Width, dest.Height));
}
And conversion to BitmapImage to bind to image control.
using (MemoryStream memory = new MemoryStream())
{
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.StreamSource = memory;
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
bitmapimage.EndInit();
return bitmapimage;
}
But when the final image has some pieces white color, the result of these pieces in app in treeview is black color. This is what I see in the treeview.
White color has to be on top of images on the picture below. This is what I want.
I need white color. Where is the problem?