diff options
author | ericm <ericm@noemail.net> | 2000-01-26 21:10:59 (GMT) |
---|---|---|
committer | ericm <ericm@noemail.net> | 2000-01-26 21:10:59 (GMT) |
commit | 4015ba483b9f62d5df8891da16a676537e9dc26b (patch) | |
tree | ab75a0002b8dc1779441e1af3ad2a504037a925b /generic/tkImgPhoto.c | |
parent | d13ea31f9f8b05239d98d045adc1625396932dff (diff) | |
download | tk-4015ba483b9f62d5df8891da16a676537e9dc26b.zip tk-4015ba483b9f62d5df8891da16a676537e9dc26b.tar.gz tk-4015ba483b9f62d5df8891da16a676537e9dc26b.tar.bz2 |
* generic/tkImgPhoto.c: Added some comments regarding slow
processing of transparent images.
* generic/tkImgGIF.c: Improved GIF decoder for ~60% speed
increase. Added some comments on how to further improve the
implementation, time permitting.
* doc/photo.n: Added a description of what the -data string can
contain (base64 or binary data).
FossilOrigin-Name: 45f50a399cc39791c94eff4ee1f7e8e0c1448766
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r-- | generic/tkImgPhoto.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 97e61af..17b61eb 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -15,7 +15,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.13 2000/01/26 17:02:27 ericm Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.14 2000/01/26 21:11:00 ericm Exp $ */ #include "tkInt.h" @@ -3760,7 +3760,13 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4; pitch = masterPtr->width * 4; - if ((blockPtr->pixelSize == 4) && (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 0) + /* + * This test is probably too restrictive. We should also be able to + * do a memcpy if pixelSize == 3 and alphaOffset == 0. Maybe other cases + * too. + */ + if ((blockPtr->pixelSize == 4) + && (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3) && (width <= blockPtr->width) && (height <= blockPtr->height) && ((height == 1) || ((x == 0) && (width == masterPtr->width) && (blockPtr->pitch == pitch)))) { @@ -3811,7 +3817,25 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) if (alphaOffset) { int x1, y1, end; - + + /* + * This block is grossly inefficient. For each row in the image, it + * finds each continguous string of transparent pixels, then marks those + * areas as invalid in the validRegion mask. This makes drawing very + * efficient, because of the way we use X: we just say, here's your + * mask, and here's your data. We need not worry about the current + * background color, etc. But this costs us a lot on the image setup. + * Still, image setup only happens once, whereas the drawing happens + * many times, so this might be the best way to go. + * + * An alternative might be to not set up this mask, and instead, at + * drawing time, for each transparent pixel, set its color to the + * color of the background behind that pixel. This is what I suspect + * most of programs do. However, they don't have to deal with the canvas, + * which could have many different background colors. Determining the + * correct bg color for a given pixel might be expensive. + */ + destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4 + 3; for (y1 = 0; y1 < height; y1++) { x1 = 0; |