Solved

How to get hDIB from .NET/C# Bitmap control

Posted on 2010-11-14
2
1,095 Views
Last Modified: 2012-05-10
I am using a third-party image analysis toolkit that wants me to pass in a Windows hDIB. I can't determine how to get a DIB (even a copy) from the standard .net Bitmap control.

The third-party toolkit sees and "hDIB" as an Int.
0
Comment
Question by:LarryBoyColorado
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34143131
That's because it wants a Handle to a bitmap. Try something like:

Bitmap bmp = (Bitmap)Bitmap.FromFile("Somefile.bmp");
bmp.GetHbitmap();

Open in new window

0
 

Author Closing Comment

by:LarryBoyColorado
ID: 34176655
Found out you need to free the object as well (example from MSDN)...

using System.Runtime.InteropServices;
...
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
...
Bitmap bm = new Bitmap("Picture.jpg");
IntPtr hBitmap = bm.GetHbitmap();
// Do something with hBitmap.
DeleteObject(hBitmap);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question