TERMENI importanti pentru acest document
Using Metafiles with TkPrint 1.1
The latest release of TkPrint 1.1 introduces support for several types of Windows metafile formats. Metafiles are device independant image files that can be used to publish images on different media.
Windows metafiles come in at least 4 flavours, the original (pre Windows 3.0) format, the traditional Windows 3.0 and later format (.WMF) files, Aldus Placeable Metafile format, and the Enhanced Windows metafile format (.EMF) files. Of the 4 formats, only the latter two have any general appeal for image publishing, as they are scaleable. For post Windows 95 generation applications, only the last format is generally supported.
TkPrint 1.1 can produce traditional Windows metafiles (.WMF files), Aldus format files, and Enhanced Windows metafiles (.EMF files). Optionally, these files can be placed on the Windows clipboard, and subsequently pasted into some other application, such as Word, or any of the Microsoft Office utilities.
Enhanced Windows Metafiles
Enhanced format metafiles have the advantage that they are completely scalable, and that they support the newer Graphics Device Interface (GDI) calls. When pasted from the clipboard into some other applications, the image is automatically scaled to the target area specified for the image in the destination document.
The above image is a copy of a canvas widget that has the elements of text, lines ovals, an embedded text window, and an embedded button window. This canvas was generated by a Tk script, TkPrint 1.1 generated a metafile from the canvas, then copied the metafile to the clipboard. The clipboard metafile was then pasted into this Microsoft Word document.
Using Word, the image can be scaled by dragging the object frame. The following image demonstrated the effect of expanding the object frame:
Note that because the embedded windows are actually Windows Bitmaps, they do not scale smoothly, as do the other items of the canvas, which are drawn individually by GDI within the context of the scaled object frame.
Using the MetaFile Command
The format of the metafile command is:
MetaFile path ?-file? ?file? ?-clipboard? ?boolean? ?-format? ?format?
where path is the Tk path name to the canvas to be converted to a metafile, file is the name of the file to use if the metafile is to be written to disk, boolean can be “true” or “yes” or “1” to indicate that the metafile is to be put on the clipboard, and format can be “enhanced” or “aldus” or “windows” depending on the desired metafile format.
If neither file nor clipboard are specified as options, the metafile is printed on a windows printer. The file and clipboard options are mutually exclusive. If the clipboard option is specified, then before specifying the “aldus” format you should ensure that the target application will paste an Aldus format metafile. Most newer applications will only paste “windows” or “enhanced” format metafiles.
By default, the formatof the metafiles produced is “enhanced”. If the file option is used to specify a file name, TkPrint 1.1 will check the extension of the file name and determine the desired format. File names with the extension “.EMF” are Enhanced Windows format files, any other extension is assumed to be traditional Windows format unless the format option is used to override this assumption.
TkPrint 1.1 includes the PrintMetafile command that can be used to send a disk based metafile to a local Windows printer. The format of the command is:
where name is the name of the file to be printed. Again,the file name extension is used to presume the format of the metafile. Only .EMF and .WMF format files are supported for printing with this command.
TkPrint 1.1 command recognize a long list of options in addition to those described above. These options control pagination, titles, margins and scale factors that affect the final result. Consult the TkPrint online documentation for information on these options at
Of particular interes to scripts that print metafiles is the scale option that can be used to set the horizontal and vertical scales of the image on the printed page. The format of the option is:
Where horizontal and vertical are floating point numbers that are applied to the raw image before it is printed.
If only the horizontal value is given, the input image dimensions are used to preserve the aspect ratio of the printed image. Note also that all images, whatever their original size, are limited to the size of the printer page surface exclusive of any margins, headers or trailers.
Image Capture and Window Printing
TkPrint 1.1 provides a Capture command and a PrintWindow command that can be used to either capture a Tk window as an image file, print the window on a local printer, or copy the window to the clipboard.
This release of TkPrint 1.1 supports Tk window capture and printing at user specified color depth. For capture, the default color depth of the captured image is the color depth of the screen at the time of capture. For printing, the default color depth is the color depth of the target printer.
This release of TkPrint implements color space reduction, if required, using dithering. When needed, TkPrint 1.1 will reduce the color depth of the image to that supported by a printer, or the the level specified by the user through the colordepth option. TkPrint 1.1 can dither images of 16 of 24 bits of color depth down to either 8, 4 or 1 bit of color. Because the dither method is a bi-directional Floyd-Steinberg type of scheme with noise enhancement, there can be some images that look somewhat deteriorated when printed on a monochrome printer.
The ditering scheme uses a standard palette to produce its images, so choosing a color depth below 8 bits may result in noisy images.
The Capture command supports the clipboard option as well as the expected file option. When an Tk window is captured to the clipboard, TkPrint 1.1 places a Windows Device Independant Bitmap (DIB) on the clipboard. Thes images can then be pasted into a document and resized as needed using the object frame.
The above image was captured to the clipboard, pasted into this document, and reduced to fid on the preceeding page. The evident graininess is due to color dithering from 16 bits down to 8 bits of color depth. Using this method suffers from the disadvantages of scaling bitmaps, as opposed to GDI coordinate transfomation.
Copyright and Licence
All materials, programs, libraries, scripts and documents included with this distribution of TkPrint 1.1 are Copyright (C) I.B.Findleton, 1999, 2000.
Permission is granted for private, non-commercial use of the materials and software of this distribution. Redistribution for private, non-commercial use is permitted. Resale, commercial distribution or redistribution by any means for the purpose of making a profit is prohibited without the written permission of the author.
This software is offered without warranty of any kind. USE AT YOUR OWN RISK. The author assumes no responsibility for any loss or damage you might suffer as a result of using this software.
Politica de confidentialitate|
Adauga cod HTML in site