Constructors

The TModifiableImage derived classes have two main constructors: one that creates the image in pixels, and another that creates the image in world-coordinate units. In both cases, a pixel buffer is created in memory that represents the image in pixels. Figure 82 shows a one-inch square image in terms of pixels at 300 dots per inch on the left, and the same image in world-coordinate units on the right.


Pixel constructor

This constructor sets the image to a specific size in pixels and creates the pixel buffer to store the pixels. Use this constructor to define a scanned or Tag Image File Format (TIFF) file data where the height and width in pixels is known.

      TA8R8G8B8Image( const TGPoint& dstOrigin,
                      long widthInPixels, 
                      long heightInPixels,
                      TGPoint dpi = TGImage::k72DPI, 
                      TGrafBundle* adoptBundle = NIL, 
                      TGImage::EOrientation orientation = TGImage::kIdentity,
                      const TColorProfile& theProfile = TImage::GetDefaultColorProfile() );
                      const TGPoint& sourceOrigin = TGPoint( 0,0 );
dstOrigin: The location of the upper-left corner of the image.

widthInPixels: The width of the image in the x direction.

heightInPixels: The height of the image in the y direction.

dpi: The resolution of the image in points per inch. TGPoint::fX represents the horizontal dots per inch, and TGPoint::fY represents the vertical dots per inch (see the heading "Horizontal and vertical resolution" on page 129 for more information). This parameter defines the transformation between world-coordinate units and pixels.

adoptBundle: The attribute bundle for the image. If you do not specify an attribute bundle, the attribute bundle of the drawing port is used. This attribute bundle specifies transfer modes and image sampling settings only. See the code example above for information on how to fill the image.

orientation: The rectilinear orientation of the image geometry. This parameter is used only when you convert an image in a file to a TModifiableImage using one of the converter classes. See the heading "Orientation" on page 130 for more information on this parameter.

theProfile: The colorimetric characteristic of the image. This parameter is described under the heading "Color profile" on page 130.

sourceOrigin: An offset value that is added to all graphics drawn into the image.

World coordinate unit constructor

This constructor sets the image to a specific size in world-coordinate units. The world-coordinate units are converted to pixels and stored in the pixel buffer.

      TA8R8G8B8Image( const TGPoint& dstOrigin,
                      const TGPoint& imageSizeInWorldSpace,
                      TGPoint dpi = TGImage::k72DPI,
                      TGrafBundle* adoptBundle = NIL,
                      TGImage::EOrientation orientation = TGImage::kIdentity, 
                      const TColorProfile& theProfile = TImage::GetDefaultColorProfile() );
                      const TGPoint& sourceOrigin = TGPoint( 0,0 );
imageSizeInWorldSpace: The width of the image where TGPoint::fX equals the width in the x direction, and TGPoint::fY equals the height in the y direction.

Gray image and indexed image

The TGrayImage and TIndexedImage constructors have an additional parameter.

The gray image is a 4-bit or 8-bit gray image. The constructor takes a parameter of type EGrayImageType that specifies the bit size. The enumeration values are k16GrayLevelImage for a 4-bit image, and k256GrayLevelImage for an 8 bit image.

The indexed image is a concrete 8-bit image with a color lookup table (CLUT). Embedded in TIndexedImage is a TRGBColorArray that describes the CLUT. TRGBColorArray lets you specify any number of colors between 1 and 256. The constructor for TIndexedImage has a default parameter of type TRGBColorArray to specify an 8-bit image and CLUT.

Horizontal and vertical resolution

Many hardware devices have nonsquare pixels where both horizontal and vertical dots per inch must be specified. Because TGPoint is floating point, you can specify the horizontal and vertical pixels per inch with fractional precision. Figure 83 shows horizontal and vertical dots per inch.


Orientation

The image geometry has a rectilinear orientation that you specify. This orientation is taken into account when the image is displayed or edited so that the image displays correctly when it is drawn. This parameter is used only to convert an image in a file to a TModifiableImage with converter classes. You cannot use this parameter to reorient an image when drawing into an image port. You can use the MGraphic transformation functions to transform the image itself as a whole, or the individual graphics that you draw into the image. The eight orientations with their corresponding enumeration values are shown in Figure 84.

      EOrientation TGImage::GetOrientation() const;
      virtual void TGImage::SetOrientation( EOrientation orientation );

Color profile

The color profile has a color gamut that defines eight TxyYColor instances. Color matching is used to display the image at the highest quality possible. Color profiles, color gamuts, color matching, and the xyY color space will be described in another volume in a later release.

A TImage instance can be constructed with a TColorProfile instance. You can set the color profile and retrieve the color table with the TGImage functions shown below. The color table lists the xyY colors in the current color profile.

    virtual const TColorTable* TGImage::GetColorTable() const;

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker