diff options
author | hobbs <hobbs> | 2002-10-10 07:25:23 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2002-10-10 07:25:23 (GMT) |
commit | 07bae53a89026d0bc2c8f6635c8586648a52b32e (patch) | |
tree | 250461cd6dd036597827c9fd5f9314674f2a8818 /generic | |
parent | ea99cee25a420695da7bd29c5192575f9d34907d (diff) | |
download | tk-07bae53a89026d0bc2c8f6635c8586648a52b32e.zip tk-07bae53a89026d0bc2c8f6635c8586648a52b32e.tar.gz tk-07bae53a89026d0bc2c8f6635c8586648a52b32e.tar.bz2 |
* tests/canvPs.test: tests for canvas embedded window ps generation
* generic/tkCanvWind.c (CanvasPsWindow): removed dead code loop.
* generic/tkCanvas.h: moved TkColormapData struct to tkCanvPs.c
* generic/tkCanvPs.c (TkImageGetColor): corrected bogus use of
TkColormapData on Windows. Non-separated data may need correction
as well.
* win/tkWinImage.c (XGetImage, XGetImageZPixmap): added support
for generating ps for embedded windows on canvases.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkCanvPs.c | 50 | ||||
-rw-r--r-- | generic/tkCanvWind.c | 9 | ||||
-rw-r--r-- | generic/tkCanvas.h | 16 |
3 files changed, 38 insertions, 37 deletions
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index 643f2a9..b72ded9 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvPs.c,v 1.10 2002/08/05 04:30:38 dgp Exp $ + * RCS: @(#) $Id: tkCanvPs.c,v 1.11 2002/10/10 07:25:24 hobbs Exp $ */ #include "tkInt.h" @@ -23,6 +23,20 @@ */ /* + * The following definition is used in generating postscript for images + * and windows. + */ + +typedef struct TkColormapData { /* Hold color information for a window */ + int separated; /* Whether to use separate color bands */ + int color; /* Whether window is color or black/white */ + int ncolors; /* Number of color values stored */ + XColor *colors; /* Pixel value -> RGB mappings */ + int red_mask, green_mask, blue_mask; /* Masks and shifts for each */ + int red_shift, green_shift, blue_shift; /* color band */ +} TkColormapData; + +/* * One of the following structures is created to keep track of Postscript * output being generated. It consists mostly of information provided on * the widget command line. @@ -458,12 +472,13 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) /* * Insert the prolog */ - Tcl_AppendResult(interp, Tcl_GetVar(interp,"::tk::ps_preamable",TCL_GLOBAL_ONLY), (char *) NULL); + Tcl_AppendResult(interp, Tcl_GetVar(interp,"::tk::ps_preamable", + TCL_GLOBAL_ONLY), (char *) NULL); + if (psInfo.chan != NULL) { Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1); Tcl_ResetResult(canvasPtr->interp); } - /* *----------------------------------------------------------- @@ -1118,13 +1133,24 @@ TkImageGetColor(cdata, pixel, red, green, blue) int r = (pixel & cdata->red_mask) >> cdata->red_shift; int g = (pixel & cdata->green_mask) >> cdata->green_shift; int b = (pixel & cdata->blue_mask) >> cdata->blue_shift; - *red = cdata->colors[r].red / 65535.0; +#ifdef WIN32 + /* + * Because XQueryColors is an empty stub on Windows, we need + * to just make this simple calculation. The TkColormapData + * XColor data is otherwise bogus on Windows. -- hobbs + */ + *red = (double)r / 255.0; + *green = (double)g / 255.0; + *blue = (double)b / 255.0; +#else + *red = cdata->colors[r].red / 65535.0; *green = cdata->colors[g].green / 65535.0; - *blue = cdata->colors[b].blue / 65535.0; + *blue = cdata->colors[b].blue / 65535.0; +#endif } else { - *red = cdata->colors[pixel].red / 65535.0; + *red = cdata->colors[pixel].red / 65535.0; *green = cdata->colors[pixel].green / 65535.0; - *blue = cdata->colors[pixel].blue / 65535.0; + *blue = cdata->colors[pixel].blue / 65535.0; } } @@ -1218,7 +1244,6 @@ TkPostscriptImage(interp, tkwin, psInfo, ximage, x, y, width, height) else cdata.color = 1; - XQueryColors(Tk_Display(tkwin), cmap, cdata.colors, ncolors); /* @@ -1241,8 +1266,7 @@ TkPostscriptImage(interp, tkwin, psInfo, ximage, x, y, width, height) * Postscript interpreter). */ - switch (level) - { + switch (level) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; case 2: bytesPerLine = 3 * width; maxWidth = 20000; break; @@ -1323,9 +1347,7 @@ TkPostscriptImage(interp, tkwin, psInfo, ximage, x, y, width, height) TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); sprintf(buffer, "%02X", (int) floor(0.5 + 255.0 * - (0.30 * red + - 0.59 * green + - 0.11 * blue))); + (0.30 * red + 0.59 * green + 0.11 * blue))); Tcl_AppendResult(interp, buffer, (char *) NULL); lineLen += 2; if (lineLen > 60) { @@ -1340,7 +1362,7 @@ TkPostscriptImage(interp, tkwin, psInfo, ximage, x, y, width, height) * Finally, color mode. Here, just output the red, green, * and blue values directly. */ - for (xx = x; xx < x+width; xx++) { + for (xx = x; xx < x+width; xx++) { TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), &red, &green, &blue); sprintf(buffer, "%02X%02X%02X", diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c index c197584..b82efa1 100644 --- a/generic/tkCanvWind.c +++ b/generic/tkCanvWind.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvWind.c,v 1.7 2002/08/05 04:30:38 dgp Exp $ + * RCS: @(#) $Id: tkCanvWind.c,v 1.8 2002/10/10 07:25:24 hobbs Exp $ */ #include <stdio.h> @@ -845,7 +845,6 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height) int width, height; /* width/height of window. */ { char buffer[256]; - TkWindow *winPtr; XImage *ximage; int result; Tcl_DString buffer1, buffer2; @@ -885,12 +884,6 @@ CanvasPsWindow(interp, tkwin, canvas, x, y, width, height) (char *) NULL); Tcl_DStringFree(&buffer1); - for (winPtr = ((TkWindow *) tkwin)->childList; winPtr != NULL; - winPtr = winPtr->nextPtr) { - if (Tk_IsMapped(winPtr)) { -/* printf("child window: %s\n", winPtr->pathName);*/ - } - } return result; } Tcl_DStringFree(&buffer1); diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index 70cb03d..cb601a9 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvas.h,v 1.5 2002/08/05 04:30:38 dgp Exp $ + * RCS: @(#) $Id: tkCanvas.h,v 1.6 2002/10/10 07:25:24 hobbs Exp $ */ #ifndef _TKCANVAS @@ -295,18 +295,4 @@ typedef struct TkCanvas { extern int TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr, Tcl_Interp *interp, int argc, CONST char **argv)); -/* - * The following definition is shared between tkCanvPs.c and tkCanvImg.c, - * and is used in generating postscript for images and windows. - */ - -typedef struct TkColormapData { /* Hold color information for a window */ - int separated; /* Whether to use separate color bands */ - int color; /* Whether window is color or black/white */ - int ncolors; /* Number of color values stored */ - XColor *colors; /* Pixel value -> RGB mappings */ - int red_mask, green_mask, blue_mask; /* Masks and shifts for each */ - int red_shift, green_shift, blue_shift; /* color band */ -} TkColormapData; - #endif /* _TKCANVAS */ |