I really don't understand, what's wrong with this code, but I never "Got
Image". Think it worked before this way, but what is it missing now? To
me it seems, fl_read_image() doesn't find the offscreen:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/fl_draw.H>
#include <FL/x.H>
#include <iostream>
using std::cout;
using std::endl;
class Fl_Test_Window: public Fl_Window
{
public:
Fl_Test_Window(int w, int h, const char* l= 0):
Fl_Window(w, h, l)
{
new Fl_Input(100, 100, 100, 25, "Input");
end();
resizable(this);
}
protected:
void draw()
{
Fl_Window::draw(); // draws window on screen
fl_rect(100, 100, 100, 100, FL_BLACK);
Fl_Offscreen OF= fl_create_offscreen(1000, 1000);
fl_begin_offscreen(OF);
Fl_Window::draw(); // draws window off screen
fl_end_offscreen();
if (unsigned char* pImage= fl_read_image(0, 0, 0, 1000, 1000, 0))
{ // pImage stays NULL
cout << "Got Image!" << endl;
delete[] pImage;
}
else cout << "No Image!" << endl;
fl_delete_offscreen(OF);
}
};
int main()
{
Fl_Test_Window Win(640, 480, "Offscreen Image");
Win.show();
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk