Skip to content

Commit

Permalink
Merge pull request #1288 from radarhere/tk
Browse files Browse the repository at this point in the history
Removed support for Tk versions earlier than 8.4
  • Loading branch information
wiredfool committed Jun 19, 2015
2 parents 081839f + 68ca91f commit f0ac7f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 60 deletions.
8 changes: 3 additions & 5 deletions Tk/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ The Photoimage Booster Patch (for Windows 95/NT)

This patch kit boosts performance for 16/24-bit displays. The
first patch is required on Tk 4.2 (where it fixes the problems for
16-bit displays) and later versions, with the exception for Tk 8.0b1
where Sun added something similar themselves, only to remove it in
8.0b2. By installing both patches, Tk's PhotoImage handling becomes
much faster on both 16-bit and 24-bit displays. The patch has been
tested with Tk 4.2 and 8.0.
16-bit displays) and later versions. By installing both patches,
Tk's PhotoImage handling becomes much faster on both 16-bit and
24-bit displays. The patch has been tested with Tk 4.2 and 8.0.

Here's a benchmark, made with a sample program which loads two
512x512 greyscale PGM's, and two 512x512 colour PPM's, and displays
Expand Down
55 changes: 0 additions & 55 deletions Tk/tkImaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,60 +143,6 @@ PyImagingPhotoPut(ClientData clientdata, Tcl_Interp* interp,
src_xoffset * im->pixelsize;
#endif

#if TK < 84 /* < 8.4.0 */
if (strcmp(im->mode, "RGBA") == 0) {
/* Copy non-transparent pixels to photo image */
int x, y;
Tk_PhotoImageBlock run;

/* Clear current contents */
Tk_PhotoBlank(photo);

/* Setup run descriptor */
run.height = 1;
run.pitch = block.pitch;
run.pixelSize = block.pixelSize;
run.offset[0] = 0;
run.offset[1] = 1;
run.offset[2] = 2;
run.offset[3] = 0; /* no alpha (or reserved, under 8.2) */

/* Copy opaque runs to photo image */
for (y = 0; y < block.height; y++) {
unsigned char* p = block.pixelPtr + y*block.pitch;
unsigned char* s = p;
int w = 0;
for (x = 0; x < block.width; x++) {
if (p[3]) {
/* opaque: add pixel to current run */
if (w == 0)
s = p;
w = w + 1;
} else if (s) {
/* copy run to photo image */
if (w > 0) {
run.width = w;
run.pixelPtr = s;
Tk_PhotoPutBlock(photo, &run, x-w, y, run.width, 1);
}
w = 0;
}
p += block.pixelSize;
}
if (w > 0) {
/* copy final run, if any */
run.width = w;
run.pixelPtr = s;
Tk_PhotoPutBlock(photo, &run, x-w, y, run.width, 1);
}
}

} else

/* Copy opaque block to photo image, and leave the rest to TK */
Tk_PhotoPutBlock(photo, &block, 0, 0, block.width, block.height);

#else /* Tk 8.4 and newer */
#if TK < 85 /* Tk 8.4 */
Tk_PhotoPutBlock(photo, &block, 0, 0, block.width, block.height,
TK_PHOTO_COMPOSITE_SET);
Expand All @@ -207,7 +153,6 @@ PyImagingPhotoPut(ClientData clientdata, Tcl_Interp* interp,
#else /* Tk 8.5 */
Tk_PhotoPutBlock(interp, photo, &block, 0, 0, block.width, block.height,
TK_PHOTO_COMPOSITE_SET);
#endif
#endif

return TCL_OK;
Expand Down

0 comments on commit f0ac7f6

Please sign in to comment.