bitmapimage

WinRT Loading an Image into a Byte array

走远了吗. 提交于 2019-12-04 05:28:47
问题 I'm trying to learn how to interact with the some of the WinRT (Metro) objects for images. Basically, I'm working towards creating a "GetPixel" and "SetPixel" method that's easy to use (similiar to what's in System.Drawing.Bitmap that can't be used in Metro apps). For testing, I created a "Bitmap" class. It loads based off of a IRandomAccessStream that I get from the Metro file picker control. I'm able to load the pixel data into a Byte array and then create a BitmapImage from it that renders

Changing the dimensions of a BitMapImage in WPF, and what kind of objects can I put in an <Image> element?

我的梦境 提交于 2019-12-04 04:22:26
问题 I am trying to create an explorer app with a TreeView element, and have different icons for each level of the tree, and following the article here: http://www.codeproject.com/Articles/21248/A-Simple-WPF-Explorer-Tree It is all working great, except that I want to have different sized icons as well. My XAML for the Image element is here: <Image Name="img" Source="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TreeViewItem}}, Path=Header, Converter={x:Static

Convert ImageSource to BitmapImage - WPF

时光怂恿深爱的人放手 提交于 2019-12-04 00:29:06
问题 I'm using a class library that generates a large ImageSource, > 3000x3750 pixels. I would like to convert this ImageSource to BitmapImage so that I can take advantage of DecodePixelWidth or DecodePixelHeight instead of resizing it everytime this image is generated. I need to display this image for the user first, and most of the users have a screen resolution of 1024x768, I'm binding this ImageSource to an Image control for this, but it can be noticed how "heavy" it is. How can I do this? Or

XAML bind BitmapImage ViewModel property

流过昼夜 提交于 2019-12-03 10:37:26
问题 I have problem with update listbox from view model class. I use Caliburn Micro framework. My scenario is here: I bind property of type bindableCollection on listbox: Code from view model: private BindableCollection<UserInfo> _friends; public BindableCollection<UserInfo> Friends { get { return _friends; } set { _friends= value; NotifyOfPropertyChange(()=>Friends); } } In view model I create fake service method wich return new fresh data as List and with this data I update property Friends

XAML bind BitmapImage ViewModel property

孤者浪人 提交于 2019-12-03 01:08:38
I have problem with update listbox from view model class. I use Caliburn Micro framework. My scenario is here: I bind property of type bindableCollection on listbox: Code from view model: private BindableCollection<UserInfo> _friends; public BindableCollection<UserInfo> Friends { get { return _friends; } set { _friends= value; NotifyOfPropertyChange(()=>Friends); } } In view model I create fake service method wich return new fresh data as List and with this data I update property Friends which is bind on listbox. I call fake service method in dispatcher timer tick event every 3 seconds.

How to convert Colors to Grayscale in java with just the java.io.*; library?

旧城冷巷雨未停 提交于 2019-12-02 14:06:41
问题 Well, i got this.. cause in my place they request it like that.. Well i have this: //some variables and coments are a possible code.. But i mean i don't know how to do it exactly, i found on internet that to convert R is the byte is in *0.21 with G is *0.71 i guess and blue is * 0.07. I just can use that library java.io.*; and i'm working with BMP format images of 1024 x 768, if you can help me, or you want me to be more specific please tell me. i don't know if i have to add another variables

Silverlight 4 BitmapImage - bmp file support

放肆的年华 提交于 2019-12-02 12:13:58
MSDN mentions support for PNG and JPG, but many people are trying setSource(file.bmp) and complaining about "Catastrophic failures". Can someone clarify this, is bmp supported or not ? And if not, what is the best way for displaying a bmp in silverlight ? BMP is not supported in Silverlight. BMP is a very old and not a very efficient format (compared with PNG & JPG) so they have not bothered to support it. Silverlight only supports JPG & PNG format images. The best way to display them is to convert them on the web server so they can be served up as PNGs. The webserver will have access to

Handling image load exception gracefully

我是研究僧i 提交于 2019-12-02 09:19:41
I'm loading user images using Silverlight 3. Everything works fine and I can set the file stream to a BitmapImage and it gets rendered OK. The problem is that if I try to load something that's not an image (like a .exe that's been renamed to .png) Silverlight crashes with a System.Exception that says "Catastrophic failure". The MSDN documentation unhelpfully says that it should be so there msdn link and I should listen to the ImageFailed event (which never gets fired). Am I missing something there or is the library broken when loading from a stream? The code I've got loading the image from the

BitmapImage: Accessing closed StreamSource

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 07:19:16
I'm using the following code trying to convert my BitmapImage to a byte[] so I can save it in my MS SQL Database. public static byte[] BufferFromImage(BitmapImage img) { if (img == null) return null; byte[] result = null; using (Stream stream = img.StreamSource) { if (stream != null && stream.Length > 0) { using (BinaryReader br = new BinaryReader(stream)) { result = br.ReadBytes((int)(stream.Length)); } } } return result; } Sadly this doesn't work as img.StreamSource is disposed when I try to access it in the if-statement, resulting in an exception "Cannot access a disposed file". My call:

Error: The calling thread cannot access this object because a different thread owns it

雨燕双飞 提交于 2019-12-02 07:08:49
问题 I get this error. Here is the code: Image image; BitmapImage BmpImg; MemoryStream ms; public void Convert() { ms = new MemoryStream(); image.Save(ms, ImageFormat.Jpeg); BmpImg = new BitmapImage(); BmpImg.BeginInit(); BmpImg.StreamSource = new MemoryStream(ms.ToArray()); BmpImg.EndInit(); } private void Btn_Click(object sender, RoutedEventArgs e) { Dispatcher.Invoke(new Action(() => { Image.Source = BmpImg; })); } How to convert a System.Drawing.Image to BitmapImage and display the same on wpf