Click here to Skip to main content
15,920,217 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Image loading Pin
Pete O'Hanlon28-Jul-09 1:41
mvePete O'Hanlon28-Jul-09 1:41 
Try using this method instead:
public static BitmapImage BitmapImageFromBytes(byte[] bytes) 
{ 
  BitmapImage image = null; 
  MemoryStream stream = null; 
  try { 
    stream = new MemoryStream(bytes); 
    stream.Seek(0, SeekOrigin.Begin);
    System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
    image = new BitmapImage(); 
    image.BeginInit();
    MemoryStream ms = new MemoryStream();
    img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
    ms.Seek(0, SeekOrigin.Begin);
    image.StreamSource = ms;
    //image.StreamSource = stream; 
    //image.DecodePixelWidth = desiredX; 
    //image.DecodePixelHeight = desiredY; 
    image.StreamSource.Seek(0, SeekOrigin.Begin);
    image.EndInit(); 
  } 
  catch (Exception ex) 
  { 
    if (ex != null) 
    { 
    } 
    throw; 
  } 
  finally { 
    stream.Close(); 
    stream.Dispose(); 
  } 
  return image; 
}
This requires you to import System.Drawing, but it does the job.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



GeneralRe: Image loading Pin
#realJSOP28-Jul-09 12:30
professional#realJSOP28-Jul-09 12:30 
GeneralRe: Image loading Pin
Pete O'Hanlon28-Jul-09 21:35
mvePete O'Hanlon28-Jul-09 21:35 
AnswerRe: Image loading Pin
Christian Graus27-Jul-09 23:33
protectorChristian Graus27-Jul-09 23:33 
GeneralRe: Image loading Pin
Jacquers28-Jul-09 0:20
Jacquers28-Jul-09 0:20 
GeneralRe: Image loading Pin
Christian Graus28-Jul-09 11:13
protectorChristian Graus28-Jul-09 11:13 
QuestionParametrize WPF code generator Pin
califax2k26-Jul-09 22:43
califax2k26-Jul-09 22:43 
QuestionCan't find System.ServiceModel.Syndication Pin
Nekkantidivya26-Jul-09 21:50
Nekkantidivya26-Jul-09 21:50 
AnswerRe: Can't find System.ServiceModel.Syndication Pin
Pete O'Hanlon26-Jul-09 22:38
mvePete O'Hanlon26-Jul-09 22:38 
AnswerRe: Can't find System.ServiceModel.Syndication Pin
Pete O'Hanlon27-Jul-09 1:50
mvePete O'Hanlon27-Jul-09 1:50 
Questionselecting iterms from Listbox and displaying in ListView using C#, XAML Pin
Krishna Aditya26-Jul-09 21:01
Krishna Aditya26-Jul-09 21:01 
AnswerRe: selecting iterms from Listbox and displaying in ListView using C#, XAML Pin
Christian Graus26-Jul-09 21:52
protectorChristian Graus26-Jul-09 21:52 
QuestionWPF: Window 7 CustomWindowManager for UserControl [Help] Pin
Kunal Chowdhury «IN»26-Jul-09 20:16
professionalKunal Chowdhury «IN»26-Jul-09 20:16 
AnswerRe: WPF: Window 7 CustomWindowManager for UserControl [Solved] Pin
Kunal Chowdhury «IN»26-Jul-09 21:16
professionalKunal Chowdhury «IN»26-Jul-09 21:16 
QuestionListView selecteditem Pin
Jacob Dixon26-Jul-09 15:23
Jacob Dixon26-Jul-09 15:23 
QuestionProblems Merging a MediaPlayer SL2Gallery Template into an Existing SL 2 App Pin
SBJ26-Jul-09 7:50
SBJ26-Jul-09 7:50 
AnswerRe: Problems Merging a MediaPlayer SL2Gallery Template into an Existing SL 2 App Pin
Michael Sync28-Jul-09 6:04
Michael Sync28-Jul-09 6:04 
GeneralRe: Problems Merging a MediaPlayer SL2Gallery Template into an Existing SL 2 App Pin
SBJ28-Jul-09 12:32
SBJ28-Jul-09 12:32 
GeneralRe: Problems Merging a MediaPlayer SL2Gallery Template into an Existing SL 2 App Pin
Michael Sync29-Jul-09 5:12
Michael Sync29-Jul-09 5:12 
GeneralRe: Problems Merging a MediaPlayer SL2Gallery Template into an Existing SL 2 App Pin
SBJ11-Aug-09 15:31
SBJ11-Aug-09 15:31 
QuestionHow to build a WPF report for WPF application ? Pin
error197926-Jul-09 6:19
error197926-Jul-09 6:19 
AnswerRe: How to build a WPF report for WPF application ? Pin
Sperneder Patrick26-Jul-09 7:46
professionalSperneder Patrick26-Jul-09 7:46 
AnswerRe: How to build a WPF report for WPF application ? Pin
Pete O'Hanlon26-Jul-09 10:25
mvePete O'Hanlon26-Jul-09 10:25 
QuestionBackGroundWorker In WPF Problem Pin
Member 306874125-Jul-09 14:56
Member 306874125-Jul-09 14:56 
AnswerRe: BackGroundWorker In WPF Problem Pin
Mark Salsbery27-Jul-09 5:21
Mark Salsbery27-Jul-09 5:21 

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.