07-18-2008 07:34 AM
07-18-2008 09:10 AM
07-18-2008 09:26 AM
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
(m.Msg = SpecificU32Message) ThenIf
...
PictureBox.Image = Image.FromHbitmap(m.LParam)
End IF
.WndProc(m) End SubMyBase
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 )
)
07-18-2008 10:40 AM
07-18-2008 10:52 AM - edited 07-18-2008 10:53 AM
07-21-2008 03:40 AM
03-05-2010 06:48 AM
GetDIBits_Dll.vi (114 kb) |
03-05-2010 03:50 PM
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!
03-07-2010 10:14 AM
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!
03-08-2010 12:45 AM
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.