bitmapimage

Update BitmapImage every second flickers

陌路散爱 提交于 2020-02-24 09:26:07
问题 I am trying to update an image by setting the source property every second, this works however causes a flicker when updated. CurrentAlbumArt = new BitmapImage(); CurrentAlbumArt.BeginInit(); CurrentAlbumArt.UriSource = new Uri((currentDevice as AUDIO).AlbumArt); CurrentAlbumArt.CreateOptions = BitmapCreateOptions.IgnoreImageCache; CurrentAlbumArt.EndInit(); If I don't set IgnoreImageCache , the image does not update thus no flickering either. Is there a way around this caveat? Cheers. 回答1:

Loading an .ico from web and convert to BitmapSource

有些话、适合烂在心里 提交于 2020-01-16 19:36:33
问题 Im trying to load a file of type .ICO from web and use it as an image in my windows phone. But I get an error when trying to set the source of the BitmapImage. Here is my code: WebClient client = new WebClient(); client.OpenReadCompleted += (s, e) => { if (e.Cancelled) return; if (null != e.Error) throw e.Error; BitmapImage image = new BitmapImage(); image.SetSource(e.Result); this.Favicon = image; }; client.OpenReadAsync(new Uri(@"http://mysite/myimage.ico", UriKind.RelativeOrAbsolute));

How to add and show images in a WPF TreeView?

為{幸葍}努か 提交于 2020-01-15 19:55:25
问题 I fill a TreeView (WPF) in the code and want to use some icons in the items. I can load and add BitmapImage but it is only displayed, when the BitmapImage is also assigned to another ImageControl in the window (and shown there): TreeViewItem newItem = new TreeViewItem(); Image tempImage = new Image(); BitmapImage bitmapImage = new BitmapImage(new Uri(@"/Resources/ok-01.png", UriKind.Relative)); tempImage.Source = bitmapImage; imageControlInWindow.Source = bitmapImage; //if I delete this line

How to add and show images in a WPF TreeView?

我们两清 提交于 2020-01-15 19:52:29
问题 I fill a TreeView (WPF) in the code and want to use some icons in the items. I can load and add BitmapImage but it is only displayed, when the BitmapImage is also assigned to another ImageControl in the window (and shown there): TreeViewItem newItem = new TreeViewItem(); Image tempImage = new Image(); BitmapImage bitmapImage = new BitmapImage(new Uri(@"/Resources/ok-01.png", UriKind.Relative)); tempImage.Source = bitmapImage; imageControlInWindow.Source = bitmapImage; //if I delete this line

How to add and show images in a WPF TreeView?

自作多情 提交于 2020-01-15 19:52:20
问题 I fill a TreeView (WPF) in the code and want to use some icons in the items. I can load and add BitmapImage but it is only displayed, when the BitmapImage is also assigned to another ImageControl in the window (and shown there): TreeViewItem newItem = new TreeViewItem(); Image tempImage = new Image(); BitmapImage bitmapImage = new BitmapImage(new Uri(@"/Resources/ok-01.png", UriKind.Relative)); tempImage.Source = bitmapImage; imageControlInWindow.Source = bitmapImage; //if I delete this line

BitmapImage decoding speed performance wpf

你。 提交于 2020-01-13 09:41:11
问题 I have 5 images all the same pixel height and pixel width (2481 * 3508 for that matter). But, one is gif, one jpeg, one png and one bmp. Now I render them into a BitmapSource with (1) two thirds of the original pixel height for DecodePixelHeight and (2) original pixel height for DecodePixelHeight. First scenario: bitmapImage.BeginInit(); bitmapImage.CreateOptions = BitmapCreateOptions.IgnoreColorProfile; bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.DecodePixelHeight = 2/3 *

C# Load JPG file, extract BitmapImage

为君一笑 提交于 2020-01-11 04:26:07
问题 I am trying to extract a BitmapImage from a JPG. This is the code I have: FileStream fIn = new FileStream(sourceFileName, FileMode.Open); // source JPG Bitmap dImg = new Bitmap(fIn); MemoryStream ms = new MemoryStream(); dImg.Save(ms, ImageFormat.Jpeg); image = new BitmapImage(); image.BeginInit(); image.StreamSource = new MemoryStream(ms.ToArray()); image.EndInit(); ms.Close(); image comes back with a 0 × 0 image, which of course means it didn't work. How do I do this? 回答1: Try this: public

How to free the memory after the BitmapImage is no longer needed?

半腔热情 提交于 2020-01-08 21:39:33
问题 First, I load a BitmapImage on the Image control on the Window . Second, I work with the Image control and then close the Window . I do it 2-3 times in a minute and my memory fills up very quickly because the images do not unload back when the window is closed. So how to unload BitmapImage from Image.Source control manually to free the memory? 回答1: I believe the solution you are looking for is at http://www.ridgesolutions.ie/index.php/2012/02/03/net-wpf-bitmapimage-file-locking/. In my case,

How to free the memory after the BitmapImage is no longer needed?

北城以北 提交于 2020-01-08 21:39:04
问题 First, I load a BitmapImage on the Image control on the Window . Second, I work with the Image control and then close the Window . I do it 2-3 times in a minute and my memory fills up very quickly because the images do not unload back when the window is closed. So how to unload BitmapImage from Image.Source control manually to free the memory? 回答1: I believe the solution you are looking for is at http://www.ridgesolutions.ie/index.php/2012/02/03/net-wpf-bitmapimage-file-locking/. In my case,

Can not create OpacityMask from Byte[]

我的未来我决定 提交于 2020-01-06 18:03:44
问题 I have a rectange which I want to set an OpacityMask for. I tried it directly from a PNG Image, which was working. But since my image comes from a Database later, I tried saving the PNG into an array first, and then restoring the BitmapImage from it. This is what I have now: bodenbitmap = new BitmapImage(); bodenbitmap.BeginInit(); bodenbitmap.UriSource = new Uri(@"C:\bla\plan.png", UriKind.Relative); bodenbitmap.EndInit(); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Frames.Add