diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 57 |
2 files changed, 42 insertions, 22 deletions
@@ -1,3 +1,10 @@ +2004-12-03 Donal K. Fellows <donal.k.fellows@man.ac.uk> + + * generic/tkImgPhoto.c (Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock): + Make overlay compositing where the target is empty no longer set + the target to magical gray, and also make sure that the + complex-alpha flag is toggled when necessary. [Patch 848161] + 2004-12-01 Jeff Hobbs <jeffh@ActiveState.com> * unix/tkUnixButton.c (TkpDisplayButton): constrain coords to diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 76a07dd..34d0d46 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.52 2004/12/02 02:10:37 hobbs Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.53 2004/12/03 13:09:39 dkf Exp $ */ #include "tkInt.h" @@ -2545,14 +2545,15 @@ static int ToggleComplexAlphaIfNeeded(PhotoMaster *mPtr) { size_t len = MAX(mPtr->userWidth, mPtr->width) * - MAX(mPtr->userHeight, mPtr->height) * 4; - unsigned char *c = mPtr->pix32; + MAX(mPtr->userHeight, mPtr->height) * 4; + unsigned char *c = mPtr->pix32; unsigned char *end = c + len; /* * Set the COMPLEX_ALPHA flag if we have an image with partially * transparent bits. */ + mPtr->flags &= ~COMPLEX_ALPHA; c += 3; /* start at first alpha byte */ for (; c < end; c += 4) { @@ -4476,20 +4477,20 @@ Tk_PhotoPutBlock(interp, handle, blockPtr, x, y, width, height, compRule) * Combine according to the compositing rule. */ switch (compRule) { - case TK_PHOTO_COMPOSITE_SET: - *destPtr++ = srcPtr[0]; - *destPtr++ = srcPtr[greenOffset]; - *destPtr++ = srcPtr[blueOffset]; - *destPtr++ = alpha; - break; - case TK_PHOTO_COMPOSITE_OVERLAY: if (!destPtr[3]) { /* - * There must be a better way to select a - * background colour! + * The destination is entirely + * blank, so set it to the source, + * just as if we used the SET + * compositing rule. */ - destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; + case TK_PHOTO_COMPOSITE_SET: + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = alpha; + break; } if (alpha) { @@ -4586,6 +4587,12 @@ Tk_PhotoPutBlock(interp, handle, blockPtr, x, y, width, height, compRule) } /* + * Check if display code needs alpha blending... + */ + + ToggleComplexAlphaIfNeeded(masterPtr); + + /* * Update each instance. */ @@ -4779,19 +4786,19 @@ Tk_PhotoPutZoomedBlock(interp, handle, blockPtr, x, y, width, height, } switch (compRule) { - case TK_PHOTO_COMPOSITE_SET: - *destPtr++ = srcPtr[0]; - *destPtr++ = srcPtr[greenOffset]; - *destPtr++ = srcPtr[blueOffset]; - *destPtr++ = alpha; - break; case TK_PHOTO_COMPOSITE_OVERLAY: if (!destPtr[3]) { /* - * There must be a better way to select a - * background colour! + * The destination is entirely blank, + * so set it to the source, just as if + * we used the SET compositing rule. */ - destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; + case TK_PHOTO_COMPOSITE_SET: + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = alpha; + break; } if (alpha) { int Alpha = destPtr[3]; @@ -4880,6 +4887,12 @@ Tk_PhotoPutZoomedBlock(interp, handle, blockPtr, x, y, width, height, } /* + * Check if display code needs alpha blending... + */ + + ToggleComplexAlphaIfNeeded(masterPtr); + + /* * Update each instance. */ |