bitmapimage

Showing Bitmap Images in WPF via C#

Hi guys, What I am trying to do is so simple but I am having a hard time making it work. I saw some posts along the same lines but I still have questions. I have a MenuItem object called mnuA. All I want is set the icon property programatically in C#. I have tried the following a) mnuA.Icon = new BitmapImage{UriSource = new Uri(@"c:\ic...

Loading BitmapImage in code

From my assembly (A) I want to call a method in another assembly (B) which passes an image. This image is then shown in a WPF Window - the window is part of B's project. I can't seem to pass an ImageSource with a pack:// uri as this gets evaluated in the context of B, so I guess I need to cache the image using CachedBitmap (?) when stil...

How can I read a pixel's color from a BitmapImage in Silverlight?

I have a BitmapImage instance in Silverlight, and I am trying to find a way to read the color information of each pixel in the image. How can I do this? I see that there is a CopyPixels() method on this class that writes pixel information into the array that you pass it, but I don't know how to read color information out of that array. ...

How can I get a BitmapImage from a Resource?

My assembly includes an image with BuildAction==Resource. I want to obtain a BitmapImage from this embedded resource. I can load a BitmapImage from file like this: var bitmap = new BitmapImage(new Uri(path)); But how to I create a Uri that will refer to an embedded resource image? When I try and create a 'pack URI' (for example pac...

How to set BitmapImage.CreateOptions in WPF using C#

BitmapImage bi = new BitmapImage(new Uri(@"D:\DSC_0865.png")); bi.CreateOptions = BitmapCreateOptions.PreservePixelFormat; img1.Source = bi; In the above code, if I try to set bi.CreateOptions, it is not taking it. It is showing as none. Please can you suggest a solution? ...

Creating a CroppedBitmap at runtime - won't load from resource

I'm trying to write code that will load an image from a resource, and then crop it. This code works when I do all, or part, of it in XAML. I want to switch from all-XAML to all-code, so I can reuse this more than one place, with different Uris. But when I try to do the same thing in code, I get a DirectoryNotFoundException, because sudd...

I'm Trying to Create an Image Object with a Byte Array as Its Source. What Am I Doing Wrong?

I'm trying to create an image object with a byte array as its source. What am I doing wrong? An exception is thrown when I try to initialize the image object with an array of bytes as source data. The exception is shown in my code, below. public class MyClass { publuc System.Windows.Media.Imaging.BitmapImage InstanceImage { get...

Convert Bitmap to Image

So after I pull an image out of DLL and put it into an image control it is a BitmapImage. To package it back into the dll it has to be converted back to an image. How can I convert it back to image and how can i repackage it back into the dll? This is all in wpf written in c#. private void compileDLL_Click(object sender, RoutedEventArgs...

WPF BitmapImage Get image pixelwidth

Hi In the following code i want to get the pixelwidth but when i apply DecodePixelWidth because of memory performance i loose the original pixelwidth value. Thanks in advanced. BitmapImage myBitmapImage = new BitmapImage(); myBitmapImage.BeginInit(); myBitmapImage.UriSource = new Uri(uri, UriKind.Absolute); myBitmapImage.DecodePixelWid...

How to save BitmapImage / WriteableBitmap using SaveFileDialog in Silverlight 3.0?

How can a WriteableBitmap from Silverlight be Saved onto the File System, I am unsure what to do with the FileStream to make this work, it can be in Bitmap, PNG, Jpeg format etc, as long as a commercial library is not required. Is it possible to do this? Here is my call to SaveDialog, below: Dim SaveDialog As New SaveFileDialog ...

Getting the size of a downloaded image in Silverlight

If I've got a Silverlight Image control that downloads from a full URL, how can I get the size (in bytes) of the downloaded image without making another web call? I can't find anything on the Image or the BitmapImage source behind it that would tell me. And even the DownloadProgress event on the BitmapImage only gives a percentage. ...

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

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 represen...

how to convert a paint image to bitmap

hi, i am able to save the source image but not able save the image with colorfilter paint.setColorFilter(new ColorMatrixColorFilter(cm)); if this image is converted into bitmap it can be saved easily. but dunno how to do this. Is there anyone to give solution thanks in advance ...

Layer two BitmapImage's in WPF

Hello, I have two instances of BitmapImage. I would like to layer then on eachother the create a new BitmapImage. How would I do this? (Using C#) Thanks! ...

Why do I get an AG_E_NETWORK_ERROR in Silverlight on my local machine

I am hosting my Silverlight app in SharePoint 2010, which is running on my machine. Suddenly my images stopped showing up, and after a lot of fiddling, I tracked the issue down to an AG_E_NETWORK_ERROR. Searching all over the internet says I can't do cross-whatever in Silverlight, but that is not my issue. My site is on http://my-site...

Why is the BitmapImage a sealed class?

I was about to inherit from the BitmapImage class when I noticed it was sealed, I've had a quick look around but I can't find a reason it is sealed. Any body know why this is? Thanks ...

Wpf: Image Control does not support .TGA files

In my application I am using Images, these images can be .tga(Targa Graphic) file as well, when I am creating instance of BitmapImage using .tga file, it throws exception saying "No imaging component suitable to complete this operation was found.". Is there any other way to work with .tga file in wpf? How can I use these(.tga) files jus...

InteropBitmap to BitmapImage

Hi, I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource, but it returns an InteropBitmapImage, now the problem is how to convert it to a BitmapImage. A direct cast does not seem to work. Does anybody know how to do i...

Flash 4 BitmapImage and events

Hi, I am trying to use BitmapImage spark class instead of mx image class. Image loads the same, fine <s:BitmapImage id="img" source="sample.jpg"> </s:BitmapImage> But I have an issue with adding mouse events on it, eg: img.addEventListener(MouseEvent.CLICK,clicked); do not trigger any mouse events when clicking on the image Hel...

EOF error encountered while converting bytearray to bitmapdata

I am using var bitmapdata:BitmapData=new BitmapData(); var pixels:Bytearray=new Bytearray(); pixels = rleDecodePixles(); bitmapdata.setPixels(bitmapdata.rect, pixels); In the 4th line in the code above i am getting "Error: Error #2030: End of file was encountered." I checked the length of the pixels object which is 4 times the width...