Solved

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

Posted on 2010-11-14
2
1,077 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now