bitmapimage

still memory-leaks in .net4 - binding memory BitmapImage to Image-Source

China☆狼群 提交于 2019-12-06 02:32:11
I know very similar questions were asked here in the past - but neither had a solution for my problem: I load a image from memory into a BitmapImage: private static BitmapImage LoadImage(byte[] imageData) { if (imageData == null || imageData.Length == 0) return null; var image = new BitmapImage(); using (var mem = new MemoryStream(imageData)) { mem.Position = 0; image.BeginInit(); image.CreateOptions = BitmapCreateOptions.PreservePixelFormat; image.CacheOption = BitmapCacheOption.OnLoad; image.UriSource = null; image.StreamSource = mem; image.EndInit(); } image.Freeze(); return image; } And

How to get BitmapSource from BitmapImage?

夙愿已清 提交于 2019-12-05 14:19:11
How to get BitmapSource from BitmapImage? Or how to convert BitmapImage to BitmapFrame directly? It seems to me that if I have BitmapSource I could use BitmapFrame.Create and finally get BitmapFrame object from given BitmapImage A BitmapImage inherits from BitmapSource so no conversion is needed The BitmapImage inherits from BitmapSource as parapura said. Example: BitmapSource bitmapSource = new BitmapImage(); BitmapImage bitmapImage = bitmapSource as BitmapImage; Source: BitmapSource MSDN 来源: https://stackoverflow.com/questions/8138610/how-to-get-bitmapsource-from-bitmapimage

Get supported image formats from BitmapImage

谁说我不能喝 提交于 2019-12-05 14:05:00
How can I get a list of image formats supported by System.Windows.Media.Imaging.BitmapImage? I am writing a simple image processing tool in C# WPF. The BitmapImage class is one of the more useful bitmap classes as it is able to decode from a wide variety of formats. In particular, it is able to open NEF (Nikon's RAW format) on my computer. It is likely that BitmapImage can open a wide variety of RAW formats from other manufacturers, a function I am keen to make use of. As I don't know every format that can be opened as a BitmapImage, I am currently using a try/catch to try and construct a

Scale image without losing image quality did not work

最后都变了- 提交于 2019-12-05 09:33:45
Does anyone know how to scale the bitmap image without losing the image quality ? Currently I facing this problem , where the size of selected image maybe too big caused the app return to another activity. So now I tried using this method to scale the selected image without losing its quality. I get the code from here . protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_LOAD_IMAGE: if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK & null != data) { Uri

Can I get a byte[] from a BitmapImage in Silverlight?

我只是一个虾纸丫 提交于 2019-12-05 08:16:23
I'm trying to pass some representation of an image back and forth between Silverlight and a WCF service. If possible I'd like to pass a System.Windows.Media.Imaging.BitmapImage , since that would mean the client doesn't have to do any conversion. However, at some point I need to store this image in a database, meaning the image representation must be able to convert to and from byte[] . I can create a BitmapImage from a byte[] by reading the array into a MemoryStream and using BitmapImage.SetSource() . But I can't seem to find a way to convert the other way - from BitmapImage to byte[] . Am I

Write hidden messages to image file c#

孤人 提交于 2019-12-04 22:55:46
I was looking for a tutorial where is described how to write/read hidden text into image file using C#, but unfortunately I din;t find any good posts about this, so I decided to ask here about this small trick. Suppose I have an image file called test.jpg , is there any way to write an hidden text like "Hello word " to this file ? I have read about image metadata , and I suppose that I should try to write somehow to this metadata , but I din;t find how. If anybody know how to do it , please help me to understand how to it. Thanks. The correct term for this is "Steganography". The following

Extract path information from an black&white bitmap image

不打扰是莪最后的温柔 提交于 2019-12-04 14:05:54
问题 It is not easy to draw a shape with Quartz 2D to depict an image as following. Is it possible to extract a CGPathRef information from a black&white bitmap image? The white part is actually transparent. Edit : What I want to achieve: I want to set the physicsBody of a SKSpriteNode with the same shape of the image bottle.png SKSpriteNode * myBottle = [SKSpriteNode spriteNodeWithImageNamed:@"bottle"]; . . . myBottle.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:path]; Her path is a

how to compress Uri image to bitmap

半世苍凉 提交于 2019-12-04 10:03:10
this code show me an error i want to add selected image save to database and retrive i follow this 2 tutorials http://nizaqatali.wordpress.com/2011/06/21/android-dialog-select-image-from-gallery/ and this http://androidhub4you.blogspot.com/2012/09/hello-friends-today-i-am-going-to-share.html but this problem is come error message"The method compress(Bitmap.CompressFormat, int, ByteArrayOutputStream) is undefined for the type Uri" import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import android.app.Activity; import android.content.Intent; import android

How can I set the WPF BitmapImage UriSource property to a relative path?

非 Y 不嫁゛ 提交于 2019-12-04 08:59:23
I'm loading an image in WPF by using the BitmapImage class. My code works perfectly when I give an absolute path for the UriSource but not when I try and use a relative path. My XAML is: <Image Width="50" Name="MemberImage" HorizontalAlignment="Left"> <Image.Source> <BitmapImage DecodePixelWidth="50" UriSource="questionmark.jpg" /> </Image.Source> </Image> The questionmark.jpg is added to the project with a Build Action of Resource and Copy to Output Directory set to Copy always. The error I get is "The file [file name] is not part of the project or its 'Build Action' property is not set to

How can I merge 2 images on Windows Phone

一笑奈何 提交于 2019-12-04 07:58:23
I have 2 images and I want to merge them into one on my apps in Windows Phone. The first image captured by my WP's camera, the second image is a frame (borders, filter, etc.) which user can choose among our templates. So how can I merge them into one. Thanks and best regards. Agung Pratama I don't quite understand what you ask. But I guess you want to overlay 1 image on top of another. If so, there is already an answer here . Inside the <grid> , you can provide both the image, and customize the opacity of each image to make it overlay-ed. EDITED: You can use Writeablebitmap for that and there