summaryrefslogtreecommitdiffstats
path: root/unix/tkUnix.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-26 13:15:07 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-26 13:15:07 (GMT)
commitb646dee7570b4d082ceac3d8a05e48f45eacbfc5 (patch)
tree3ac49ba01df01ed987ab98e03f908435a0256200 /unix/tkUnix.c
parent36091348f8af6507a2beef8d03568d26b45bd2c8 (diff)
downloadtk-b646dee7570b4d082ceac3d8a05e48f45eacbfc5.zip
tk-b646dee7570b4d082ceac3d8a05e48f45eacbfc5.tar.gz
tk-b646dee7570b4d082ceac3d8a05e48f45eacbfc5.tar.bz2
Attempt to fix [Bug 919066] by allowing the code that creates the region
much more knowledge of the platform functions available to it.
Diffstat (limited to 'unix/tkUnix.c')
-rw-r--r--unix/tkUnix.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/unix/tkUnix.c b/unix/tkUnix.c
index 0d6ecc5..65f1a90 100644
--- a/unix/tkUnix.c
+++ b/unix/tkUnix.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnix.c,v 1.5 2002/01/25 21:09:37 dgp Exp $
+ * RCS: @(#) $Id: tkUnix.c,v 1.6 2004/10/26 13:15:09 dkf Exp $
*/
#include <tkInt.h>
@@ -106,3 +106,62 @@ Tk_UpdatePointer(tkwin, x, y, state)
* This function intentionally left blank
*/
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpBuildRegionFromAlphaData --
+ *
+ * Set up a rectangle of the given region based on the supplied
+ * alpha data.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * The region is updated, with extra pixels added to it.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr,
+ pixelStride, lineStride)
+ TkRegion region;
+ unsigned int x, y; /* Where in region to update. */
+ unsigned int width, height; /* Size of rectangle to update. */
+ unsigned char *dataPtr; /* Data to read from. */
+ unsigned int pixelStride; /* num bytes from one piece of alpha
+ * data to the next in the line. */
+ unsigned int lineStride; /* num bytes from one line of alpha
+ * data to the next line. */
+{
+ unsigned char *lineDataPtr;
+ unsigned int x1, y1, end;
+ XRectangle rect;
+
+ for (y1 = 0; y1 < height; y1++) {
+ lineDataPtr = dataPtr;
+ for (x1 = 0; x1 < width; x1 = end) {
+ /* search for first non-transparent pixel */
+ while ((x1 < width) && !*lineDataPtr) {
+ x1++;
+ lineDataPtr += pixelStride;
+ }
+ end = x1;
+ /* search for first transparent pixel */
+ while ((end < width) && *lineDataPtr) {
+ end++;
+ lineDataPtr += pixelStride;
+ }
+ if (end > x1) {
+ rect.x = x + x1;
+ rect.y = y + y1;
+ rect.width = end - x1;
+ rect.height = 1;
+ TkUnionRectWithRegion(&rect, region, region);
+ }
+ }
+ dataPtr += lineStride;
+ }
+}