bitmapimage

How do I convert a WriteableBitmap object to a BitmapImage Object in WPF

谁说胖子不能爱 提交于 2019-11-28 01:56:14
How do I convert a WriteableBitmap object to a BitmapImage Object in WPF? This link covers silverlight, the process is not the same in WPF as the WriteableBitmap object does not have a SaveJpeg method. So my question is How do I convert a WriteableBitmap object to a BitmapImage Object in WPF? You can use one of the BitmapEncoders to save the WriteableBitmap frame to a new BitmapImage In this example we will use the PngBitmapEncoder but just choose the one that fits your situation. public BitmapImage ConvertWriteableBitmapToBitmapImage(WriteableBitmap wbm) { BitmapImage bmImage = new

pass a bitmap image from one activity to another

谁都会走 提交于 2019-11-27 21:38:59
In my app i am displaying no.of images from gallery from where as soon as I select one image , the image should be sent to the new activity where the selected image will be set as background.However, I am able to get the images from gallery but as soon as I select one the application crashes.Thanks in advance Activity-1(The images are shown in gallery and the selected image is sent to new activity) public class Gallery extends Activity { private static int RESULT_LOAD_IMAGE = 1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super

Reloading an image in wpf

别来无恙 提交于 2019-11-27 20:16:26
I'm trying to reload an image (System.Windows.Controls.Image) I display in WPF. I set the source like this: ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute)); I made a button, which should force a reload of this image (it changes on disk every second). I have tried resetting the Source, but that doesn't do anything. However if I change the Source to a different image, this different image does get loaded. It seems like something is beeing cached? Thanks for you help. Found an answer that works for me: BitmapImage

byte[] to BitmapImage in silverlight

无人久伴 提交于 2019-11-27 15:42:37
For the purpose of a game, I need to serialize some pictures in a binary file through a WPF application, using bitmapEncoder and its child classes. But these class are not available in silverlight, so I can't load them into the browser from the same binary file. Does someone know how to convert a byte[] to BitmapImage in silverlight? Thanks, KiTe Try something like this: BitmapImage GetImage( byte[] rawImageBytes ) { BitmapImage imageSource = null; try { using ( MemoryStream stream = new MemoryStream( rawImageBytes ) ) { stream.Seek( 0, SeekOrigin.Begin ); BitmapImage b = new BitmapImage(); b

WP8: Is there an easy way to scale and blur an BitmapImage for windows phone app?

微笑、不失礼 提交于 2019-11-27 15:10:34
问题 I am working on a windows Phone app that can read Album arts dynamically from Music files through MediaPlayer APIs. I wish to get album arts and resize for view's background. Since the resize would lose details and make image ugly so I would like to blur it or some kind of effect. Is there any API that I can blur the image? (either from C# or XAML)? Thanks a lot! 回答1: I would start by using WriteableBitmap instead, to get a WriteableBitmap from a BitmapImage you can do the following:

Memory consumption of BitmapImage/Image control in Windows Phone 8

左心房为你撑大大i 提交于 2019-11-27 15:09:38
I am testing a WP8 app and it's image viewer to show many images, I found app's memory consumption is raising and want to find out how to solve it. I've read some articles from web, however the solutions provided by those articles are not working on my app, please read the history below. First, I found the article " Image Tips for Windows Phone 7 " and download its sample to do clean image cache testing, it's working with 1 image . And then for testing purposes, I make this app compiled with 15 offline images inside the app, and set as "Content", please download test app from here . My testing

WPF BitmapImage Serialization/Deserialization

こ雲淡風輕ζ 提交于 2019-11-27 14:53:55
I've been trying to Serialize and Deserialize BitmapImages. I've been using methods which supposedly works which I found in this thread: error in my byte[] to WPF BitmapImage conversion? Just to iterate what is going on, here is part of my Serialization code: using (MemoryStream ms = new MemoryStream()) { // This is a BitmapImage fetched from a dictionary. BitmapImage image = kvp.Value; PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(ms); byte[] buffer = ms.GetBuffer(); // Here I'm adding the byte[] array to SerializationInfo info

How to put image in a picture box from a byte[] in C#

蹲街弑〆低调 提交于 2019-11-27 13:51:08
问题 I've a byte array which contains an image binary data in bitmap format. How do I display it using the PictureBox control in C#? I went thru a couple of posts listed below but not sure if I need to convert the byte array into something else before sending it to a picturebox. I'd appreciate your help. Thanks! How to put image in a picture box from Bitmap Load Picturebox Image From Memory? 回答1: This function converts byte array into Bitmap which can be use to set the Image Property of the

BitmapSource to BitmapImage

别来无恙 提交于 2019-11-27 13:44:50
问题 I need to parse the content of Clipboard.GetImage() (a BitmapSource ) to a BitmapImage . Does anyone knows how can this be done? 回答1: I've found a clean solution that works: BitmapSource bitmapSource = Clipboard.GetImage(); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); MemoryStream memoryStream = new MemoryStream(); BitmapImage bImg = new BitmapImage(); encoder.Frames.Add(BitmapFrame.Create(bitmapSource)); encoder.Save(memoryStream); memoryStream.Position = 0; bImg.BeginInit(); bImg

read bitmap file into structure

谁说我不能喝 提交于 2019-11-27 09:53:15
问题 I would like to read a bitmap file into a struct and manuplate it like make a mirror effect etc. but I cannot understand which kind of struct should i be creating in order to read into it. Thank you for your help 回答1: »This is how you maually load a bmp file The bitmap file format: Bitmap file header Bitmap info header palette data Bitmap Dada so on with the code part, this is our struct we need to create to hold the bitmap file header #pragma pack(push, 1) typedef struct tagBITMAPFILEHEADER