Fabio Bracci wrote:

> The problem is that this is the only working sequence:
> performing a  fl_read_image *after* fl_end_offscreen() simply causes an ugly 
> segmentation fault.

This is because fl_read_image() does not have any argument to specify
from WHICH drawable the image pixels should be read, so it always reads
from CURRENT drawable. Normally during Fl::flush() the drawable is a
screen window. But outside  this, there is no current drawable set so
fl_read_image() does not know from where to read the pixels an it is
probably accessing a NULL pointer.  To read the pixels from your your
offscreen, this offscreen needs to be current and you can set this as
current by fl_begin_offscreen(my_ofscreen). The function
fl_end_offscreen() sets back the previous active drawable as current,
and if it happens to be 0, then fl_read_image() crashes.

Your offscreen remains persistent until you call
fl_delete_offscreen(my_offscreen), but to access it, you have to make it
current again by encapsulating it within
fl_begin_offscreen()/fl_end_offscreen() brackets like

fl_begin_ofscreen(my_offscreen); // makes my_offscreen current
fl_read_image(...); // reads from current drawable
fl_end_offscreen(); //sets back previous drawable as current


Roman

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

Reply via email to