Solved

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

Posted on 2010-11-14
2
1,114 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
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…

626 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