mirror of https://github.com/fltk/fltk
Fix for issue #159 - continued
Changes here concentrate the fix within static function alpha_blend() and thus are visible only when drawing transparent images under X11 platform without Xrender.
This commit is contained in:
parent
aa140973a3
commit
aa9e2e888e
|
@ -839,19 +839,12 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int
|
|||
}
|
||||
}
|
||||
|
||||
if (!image) return 0;
|
||||
if (s != 1) {
|
||||
w = ws;
|
||||
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
|
||||
printf("width = %d\n", image->width);
|
||||
printf("height = %d\n", image->height);
|
||||
|
@ -871,6 +864,14 @@ 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);
|
||||
#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...
|
||||
if (!image->red_mask && image->bits_per_pixel > 12) {
|
||||
// Greater than 12 bits must be TrueColor...
|
||||
|
@ -1162,7 +1163,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...
|
||||
XDestroyImage(image);
|
||||
}
|
||||
|
||||
Fl_RGB_Image *rgb = new Fl_RGB_Image(p, w, h, d);
|
||||
rgb->alloc_array = 1;
|
||||
return rgb;
|
||||
|
|
|
@ -658,13 +658,15 @@ static void alpha_blend(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, i
|
|||
int ld = img->ld();
|
||||
if (ld == 0) ld = img->data_w() * img->d();
|
||||
uchar *srcptr = (uchar*)img->array + cy * ld + cx * img->d();
|
||||
|
||||
uchar *dst = fl_read_image(NULL, X, Y, W, H, 0);
|
||||
if (!dst) {
|
||||
fl_draw_image(srcptr, X, Y, W, H, img->d(), ld);
|
||||
return;
|
||||
}
|
||||
int srcskip = ld - img->d() * W;
|
||||
|
||||
uchar *dst = new uchar[W * H * 3];
|
||||
uchar *dstptr = dst;
|
||||
|
||||
fl_read_image(dst, X, Y, W, H, 0);
|
||||
|
||||
uchar srcr, srcg, srcb, srca;
|
||||
uchar dstr, dstg, dstb, dsta;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ uchar *fl_read_image(uchar *p, int X, int Y, int w, int h, int alpha) {
|
|||
img = Fl_Screen_Driver::traverse_to_gl_subwindows(Fl_Window::current(), X, Y, w, h, NULL);
|
||||
}
|
||||
int depth = alpha ? 4 : 3;
|
||||
if (img->d() != depth) {
|
||||
if (img && img->d() != depth) {
|
||||
uchar *data = new uchar[img->w() * img->h() * depth];
|
||||
if (depth == 4) memset(data, alpha, img->w() * img->h() * depth);
|
||||
uchar *d = data;
|
||||
|
|
Loading…
Reference in New Issue