Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

bitmap to imagesource c#

    //If you get 'dllimport unknown'-, then add 'using System.Runtime.InteropServices;'
    [DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool DeleteObject([In] IntPtr hObject);

    public ImageSource ImageSourceFromBitmap(Bitmap bmp)
    {
        var handle = bmp.GetHbitmap();
        try
        {
            return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
        }
        finally { DeleteObject(handle); }               
    }
Comment

c# convert bitmap to image

Bitmap inherits from System.Drawing.Image
Comment

PREVIOUS NEXT
Code Example
Csharp :: redirect to another controller page in asp.net core 
Csharp :: c# winforms textbox select text 
Csharp :: C# get md5 of file 
Csharp :: System command c# 
Csharp :: add mime type for woff in web.config 
Csharp :: how to remove space between string in c# 
Csharp :: byte to binary c# 
Csharp :: get char lowercase in c# 
Csharp :: 3d perlin noise unity 
Csharp :: c# convert stream to memorystream 
Csharp :: godot c# export variables 
Csharp :: c# optional parameters 
Csharp :: c# how to call a method from another class 
Csharp :: c# multiline comment 
Csharp :: How to take input on float in c# 
Csharp :: color unity 
Csharp :: c# bitmap to array byte 
Csharp :: c# last char in string 
Csharp :: weapon switching unity 
Csharp :: join two array c# 
Csharp :: recursive reverse linked list 
Csharp :: Unity Interstitial ad C# 
Csharp :: all possible substrings of a string 
Csharp :: unity no serializefield 
Csharp :: c# readline char 
Csharp :: how to check type c# 
Csharp :: c# return 2 values 
Csharp :: Long, Max and Min value 
Csharp :: c# today without time 
Csharp :: is number c# 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =