From e3670dfda6799aa92ed30c770dd9c811f4d74b54 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Fri, 14 Oct 2016 16:35:52 +0000 Subject: Fix inconsistent interpretation of ld() in image handling (STR #3308). Documentation has been fixed and clarified, and ld() handling is now consistent in Fl_(RGB_)Image, their subclasses and fl_draw_image() and similar functions. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@12029 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Fl_x.cxx') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 3ba9ba6bc..93ef26d78 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2612,9 +2612,11 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count, data[1] = image->h(); data += 2; + const int extra_data = image->ld() ? (image->ld()-image->w()*image->d()) : 0; + const uchar *in = (const uchar*)*image->data(); - for (int y = 0;y < image->h();y++) { - for (int x = 0;x < image->w();x++) { + for (int y = 0; y < image->h(); y++) { + for (int x = 0; x < image->w(); x++) { switch (image->d()) { case 1: *data = ( 0xff<<24) | (in[0]<<16) | (in[0]<<8) | in[0]; @@ -2632,7 +2634,7 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count, in += image->d(); data++; } - in += image->ld(); + in += extra_data; } } } @@ -2748,6 +2750,7 @@ int Fl_X11_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int ho if (!cursor) return 0; + const int extra_data = image->ld() ? (image->ld()-image->w()*image->d()) : 0; const uchar *i = (const uchar*)*image->data(); XcursorPixel *o = cursor->pixels; for (int y = 0;y < image->h();y++) { @@ -2769,7 +2772,7 @@ int Fl_X11_Window_Driver::set_cursor(const Fl_RGB_Image *image, int hotx, int ho i += image->d(); o++; } - i += image->ld(); + i += extra_data; } cursor->xhot = hotx; -- cgit v1.2.3