LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Need sample code using windows BitBlt() function to display image in CVI

Hello all,

 

I need a sample code which uses windows BitBlt() function to display image in CVI

Thank you.

 

Bob.

0 Kudos
Message 1 of 11
(4,227 Views)

Hi Robert,

 

The best way to do this in CVI is to use GetCtrlBitmap() to take the bitmap from the source and then use CanvasDrawBitmap() to then draw the bitmap in the destination canvas. If you want to use the Bitblt function, you may be able to use the GetWindowDC() function in order to retrieve the handle for a panel which you then may be able to use with the Bitblt() function. This may work, however I do not believe individual CVI controls have device context handles so you will not be able to draw to them directly. See these forum posts for more information:

 

http://forums.ni.com/t5/LabWindows-CVI/How-do-I-include-Win32-API-function-BitBlt-in-CVI7-0/td-p/261...
http://forums.ni.com/t5/LabWindows-CVI/Getting-the-hDC-of-a-Canvas-Control/td-p/1079481

Justin D
Applications Engineer
National Instruments
http://www.ni.com/support/
0 Kudos
Message 2 of 11
(4,216 Views)

Hello JD_war_eagle,

 

Thanks for the reply.

The first post you refered me to was initiated by me. I tried the response that was suggested then and I did not succeed. That is why I re-phrased the question this time asking for a sample code.

I hope someone can help with a sample code that works.

Thank you.

 

Bob.

0 Kudos
Message 3 of 11
(4,212 Views)

Hello Bob -

 

I recently posted some sample code that uses the BitBlt function.  You can find it here.  Note this is not production quality code - make sure you closely examine the MSDN pages for these functions in order to harden your code.

 

NickB

National Instruments

0 Kudos
Message 4 of 11
(4,201 Views)

Hello NickB,

 

Thanks for the response and the code you refered me to.

When I run the code, a panel with "Take Screenshot" button appeared. However, When I pressed on the "Take Screenshot" button nothing happened. I was expecting an image to appear on the panel. Would you please verify the code you posted for me?

Thank you.

 

Bob

0 Kudos
Message 5 of 11
(4,181 Views)

Hello Bob -

 

Sorry, I should have explained the code a little bit more.  The intention of the code was to take a screenshot of the panel, and then place the screenshot on the clipboard - essentially replicating Alt+PrtScn.  After pressing the button, you should be able to paste the image of the panel into Paint, or something similar.

 

- Nick

0 Kudos
Message 6 of 11
(4,175 Views)

Hello Nick,

 

I just verified that the code stores an image of the panel on the clip board like you said. However, I would like to use BitBlt() (not CVI function) to display the image on the panel or, on a canvas on the panel. Would you please help?

Thank you.

 

Bob

0 Kudos
Message 7 of 11
(4,169 Views)

Hello Bob -

 

It's not really clear to me why you would need to do this.  Can you explain what you're trying to achieve?  The problem is that CVI is not going to know anything about what you're drawing on a CVI panel, and will likely erase anything you draw when it paints the panel.  If you can describe what you're trying to do, maybe I can help find a more natural CVI answer.

 

- Nick

0 Kudos
Message 8 of 11
(4,155 Views)

Hello Nick,

 

I want to use BitBlt() function to create transitions to display pictures on a canvas. I have searched CVI functions and non seems to have similar capabilities.

 

Bob 

0 Kudos
Message 9 of 11
(4,144 Views)

Hello Bob -

 

I'm curious why you'd like to use BitBlt.  What functionality does it offer that you've not seen in the CVI canvas control?

 

It's hard to say without knowing what transitions you're looking for, but the canvas is very capable of animating/transitioning.  The place it can fall a little short is if you require access to the alpha channel for transparency.

 

I put together a short demo for you - maybe it will address some of what you're looking for.  The important functions are CanvasStartBatchDraw, CanvasEndBatchDraw, and CanvasDrawBitmap.  The animation/transition is driven by a simple UI timer.

 

Let me know if you have any questions -

 

NickB

National Instruments

0 Kudos
Message 10 of 11
(4,125 Views)