diff options
| author | Manolo Gouy <Manolo> | 2016-03-09 06:59:12 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-03-09 06:59:12 +0000 |
| commit | 309213bfaeaff9b3beec9548aeb7762d7dbaa2f8 (patch) | |
| tree | 23b425be0c937840e42d661571a2c18b841680ae /src/fl_read_image.cxx | |
| parent | 0b751e8175debe3fa2c7b1d80693d1178565e664 (diff) | |
Simpler code for capture of OpenGL windows: the pixel array is converted to top-to-bottom earlier.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11326 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_read_image.cxx')
| -rw-r--r-- | src/fl_read_image.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/fl_read_image.cxx b/src/fl_read_image.cxx index 3a4d8ede3..ebf43c324 100644 --- a/src/fl_read_image.cxx +++ b/src/fl_read_image.cxx @@ -45,14 +45,14 @@ static uchar *read_win_rectangle(uchar *p, int X, int Y, int w, int h, int alpha static void write_image_inside(Fl_RGB_Image *to, Fl_RGB_Image *from, int to_x, int to_y) /* Copy the image "from" inside image "to" with its top-left angle at coordinates to_x, to_y. - Also, exchange top and bottom of "from". Image depth can differ between "to" and "from". + Image depth can differ between "to" and "from". */ { int to_ld = (to->ld() == 0? to->w() * to->d() : to->ld()); int from_ld = (from->ld() == 0? from->w() * from->d() : from->ld()); uchar *tobytes = (uchar*)to->array + to_y * to_ld + to_x * to->d(); - const uchar *frombytes = from->array + (from->h() - 1) * from_ld; - for (int i = from->h() - 1; i >= 0; i--) { + const uchar *frombytes = from->array; + for (int i = 0; i < from->h(); i++) { if (from->d() == to->d()) memcpy(tobytes, frombytes, from->w() * from->d()); else { for (int j = 0; j < from->w(); j++) { @@ -60,7 +60,7 @@ static void write_image_inside(Fl_RGB_Image *to, Fl_RGB_Image *from, int to_x, i } } tobytes += to_ld; - frombytes -= from_ld; + frombytes += from_ld; } } @@ -92,9 +92,9 @@ static Fl_RGB_Image *traverse_to_gl_subwindows(Fl_Group *g, uchar *p, int x, int Fl_Plugin_Manager pm("fltk:device"); Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); if (!pi) return full_img; - Fl_RGB_Image *img = pi->rectangle_capture(g, x, y, w, h); // bottom to top image - if (full_img) full_img = img; // top and bottom will be exchanged later - else { // exchange top and bottom to get a proper FLTK image + Fl_RGB_Image *img = pi->rectangle_capture(g, x, y, w, h); + if (full_img) full_img = img; + else { uchar *data = ( p ? p : new uchar[img->w() * img->h() * (alpha?4:3)] ); full_img = new Fl_RGB_Image(data, img->w(), img->h(), alpha?4:3); if (!p) full_img->alloc_array = 1; |
