0

I'm trying to capture an image of either the current window or a widget and save it to an image file. The problem is that I'm using Gtk# on Mono, so it needs to be a solution that'll work with that.

Essentially, something like this:

myWidget.SaveImage("imageFile.png");

I'd prefer a PNG or JPEG, but a raw bitmap will do.

Polynomial
  • 27,674
  • 12
  • 80
  • 107

1 Answers1

0

You should be able to do this using Gdk.

This is very similar to this question: How to take a screenshot with Mono C#?

I've also found a php-gtk example here: http://php-gtk.eu/code-hints/grabbing-a-screenshot-with-gdk

Community
  • 1
  • 1
IanNorton
  • 7,145
  • 2
  • 25
  • 28
  • Not what I want to do. If another window is displayed on top, my window will be obscured. I want to capture an image regardless of its state or position - even if the window is minimised. – Polynomial Oct 06 '11 at 18:38
  • Hmm, I'm pretty sure that isn't going to be possible without getting help from the window manager. – IanNorton Oct 06 '11 at 18:50
  • "regardless of state" sounds a little odd, widgets respond to different events, including resize, mouse, focus etc. In what context do you need this? ( You might be able to do somthing with a compositing window manager ) – IanNorton Oct 06 '11 at 18:52
  • I'm producing graphs on a monitoring frontend, and they need to periodically be dumped to images. – Polynomial Oct 07 '11 at 08:06
  • Oh, right, a screenshot of a gtk widget doesnt sound like what you want then. How are you drawing your graphs? If you use Cairo you will find it easier I think to do both the drawing and capture. – IanNorton Oct 07 '11 at 19:26
  • The graphs are generated by the library. – Polynomial Oct 11 '11 at 16:17