summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXImage.c
diff options
context:
space:
mode:
authorculler <culler>2017-11-14 06:12:12 (GMT)
committerculler <culler>2017-11-14 06:12:12 (GMT)
commitbc151889837903b15310b5b9fb9ad5837b4a8b89 (patch)
tree85bb4b51230a36e6aaa22197cda7746ad85696f0 /macosx/tkMacOSXImage.c
parenteb1ab83b17eae759265ae8f1489c24a0f1838dcb (diff)
downloadtk-bc151889837903b15310b5b9fb9ad5837b4a8b89.zip
tk-bc151889837903b15310b5b9fb9ad5837b4a8b89.tar.gz
tk-bc151889837903b15310b5b9fb9ad5837b4a8b89.tar.bz2
Implemented a more robust and transparent scheme for making
sure that iconphoto images are not blended with a black background.
Diffstat (limited to 'macosx/tkMacOSXImage.c')
-rw-r--r--macosx/tkMacOSXImage.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index 02e8c54..adcb0f5 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -160,25 +160,20 @@ XGetImage(
unsigned int bytes_per_row, size, row, n, m;
unsigned int scalefactor=1, scaled_height=height, scaled_width=width;
NSWindow *win = TkMacOSXDrawableWindow(drawable);
- TkWindow *winPtr = TkMacOSXGetTkWindow(win);
+ MacDrawable *macDraw = ((MacDrawable*)drawable);
static enum {unknown, no, yes} has_retina = unknown;
- if (win && !winPtr) {
+ if (macDraw->flags & TK_DO_NOT_BLEND) {
/*
- * If this drawable has an associated NSWindow but does not have an
- * associated Tk window then it must be a dock icon. We are being
- * called by TkImgPhotoDisplay because it is displaying a photoimage
- * with an alpha channel, e.g. one generated from a png file, as the
- * dock icon. It is asking us to create a pixmap for the rectangle
- * where the image will be drawn so that it can blend the photoimage
- * with its background using the alpha values. But in the case of a
- * dock icon, that background will be black, not transparent as it
- * should be.
- *
- * By returning NULL here, we force TkImgPhotoDisplay to give up on
- * trying to blend, and just copy the image pixels to the screen. That
- * does the right thing for a dock icon, as it happens.
- */
+ * When called by TkImgPhotoDisplay we are being asked to return a
+ * background image to be blended with the photoimage using its alpha
+ * channel, if it has one. Returning NULL here makes TkImgPhotoDisplay
+ * simply copy the image data, including the alpha channel, rather than
+ * do any blending. For example, when creating an iconphoto from a
+ * photoimage with transparency we will be passed a newly created
+ * pixmap filled with black pixels. These should not be blended with
+ * the pixels in the photoimage.
+ */
return NULL;
}