summaryrefslogtreecommitdiffstats
path: root/win
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 /win
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 'win')
-rw-r--r--win/tkWinRegion.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c
index 8a50620..27a74b5 100644
--- a/win/tkWinRegion.c
+++ b/win/tkWinRegion.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinRegion.c,v 1.3 2002/06/14 13:35:49 dkf Exp $
+ * RCS: @(#) $Id: tkWinRegion.c,v 1.4 2004/10/26 13:15:09 dkf Exp $
*/
#include "tkWinInt.h"
@@ -147,6 +147,67 @@ TkUnionRectWithRegion(rectangle, src_region, dest_region_return)
/*
*----------------------------------------------------------------------
*
+ * 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;
+ HRGN rectRgn = CreateRectRgn(0,0,1,1); /* Workspace region. */
+
+ 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) {
+ /*
+ * Manipulate Win32 regions directly; it's more efficient.
+ */
+ SetRectRgn(rectRgn, x+x1, y+y1, x+end, y+y1+1);
+ CombineRgn((HRGN) region, (HRGN) region, rectRgn, RGN_OR);
+ }
+ }
+ dataPtr += lineStride;
+ }
+
+ DeleteObject(rectRgn);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkRectInRegion --
*
* Test whether a given rectangle overlaps with a region.