Click here to Skip to main content
15,892,674 members
Home / Discussions / WPF
   

WPF

 
QuestionConverting an Bitmap to ImageSource problem Pin
Mike Hankey4-Sep-11 10:31
mveMike Hankey4-Sep-11 10:31 
AnswerRe: Converting an Bitmap to ImageSource problem Pin
RichardGrimmer5-Sep-11 5:25
RichardGrimmer5-Sep-11 5:25 
GeneralRe: Converting an Bitmap to ImageSource problem Pin
Pete O'Hanlon5-Sep-11 5:30
mvePete O'Hanlon5-Sep-11 5:30 
GeneralRe: Converting an Bitmap to ImageSource problem Pin
RichardGrimmer5-Sep-11 5:33
RichardGrimmer5-Sep-11 5:33 
GeneralRe: Converting an Bitmap to ImageSource problem Pin
Pete O'Hanlon5-Sep-11 5:37
mvePete O'Hanlon5-Sep-11 5:37 
GeneralRe: Converting an Bitmap to ImageSource problem Pin
Mike Hankey5-Sep-11 9:57
mveMike Hankey5-Sep-11 9:57 
AnswerRe: Converting an Bitmap to ImageSource problem Pin
Pete O'Hanlon5-Sep-11 5:37
mvePete O'Hanlon5-Sep-11 5:37 
GeneralRe: Converting an Bitmap to ImageSource problem [modified] Pin
Mike Hankey5-Sep-11 10:05
mveMike Hankey5-Sep-11 10:05 
I saw that solution in a couple of places but was hoping not to get my hands to dirty.

Also I'm afraid of performance issues as I'm trying to put an image in a DataGridView column where the application
is an VS2010 extension here[^] that I'm trying to add functionality. It's not a gotta have but thought it might enhance the
touchy-feely.

Thanks I'll give a shot and see how it works.

[update]
Worked like a charm but there was a gotcha;

1) Had to put it inline because I'm using in a ValueConverter it complained about it not being static then
when I made static it complained something about class needed to be non-generic???


var bitmap = new System.Windows.Media.Imaging.BitmapImage();

MemoryStream stream = new MemoryStream();
img.Save(stream, ImageFormat.Bmp);
stream.Seek(0, SeekOrigin.Begin);
 bitmap.StreamSource = stream;

Bitmap bitmap1 = new Bitmap(stream);
bitmap1.MakeTransparent();
return Imaging.CreateBitmapSourceFromHBitmap(
      bitmap1.GetHbitmap(),
      IntPtr.Zero,
      Int32Rect.Empty,
      BitmapSizeOptions.FromEmptyOptions()
);


Thanks for the tip.
Sects Therapy
modified on Monday, September 5, 2011 4:27 PM

GeneralRe: Converting an Bitmap to ImageSource problem Pin
Pete O'Hanlon5-Sep-11 20:16
mvePete O'Hanlon5-Sep-11 20:16 
QuestionWPF Pin
mumshad3-Sep-11 20:53
mumshad3-Sep-11 20:53 
AnswerRe: WPF Pin
Abhinav S3-Sep-11 21:02
Abhinav S3-Sep-11 21:02 
QuestionVisual Web Developer express 2010 Pin
arkiboys1-Sep-11 20:51
arkiboys1-Sep-11 20:51 
AnswerRe: Visual Web Developer express 2010 Pin
Abhinav S1-Sep-11 21:00
Abhinav S1-Sep-11 21:00 
GeneralRe: Visual Web Developer express 2010 Pin
arkiboys1-Sep-11 22:07
arkiboys1-Sep-11 22:07 
GeneralRe: Visual Web Developer express 2010 Pin
Abhinav S1-Sep-11 22:29
Abhinav S1-Sep-11 22:29 
AnswerRe: Visual Web Developer express 2010 Pin
Columbus-MCSD2-Sep-11 4:37
Columbus-MCSD2-Sep-11 4:37 
QuestionWpf Pin
radhika 51-Sep-11 18:57
radhika 51-Sep-11 18:57 
AnswerRe: Wpf Pin
Abhinav S1-Sep-11 21:17
Abhinav S1-Sep-11 21:17 
GeneralRe: Wpf Pin
radhika 51-Sep-11 21:23
radhika 51-Sep-11 21:23 
GeneralRe: Wpf Pin
Saksida Bojan9-Sep-11 23:45
Saksida Bojan9-Sep-11 23:45 
QuestionSwitch between diffrent languages with indexers Pin
Mc_Topaz31-Aug-11 21:37
Mc_Topaz31-Aug-11 21:37 
AnswerRe: Switch between diffrent languages with indexers Pin
Wayne Gaylard31-Aug-11 23:13
professionalWayne Gaylard31-Aug-11 23:13 
GeneralRe: Switch between diffrent languages with indexers Pin
Mc_Topaz31-Aug-11 23:36
Mc_Topaz31-Aug-11 23:36 
GeneralRe: Switch between diffrent languages with indexers Pin
Wayne Gaylard31-Aug-11 23:40
professionalWayne Gaylard31-Aug-11 23:40 
GeneralRe: Switch between diffrent languages with indexers Pin
Mc_Topaz1-Sep-11 1:57
Mc_Topaz1-Sep-11 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.