Raster Graphics Operators

Model for Raster Graphics

Raster graphics refers to the representation of graphical information by means of information about a rectangular array of rectangular elements called picture elements or pels. This information can be used in either of two ways

The first type of raster graphics is called bitmap raster graphics. Bitmap raster graphics are provided in SPDL by means of the MaskBitMap operator. The second type of raster graphics is called sampled raster graphics. Sampled raster graphics are provided by the ImageRasterElement operator.

Both types of raster graphics require similar facilities for the acquisition and processing of the raster graphics image data. They differ primarily in that the raster graphics image data used for bitmap raster graphics consists of a Boolean value for each pel which specifies whether or not that pel is inside the shape being defined, whereas the raster graphics image data used for sampled raster graphics may involve more complex values which specify the value and/or color of each pel.

The operators and data types for raster graphics make possible the presentation of large raster graphics elements even on printers that are incapable of storing all of the raster graphics image data required for a raster graphics image element prior to imaging. It also provides flexibility in the format of raster graphics image data, so that the output of many types of scanners, possibly compressed via a variety of data compression algorithms, can be used. It is important to note that SPDL specifies the effect to be achieved in the imaging of a raster graphics element, and not the technique used to produce this effect. It is unlikely that real implementations will perform all of the intermediate steps described in the definitions of the raster imaging operators. The purpose of these descriptions is to facilitate the independent binding of the major components of the raster imaging process to a particular instance of such imaging, and to allow the precise description of the required end result.

Sampled Raster Graphics

A sampled raster graphics representation of an image consists of information about the color and/or intensity of the image at a large number of sample points from which the image may be reconstructed. The individual units of information are called sample values, and the collection of the sample values for a particular image is called the sample data for that image. Such raster graphics image data can be produced by scanners by taking measurements on an existing picture at each of the points of a sampling grid, or may be generated synthetically by graphics systems.

The process of scanning a picture to produce a sampled image consists of two main steps:

The reconstruction of a graphic image from the sampled data requires that these steps be reversed. The model for the reconstruction and imaging of a raster graphics image involves four steps: the following description is a conceptual overview; it is not intended as a complete description of the reconstruction; that is given in below.

Examples of sample value vectors are a single element vector consisting of a gray level or a three element vector consisting of a set of RGB color components. When rendering the page image onto an instance of the media, presentation devices frequently increase their apparent gamuts of visible color by approximating colors which they cannot reproduce directly with spatially dispersed patterns of spots of their primary colors. A common use of this technique is the halftone rendering of images on black-and-white devices to produce the appearance of gray-scale colors. It is also common for raster image creation devices to produce image data which already incorporates such methods for color gamut extension. Such a device might for example, produce bi-level raster data for the representation of gray-scale photographic images. The SPDL raster graphics imaging operators allow the use of either technique for the representation of raster graphics images.

Bitmap Raster Graphics

Bitmap raster graphics image data consists of a Boolean value for each pel which specifies whether or not that pel is inside the shape being defined. The aggregate of the bitmap raster graphics image data defines a shape which is used as a mask for a imaging operator. For each sample in the bitmap raster graphics image data, one of the Boolean values indicates that the sample is in the opaque part of the mask, and the other Boolean value indicates that the sample is in the part of the mask through which ink is deposited. Which values correspond to the opaque part of the mask and which value correspond to the part of the mask through which ink is deposited is specified by the Decode key in the image Dictionary operand to the MaskBitMap operator (see 28.2.1.2).

Although bitmap raster graphics image data is logically two-valued, the manipulation of the raster graphics image data to obtain the final values used to define the mask frequently requires the same kinds of operations as are required for sampled raster graphics image data. For this reason SPDL uses the same facilities for the manipulation of bitmap raster graphics image data and sampled raster graphics image data.

Raster Graphics Image Data

Three important characteristics of raster graphics technology are

While the first of these is applicable only to sampled images, the later two are equally applicable to bitmap raster data.

As a result of these characteristics it is not reasonable to require that all systems which deal with raster graphic data translate all raster data into a single standard representation in order to be able to use the SPDL syntax and semantics. SPDL defines a syntax for raster graphics image processing which allows for the use of non-standard as well as standard color representation methods and data compression methods. SPDL defines standard ways of specifying those methods which will be supported by every implementation; however, the syntax is capable of supporting the use of non-standard methods for private interchange.

Image Dictionaries

Both the ImageRasterElement and MaskBitMap operators take a reference to an image Dictionary as their single explicit operand. An image Dictionary is a self-contained collection of all the parameters necessary for imaging a sampled or bitmap raster graphics image. The contents of the image Dictionary specify the following:

Image Dictionary Contents and Semantics

The required and optional image Dictionary key/value pairs are:

DataSources

The mandatory key/value pair <DataSources: Vector> references a Vector of data sources. A detailed description of the required contents of DataSources in both single and multiple data source cases is given in .

Width

The mandatory key/value pair <Width: Cardinal> specifies the width of the image or mask bitmap in samples.

Height

The mandatory key/value pair <Height: Cardinal> specifies the height of the image or mask bitmap in samples.

BitsPerComponent

The mandatory key/value pair <BitsPerComponent: Cardinal> specifies the number of bits used to represent each color component. The BitsPerComponent key/value pair specifies how to decompose the raster graphics image data into Cardinal sample values between 0 and (2 ˜ BitsPerComponent)-1. In decomposing the data, the ImageRasterElement and MaskBitMap operators read the octets of the data in the order in which they are obtained from the data source, and reads bits starting with the high-order bit of each octet. For each sample value, the first bit read is the high order bit of that sample value. Subsequent bits are the next lower order bits. Allowed values for BitsPerComponent are 1, 2, 4, 8, and 12. If the image Dictionary is an operand to the MaskBitMap operator, the value bound to the BitsPerComponent key shall be 1. Each row of sample values shall begin on an octet boundary. If a row of sample values is not an integral number of octets long the data shall be padded with enough bits to fill the last octet.

Decode

The mandatory key/value pair <Decode: VectorReference> references a Vector called the Decode Vector. If the image Dictionary is an operand to the ImageRasterElement operator, the Decode Vector specifies the mapping of the sample values to the range of values appropriate to the corresponding color space components. If the image Dictionary is an operand to the MaskBitMap operator, the Decode Vector specifies the polarity of the mask. A detailed description of the required contents of the Decode Vector in each case is given in .

Interpolate

The optional key/value pair <Interpolate: Boolean> specifies whether image interpolation is to be perfomed (if the implementation is capable of doing so). See . A value of true specifies that image interpolation is to be performed. A value of false specifies no image interpolation is to be performed. If this key is not in the image Dictionary, the default value is false.

ImageMatrix

The mandatory key/value pair <ImageMatrix: Transformation> specifies a transformation of the image. The raster graphics image is considered to exist in its own rectangular image coordinate space whose lower-left corner is (0,0) and whose upper-right corner is (Width,Height). The rows of a raster graphics image are the set of samples with the same first coordinate value. The columns of a raster graphics image are the set of samples with the same second coordinate value. ImageMatrix specifies the mapping from User Coordinate Space to this image coordinate space.

Data Sources

The image Dictionary contains key/value pairs specifying the Width and Height of the raster graphics image data in samples. The sample or bitmap mask values acquired by the raster graphics operators during decomposition are interpreted as a rectangular array and are assumed to be acquired in a fixed order: (0,0) through (Width-1,0), then (0,1) through (Width-1,1), until (0, Height-1) through (Width-1, Height-1). It is the responsibility of the data sources specified in the DataSources image Dictionary key/value pair to provide octets of data in such a manner that decomposition yields correct sample values in this order. If the image Dictionary is used as the operand of a MaskBitMap operator, the value of the DataSources key in the image Dictionary shall be a reference to a single-element DataSources Vector.

Single-element DataSources Vector

If the value DataSources key in the image Dictionary is a reference to a single-element Vector, it is assumed to specify a single data source. If the current color space has more than one component, the data for all color components is assumed to be acquired from the data source in bit-wise order, interleaved on a per-sample basis. The set of allowable data sources types is:

If the data source is of type StreamObject, there shall be sufficient data available to the decomposition process to produce the required number of samples. StreamObjects may be created in content by the Filter operator (see ) or the FindResource operator (see ). StreamObjects created by the FindResource operator may be filtered, depending on the Data Source resource bound to the INTERNAL RESOURCE IDENTIFIER operand to the FindResource operator, as follows:

If the data source is of type OctetString, the octets that make up the OctetString are taken in sequential order as octets of image or bitmap mask data. If the length of the OctetString is insufficient to provide the required number of samples, the data in the OctetString is re-used repeatedly until the required number of samples have been extracted.

If the data source is of type Procedure, when executed it shall return (on the Operand Stack) an OctetString containing octets of sampled raster graphics or bitmap mask data. If the data in the OctetString is exhausted before the required number of samples have been extracted, the Procedure is called repeatedly to return new OctetStrings of data until the required number of samples have been extracted. The Procedure may not execute the ImageRasterElement or MaskBitMap operators. The Procedure should not alter the contents of the image Dictionary or the graphics state; the effect of such actions is not defined in this International Standard and may cause unpredictable and undesirable results.

Multi-element DataSources Vector

If the value bound to the DataSources key in the image Dictionary is a reference to a multi-element Vector, it is assumed to specify multiple data sources; one data source per color component in the current color space. Data for each color component of the current color space is drawn from a different data source. All elements of the DataSources Vector shall be of the same type, and the ordering of the data sources in the Vector shall match the ordering of the required color components for the current color space.

In the multiple data sources case, each data source shall meet the requirements set forth above for the single data source case. In addition, the following restrictions also apply:

In-Line Data

SPDL provides for the inclusion of raster graphics image data in documents, termed in-line data, via the DataBlock content token type. This token type, represents a sequence of octets, and is defined for documents in both the Binary or Clear Text Representation and Interchange Format in and . In documents in the Binary Representation and Interchange Format, these octet sequences represent binary raster graphics image data; in documents in the Clear Text Representation and Interchange Format the octet sequences represent ASCII85-encoded raster graphics image data (see and ).

The use of in-line raster graphics image data shall be as follows:

In-line data shall be placed in content so as to be accessible by the raster graphics imaging operator when the operator is actually interpreted. Thus, if the raster graphics imaging operator occurs inside a Procedure which is interpreted by a looping operator (for example, the For operator), the in-line data for all interpretations of the raster graphics imaging operator in the loop shall immediately follow the looping operator in the form of one or more DataBlock tokens. The order of these sequences shall correspond to the sequential order of interpretation of the raster graphics imaging operator in the loop, and the data for each interpretation of the raster graphics imaging operator shall begin with a new DataBlock token.

A DataBlock token encountered in content other than where necessary as a data source for an imaging operator shall result in RaiseError being invoked with SyntaxError as its operand.

Decode Vector

In an image Dictionary used as an operand to the ImageRasterElement operator, the value bound to the BitsPerComponent key in the image Dictionary specifies how to decompose the raster graphics image data into sample values. The Decode Vector specifies a linear mapping of the sample values into the range of values appropriate to each color component of the current color space. For each color component, a minimum and maximum value for the mapping are specified, and the linear mapping will be

  • OutputValue = MIN + InputValue × (MAX - MIN) / N where

    The numbers in the Decode Vector are interpreted in pairs, with each pair applying to the one component of the current color space. Thus the length of the Decode Vector shall be twice the number of color components in the current color space, and the ordering of the MIN/MAX pairs in the Decode Vector shall match the ordering of the required color components for the current color space. If an OutPutValue falls beyond the valid range for the color component, the OutputValue will be set to the nearest value in the valid range.

    In an image Dictionary used as an operand to the MaskBitMap operator, the Decode Vector is a two-element Vector which specifies the polarity of the mask. The two allowed values of the Decode Vector in this case, and their meanings, are shown in : Valuemeaning [0 1]Sample values of 0 are painted with the current color; sample values of 1 correspond to the opaque part of the mask [1 0]Sample values of 1 are painted with the current color; sample values of 0 correspond to the opaque part of the mask

    Interpolation

    When the resolution of the source image is significantly lower than the resolution of the presentation device, each source sample covers many pixels of the device; this can result in poor output appearance. These visual artifacts can be reduced by interpolation between adjacent sample values. If the value bound to the Interpolate key in an image Dictionary is true, this is an indication to the implementation that interpolation is desired. There are, however, no interpolation algorithms defined by this International Standard. The nature and implementation of interpolation algorithms can depend on the device on which the output of processing is being realized. Hence, the choice of interpolation algorithm, if any, is left to the implementation.

    Operators

    The specification of these operators and their semantics includes the specification of conditions which may cause content exceptions to be raised as a result of interpretation of the operators. Content exceptions and exception handling are defined in . In addition to these operator-specific exceptions, there are generic exceptions which may be raised during the interpretation of almost any operator. These generic exceptions and their semantics are described in .

    ImageRasterElement

    The ImageRasterElement imaging operator accepts one explicit operand

  • <imagedictionary: DictionaryReference> and returns no results. The ImageRasterElement operator uses the information in the imagedictionary to acquire sample values, interpret them, and image the raster graphics image data.

    The set of mandatory key/value pairs is checked. If any keys are missing, RaiseError shall be invoked with UndefinedKey as its operand. If the key is present but the value bound to it is of the wrong type, RaiseError shall be invoked with TypeCheck as its operand. If the key is present and the type is correct but the bound value is out of range, RaiseError shall be invoked with RangeCheck as its operand.

    If any DataSources are Procedures which execute the ImageRasterElement or MaskBitMap operator, RaiseError shall be invoked with UndefinedKey as its operand. If there are multiple DataSources and any one terminates before the others (either due to an End-Of-Data condition on a StreamObject or due to a Procedure returning a empty OctetString), RaiseError shall be invoked with RangeCheck as its operand. If there is only one element in DataSources and it terminates before the complete rectangular array is imaged, then RaiseError will not be invoked and the page image will have that portion of the array that was imaged except that the last row imaged may not be present if it was not a full row. If there are problems in any StreamObject that is an element in DataSources, RaiseError shall be invoked with IOError or DataError, as appropriate, as its operand.

    The input to the imaging activity is a sequence of sample values to be imaged as a rectangular array. Each sample value corresponds to a unit rectangle in the image coordinate system described in the ImageMatrix key/value pair in the imagedictionary. The order of the sample values is specified in .

    The inverse of the ImageMatrix transformation transforms and positions the image coordinate space into the UCS. It is often simpler to position a sampled raster graphic image on a page by splitting the positioning into three simple transformations. First the ImageMatrix transformation is defined to map the unit square in UCS into the image coordinate space and to handle the scanline order of the image data. A Width by Height image that was scanned from left to right within a line and from top to bottom among the lines (the first sample is in the top left corner) would have an ImageMatrix of [Width 0 0 -Height 0 Height]. Then, before the sampled raster graphic image is imaged, UCS is changed by {LowerLeftX LowerLeftY TranslateXSizeinUCS YSizeinUCS Scale}. The first operator positions the lower left corner of the sampled raster graphic image and the second determines the size of that image in the prior UCS. To preserve the prior UCS, encompass these transformations and the ImageRasterElement operator between a SaveGraphicsState operator and a RestoreGraphicsState operator.

    The CurrentColorSpace determines the number of color components per sample value. The vector of potential color components that make up each sample value is assembled by using the BitsPerComponent key/value pair in imagedictionary to decompose the OctetStrings produced as described in . The Decode key/value pair in imagedicationary is used to map the potential color components into actual color components which can be used to specify a color in the CurrentColorSpace as described in .

    The array of colored rectangular areas is imaged onto the page image, element by element. Each element is painted onto the page image using the color of that element as the ink, the rectangular area the element occupies as the mask, and the CurrentClippingRegion as the clipping region.

    MaskBitMap

    The MaskBitMap imaging operator accepts one explicit operand

  • <imagedictionary: DictionaryReference>

    and returns no results. The MaskBitMap operator uses the information in the imagedictionary to acquire bitmap sample values, interpret them to form a mask, and execute an imaging activity using the CurrentColor Graphics State Variable and the mask. The contents and semantics of image Dictionaries are described in detail in .

    The set of mandatory key/value pairs is checked. If any keys are missing, RaiseError shall be invoked with UndefinedKey as its operand. If the key is present but the value bound to it is of the wrong type, RaiseError shall be invoked with TypeCheck as its operand. If the key is present and the type is correct but the bound value is out of range, RaiseError shall be invoked with RangeCheck as its operand. If the sole element of DataSources is a Procedure which executes the ImageRasterElement or MaskBitMap operator, RaiseError shall be invoked with UndefinedKey as its operand.

    If the single element in DataSources is a Procedure which executes the ImageRasterElement or MaskBitMap operator, RaiseError shall be invoked with UndefinedKey as its operand. If there are problems in any StreamObject that is an element in DataSources, RaiseError shall be invoked with IOError or DataError, as appropriate, as its operand.

    The input to the mask creation is a sequence of sample values which are positioned in a rectangular array. Each sample value corresponds to a unit rectangle in the image coordinate system described in the ImageMatrix key/value pair in the imagedictionary. The order of the sample values is specified in .

    The inverse of the ImageMatrix transformation transforms and positions the image coordinate space into the UCS.

    The Decode key/value pair in imagedictionary is used to determine whether the unit rectangle that corresponds to the sample value is part of the mask or part of the opaque region.

    The mask thus created is used in an imaging activity in which the ink is the CurrentColor in the CurrentColorSpace and the CurrentClippingRegion is the clipping region.