LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

GetDC and BitBlt in Labview C DLL

Hey,
Thanks for the VI it explain a lot.
but i still get error (cannot get bits)..
 
0 Kudos
Message 21 of 35
(2,447 Views)
How do you get the bitmap handle?

Regards,

Wiebe.


0 Kudos
Message 22 of 35
(2,440 Views)
There is some dll that start an stream from camera and send message when frame ready.
i have a VB code example that work with the dll:
 
 

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If

(m.Msg = SpecificU32Message) Then

...

PictureBox.Image = Image.FromHbitmap(m.LParam)

End IF

MyBase

.WndProc(m)

End Sub

The L.Param (from message parameter) is the HBITMAP handle.

(

BTW, I already tried to copy this .NET function to Labview but i failed (.Net unexplained error, this is how i did it: http://forums.ni.com/attachments/ni/200/18894/1/SNAG-0000.jpg )

)

0 Kudos
Message 23 of 35
(2,439 Views)
Something like this?

http://forums.msdn.microsoft.com/fr-FR/netfxbcl/thread/2299d615-8e4e-45af-8023-e4a212ea55c4/

Btw. I'm also not able to convert a hbitmap to a .net bitmap... However,
even if you succeed in getting a .net image (for instance using fromfile),
there doesn't seem to be an easy way to get the data of the image from it.

There are other ways to get an image from a webcam. Is that your main goal?

Regards,

Wiebe.


0 Kudos
Message 24 of 35
(2,429 Views)
Its not webcam...it special purpose camera DLL that is work in VB...
Are you going to paste an GIBITS example like you said? 😕


Message Edited by HaD on 07-18-2008 10:53 AM
0 Kudos
Message 25 of 35
(2,420 Views)
I thought the GetDIBits_dll.vi would suffice as example.

If you want, I can post a complete example, but it won't be much more then a
LoadImage, GetDIBits, ReleaseObject...

The only thing that is wired to GetDIBits is the HBITMAP and the error.

Regards,

Wiebe.


0 Kudos
Message 26 of 35
(2,400 Views)
I was wondering how to prevent LabVIEW from crashing after receving bits from .dll?
-Artur 
//Here it is as a one-liner.
//Regards,
//Wiebe.

 

AttachmentGetDIBits_Dll.vi (114 kb)

0 Kudos
Message 27 of 35
(2,141 Views)

GriffinRU wrote:
I was wondering how to prevent LabVIEW from crashing after receving bits from .dll?

  


This VI won't work because of the embedded ColorTable array in the Bitmapheader cluster. The bitmaheader structure in Windows has those color elements inlined but a LabVIEW array in a cluster is something VERY different.

 

And there is no trivial solution to this since the array is bigger than 256 elements. Sorry!

Rolf Kalbermatter
My Blog
0 Kudos
Message 28 of 35
(2,086 Views)

I am sorry I haven't attached my vi earlier, but I think LabVIEW crashes because it cannot obtain data from .net object... it can get properties but not data...

- I am guessing here

 

So, I tried to obtain bitmap only with API calls and was succefull in getting bitmap, following get DC, drawIcon, get individual pixels and display...

 

If that works then GetDIbits should works as well, right?

 

Well, here is my challenge, getting HBITMAP from HICON should be straight forward (GetIconInfo) and you good to go, pass it to GetDIbits with nulls to get bitmap parameters and of you go drawing...

Example attached, I would like to know why GetDIbits returns error (0) on Hbitmap while all MSDN and web examples tell it should return with bitmap parameters?

 

-Artur

-----

P.S.

Are you referring to "CIEXYZTRIPLE" structure? 

 

//This VI won't work because of the embedded ColorTable array in the Bitmapheader cluster.

//The bitmaheader structure in Windows has those color elements inlined but a LabVIEW array in a cluster is something VERY different.

 

//And there is no trivial solution to this since the array is bigger than 256 elements. Sorry!

 

 

Rolf Kalbermatter
0 Kudos
Message 29 of 35
(2,063 Views)

GriffinRU wrote: 

Are you referring to "CIEXYZTRIPLE" structure? 

 

Rolf Kalbermatter

Last time I checked this was called RGBQUAD (or RGBTRIPLE for OS/2 style bitmaps). Maybe that BITMAPHEADERV4 defines them as CIEXYZTRIPLE but that would sound inconsistent with earlier Windows versions.

 

Most likely GetDIBits does some pointer checks and sees that the pointer is not large enough to also contain the color table (it only contains the 4 byte pointer to the LabVIEW array at the end instead of a reasonably sized number of bytes to store the entire color table) and therefore fails.

 

The most easy solution is to startup your C compiler and write some wrapper DLL that does wrap GetDIBits into a function that takes LabVIEW friendly parameters and passes them in an API friendly manner to the Windows API. After all, if you go about optimizing Windows screen drawing in such a dirty way you really should know about C programming too, and making such a DLL should be a piece of cake then.

Rolf Kalbermatter
My Blog
0 Kudos
Message 30 of 35
(2,045 Views)