> Hi, I want to save the contents of an FLTK double-window as a 
> PNG or PPM 
> file.  Is there an easy way to do this (from a program, not using a 
> screenshot)?

What you have to do is use:

uchar *fl_read_image(uchar *p, int X, int Y, int W, int H, int alpha =
0);


To get the window data. You need to call my_window->current() first
though - or better, only ever grab the window at the end of the windows
(subclassed) ::draw() routine, when it will be inherently current
anyway...

So, what we did was something like this:
- add a "save window" button.
- the button callback sets a "flag"
- the window in question has a subclassed draw method that simply calls
the regular draw, then check to see if "flag" is set.
- if "flag" is set, we call fl_read_image(...)
- the grabbed data is then written to a PNG by convetional means.

(an earlier version called my_window->current() then fl_read_image(...)
in the button callback, which also worked - this way seemed more
"proper" however!)

Now, this seems to work, at least on win32 and linux, but with the
following caveats:

- it's not all that quick (but we don't care as it is only invoked in
response to operator interaction.)

- if the window is obscured on-screen by other windows, you grab the
other window's contents. You may also want to look into using the
fl_offscreen methods as a way or avoiding this later problem. We worked
around it by making the button callback show() the window to push it to
the top of the window stack, which is a nasty workaround.





SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to