|
List Info
Thread: Patch: alpha-channel support for ImageTk
|
|
| Patch: alpha-channel support for
ImageTk |

|
2007-02-27 10:35:42 |
Hello!
Since 8.4.4 Tk support alpha blending for images with
partial
transparency.
This patch added alpha-channel support for ImageTk.
== patch ==
--- Tk/tkImaging.c.orig 2007-02-26 22:33:45.000000000 +0300
+++ Tk/tkImaging.c 2007-02-27 15:30:31.000000000 +0300
 -39,10
+39,7 
* See the README file for information on usage and
redistribution.
*/
-/* This is needed for (at least) Tk 8.4.1, otherwise the
signature of
-** Tk_PhotoPutBlock changes.
-*/
-#define USE_COMPOSITELESS_PHOTO_PUT_BLOCK
+#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 +
TK_MINOR_VERSION)
/* This is needed for (at least) Tk 8.4.6 and later, to
avoid warnings
for the Tcl_CreateCommand command. */
 -125,7
+122,7 
block.offset[0] = 0;
block.offset[1] = 1;
block.offset[2] = 2;
- block.offset[3] = 0; /* no alpha (or reserved, under 8.2)
*/
+ block.offset[3] = 3; /* alpha (or reserved, under 8.2) */
} else {
Tcl_AppendResult(interp, "Bad mode",
(char*) NULL);
return TCL_ERROR;
 -141,6
+138,7 
src_xoffset * im->pixelsize;
#endif
+#if TKMAJORMINOR < 8004 /* Tk < 8.4.0 */
if (strcmp(im->mode, "RGBA") == 0) {
/* Copy non-transparent pixels to photo image */
int x, y;
 -193,6
+191,15 
/* 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.0 */
+ Tk_PhotoPutBlock(photo, &block, 0, 0, block.width,
block.height,
+ TK_PHOTO_COMPOSITE_SET);
+ if (strcmp(im->mode, "RGBA") == 0)
+ /* Tk workaround: we need apply
ToggleComplexAlphaIfNeeded */
+ /* (fixed in Tk 8.5a3) */
+ Tk_PhotoSetSize(photo, block.width, block.height);
+#endif
+
return TCL_OK;
}
== end ==
--
wbr, con
Today is Pungenday, the 58th day of Chaos in the YOLD 3173
_______________________________________________
Image-SIG maillist - Image-SIG python.org
htt
p://mail.python.org/mailman/listinfo/image-sig
|
|
|
| Re: Patch: alpha-channel support for
ImageTk |

|
2007-03-01 07:56:25 |
Hello!
I found bug in previous patch. This patch more correct.
== patch ==
--- Tk/tkImaging.c.orig 2007-02-26 22:33:45.000000000 +0300
+++ Tk/tkImaging.c 2007-03-01 16:46:18.000000000 +0300
 -39,10
+39,7 
* See the README file for information on usage and
redistribution.
*/
-/* This is needed for (at least) Tk 8.4.1, otherwise the
signature of
-** Tk_PhotoPutBlock changes.
-*/
-#define USE_COMPOSITELESS_PHOTO_PUT_BLOCK
+#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 +
TK_MINOR_VERSION)
/* This is needed for (at least) Tk 8.4.6 and later, to
avoid warnings
for the Tcl_CreateCommand command. */
 -125,7
+122,10 
block.offset[0] = 0;
block.offset[1] = 1;
block.offset[2] = 2;
- block.offset[3] = 0; /* no alpha (or reserved, under 8.2)
*/
+ if (strcmp(im->mode, "RGBA") == 0)
+ block.offset[3] = 3; /* alpha (or reserved,
under 8.2) */
+ else
+ block.offset[3] = 0; /* no alpha */
} else {
Tcl_AppendResult(interp, "Bad mode",
(char*) NULL);
return TCL_ERROR;
 -141,6
+141,7 
src_xoffset * im->pixelsize;
#endif
+#if TKMAJORMINOR < 8004 /* Tk < 8.4.0 */
if (strcmp(im->mode, "RGBA") == 0) {
/* Copy non-transparent pixels to photo image */
int x, y;
 -193,6
+194,15 
/* 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.0 */
+ Tk_PhotoPutBlock(photo, &block, 0, 0, block.width,
block.height,
+ TK_PHOTO_COMPOSITE_SET);
+ if (strcmp(im->mode, "RGBA") == 0)
+ /* Tk workaround: we need apply
ToggleComplexAlphaIfNeeded */
+ /* (fixed in Tk 8.5a3) */
+ Tk_PhotoSetSize(photo, block.width, block.height);
+#endif
+
return TCL_OK;
}
== end ==
--
wbr, con
Today is Setting Orange, the 60th day of Chaos in the YOLD
3173
_______________________________________________
Image-SIG maillist - Image-SIG python.org
htt
p://mail.python.org/mailman/listinfo/image-sig
|
|
|
[1-2]
|
|