Simon schrieb:
> Hi there,
>    is there a quick and simple way to save a window's drawn contents to a
> file (like a screenshot but clipped to the fltk window)?

there is a way, but "quick and simple" seems a bit euphemistic to me. 
You can get the windows content out of the draw-function and then save 
it, when you know how. :o)

First a point out how to use the draw:

#include <FL/Fl_Double_Window.H>
#include <FL/fl_draw.H>
#include <FL/x.H>
#include <write_png.h>

class Fl_Screenshot_Window: public Fl_Double_Window
{
public:
  Fl_Screenshot_Window(int x, int y, int w, int h, const char*l= 0):
        Fl_Double_Window(x, y, w, h, l)
  {}
  Fl_Screenshot_Window(int w, int h, const char*l= 0):
        Fl_Double_Window(w, h, l)
  {}

protected:
  void draw()
  {
   Fl_Double_Windwo::draw();
   if (unsigned char* pImage= fl_read_image(0, 0, 0, w(), h(), 0))
   {
        write_png("/home/ed/temp/image.png", pImage, w(), h(), 3);
        delete[] pImage;
   }
  }
};

When you use this window-class, it will copy every draw to "image.png".

Beside this code you need to include "libpng.a" or "libflt_kpng.a".
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to