Fix negative 'd' and 'ld' args in fl_draw_image() (X11 + Windows).
This commit fixes a regression in FLTK 1.3.x, where negative values of 'd' (pixel delta) and 'ld' (line delta) didn't work anymore under Unix/Linux (X11) and Windows. With this commit the regression is fixed on all supported platforms. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11270 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
59aa9b25d6
commit
3948405951
2
CHANGES
2
CHANGES
@ -162,7 +162,7 @@ CHANGES IN FLTK 1.3.4 RELEASED: ??? ?? 2016
|
||||
- Fixed a potential hangup of the Fl::awake() queue under Windows if
|
||||
a window is resized or moved while the Fl::awake() message is sent
|
||||
(STR #3143).
|
||||
- Fixed a regression under Mac OS X: restore the possibility to call
|
||||
- Fixed a regression: restore the possibility to call
|
||||
fl_draw_image(buf,X,Y,W,H,D,L) with negative D and/or L arguments.
|
||||
|
||||
|
||||
|
@ -461,7 +461,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
||||
Fl_Draw_Image_Cb cb, void* userdata,
|
||||
const bool alpha)
|
||||
{
|
||||
if (!linedelta) linedelta = W*delta;
|
||||
if (!linedelta) linedelta = W*abs(delta);
|
||||
|
||||
int dx, dy, w, h;
|
||||
fl_clip_box(X,Y,W,H,dx,dy,w,h);
|
||||
@ -573,22 +573,27 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w, int h, int d, int l){
|
||||
|
||||
const bool alpha = !!(d & FL_IMAGE_WITH_ALPHA);
|
||||
d &= ~FL_IMAGE_WITH_ALPHA;
|
||||
const bool alpha = !!(abs(d) & FL_IMAGE_WITH_ALPHA);
|
||||
if (alpha) d ^= FL_IMAGE_WITH_ALPHA;
|
||||
const int mono = (d>-3 && d<3);
|
||||
|
||||
innards(buf,x,y,w,h,d,l,(d<3&&d>-3),0,0,alpha);
|
||||
innards(buf,x,y,w,h,d,l,mono,0,0,alpha);
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data,
|
||||
int x, int y, int w, int h,int d) {
|
||||
|
||||
const bool alpha = !!(d & FL_IMAGE_WITH_ALPHA);
|
||||
d &= ~FL_IMAGE_WITH_ALPHA;
|
||||
const bool alpha = !!(abs(d) & FL_IMAGE_WITH_ALPHA);
|
||||
if (alpha) d ^= FL_IMAGE_WITH_ALPHA;
|
||||
const int mono = (d>-3 && d<3);
|
||||
|
||||
innards(0,x,y,w,h,d,0,(d<3&&d>-3),cb,data,alpha);
|
||||
innards(0,x,y,w,h,d,0,mono,cb,data,alpha);
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::draw_image_mono(const uchar* buf, int x, int y, int w, int h, int d, int l){
|
||||
innards(buf,x,y,w,h,d,l,1,0,0,0);
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data,
|
||||
int x, int y, int w, int h,int d) {
|
||||
innards(0,x,y,w,h,d,0,1,cb,data,0);
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// WIN32 image drawing code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2012 by Bill Spitzak and others.
|
||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -103,6 +103,8 @@ static void monodither(uchar* to, const uchar* from, int w, int delta) {
|
||||
|
||||
#endif // USE_COLORMAP
|
||||
|
||||
static int fl_abs(int v) { return v<0 ? -v : v; }
|
||||
|
||||
static void innards(const uchar *buf, int X, int Y, int W, int H,
|
||||
int delta, int linedelta, int depth,
|
||||
Fl_Draw_Image_Cb cb, void* userdata)
|
||||
@ -117,7 +119,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
||||
if (indexed || !fl_can_do_alpha_blending())
|
||||
depth = (depth-1)|1;
|
||||
|
||||
if (!linedelta) linedelta = W*delta;
|
||||
if (!linedelta) linedelta = W*fl_abs(delta);
|
||||
|
||||
int x, y, w, h;
|
||||
fl_clip_box(X,Y,W,H,x,y,w,h);
|
||||
@ -278,8 +280,6 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
|
||||
}
|
||||
}
|
||||
|
||||
static int fl_abs(int v) { return v<0 ? -v : v; }
|
||||
|
||||
void Fl_GDI_Graphics_Driver::draw_image(const uchar* buf, int x, int y, int w, int h, int d, int l){
|
||||
if (fl_abs(d)&FL_IMAGE_WITH_ALPHA) {
|
||||
d ^= FL_IMAGE_WITH_ALPHA;
|
||||
|
Loading…
Reference in New Issue
Block a user