Chapter Contents

Previous

Next
The GIMPORT Procedure

Concepts


About Importing Graphics

A computer graphics metafile (CGM) is a graphics output file that is created according to a standard (ANSI X3.122). Since many graphics applications, including SAS/GRAPH software, can generate and import CGMs, these files can be read by different applications programs or used on different machines.

The GIMPORT procedure imports a CGM with which a fileref has been associated. Using the CGM as input, the procedure displays the graphics output and creates a catalog entry. The following sections address how to assign the fileref to the external file (CGM) and how to import the file.

Specifying a Fileref

You must assign a fileref to the external file that contains the CGM that you want to use as input so that the GIMPORT procedure can locate it. You can do this with a FILENAME statement that has the following form:

FILENAMEcgm-fileref'external-file';

Replace cgm-fileref with any fileref name that you want. Replace 'external-file' with the complete file name of the CGM. You can omit the FILENAME statement if you have already defined the fileref. You can also specify a fileref with a host command in some operating environments. See FILENAME Statement for additional information.

Importing the File

The PROC GIMPORT statement reads the input CGM and displays the graphics output. When the CGM is displayed using only the PROC GIMPORT statement, the resulting graphics output may not be sized or positioned correctly for the device on which it is displayed. In these cases, you can use the SCALE and TRANSLATE statements to adjust the size and location of the new graphics output.

In addition, if the CGM contains the FONT LIST element, the procedure lists in the log the fonts used in the CGM. You can change these fonts to SAS software fonts using the MAP statement. If you do not change these fonts to SAS software fonts, the GIMPORT procedure uses a default font.

Because it is easier to determine what adjustments the graphics output needs after it has been displayed, you may want to follow these steps:

  1. Import the CGM and display the graphics output using only the PROC GIMPORT statement.

  2. Decide what adjustments you want to make to the size and position of the graphics output.

  3. If the procedure lists the fonts that are used by the CGM, decide what font substitutions you want to make.

  4. Run the procedure again with the appropriate MAP, SCALE, or TRANSLATE statements.

Note:   Once you have determined the correct values for the SCALE and TRANSLATE statements for the graphics output produced by a particular CGM, you can use the same values for all other graphics output that is generated by the same software application.  [cautionend]

CGM Elements Not Supported

The GIMPORT procedure does not support certain CGM elements. If the input CGM contains any of the following elements, the GIMPORT procedure writes a message to the log noting that the procedure cannot process them:

These elements are rarely used and their absence should not affect the graphics output produced by the GIMPORT procedure.


About Color Mapping

If the CGM specifies colors for the graphics elements that it generates, you may or may not be able to map them to the color that you want in your SAS/GRAPH output, depending on the way these colors are specified in the CGM.

You cannot change the color mapping if, in the CGM, the COLOUR SELECTION MODE element is set to DIRECT. In this case, the colors are explicitly defined by the CGM and you cannot change them. However, if the CGM was created with a SAS/GRAPH CGM device driver, you can control the colors by specifying the appropriate colors when you create the graphics output or by changing the colors in the CGM device entry and re-creating the CGM. See The GDEVICE Procedure for details. In addition, you can use a color map with the GREPLAY procedure to remap the colors. In the color map, the FROM color must be specified in RGB format, but the TO color can be any valid color name. See The GREPLAY Procedure for details on color maps.

You can change the color mapping if the COLOUR SELECTION MODE element is set to INDEXED and there is no color table defined in the CGM file. In this case, you can map the colors from the CGM to the colors of your choice by using the COLORS= graphics option when you run the GIMPORT procedure. The CGM colors are mapped to match the order of the colors in the colors list. If the procedure cannot reproduce the colors specified in the CGM, the following message is written to the log:

WARNING: Invalid color index n encountered.
         It has been mapped to color-name.

Note:   The color name from the CGM is converted to the RGB format for SAS/GRAPH color names; that is, WHITE is converted to CXFFFFFF, and so on. See SAS/GRAPH Colors for details.  [cautionend]


About Pattern Mapping

If the CGM contains pattern specifications, you may be able to map them to patterns of your choice using SAS/GRAPH PATTERN definitions.

If the CGM defines a PATTERN TABLE, then the patterns defined by this table are the patterns that are used and you cannot change them.

If a PATTERN TABLE is not defined in the CGM, under certain conditions you may be able to use SAS/GRAPH PATTERN definitions to control the patterns that are used. If INTERIOR STYLE is set to PATTERN and if a PATTERN TABLE INDEX has been specified, then the GIMPORT procedure uses the PATTERN TABLE INDEX to look up SAS/GRAPH PATTERN definitions. If patterns are defined, the procedure uses the first available pattern. For example, if the PATTERN TABLE INDEX n has been defined, the procedure uses SAS/GRAPH PATTERN definition n. If the SAS/GRAPH PATTERN definition is not the correct pattern type, the procedure modifies the pattern as necessary. If no PATTERN definitions are currently in effect, an INVALID PATTERN TABLE INDEX warning is issued and no pattern is used.


About Font Mapping

By default, the GIMPORT procedure maps all of the fonts in the CGM to the font that is specified by the FTEXT= graphics option. If the FTEXT= graphics option is not used, the default is the hardware font NONE. However, you may be able to specify a different font either by mapping the fonts or by using a graphics option.

When the CGM is imported, a numbered list of the fonts that are used in the CGM may be displayed in the LOG window. These are the fonts that were available to the application that originally generated the CGM. Depending on how the fonts are represented in the CGM, you may be able to map these fonts to fonts of your choice.

If the font and text in the imported graphics output are produced with move and draw commands that are included in the CGM, then no font name appears in the LOG window and the font cannot be mapped to a different one.

If the fonts used in the imported graphics output are represented in the CGM as a font name accompanied by a text string, they can be mapped to SAS/GRAPH fonts using the MAP statement. You can use the MAP statement if the message "WARNING: Invalid font index n. Font has been mapped to font-name" appears in the LOG window after the list of fonts. This means that font n in the list could not be reproduced and was mapped to the font specified in the FTEXT= graphics option or to the hardware font. You can map this font to a SAS/GRAPH software font of your choice using the MAP statement. See MAP Statement for more information on mapping fonts.

You can also specify a font with the FTEXT= or CHARTYPE= graphics options if both of the following conditions are true:

However, using a graphics option causes all fonts to be mapped to the one that is specified. See SAS/GRAPH Fonts for details of font specification and Adjusting the Graphics Output.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.