summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2023-12-09 10:18:00 (GMT)
committerfvogel <fvogelnew1@free.fr>2023-12-09 10:18:00 (GMT)
commit1aa7569a22cc4795cda1475a17c31ea0164a0581 (patch)
tree3430a32223e53c3a4b91580d8332cdecca5181f6
parentcf28e70a810d8fe325d1724cc5db74e9e0732a5f (diff)
parentd276dd2c72119f6afbfe4c15127fbbd05fc88522 (diff)
downloadtk-1aa7569a22cc4795cda1475a17c31ea0164a0581.zip
tk-1aa7569a22cc4795cda1475a17c31ea0164a0581.tar.gz
tk-1aa7569a22cc4795cda1475a17c31ea0164a0581.tar.bz2
Fix [1d8b7124b6]: X11: Photo images not drawn correctly for 32-bit visuals. Patch from Christian Werner.
-rw-r--r--generic/tkImgPhInstance.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 05fa40c..a6910da 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -222,6 +222,9 @@ TkImgPhotoGet(
char buf[TCL_INTEGER_SPACE * 3];
XColor *white, *black;
XGCValues gcValues;
+#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
+ int gcmask;
+#endif
/*
* Table of "best" choices for palette for PseudoColor displays with
@@ -254,7 +257,11 @@ TkImgPhotoGet(
for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
instancePtr = instancePtr->nextPtr) {
if ((colormap == instancePtr->colormap)
- && (Tk_Display(tkwin) == instancePtr->display)) {
+ && (Tk_Display(tkwin) == instancePtr->display)
+#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
+ && (Tk_Visual(tkwin) == instancePtr->visualInfo.visual)
+#endif
+ ) {
/*
* Re-use this instance.
*/
@@ -311,6 +318,10 @@ TkImgPhotoGet(
nGreen = nBlue = 0;
mono = 1;
instancePtr->visualInfo = *visInfoPtr;
+#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
+ gcmask = 0;
+ instancePtr->visualInfo.visual = Tk_Visual(tkwin);
+#endif
switch (visInfoPtr->c_class) {
case DirectColor:
case TrueColor:
@@ -318,6 +329,14 @@ TkImgPhotoGet(
nGreen = 1 << CountBits(visInfoPtr->green_mask);
nBlue = 1 << CountBits(visInfoPtr->blue_mask);
mono = 0;
+#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
+ if (visInfoPtr->depth > 24) {
+ gcValues.plane_mask = visInfoPtr->red_mask
+ | visInfoPtr->green_mask
+ | visInfoPtr->blue_mask;
+ gcmask = GCPlaneMask;
+ }
+#endif
break;
case PseudoColor:
case StaticColor:
@@ -362,8 +381,13 @@ TkImgPhotoGet(
Tk_FreeColor(white);
Tk_FreeColor(black);
gcValues.graphics_exposures = False;
+#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
+ instancePtr->gc = Tk_GetGC(tkwin,
+ gcmask|GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
+#else
instancePtr->gc = Tk_GetGC(tkwin,
- GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
+ GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
+#endif
/*
* Set configuration options and finish the initialization of the