This is a FAQ, but I missed to keep track of this.

I need to save a plotted graph as a picture, e.g. png, bmp, jpg. I 
think, I should use Fl_Offscreen and something like 
Fl_Offscreen::Save_Png() is what I need.

I found an existing function "write_jpg()" which needs "unsigned char 
*datap; // pointer to image data array" and which I created before, to 
save images from Fl_RGB_Image. Seems to be easy to use this for my 
screenshot, but what in detail is Fl_Offscreen?

./FL/mac.H:39:typedef void* Fl_Offscreen;
        // this is really a CGContextRef
./FL/mac.H:116:  Fl_Offscreen other_xid;
        // pointer for offscreen bitmaps (overlay window)
./FL/win32.H:134:typedef HBITMAP Fl_Offscreen;
./FL/x.H:95:typedef ulong Fl_Offscreen;

This sample code crashes on write_jpg():

Fl_Offscreen OF=  fl_create_offscreen(1000, 1000);
fl_begin_offscreen(OF);
draw_plot();
fl_end_offscreen();
unsigned char* pImage= (unsigned char*) OF;
write_jpg("/home/ed/temp/test.jpg", pImage, 1000, 1000, 3, 0, 0);
fl_delete_offscreen(OF);

I'm sure pImage is wrong, but how can I change Fl_Offscreen to plain RGB 
pointer (for Linux & Windows)?

Or is there somewhere existing code to achieve this?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to