diff options
author | fvogel <fvogelnew1@free.fr> | 2023-12-02 11:35:55 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-12-02 11:35:55 (GMT) |
commit | d276dd2c72119f6afbfe4c15127fbbd05fc88522 (patch) | |
tree | f3dff9576414ba2b030e6855e684a94e2c662a59 | |
parent | ac572d67848f66d7abcfd7045c6097b55a36b1fc (diff) | |
download | tk-d276dd2c72119f6afbfe4c15127fbbd05fc88522.zip tk-d276dd2c72119f6afbfe4c15127fbbd05fc88522.tar.gz tk-d276dd2c72119f6afbfe4c15127fbbd05fc88522.tar.bz2 |
Fix [1d8b7124b6]: X11: Photo images not drawn correctly for 32-bit visuals. Patch from Christian Werner proposed in [https://www.androwish.org/home/info/7aeac931688d2525].
-rw-r--r-- | generic/tkImgPhInstance.c | 28 |
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 |