- Created by David Stevenson, last modified on Aug 08, 2019
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 6 Next »
Introduction
ITransforms
provide a method of applying common operations on DOM objects such as brushes, nodes, colors, colorspaces or entire trees.
For example, there are many built-in transforms in Mako for:
- Image downsampling (
IImageDownsamplerTransform
) - Color conversion (
IColorConverterTransform
) - Color simplification (
IComplexColorSimplifierTransform
) - Image merging (
IImageMergerTransform
) - Remove non-visible Optional Content (
IOptionalContentFixerTransformPtr
)
Thus, transforms simplify complex operations to be applied to a number of DOM objects in one go.
A custom transform enables a Mako SDK developer to take advantage of the ITransforms framework for their own purposes.
Custom Transform header
A framework to enable development of custom transforms is provided as a header, customtransform.h
.
It's not part of the standard distribution, but can be downloaded from the link shown on the right of this page. Note that there are two versions, one for pre-Mako 4.8 and another for Mako 4.8. Mako 4.8 introduces a mechanism for aborting a transform operation, so the Mako 4.8 header must be used with Mako 4.8.
A custom transform implements call backs for the DOM objects listed below. All you need do is override the cases you are interested in, providing one or more methods for actually doing the work
For example, let's say you wanted to find out information for every image in a document. You could write a custom transform to override transformImageBrush()
. Your code will be called every time an imagebrush (IDOMImageBush
) is encountered, and from there get to the image (IDOMImage
) and its frame (IDOMFrame
) to obtain all the information you need - size, resolution, colorspace etc. You would run the transform on a page and repeat for all pages in a document.
A more likely scenario is one where you want to change the object in some way. Your implementation can do this, returning the updated object or a NULL if you want it removed from the DOM tree.
IDOM object | Description | IDOM object | Description | |
---|---|---|---|---|
IAnnotationAppearance | Annotation appearance | IDOMForm | The children of this node type comprise the contents of a PDF/PS style form. (XForm) | |
IDOMColor | Color | IDOMFormInstance | A node whose content must be an IDOMForm | |
IDOMColorSpace | Color space | IDOMBrush | The parent class for the many brush types. Brushes are used to fill paths, ie a defined geometric region on the page | |
IDOMImage | Base class describing an image | IDOMSolidColorBrush | A solid color brush is used to fill a path with a solid color | |
IDOMNode | Base class for the many DOM node types | IDOMGradientBrush | The parent class for linear and radial gradient brushes | |
IDOMFixedPage | The contents of a page | IDOMLinearGradientBrush | A linear gradient brush is used to specify a gradient along a vector | |
IDOMGroup | A DOM node representing Group Elements. A group of IDOMNodes that share common properties such as a clipping path or render transform | IDOMRadialGradientBrush | A radial gradient brush defines an ellipse to be filled with a gradient | |
IDOMCharPathGroup | A DOM node representing Group Elements that consist of stroked text | IDOMVisualBrush | A visual brush is used to fill a path with a vector drawing | |
IDOMTransparencyGroup | A DOM node representing Group Elements that share common transparency settings. Analogous to PDF Transparency Groups. | IDOMImageBrush | An image brush is used to fill a path with an image | |
IDOMCanvas | A canvas is a special form of an isolated, non-knockout, normal | IDOMTilingPatternBrush | A tiling pattern brush is used to fill a path with a PS-style tiling pattern. | |
IDOMGlyphs | Glyphs nodes are used to represent a run of uniformly formatted text from a single font | IDOMShadingPatternBrush | A shading pattern brush is used to fill a defined geometric region | |
IDOMFont | Font base class | IDOMSoftMaskBrush | A soft mask brush provides a way of representing a PDF-style soft mask in its entirety. It will contain a suitable IDOMTransparency group as well as the necessary soft mask details | |
IDOMPathNode | A path node specifies geometry that can be filled with a brush | IDOMMaskedBrush | A masked brush describes a generalization of a masked image | |
IDOMVisualRoot | Special node type used by XPS for the root node inside a visual | IDOMNullBrush | A null brush |
CTransformState
Class for tracking the graphics state leading to the point where a transform is applied.
Consider for example the IImageDownsamplerTransform described elsewhere. In order to determine how to downsample an image, the transform needs to know how large the image will eventually be. The CTransformState provides this information by providing the combined transform that applies to the image based on the RenderTransforms of all the nodes entered leading to the point where the image is actually encountered.
Other transforms need access to other information, such as the approximate clip area, the current group color space, the renderingIntent (if present), the current antialiasing mode (edge mode) and/or how a brush is used.
CTransformState::transformPriv
New to Mako 4.8.0, this member can be used to track extra information needed by the transform process.
Custom Transform headers
Mako 4.7 or earlier | Mako 4.8 |
---|---|
- No labels