|
commit 397226b75d0c2eb8bc7ecb25f6aa0c496ee08b60
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue Nov 16 15:03:36 2021 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue Nov 16 15:03:36 2021 +0100
Add use of fl_capture_window() by test/device
Also, rename fl_capture_window_part() to fl_capture_window().
FL/fl_draw.H | 2 +-
src/Fl_Screen_Driver.H | 2 +-
src/fl_read_image.cxx | 4 ++--
test/device.cxx | 43 +++++++++++++++++++++++++++++++------------
4 files changed, 35 insertions(+), 16 deletions(-)
diff --git FL/fl_draw.H FL/fl_draw.H
index b2602b5..c11dc9f 100644
--- FL/fl_draw.H
+++ FL/fl_draw.H
@@ -1035,7 +1035,7 @@ inline char fl_can_do_alpha_blending() {
}
FL_EXPORT uchar *fl_read_image(uchar *p, int X, int Y, int W, int H, int alpha = 0);
-FL_EXPORT Fl_RGB_Image *fl_capture_window_part(Fl_Window *win, int x, int y, int w, int h);
+FL_EXPORT Fl_RGB_Image *fl_capture_window(Fl_Window *win, int x, int y, int w, int h);
// pixmaps:
/**
diff --git src/Fl_Screen_Driver.H src/Fl_Screen_Driver.H
index c160f8a..8bff6fa 100644
--- src/Fl_Screen_Driver.H
+++ src/Fl_Screen_Driver.H
@@ -149,7 +149,7 @@ public:
virtual void release_keyboard() {}
/* Member function read_win_rectangle() supports public functions
- fl_read_image() and fl_capture_window_part() which capture pixel data from
+ fl_read_image() and fl_capture_window() which capture pixel data from
a window (or also from an offscreen buffer with fl_read_image).
If 'may_capture_subwins' is true, an implementation may or may not capture
diff --git src/fl_read_image.cxx src/fl_read_image.cxx
index de6907f..129aeaa 100644
--- src/fl_read_image.cxx
+++ src/fl_read_image.cxx
@@ -35,7 +35,7 @@
and the value that is placed in the alpha channel. If 0, no alpha
channel is generated.
- \see fl_capture_window_part()
+ \see fl_capture_window()
*/
uchar *fl_read_image(uchar *p, int X, int Y, int w, int h, int alpha) {
uchar *image_data = NULL;
@@ -96,7 +96,7 @@ uchar *fl_read_image(uchar *p, int X, int Y, int w, int h, int alpha) {
The image depth may differ between platforms.
\version 1.4
*/
-Fl_RGB_Image *fl_capture_window_part(Fl_Window *win, int x, int y, int w, int h)
+Fl_RGB_Image *fl_capture_window(Fl_Window *win, int x, int y, int w, int h)
{
Fl_RGB_Image *rgb = NULL;
if (win->shown()) {
diff --git test/device.cxx test/device.cxx
index 3f67ce1..f58fbd1 100644
--- test/device.cxx
+++ test/device.cxx
@@ -16,7 +16,7 @@
#include <math.h>
#include <FL/Fl.H>
-#include <FL/Fl_Overlay_Window.H>
+#include <FL/Fl_Window.H>
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Radio_Round_Button.H>
#include <FL/fl_draw.H>
@@ -495,7 +495,7 @@ void copy(Fl_Widget *, void *data) {
delete rgb_surf;
Fl_Surface_Device::pop_current();
if (img) {
- Fl_Window* g2 = new Fl_Window(img->w()+10, img->h()+10);
+ Fl_Window* g2 = new Fl_Window(img->w()+10, img->h()+10, "Fl_Image_Surface");
g2->color(FL_YELLOW);
Fl_Box *b = new Fl_Box(FL_NO_BOX,5,5,img->w(), img->h(),0);
b->image(img);
@@ -602,6 +602,22 @@ void copy(Fl_Widget *, void *data) {
}
}
}
+
+ if (strcmp(operation, "fl_capture_window") == 0) {
+ Fl_Window *win = target->as_window() ? target->as_window() : target->window();
+ int X = target->as_window() ? 0 : target->x();
+ int Y = target->as_window() ? 0 : target->y();
+ Fl_RGB_Image *img = fl_capture_window(win, X, Y, target->w(), target->h());
+ if (img) {
+ Fl_Window* g2 = new Fl_Window(img->w()+10, img->h()+10, "fl_capture_window()");
+ g2->color(FL_YELLOW);
+ Fl_Box *b = new Fl_Box(FL_NO_BOX,5,5,img->w(), img->h(),0);
+ b->image(img);
+ g2->end();
+ g2->callback(close_tmp_win, img);
+ g2->show();
+ }
+ }
}
class My_Button:public Fl_Button {
@@ -708,20 +724,23 @@ int main(int argc, char ** argv) {
Fl_Group *g1 = new Fl_Group(w3->x(),w3->y(),w3->w(),w3->h());
rb = new Fl_Radio_Round_Button(5,5,150,12, "Fl_Image_Surface");
rb->set(); rb->callback(operation_cb, NULL); operation = rb->label(); rb->labelsize(12);
- rb = new Fl_Radio_Round_Button(5,18,150,12, "Fl_Copy_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
- rb = new Fl_Radio_Round_Button(5,31,150,12, "Fl_Printer"); rb->callback(operation_cb, NULL); rb->labelsize(12);
- rb = new Fl_Radio_Round_Button(5,44,150,12, "Fl_PostScript_File_Device"); rb->callback(operation_cb, NULL); rb->labelsize(12);
- rb = new Fl_Radio_Round_Button(5,57,150,12, "Fl_EPS_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
- rb = new Fl_Radio_Round_Button(170,57,150,12, "Fl_SVG_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(170,5,150,12, "Fl_Copy_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(5,18,150,12, "Fl_Printer"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(170,18,150,12, "Fl_PostScript_File_Device"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(5,31,150,12, "Fl_EPS_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(170,31,150,12, "Fl_SVG_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
+ rb = new Fl_Radio_Round_Button(5,44,150,12, "fl_capture_window"); rb->callback(operation_cb, NULL); rb->labelsize(12);
g1->end();
Fl_Group *g2 = new Fl_Group(w3->x(),w3->y(),w3->w(),w3->h());
- rb = new Fl_Radio_Round_Button(170,5,150,12, "Decorated Window");
- rb->set(); rb->callback(target_cb, w2); target = w2;
- rb = new Fl_Radio_Round_Button(170,22,150,12, "Sub-window"); rb->callback(target_cb, w3);
- rb = new Fl_Radio_Round_Button(170,39,150,12, "Group"); rb->callback(target_cb, group);
+ rb = new Fl_Radio_Round_Button(5,57,150,12, "Decorated Window");
+ rb->labelsize(12); rb->set(); rb->callback(target_cb, w2); target = w2;
+ rb = new Fl_Radio_Round_Button(170,57,150,12, "Sub-window");
+ rb->labelsize(12); rb->callback(target_cb, w3);
+ rb = new Fl_Radio_Round_Button(335,57,150,12, "Group");
+ rb->labelsize(12);rb->callback(target_cb, group);
g2->end();
- Fl_Button *b4 = new Fl_Button(330, (w3->h() - 25)/2, 150, 25, "GO");
+ Fl_Button *b4 = new Fl_Button(380, (w3->h() - 25)/2, 100, 25, "GO");
b4->callback((Fl_Callback*)copy,NULL);
w3->end();
[ Direct Link to Message ] | |