.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How convert bitmap to Image.source ?

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :WPF
I hold some bitmap object in the memory  ( simple System.Drawing.Bitmap ). I want to make some wpf image control to show this bitmap. I dont want to save the bitmap to the disk and then load it as URI to the wpf image control So, How can i do this simple action ?   Thanks.

View Complete Post

More Related Resource Links

Convert Bitmap to Image with transparency


I like to export the Bitmap directly to a Image without saving it.
How can i do that, if i save the image i get a correct png image.
But if i convert it on the way below, i get a black color on the transparancy part.
How can i solve this?

                                    Bitmap bm = new Bitmap(thumbnailImage);                                    
                                    //bm.Save(@"C:\temp\bw.png", System.Drawing.Imaging.ImageFormat.Png);

                                    thumbnailImage = (System.Drawing.Image)bm;

How to Convert HTML to Image


 HI all,

I was struggling for the process/code to convert html to image. Please suggest any tutorials for this. And also any code help greatly appreciated.


thanks and regards,



Bitmap to Image Control - ImageUrl


 This is my first attempt at using the drawing features of asp.net.  I just want to start simple, and create a single color bar based on a value for a single graph.  I wrote this so far, but I can't figure out how to take the bitmap I just created, and apply it to the Image Control. Do I have to save the file first, and then reload it.

Plus, my box keeps coming out pure black, I trying to fill the box with a color. 

This is part of a web custom control, in which I dynamically created an Image Control. I want to apply the bitmap I made to the image control. 


Dim imgGoogle As Image
imgGoogle = New Image
imgGoogle.ImageAlign = ImageAlign.AbsMiddle
imgGoogle.ImageUrl = cs.GetWebResourceUrl(rsType, "ice5software.BotCatcher.Google.gif")
Private Sub DrawBarGraph_Google(ByVal BarValue As Integer)

	Dim objBitmap As System.Drawing.Bitmap
	Dim objGraphics As S

Displaying a System.Drawing.Bitmap in a WPF Image control

How would I convert a System.Drawing.Btimap into a comparable WPF image control so I can display in on my WPF window? Thanks

Failed to set image source with string resource

User can set image source property like this: <Image Source="pack://application:,,,/MyResource;component/Images/1.ico" /> I think the source string is a little bit longer, so I want to make it as string resource: <sys:String x:Key="StringSourceKey">pack://application:,,,/MyResource;component/Images/1.ico</sys:String> After define the string resource, I use it to set image source, like this: <Image Source="{StaticResource StringSourceKey}" /> But, this time, it failed. It doesn't work. I think it is a contert error. Anybody know what's wrong?  Or any method to make the resource uri path shorter? Thanks.

How to convert both text and image into image

Hi, Here is a question. how to convert both text and image together into an image. To clarify my question I can say if I have a text editor where I can add both text,image,audio or video player, how can I convert the whole texteditor.text (it gives me html code) to an image and save it in a file. I will be highly pleased with your answer. Help me please. Thank you. 

How to convert raster Image to Vector image format

I want to covert raster image to vector image format in  C#is it possible ??Thanks

linq to sql varbinary assign to image source

Hi All, can you please tell me why this doesnt work:   <Grid> <Image Source="{Binding Path=currentUser.userStatus.icon.bm}" Width="89" Height="90" Margin="309,140,270,99" Name="im" /> </Grid>   where as if I assign the image source via the code behind it does? im.Source = currentUser.userStatus.icon.bm; The currentUser.userStatus.icon.bm object is a BitmapImage type generated from a database varbinary field using linq to sql partial methods like this:   public partial class icon { public BitmapImage bm = new BitmapImage(); public System.Drawing.Icon ic; public System.Drawing.Image img; partial void OnLoaded() { byte[] data = (byte[])this.imageBinary.ToArray(); MemoryStream strm = new MemoryStream(); strm.Write(data, 0, data.Length); strm.Position = 0; img = System.Drawing.Image.FromStream(strm); System.Drawing.Bitmap b = (System.Drawing.Bitmap)img; ic = System.Drawing.Icon.FromHandle(b.GetHicon()); //string imagePath = "Icons/go-down-8.ico"; //System.Drawing.Image img = System.Drawing.Image.FromFile(imagePath); //BitmapImage bi = new BitmapImage(); bm.BeginInit(); bm.DecodePixelWidth = 128; MemoryStream ms = new MemoryStream(); if (this.ext

convert image to rtf code

how can i convert image to rtf code

Value Converter Without Binding On Image Source


I need to get the path of an image through a value converter. However I can't find any examples of using a value converter without binding.

I would be looking to do something along these lines:

<Image source="{Value=Image1, Converter={ImageConverter}}" />

The image converter will then go check an image folder and return the correct file path.

Interesting Problem WPF Visual to Image Convert.


I am converting the Canvas to Image By using

renderBitmap = new RenderTargetBitmap(desiredWidth, desiredHeight, 96d, 96d, PixelFormats.Pbgra32);// PixelFormats.Pbgra32);
                    //RenderOptions.SetEdgeMode(drawingVisual, EdgeMode.Aliased);
                    RenderOptions.SetBitmapScalingMode(drawingVisual, BitmapScalingMode.HighQuality );
                    drawingVisual.SnapsToDevicePixels = true;
                    var dv = new DrawingVisual();
                    using (DrawingContext ctx = dv.RenderOpen())

                        var vb = new VisualBrush(drawingVisual);

Set Image Source to DIB in Memory?


Hello all.

I have a piece of hardware saving image data to memory which I would like to retrieve and set as the source to an Image element.  I am able to ask the hardware for a DIB handle to the image -- the return value is documented as "a long, which should be cast to a HBITMAP".  How can I do this in WPF?

I'm currently reading up on BitmapSource.Create(), which takes an IntPtr to memory, but I'm not sure it is expecting a DIB or not.  Also, the function asks for "stride" which I am unfamiliar with computing.  This appears to be the most promising though, since I can set it straight to an Image.Source parameter.

The hardware I have also has a function to grab a LPPICTUREDISP handle, which is documented as being compatible with the "Picture Object" of Visual Basic and C++.  From my reading so far it doesn't sound like this is something that is better suited for my needs, but I'm not sure.

Thanks for any help

How to change wpf image source on runtime ?


I get new bitmap from some other component ( dont have any control on the other component ) every 5 seconds and i need to update my wpf image control with the new bitmap ( every 5 seconds ... ).


[ i cant save the bitmap to the disk and then load it as file ]

I cant find any way to update this wpf image control in run-time.

How can i do it ?


How to Convert System.Drawing.Image Variable to Byte variable



I got a variable of type System.Drawing.Image and need to convert it to a variable of type byte so I can store the image in the database. Can someone show me how to do that in VB.NET code.

Thanks alot

Can't update image.source at runtime ( ??? )

I change wpf image.source dynamically during runtime.
Its seen everything is find - the image is not empty ( i saving it to my disk )...
but on the "image.source = ... " i dont see any image on the Image controler.
Actually - i dont see any image on the image controler.

I check if the Image controler can have some hard code image ( not change on runtime ) and its look fine also. Just update the image.source is not update the right image on the runtime.

The code is simple 3 line ... function name that get argument of BitmapImage and then call => image.source = BitmapImage - that it ===> image is the x:Name of the Image object on the xaml.

Any suggestion? what to check ... ? what is wrong ?


Convert Image to PDFusing C#



I need to convert IMAGE to PDF, I have used ITextSharp, PdfSharp and PdfVision but the output PDF is not full image, either cutted or 20% of the image is converted....

Waiting for kind response...



Scaling an image source

I have an image in which I set the image.Source to a writeableBitmap - I want to know how to scale the image.Source so the whole writeableBitmap fits into the image control initially, to avoid having to scroll.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend