mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 14:52:46 +08:00
Fix for issue #159.
This commit is contained in:
@@ -839,12 +839,19 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!image) return 0;
|
|
||||||
if (s != 1) {
|
if (s != 1) {
|
||||||
w = ws;
|
w = ws;
|
||||||
h = hs;
|
h = hs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int d = 3; // Depth of image
|
||||||
|
uchar *p = NULL;
|
||||||
|
// Allocate the image data array as needed...
|
||||||
|
p = new uchar[w * h * d];
|
||||||
|
|
||||||
|
// Initialize the default colors/alpha in the whole image...
|
||||||
|
memset(p, 0, w * h * d);
|
||||||
|
if (image) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("width = %d\n", image->width);
|
printf("width = %d\n", image->width);
|
||||||
printf("height = %d\n", image->height);
|
printf("height = %d\n", image->height);
|
||||||
@@ -864,14 +871,6 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int
|
|||||||
printf("map_entries = %d\n", fl_visual->visual->map_entries);
|
printf("map_entries = %d\n", fl_visual->visual->map_entries);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
const int d = 3; // Depth of image
|
|
||||||
uchar *p = NULL;
|
|
||||||
// Allocate the image data array as needed...
|
|
||||||
p = new uchar[w * h * d];
|
|
||||||
|
|
||||||
// Initialize the default colors/alpha in the whole image...
|
|
||||||
memset(p, 0, w * h * d);
|
|
||||||
|
|
||||||
// Check that we have valid mask/shift values...
|
// Check that we have valid mask/shift values...
|
||||||
if (!image->red_mask && image->bits_per_pixel > 12) {
|
if (!image->red_mask && image->bits_per_pixel > 12) {
|
||||||
// Greater than 12 bits must be TrueColor...
|
// Greater than 12 bits must be TrueColor...
|
||||||
@@ -1163,7 +1162,7 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int
|
|||||||
|
|
||||||
// Destroy the X image we've read and return the RGB(A) image...
|
// Destroy the X image we've read and return the RGB(A) image...
|
||||||
XDestroyImage(image);
|
XDestroyImage(image);
|
||||||
|
}
|
||||||
Fl_RGB_Image *rgb = new Fl_RGB_Image(p, w, h, d);
|
Fl_RGB_Image *rgb = new Fl_RGB_Image(p, w, h, d);
|
||||||
rgb->alloc_array = 1;
|
rgb->alloc_array = 1;
|
||||||
return rgb;
|
return rgb;
|
||||||
|
|||||||
@@ -644,6 +644,16 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i
|
|||||||
if (cy < 0) { H += cy; Y -= cy; cy = 0; }
|
if (cy < 0) { H += cy; Y -= cy; cy = 0; }
|
||||||
if (W + cx > img->data_w()) W = img->data_w() - cx;
|
if (W + cx > img->data_w()) W = img->data_w() - cx;
|
||||||
if (H + cy > img->data_h()) H = img->data_h() - cy;
|
if (H + cy > img->data_h()) H = img->data_h() - cy;
|
||||||
|
// don't attempt to read outside the window/offscreen buffer limits
|
||||||
|
Window root_return;
|
||||||
|
int x_return, y_return;
|
||||||
|
unsigned int winW, winH;
|
||||||
|
unsigned int border_width_return;
|
||||||
|
unsigned int depth_return;
|
||||||
|
XGetGeometry(fl_display, fl_window, &root_return, &x_return, &y_return, &winW,
|
||||||
|
&winH, &border_width_return, &depth_return);
|
||||||
|
if (X+W > winW) W = winW-X;
|
||||||
|
if (Y+H > winH) H = winH-Y;
|
||||||
if (W <= 0 || H <= 0) return;
|
if (W <= 0 || H <= 0) return;
|
||||||
int ld = img->ld();
|
int ld = img->ld();
|
||||||
if (ld == 0) ld = img->data_w() * img->d();
|
if (ld == 0) ld = img->data_w() * img->d();
|
||||||
|
|||||||
Reference in New Issue
Block a user