Click here to Skip to main content
15,879,535 members
Home / Discussions / C#
   

C#

 
GeneralMessage Closed Pin
30-Mar-16 8:52
mveGerry Schmitz30-Mar-16 8:52 
GeneralRe: Dynamically close DB2 CLP window using C# Pin
Richard Deeming30-Mar-16 8:54
mveRichard Deeming30-Mar-16 8:54 
AnswerRe: Dynamically close DB2 CLP window using C# Pin
Richard Deeming30-Mar-16 8:52
mveRichard Deeming30-Mar-16 8:52 
GeneralRe: Dynamically close DB2 CLP window using C# Pin
Tej_dev30-Mar-16 9:03
Tej_dev30-Mar-16 9:03 
QuestionBitmap to BitmapImage Conversion Not Working - WPF Pin
AmbiguousName30-Mar-16 4:36
AmbiguousName30-Mar-16 4:36 
AnswerRe: Bitmap to BitmapImage Conversion Not Working - WPF Pin
Rob Philpott30-Mar-16 5:46
Rob Philpott30-Mar-16 5:46 
GeneralRe: Bitmap to BitmapImage Conversion Not Working - WPF Pin
AmbiguousName30-Mar-16 6:04
AmbiguousName30-Mar-16 6:04 
AnswerRe: Bitmap to BitmapImage Conversion Not Working - WPF Pin
Matt T Heffron30-Mar-16 6:54
professionalMatt T Heffron30-Mar-16 6:54 
Here's the converter I wrote years ago. It converts a Bitmap to ImageSource (specifically a BitmapFrame):
C#
using System;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ResourcesLibrary
{
  [ValueConversion(typeof(Bitmap), typeof(ImageSource))]
  public class BitmapToImageSourceConverter : IValueConverter
  {
    [DllImport("gdi32.dll")]
    private static extern bool DeleteObject(IntPtr hObject);
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
      Bitmap bmp = value as Bitmap;
      if (bmp == null)
        return null;
      using (Stream str = new MemoryStream())
      {
        bmp.Save(str, System.Drawing.Imaging.ImageFormat.Bmp);
        str.Seek(0, SeekOrigin.Begin);
        BitmapDecoder bdc = new BmpBitmapDecoder(str, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
        return bdc.Frames[0];
      }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}

"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton

AnswerRe: Bitmap to BitmapImage Conversion Not Working - WPF Pin
Gerry Schmitz30-Mar-16 7:06
mveGerry Schmitz30-Mar-16 7:06 
AnswerRe: Bitmap to BitmapImage Conversion Not Working - WPF Pin
V.31-Mar-16 3:42
professionalV.31-Mar-16 3:42 
Questionworking with pixels Pin
Hira Khalid29-Mar-16 3:16
Hira Khalid29-Mar-16 3:16 
AnswerRe: working with pixels Pin
OriginalGriff29-Mar-16 3:33
mveOriginalGriff29-Mar-16 3:33 
AnswerRe: working with pixels Pin
Dave Kreskowiak29-Mar-16 3:45
mveDave Kreskowiak29-Mar-16 3:45 
AnswerRe: working with pixels Pin
Eddy Vluggen29-Mar-16 4:06
professionalEddy Vluggen29-Mar-16 4:06 
QuestionRe: working with pixels Pin
Richard MacCutchan29-Mar-16 4:25
mveRichard MacCutchan29-Mar-16 4:25 
GeneralRe: working with pixels Pin
harold aptroot29-Mar-16 9:34
harold aptroot29-Mar-16 9:34 
QuestionAccessing unmanaged class from C# Pin
Leif Simon Goodwin29-Mar-16 1:22
Leif Simon Goodwin29-Mar-16 1:22 
QuestionRe: Accessing unmanaged class from C# Pin
Richard MacCutchan29-Mar-16 1:42
mveRichard MacCutchan29-Mar-16 1:42 
AnswerRe: Accessing unmanaged class from C# Pin
Leif Simon Goodwin29-Mar-16 4:17
Leif Simon Goodwin29-Mar-16 4:17 
GeneralRe: Accessing unmanaged class from C# Pin
Richard MacCutchan29-Mar-16 4:32
mveRichard MacCutchan29-Mar-16 4:32 
GeneralRe: Accessing unmanaged class from C# Pin
Leif Simon Goodwin29-Mar-16 5:10
Leif Simon Goodwin29-Mar-16 5:10 
AnswerRe: Accessing unmanaged class from C# Pin
Garth J Lancaster29-Mar-16 1:47
professionalGarth J Lancaster29-Mar-16 1:47 
GeneralRe: Accessing unmanaged class from C# Pin
Leif Simon Goodwin29-Mar-16 1:49
Leif Simon Goodwin29-Mar-16 1:49 
AnswerReply # 2 Pin
Garth J Lancaster29-Mar-16 2:03
professionalGarth J Lancaster29-Mar-16 2:03 
AnswerRe: Accessing unmanaged class from C# Pin
Bernhard Hiller31-Mar-16 0:39
Bernhard Hiller31-Mar-16 0:39 

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.