summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPhInstance.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-08-29 15:28:20 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-08-29 15:28:20 (GMT)
commit992eb3df2d03dec6291784e8dca7e6d85b279c7a (patch)
treec885db53fd7bd38e3971e2b93242b2e798961ee9 /generic/tkImgPhInstance.c
parent1052e56fe96f3ece407a6374714af0302c9a5e3c (diff)
parent76052445ac39afd2c455431d80335dd464ed755e (diff)
downloadtk-992eb3df2d03dec6291784e8dca7e6d85b279c7a.zip
tk-992eb3df2d03dec6291784e8dca7e6d85b279c7a.tar.gz
tk-992eb3df2d03dec6291784e8dca7e6d85b279c7a.tar.bz2
Rebased to trunk since TIP #449 was accepted for merging to trunk only, not to core-8-6-branchtip_449
Diffstat (limited to 'generic/tkImgPhInstance.c')
-rw-r--r--generic/tkImgPhInstance.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 666a9b0..bd152f2 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -404,6 +404,9 @@ TkImgPhotoGet(
*
* Note that Win32 pre-defines those operations that we really need.
*
+ * Note that on MacOS, if the background comes from a Retina display
+ * then it will be twice as wide and twice as high as the photoimage.
+ *
*----------------------------------------------------------------------
*/
@@ -433,7 +436,16 @@ BlendComplexAlpha(
unsigned long pixel;
unsigned char r, g, b, alpha, unalpha, *masterPtr;
unsigned char *alphaAr = iPtr->masterPtr->pix32;
-
+#if defined(MAC_OSX_TK)
+ /* Background "pixels" are actually 2^pp x 2^pp blocks of subpixels. Each
+ * block gets blended with the color of one image pixel. Since we iterate
+ * over the background subpixels, we reset the width and height to the
+ * subpixel dimensions of the background image we are using.
+ */
+ int pp = bgImg->pixelpower;
+ width = width << pp;
+ height = height << pp;
+#endif
/*
* This blending is an integer version of the Source-Over compositing rule
* (see Porter&Duff, "Compositing Digital Images", proceedings of SIGGRAPH
@@ -532,9 +544,16 @@ BlendComplexAlpha(
#endif /* !_WIN32 && !MAC_OSX_TK */
for (y = 0; y < height; y++) {
+# if !defined(MAC_OSX_TK)
line = (y + yOffset) * iPtr->masterPtr->width;
for (x = 0; x < width; x++) {
masterPtr = alphaAr + ((line + x + xOffset) * 4);
+#else
+ /* Repeat each image row and column 2^pp times. */
+ line = ((y>>pp) + yOffset) * iPtr->masterPtr->width;
+ for (x = 0; x < width; x++) {
+ masterPtr = alphaAr + ((line + (x>>pp) + xOffset) * 4);
+#endif
alpha = masterPtr[3];
/*
@@ -635,7 +654,9 @@ TkImgPhotoDisplay(
(unsigned int)width, (unsigned int)height, AllPlanes, ZPixmap);
if (bgImg == NULL) {
Tk_DeleteErrorHandler(handler);
- /* We failed to get the image so draw without blending alpha. It's the best we can do */
+ /* We failed to get the image, so draw without blending alpha.
+ * It's the best we can do.
+ */
goto fallBack;
}