imagesource

How to compress image byte[] array to JPEG/PNG and return ImageSource object

最后都变了- 提交于 2019-12-04 13:01:51
I have an image (in the form of a byte[] array) and I want to get a compressed version of it. Either a PNG or JPEG compressed version. I use the following code at the minute: private Media.ImageSource GetImage(byte[] imageData, System.Windows.Media.PixelFormat format, int width = 640, int height = 480) { return System.Windows.Media.Imaging.BitmapSource.Create(width, height, 96, 96, format, null, imageData, width * format.BitsPerPixel / 8); } How do I extend this so that I can compress and return the compressed version of image source (with the degraded quality). Thanks in advance! Using the

How Do I Create a System.Windows.Media.ImageSource From a Byte Array?

微笑、不失礼 提交于 2019-12-03 17:33:28
How do I create a System.Windows.Media.ImageSource from a byte array? I have a byte array, containing the exact and complete file contents of a TIFF image file. I need to display this on the screen, and I have no idea where to even start. Supposedly, it can be done (according to my boss, our dev team has done it in the past, but nobody remembers how). Has anyone here ever done something like this before? Lars Truijens BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = new MemoryStream(ByteArray); bi.EndInit(); Also see Load a WPF BitmapImage from a System.Drawing.Bitmap and

How do I get link to an image on wikipedia from the infobox?

橙三吉。 提交于 2019-12-03 13:44:27
问题 I'm parsing wikipedia infoboxes and I noticed that some infoboxes have image fields - these fields hold names of image files stashed on wikipedia somewhere. However they just contain the name of the file as is as opposed to the actual link. I checked the links of the images on real live infoboxes and the links do not seem to be from one source but the sources vary. How can I hyperlink to an image on wikipedia considering I only have the name of the image from an infobox entry. 回答1: Have you

Get Imagesource from Memorystream in c# wpf

给你一囗甜甜゛ 提交于 2019-12-03 09:59:12
How can I get ImageSource from MemoryStream in WPF using c# ? or convert MemoryStream to ImageSource to display it as image in wpf ? using (MemoryStream memoryStream = ...) { var imageSource = new BitmapImage(); imageSource.BeginInit(); imageSource.StreamSource = memoryStream; imageSource.EndInit(); // Assign the Source property of your image image.Source = imageSource; } 来源: https://stackoverflow.com/questions/6588974/get-imagesource-from-memorystream-in-c-sharp-wpf

How to correctly use the Image Source property with Xamarin.Forms?

不打扰是莪最后的温柔 提交于 2019-12-02 22:07:44
I am having difficulty bringing up an image on the content page in a stack layout. I looked through Xamarin API Documentation and found Xamarin.Forms.Image.Source Property , but no sample code to see how it's written. I also checked to see how it was written in C# and seems to match my code in terms of filename path, but in Xamarin, it may be slightly different since it's the first time doing this. The code I'm currently testing through an Android emulator (Google Nexus 5) in Visual Studio 2013 which runs fine, with the exception of the Image not showing. Image Source: new Image {

Display local image in UIImageView

不想你离开。 提交于 2019-11-30 11:01:02
How do I display an image in the UIImageView component from the hard drive? I have a local folder called "images" and would like to access it via a relative path, since I want to package the images with the app. To load image from somewhere on your drive use: UIImage * myImage = [UIImage imageWithContentsOfFile: @"../images/1.png"]; Or add image to the Xcode project and use: UIImage * myImage = [UIImage imageNamed: @"1.png"]; After that add image to imageview: UIImageView * myImageView = [[UIImageView alloc] initWithImage: myImage]; You dont need to give any path as long as the image is in

Change image source in code behind - Wpf

[亡魂溺海] 提交于 2019-11-30 10:55:37
问题 I need to set image source dynamically, please note my image is in somewhere on the Network, here is my code BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri(@"pack://application:,,,\\myserver\\folder1\\Customer Data\\sample.png"); logo.EndInit(); // Getting the exception here ImageViewer1.Source = logo; Exception: The URI prefix is not recognized 回答1: You just need one line: ImageViewer1.Source = new BitmapImage(new Uri(@"\myserver\folder1\Customer Data\sample

WPF - Image 'is not part of the project or its Build Action is not set to Resource'

喜欢而已 提交于 2019-11-30 05:43:43
I have a project which requires an image in the window. This is a static image and i added through 'Add>Existing Item'. It exists in the root of the project. I reference the image in a test page like so - <Page x:Class="Critter.Pages.Test" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Test"> <Image Source="bug.png"/> </Page> Problem is I get a message saying it can't be found or it's build action isn't resource but it DOES exist and it's build action IS resource. If i create a new application and just throw it on

Loading images source dynamically with IValueConverter

我们两清 提交于 2019-11-29 15:44:36
I've problems with IValueconverter and dynamically load a row grid image: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string Type = (string)value; Uri uri; try { uri = new Uri("/XConsole;component/Images/" + Type + ".png", UriKind.Relative); return new System.Windows.Media.Imaging.BitmapImage(uri) { CacheOption = BitmapCacheOption.None }; } catch (Exception e) { //donothing } uri = new Uri("/XConsole;component/Images/Type_SYSTEM.png", UriKind.Relative); return new System.Windows.Media.Imaging.BitmapImage(uri) { CacheOption

WPF - Image 'is not part of the project or its Build Action is not set to Resource'

假如想象 提交于 2019-11-29 04:53:52
问题 I have a project which requires an image in the window. This is a static image and i added through 'Add>Existing Item'. It exists in the root of the project. I reference the image in a test page like so - <Page x:Class="Critter.Pages.Test" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Test"> <Image Source="bug.png"/> </Page> Problem is I get a message saying it can't be found or it's build action isn't resource