PDA

Click to See Complete Forum and Search --> : [Resolved][C#] Bitmap to something I can display?


Pc_Madness
Feb 4th, 2009, 01:20 AM
Hey guys, I've got a resource file which I'm storing Bitmaps in (they're Image data type in .Net, but in the resource file they're System.Drawing.Bitmap).

I've read it out and converted it to a Bitmap, but now I need to get it to a format that I can display in WPF Image Control (takes an ImageSource I do believe). Any suggestions? :\ Google has epically failed me. :(

I dunno if theres a way to change how images get stored into a Resource file, maybe that could help solve the problem. :)

mendhak
Feb 4th, 2009, 02:45 AM
Can't you just set the source as the path to the image in the RESX file?

<Image Source="/Assemblyname;resourcefilename/abc.jpg" />

Else you'll have to set the Image1.Source property in code by converting the Bitmap to a BitmapSource. You could look at the BitmapSource.Create method, though there may be other ways.

Pc_Madness
Feb 4th, 2009, 03:21 AM
Can't you just set the source as the path to the image in the RESX file?

<Image Source="/Assemblyname;resourcefilename/abc.jpg" />

Else you'll have to set the Image1.Source property in code by converting the Bitmap to a BitmapSource. You could look at the BitmapSource.Create method, though there may be other ways.

Neg, the resource files are external, I'm using them as thumbs.db alternatives. :p

But your suggestion helped me find the code I need. :D PngBitmapDecoder. :) I thought I tried that earlier, but apparently not. :)

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/16bce8a4-1ee7-4be9-bd7f-0cc2b0f80cf0/