LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing Bitmap

Hi All,

I'm developing in a project an image acquisition integrating a DLL functions supplied by hardware manufacturer. I'm not an expert and without help I'm not  able to go ahead.
Once I get the pointer to bitmap (pBits) and pointer to Bitmapinfo (pBitmapInfo) I've no idea how to draw onto the screen the image. In the V.C. example supplied by the manufacturer is used the SetDIBitsToDevice method, I really don't know what is the easiest way to do - integrate this in LabVIEW.

Following the V.C. example code:

// pointer to bitmap
 void*  pBits;
 BITMAPINFO* pBitmapInfo;
 
// get bitmap from MCDAQ
 MCDAQ_ACF_IMAGE_GET_BITMAP(hACF, &m_bmp_isize_x, &m_bmp_isize_y, &pBits, &pBitmapInfo))
 
// now pBits (4 Bytes) and pBitmapInfo (4 Bytes) contain the pointers to the bitmap and you can draw it! 
 
// copy bitmap 1:1 to screen
::SetDIBitsToDevice(pDC->m_hDC, ofs_x, ofs_y, m_bmp_isize_x, m_bmp_isize_y,
           0, 0, 0, m_bmp_isize_y,
           pBits, pBitmapInfo, 0); 
 
// or stretch bitmap to screen
::StretchDIBits(pDC->m_hDC, m_bmp_ofs_x, m_bmp_ofs_y, m_bmp_size_x, m_bmp_size_y,
         0, 0, m_bmp_isize_x, m_bmp_isize_y,
         pBits, pBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
 }

Many thanks in advance

M.S.

0 Kudos
Message 1 of 10
(4,873 Views)
It seem you are not familar with Window programming.
 
Does manufacture provide a handle to the bitmap?  They usually do.
It would be a lot easier if your got the handle.
 
 
George Zou
George Zou
0 Kudos
Message 2 of 10
(4,852 Views)
Hi sciawatt,
to me this project seems to be not easy. First you have to learn how to use the "Call Library Function Node", there is a very good example attached to this page in the LabView Help. It shows you the Data- Types you have to pass to the library node, i.e. a Handle to something is a U32. Another big point is to set the option "StdCall (WinAPI)" in the dialog where you configure the library node.
The structs (like BITMAPINFO) are clusters, there you have to set the type to "Adapt to type".
But the better way seems to me to invest into George Zou's Toolkit (great work, btw.) or to program all the drawing and Bitmap-handling stuff in C++ or Delphi and building an easy-to-use dll which then is called from LabView.
Good Luck,
Dave
Greets, Dave
0 Kudos
Message 3 of 10
(4,837 Views)
Hi Dave & Gorge

Thanks for the suggestions.
Up to now, also in this project, I'm using the "Call Library Function Node" to get some data from the device involved. No problem when I simply call function to obtain e.g. machine status, serial number,... and so on (in general number or array of charachters).
In the case of the bitmap drawing, from what I'm understanding, I've to do some experiment with CIN. What is completely obscure to me is how, starting from a call of V.C. function like "SetDIBitsToDevice" (or something like that) I'll end up with the image in the LabVIEW front panel !! (George you are
right, I'm not so familiar with Window programming !!!).

Shall the George's toolkit help me? (I try to open some examples without success as they are 7.1 not recompilable and I'm using 8.0 version).

Thanks again

M.S.

0 Kudos
Message 4 of 10
(4,820 Views)
There are a few way to display an image:
1.  Buy IMAQ from NI
2.  Use picture control
3.  Create your own window
4.  Draw directly on your front panel
 
SetDIBitsToDevice works only for 3, 4.  The first input variable for SetDIBitsToDevice is hDC.  You must get a valid hDC first.
 
>Shall the George's toolkit help me?
Only if you got the handle to the bitmap (hBitmap, hDib), and use picture control.
Need some work to create the handle with the pointer to the bits, and the BitmapInfoHeader.
 
>I try to open some examples without success as they are 7.1 not recompilable and I'm using 8.0
example not available in 8.0
 
 
George Zou
 
 
George Zou
Message 5 of 10
(4,798 Views)

Try posting on the Measurement Studio for VC++  forum.  I am not familiar with this stange text based language stuff Smiley Wink

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 6 of 10
(4,790 Views)
What if He doesn't have Measurement Studio for VC++ ?
George Zou
0 Kudos
Message 7 of 10
(4,783 Views)

His code said VC so assumed he has it.  At least they deal with the text world.  I have been using LV exclusively and won't go back to text.

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 8 of 10
(4,781 Views)
Has VC doesn't mean having Measurement Studio.  Those good at text programming do not necessorily good at intergrating C to LabVIEW.
There are a many things can't be done in LV.
 
George Zou
http://gtoolbox.yeah.net
George Zou
0 Kudos
Message 9 of 10
(4,777 Views)
Thank you Zou for the interesting hints.

Next days (....weeks??!....) I'll let you know the results of my attempts to solve the problem.

M.S.

0 Kudos
Message 10 of 10
(4,756 Views)