Jump to content

How can I take a screenshot of a panel that preserves transparency?


Recommended Posts

I have a front panel with a few overlapping subpanels. The subpanels are transparent and sitting on top of a graph, with data plotted. One of them is my custom Legend control, which displays all the plotted signals.

 

I'd like to take a screenshot of it and output to picture.

 

I tried using the built-in "Get Image" invoke nodes. I found that even though the subpanels are transparent, when output as a picture, they return as opaque - thus obscuring parts of the graph.

 

I need to take a picture of the panel exactly as it is, including the signals listed on the Legend, etc. but while preserving transparency. Does anyone know a good way to do this?

 

Thanks.

Link to comment

I'm curious about this as well because I've not managed to get transparency working that we'll either. I expect that there's no way to get what you want natively. I don't think the picture API understands transparency and I believe the get image functionality uses this API.

Link to comment

For casual screenshots I use an open source tool called ShareX (formerly ZScreen).  It has command line arguments and hotkeys that would allow you to automatically take a screenshot of a particular window (you can play with this manually to see if you like it) and store it or send it to a variety of places.  Something like this might meet your needs and should be fairly lightweight.

 

https://github.com/ShareX

https://github.com/ShareX/ShareX/wiki/Command-line-arguments

http://en.wikipedia.org/wiki/ShareX (not sure why this exists, but it seems to have good info)

Link to comment

Jordan, what's the advantage of ShareX versus using LabVIEW's built-in Windows API? It seems much simpler just to drop a call to the Windows DLL for keyboard commands and use "printscreen" rather than build something in LabVIEW to talk to ShareX?

 

Maybe I'm confused about what you're suggesting.

Link to comment

Jordan, what's the advantage of ShareX versus using LabVIEW's built-in Windows API? It seems much simpler just to drop a call to the Windows DLL for keyboard commands and use "printscreen" rather than build something in LabVIEW to talk to ShareX?

 

Maybe I'm confused about what you're suggesting.

 

The primary advantage would be to specify which window you want captured rather than trying to dynamically crop based upon the current size and location of the FP within the screen.  This tool does not account for if the window is not entirely within the screen, but neither would a generic printscreen.

Link to comment

Once you get this working I'm interested in the code for this.  I implemented Alt-Printscreen using simulated keystrokes using the user32.dll keybd_event and it worked in the LV environment, but was not reliable when running it in an exe.  I had to go with a .NET method of getting an image of the screen and then cropping the image using the window location.

Link to comment

The primary advantage would be to specify which window you want captured rather than trying to dynamically crop based upon the current size and location of the FP within the screen.  This tool does not account for if the window is not entirely within the screen, but neither would a generic printscreen.

 

Well, regardless I'll have to crop it down to the Graph control and the embedded subpanels.

 

 

Once you get this working I'm interested in the code for this.  I implemented Alt-Printscreen using simulated keystrokes using the user32.dll keybd_event and it worked in the LV environment, but was not reliable when running it in an exe.  I had to go with a .NET method of getting an image of the screen and then cropping the image using the window location.

 

That's discouraging, I was planning on using user32.dll. We'll see how that goes.

Link to comment

That's discouraging, I was planning on using user32.dll. We'll see how that goes.

Here's the VIs I was using.  Hopefully it is helpful.  The idea was to get the screenshot of the top most window or VI and to save it to a file.

Here's the .NET solution to take an screenshot of a VI.  You'll find that there are other VIs on Lava G that are similar, I just formatted the .NET calls to suit my individual needs (it also uses an OpenG VI).

Simulate keyboard.vi

Save Active Window Image to File.vi

Screenshot with Options (.NET).vi

File Dialog with Overwrite Rename Cancel if exists.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.