Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-14
2
Medium Priority
?
1,133 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many of the companies I’ve worked with have embraced cloud solutions due to their desire to “get out of the datacenter business.” The ability to achieve better security and availability, and the speed with which they are able to deploy, is far grea…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

916 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