LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Capture bitmap of panel with an OGL control

The GetPanelDisplayBitmap function normally works for me, but when I have a 3D OGL plot on the panel, it does not appear in the captured bitmap - the region is blank. On the other hand the OGLGetScaledCtrlBitmap function captures a bitmap of the OGL plot only.
 
Is there a way to get the full panel image all at once? (Pressing Alt-PrtScreen does capture everything to the clipboard.) Or will I need to code some clever bitmap manipulation routine to overlay the two, taking into account panel and screen scaling, etc.?
 
Thanks,
Ian
0 Kudos
Message 1 of 5
(3,852 Views)
In the absence of any other recommendations:
Can you grab the bitmap from the 3G control and display it over the top of the 3G control while you grab the image to print:
OGLGetScaledCtrlBitmap()
then use
GetCtrlBoundingRect() to get the size of the 3G control (if required)
create a canvas in the same space as the 3G control
display the bitmap on the canvas
CanvasDrawBitmap()
Then get the bitmap for the entire panel so you have the combined image
GetPanelDisplayBitmap()
then remove the canvas
 
A bit of a run around, but if you have not found another solution it may be worth a try.

Message Edited by mvr on 06-22-2006 02:27 PM

0 Kudos
Message 2 of 5
(3,836 Views)

Hello,

 

I apologize that this isn’t working out for you. I am unfamiliar with “OGL” and couldn’t find those functions in the CVI libraries I have open…  In either case, would it be possible for you to attach a small snippet of code which reproduces the problem?  I could be a problem with CVI in which case we’ll need to find a workaround for you.  What version of CVI are you using?  I want to say I’ve seen a similar issue with CVI 7.1 and the plots appeared when we resized the image received from the function call.

 

Please let me know how I can help!

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 3 of 5
(3,826 Views)

To help Ian in his problem I asked me if I can simulate the Print Screen key. Unfortunately it seems this key is not available with ordinary FakeKeystroke function, so I had to run into Windows API to find a solution.

The result of my attempts are as follows: basically it is necessary to create the correct queue of keyboard events to send to SendInput funcion (specifically Alt and PrintScreen keys).

#define  _WIN32_WINNT 0x0401
#include "windows.h"

 int  line = 0;
 char msg[512];
 DWORD written, error = 0;
 INPUT *lpI = NULL;

 // Function for copying the panel to clipboard
 //UINT SendInput (
 // UINT nInputs,     // count of input events
 // LPINPUT pInputs,  // array of input events
 // int cbSize        // size of structure
 //);
 lpI = calloc (2, sizeof (INPUT));
 lpI[0].type = INPUT_KEYBOARD;
 lpI[0].ki.wVk = VK_MENU;
 lpI[1].type = INPUT_KEYBOARD;
 lpI[1].ki.wVk = VK_SNAPSHOT;
 if (!SendInput (2, lpI, sizeof (INPUT))) {
  error = GetLastError (); line = __LINE__;
     goto Error;
 } 

 //----

Error:
 if (error) {
  //DWORD FormatMessage (
  // DWORD dwFlags,      // source and processing options
  // LPCVOID lpSource,   // message source
  // DWORD dwMessageId,  // message identifier
  // DWORD dwLanguageId, // language identifier
  // LPTSTR lpBuffer,    // message buffer
  // DWORD nSize,        // maximum size of message buffer
  // va_list *Arguments  // array of message inserts
  //);
  FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, msg, 511, NULL);

  sprintf (msg, "%s\nRow %d", msg, line);
  MessagePopup ("Error", msg);
 }

The only problem is that the INPUT structure required by SendInput function is defined in winuser.h only after an #if (_WIN32_WINNT > 0x0400) statement, that's why I added this statement at the very beginning of my code: nevertheless there is no warning on this fact in the SDK. I tried modifying the simple.prj sample in samples\userint\custstrl\cviogl adding a button with the code I exposed here and found no problem in it, but remains a *big* question mark on that #define I had to add to the project: will it affect other functions in the software in an unpredictable way? I cannot answer this question Smiley Sad maybe someone else can...



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(3,821 Views)
Thanks for the helpful responses everyone.
 
mvr: That looks like quite a doable workaround, and I suspect it may be the shortest (albeit cludgey) path to get the job done. Thanks.
 
Travis: I'm using CVI 8.0.1. The best way to see the issue is to load the same sample as Roberto used (..samples\userint\custctrl\\cviogl\simple.prj) and add a button with a callback that contains these two lines:
GetPanelDisplayBitmap (panel, VAL_FULL_PANEL, VAL_ENTIRE_OBJECT, &bmp_id);
ClipboardPutBitmap (bmp_id);
Then compare the contents of your clipboard after an <Alt>-<PrtScrn> and clicking on your new button. 
 
Roberto: That FakeKeyStroke approach is great - you took it further than I was willing to try. Thanks! You also raise some good questions that I can't answer -- hopefully someone else can help out.
 
--Ian
 

 


0 Kudos
Message 5 of 5
(3,797 Views)