diff options
author | joye <joye> | 2013-09-13 17:18:30 (GMT) |
---|---|---|
committer | joye <joye> | 2013-09-13 17:18:30 (GMT) |
commit | 4067ea80bd24bc7f2289e46c93713d1d5330e93d (patch) | |
tree | 6a19a206557905d41b8fe1bc0e71c7b3f68460c2 /src/bltGrPSOutput.C | |
parent | fd5b88dc3d50931f3672b61a6c2a8ffc4afc7f61 (diff) | |
download | blt-4067ea80bd24bc7f2289e46c93713d1d5330e93d.zip blt-4067ea80bd24bc7f2289e46c93713d1d5330e93d.tar.gz blt-4067ea80bd24bc7f2289e46c93713d1d5330e93d.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src/bltGrPSOutput.C')
-rw-r--r-- | src/bltGrPSOutput.C | 285 |
1 files changed, 0 insertions, 285 deletions
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C index 1aff502..70ba09f 100644 --- a/src/bltGrPSOutput.C +++ b/src/bltGrPSOutput.C @@ -938,291 +938,6 @@ Blt_Ps_XSetStipple(Blt_Ps ps, Display *display, Pixmap bitmap) "grestore\n", (char *)NULL); } -static void -Base85Encode(Blt_DBuffer dBuffer, Tcl_DString *resultPtr) -{ - char *dp; - int count; - int length, nBytes, oldLength; - int n; - unsigned char *sp, *send; - - oldLength = Tcl_DStringLength(resultPtr); - nBytes = Blt_DBuffer_Length(dBuffer); - - /* - * Compute worst-case length of buffer needed for encoding. - * That is 5 characters per 4 bytes. There are newlines every - * 65 characters. The actual size can be smaller, depending upon - * the number of 0 tuples ('z' bytes). - */ - length = oldLength + nBytes; - length += ((nBytes + 3)/4) * 5; /* 5 characters per 4 bytes. */ - length += (nBytes+64) / 65; /* # of newlines. */ - Tcl_DStringSetLength(resultPtr, length); - - - n = count = 0; - dp = Tcl_DStringValue(resultPtr) + oldLength; - for (sp = Blt_DBuffer_Bytes(dBuffer), send = sp + nBytes; sp < send; - sp += 4) { - unsigned int tuple; - - tuple = 0; -#ifdef WORDS_BIGENDIAN - tuple |= (sp[3] << 24); - tuple |= (sp[2] << 16); - tuple |= (sp[1] << 8); - tuple |= sp[0]; -#else - tuple |= (sp[0] << 24); - tuple |= (sp[1] << 16); - tuple |= (sp[2] << 8); - tuple |= sp[3]; -#endif - if (tuple == 0) { - *dp++ = 'z'; - count++; - n++; - } else { - dp[4] = '!' + (tuple % 85); - tuple /= 85; - dp[3] = '!' + (tuple % 85); - tuple /= 85; - dp[2] = '!' + (tuple % 85); - tuple /= 85; - dp[1] = '!' + (tuple % 85); - tuple /= 85; - dp[0] = '!' + (tuple % 85); - dp += 5; - n += 5; - count += 5; - } - if (count > 64) { - *dp++ = '\n'; - n++; - count = 0; - } - } - - { - unsigned int tuple; - - /* Handle remaining bytes (0-3). */ - nBytes = (nBytes & 0x3); - sp -= nBytes; - tuple = 0; - switch (nBytes) { -#ifdef WORDS_BIGENDIAN - case 3: - tuple |= (sp[2] << 8); - case 2: - tuple |= (sp[1] << 16); - case 1: - tuple |= (sp[0] << 24); -#else - case 3: - tuple |= (sp[2] << 24); - case 2: - tuple |= (sp[1] << 16); - case 1: - tuple |= (sp[0] << 8); -#endif - default: - break; - } - if (nBytes > 0) { - tuple /= 85; - if (nBytes > 2) { - dp[3] = '!' + (tuple % 85); - n++; - } - tuple /= 85; - if (nBytes > 1) { - dp[2] = '!' + (tuple % 85); - n++; - } - tuple /= 85; - dp[1] = '!' + (tuple % 85); - tuple /= 85; - dp[0] = '!' + (tuple % 85); - *dp++ = '\n'; - n += 3; - } - Tcl_DStringSetLength(resultPtr, n); - } -} - -static void -AsciiHexEncode(Blt_DBuffer dBuffer, Tcl_DString *resultPtr) -{ - static char hexDigits[] = "0123456789ABCDEF"; - int length, oldLength; - int nBytes; - - /* - * Compute the length of the buffer needed for the encoding. That is 2 - * characters per byte. There are newlines every 64 characters. - */ - length = oldLength = Tcl_DStringLength(resultPtr); - nBytes = Blt_DBuffer_Length(dBuffer) * 2; /* Two characters per byte */ - length += nBytes; - length += (nBytes+63)/64; /* Number of newlines required. */ - Tcl_DStringSetLength(resultPtr, length); - { - unsigned char *sp, *send; - char *bytes, *dp; - int count, n; - - count = n = 0; - dp = bytes = Tcl_DStringValue(resultPtr) + oldLength; - for (sp = Blt_DBuffer_Bytes(dBuffer), - send = sp + Blt_DBuffer_Length(dBuffer); - sp < send; sp++) { - dp[0] = hexDigits[*sp >> 4]; - dp[1] = hexDigits[*sp & 0x0F]; - dp += 2; - n += 2; - count++; - if ((count & 0x1F) == 0) { - *dp++ = '\n'; - n++; - } - } - *dp++ = '\0'; - } -} - -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_DrawPicture -- - * - * Translates a picture into 3 component RGB PostScript output. Uses PS - * Language Level 2 operator "colorimage". - * - * Results: - * The dynamic string will contain the PostScript output. - * - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_DrawPicture(PostScript *psPtr, Blt_Picture picture, double x, double y) -{ - PageSetup *setupPtr = psPtr->setupPtr; - int w, h; - Blt_DBuffer dBuffer; - - w = Blt_PictureWidth(picture); - h = Blt_PictureHeight(picture); - Blt_Ps_Format(psPtr, - "gsave\n" - "/DeviceRGB setcolorspace\n" - "%g %g translate\n" - "%d %d scale\n", x, y, w, h); - if ((setupPtr->flags & PS_GREYSCALE) || (setupPtr->level == 1)) { - int strSize; - - strSize = (setupPtr->flags & PS_GREYSCALE) ? w : w * 3; - Blt_Ps_Format(psPtr, - "/picstr %d string def\n" - "%d %d 8\n" - "[%d 0 0 %d 0 %d]\n" - "{\n" - " currentfile picstr readhexstring pop\n" - "}\n", strSize, w, h, w, -h, h); - if (setupPtr->flags & PS_GREYSCALE) { - Blt_Picture greyscale; - - Blt_Ps_Append(psPtr, "image\n"); - greyscale = Blt_GreyscalePicture(picture); - dBuffer = Blt_PictureToDBuffer(picture, 1); - Blt_FreePicture(greyscale); - } else { - Blt_Ps_Append(psPtr, "false 3 colorimage\n"); - dBuffer = Blt_PictureToDBuffer(picture, 3); - } - AsciiHexEncode(dBuffer, &psPtr->dString); - Blt_DBuffer_Free(dBuffer); - } else { - Blt_Ps_Format(psPtr, - "<<\n" - "/ImageType 1\n" - "/Width %d\n" - "/Height %d\n" - "/BitsPerComponent 8\n" - "/Decode [0 1 0 1 0 1]\n" - "/ImageMatrix [%d 0 0 %d 0 %d]\n" - "/Interpolate true\n" - "/DataSource currentfile /ASCII85Decode filter\n" - ">>\n" - "image\n", w, h, w, -h, h); - dBuffer = Blt_PictureToDBuffer(picture, 3); - Base85Encode(dBuffer, &psPtr->dString); - Blt_DBuffer_Free(dBuffer); - } - Blt_Ps_Append(psPtr, "\ngrestore\n\n"); -} - -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_XDrawWindow -- - * - * Converts a Tk window to PostScript. If the window could not be - * "snapped", then a grey rectangle is drawn in its place. - * - * Results: - * None. - * - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_XDrawWindow(Blt_Ps ps, Tk_Window tkwin, double x, double y) -{ - Blt_Picture picture; - - picture = Blt_DrawableToPicture(tkwin, Tk_WindowId(tkwin), 0, 0, - Tk_Width(tkwin), Tk_Height(tkwin), GAMMA); - if (picture == NULL) { - /* Can't grab window image so paint the window area grey */ - Blt_Ps_VarAppend(ps, "% Can't grab window \"", Tk_PathName(tkwin), - "\"\n", (char *)NULL); - Blt_Ps_Append(ps, "0.5 0.5 0.5 setrgbcolor\n"); - Blt_Ps_XFillRectangle(ps, x, y, Tk_Width(tkwin), Tk_Height(tkwin)); - return; - } - Blt_Ps_DrawPicture(ps, picture, x, y); - Blt_FreePicture(picture); -} - -/* - *--------------------------------------------------------------------------- - * - * Blt_Ps_DrawPhoto -- - * - * Output a PostScript image string of the given photo image. The photo - * is first converted into a picture and then translated into PostScript. - * - * Results: - * None. - * - * Side Effects: - * The PostScript output representing the photo is appended to the - * psPtr's dynamic string. - * - *--------------------------------------------------------------------------- - */ -void -Blt_Ps_DrawPhoto(Blt_Ps ps, Tk_PhotoHandle photo, double x, double y) -{ - Blt_Picture picture; - - picture = Blt_PhotoToPicture(photo); - Blt_Ps_DrawPicture(ps, picture, x, y); - Blt_FreePicture(picture); -} - /* *--------------------------------------------------------------------------- * |