Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Image Data Model Class

To create an image data model, load the class from SASHELP.FSP.IMGDAT, and then create an instance of the class:

imgdat_class=loadclass('sashelp.fsp.imgdat');
imgdat_id=instance(imgdat_class);


Argument Values Common to Many Image Data Model Class Methods

Units. All width, height, x and y positions are pixel based. The upper left corner is position 0,0.

File-Specific Attributes. The Image Data Model class supports many file formats for reading and writing. These formats are listed below. When you are reading in images, include the FORMAT= attribute in the method if

FORMAT= is not required in other cases, but it is always more efficient to specify it.

When you are writing images, you must specify the FORMAT= attribute if the LNAMEMK SCL function is not used to include the FORMAT= attribute as part of the image pathname for the image-path argument in the method.


Supported Image File Types

The image class supports the following image file types:
File Type Description
BMP - Microsoft Windows Device Independent Bitmap supports color-mapped and true color images stored as uncompressed or run-length encoded. BMP was developed by Microsoft Corporation for storing images under Windows 3.0 and OS/2 operating systems.
CAT - SAS Catalog IMAGE entry
DIB - Microsoft Windows Device Independent Bitmap See the description of BMP.
EMF - Microsoft NT Enhanced Metafile
EPSI - Encapsulated PostScript Interchange is an extended version of the standard PostScript (PS) format. Files using this format can be printed on PostScript printers and also can be imported into other applications. Notice that EPSI files can be read but PS files cannot.
GIF - Graphics Interchange Format supports only color-mapped images. GIF is owned by CompuServe, Inc.
JPEG - Joint Photographic Experts Group supports compression of images with the use of JPEG File Interchange Format (JFIF) software. JFIF software is developed by the Independent JPEG Group.
MET - OS/2 Metafile
PBM - Portable Bitmap Utilities supports gray, color, RGB, and bitmap files. The Portable Bitmap Utilities is a set of free utility programs that were primarily developed by Jeff Poskanzer.
PCD - Photo CD Kodak Photo CD format which supports multiple image resolutions.
PCL - Printer Control Language
PCX - PC Paintbrush supports bitmapped, color-mapped, and true color images. PCX and PC Paintbrush are owned by Zsoft Corporation.
PICT - The QuickDraw Picture Format supports 256 color images and bitmaps. The QuickDraw Picture Format is owned by Apple Computer, Inc.
PNG - Portable Network Graphic supports truecolor, gray-scale, and 8-bit images.
PS - PostScript Image File Format The Image classes use only PostScript image operators. A level II PS printer is required for color images. PostScript was developed by Adobe Systems, Inc.
TGA - Targa supports both true color images and color-mapped images; however, the current release of the Image classes supports only true color TGA files. Targa is owned by Truevision, Inc.
TIFF - Tagged Image File Format internally supports a number of compression types and image types, including bitmapped, color-mapped, gray-scaled, and true color. TIFF was developed by Aldus Corporation and Microsoft Corporation and is used by a wide variety of applications.
WMF - Microsoft Windows Metafile
XBM - X Window Bitmaps supports bitmapped images only. XBM is owned by MIT X Consortium.
XPM - X Window Pixmap is an extended version of XBM that supports color bitmaps.
XWD - X Window Dump supports all X visual types (bitmapped, color-mapped, and true color.) XWD is owned by MIT X Consortium.


Image File Types and Attributes

The following table describes the attributes for the image readers and writers that are supported by SAS/GRAPH. You can specify an image file's attributes in SCL functions by enclosing the attributes in quotation marks and separating multiple attributes with blanks. The following examples include an Image Data object example and an SCL example:

Image Data object example:

CALL SEND (imgdat_id, "_READ_", filename, "FORMAT=TIFF COMPRESS=G3FAX");

SCL example:

rc = igop(tid, "WRITE",filename,"FORMAT=TIFF COMPRESS=G3FAX");

Image Readers for Supported File Types
File Type Reader Attributes Comment
BMP
FORMAT=BMP
COMPRESS=NONE Default
COMPRESS=RLE Run-length encoded
CAT FORMAT=CAT
DIB FORMAT=DIB only supported under Windows 3.1, Windows NT, and OS/2 operating systems
EMF FORMAT=EMF supported only under Windows NT and Windows 95
EPSI FORMAT=EPSI

DPI=num


number of dots per inch that was specified when the output file was created

GIF FORMAT=GIF
JFIF
FORMAT=JFIF required for reading JPEG files that use JPEG File Interchange Format (JFIF).
DCT=mode selects specific type of Discrete Cosine Transform (DCT) to use when processing the image; mode can be

  • INT an integer DCT

  • FAST a faster and less accurate integer DCT

  • FLOAT a slightly more accurate method that can be slower unless the host has very fast floating point hardware

GRAYSCALE produces a gray-scale image even if the JPEG file is in color. This is useful for viewing on monochrome displays. The reader runs noticeably faster in this mode.
VERSION prints the version number and copyright messages for the Independent JPEG Group's JFIF software to the log.
FAST enables certain recommended processing options for fast, low quality output; equivalent to enabling ONEPASS, DITHER=ORDERED, COLORS=216, NOSMOOTH, and DCT=FAST.
NOSMOOTH uses a faster, lower quality, upsampling routine.
ONEPASS uses a one-pass color quantization instead of the standard two-pass quantization. The one-pass method is faster and needs less memory, but it produces a lower-quality image. This attribute is ignored unless you also specify the COLORS attribute. ONEPASS is always enabled for gray-scale output.
COLORS=n reduces the number of colors in the image to at most n colors; n must be in the range 2...256.
SCALE_RATIO=n scales the output image by a factor of 1/n. Currently the scale factor must be 1/1, 1/2, 1/4, or 1/8. This is useful when processing a large image and only a smaller version is needed, as the reader is much faster when scaling down the output.
DITHER=mode selects the specific type of dithering to use color quantization; mode can be

  • FS Floyd-Steinberg dithering

  • ORDERED ordered dithering

  • NONE no dithering

MET FORMAT=MET supported only under OS/2
PBM FORMAT=PBM
PCD FORMAT=PCX FORMAT=PCD RES= specifies the image resolution to be read. Photo CD images have multiple resolution images in each image. Values are:
BASE/64 64x96
BASE/16 128x192
BASE/4 256x384
BASE 512x768 (default)
4BASE 1024x1536
16BASE 2048x3072
PCX FORMAT=PCX not supported for writing
PICT FORMAT=PICT supported only in the Macintosh environment
PNG FORMAT=PNG
TGA FORMAT=TGA
TIFF FORMAT=TIFF
XBM FORMAT=XBM
XPM FORMAT=XPM supported only under the X Windows System under UNIX
XWD FORMAT=XWD

Image Writers for Supported File Types
File Type Writer Attributes Comment
BMP FORMAT=BMP
CAT
FORMAT=CAT
COMPRESS=G3FAX FAX CCITT Group 3 for monochrome black-and-white images (depth of 1) only
COMPRESS=G4FAX FAX CCITT Group4 for monochrome black-and-white images (depth of 1) only
DESC= 'description' for catalog description
DIB FORMAT=DIB supported only under the Windows 3.1, Windows NT, Windows 95, and OS/2 operating systems
EMF FORMAT=EMF supported only under Windows NT and Windows 95
EPSI FORMAT=EPSI
GIF FORMAT=GIF
JFIF
FORMAT=JFIF required for reading JPEG files that use JPEG File Interchange Format (JFIF).
DCT=mode selects specific type of Discrete Cosine Transform (DCT) to use when processing the image; mode can be

  • INT an integer DCT

  • FAST a faster and less accurate integer DCT

  • FLOAT a slightly more accurate method that can be slower unless the host has very fast floating point hardware

GRAYSCALE produces a gray-scale image even if the JPEG file is in color. This is useful for viewing on monochrome displays. The reader runs noticeably faster in this mode.
VERSION prints the version number and copyright messages for the Independent JPEG Group's JFIF software to the log.
FAST enables certain recommended processing options for fast, low quality output; equivalent to enabling ONEPASS, DITHER=ORDERED, COLORS=216, NOSMOOTH, and DCT=FAST.
NOSMOOTH uses a faster, lower quality, upsampling routine.
ONEPASS uses a one-pass color quantization instead of the standard two-pass quantization. The one-pass method is faster and needs less memory, but it produces a lower-quality image. This attribute is ignored unless you also specify the COLORS attribute. ONEPASS is always enabled for gray-scale output.
COLORS=n reduces the number of colors in the image to at most n colors; n must be in the range 2...256.
SCALE_RATIO=n scales the output image by a factor of 1/n. Currently the scale factor must be 1/1, 1/2, 1/4, or 1/8. This is useful when processing a large image and only a smaller version is needed, as the reader is much faster when scaling down the output.
DITHER=mode selects the specific type of dithering to use color quantization; mode can be

  • FS Floyd-Steinberg dithering

  • ORDERED ordered dithering

  • NONE no dithering

MET FORMAT=MET supported only under OS/2
PBM
FORMAT=PBM
COMPRESS=NONE text PBM file (default)
COMPRESS=BINARY binary PBM file
COMPRESS=RAW binary PBM file
PCL
FORMAT=PCL
DPI=num number of dots per inch to be used in the output file
EPS does not reset the printer margins; use to embed an image into another PCL document
PICT FORMAT=PICT supported only in the Macintosh environment
PNG FORMAT=PNG
PS
FORMAT=PS
COMPRESS=NONE default for color images
COMPRESS=RLE run-length encoded; default for gray-scale images
DPI=num number of dots per inch to be used in the output file
EPS does not reset the printer margins; used to embed an image in another PCL document
PREVIEW specifies whether a scaled-down, 1-bit, black-and-white preview image is written into the encapsulation header. The preview image enables this file to be read by software (such as SAS) that doesn't support a real PostScript reader.
PREWIDTH=x
PREHEIGHT=y
size of the preview image in pixels if PREVIEW is specified (default: 25% of original size)
XSCALE directly sets width scaling (default: calculate it)
YSCALE directly sets height scaling (default: calculate it)
PAGEX sets output page width in pixels (default: 612, typical 8.5-inch page)
PAGEY sets output page height in pixels (default: 792, typical 11-inch page)
NOFIT turns off the default of scaling an oversized image down to fit the page. Must be used with XSCALE and YSCALE.
TIFF
FORMAT=TIFF
COMPRESS=NONE default
COMPRESS=G3FAX FAX CCITT Group 3 for monochrome black-and-white (depth of 1) images only
COMPRESS=G4FAX FAX CCITT Group 4 for monochrome black-and-white (depth of 1) images only
WMF FORMAT=WMF supported only under Windows operating systems
XBM FORMAT=XBM supported for writing only from interactive windows under UNIX
XPM FORMAT=XPM supported only under the X Windows System under UNIX


Digital Camera Support

Support for camera devices is added through the _READ_ method and the READ command. The OPTIONS string is used to pass information to the device.

Syntax for the image object:

CALL SEND (data-object-id, '_READ_', camera, options);

Syntax for the IMGOP function:

RC = IMGOP (tid, 'READ', camera, options);

Camera indicates which camera will be used. Two values are valid: KODAKDC40 and TWAIN.

The following table describes the attributes for a digital camera. When you read images from a digital camera, you must include the DEVICE= attribute in the method.

Reader Attributes for Kodak DC40 Cameras
Device Type Reader Attributes Comment
CAMERA
DEVICE=CAMERA required; also requires the use of either the PICNUM=n or TAKEPIC option.
DELLAST deletes the last image. Can be used to take a picture and delete it from camera as it is returned. You can put camera in a mode to delete the last image only if the camera is empty. Changing this mode limits the number of images that the camera can hold. Cannot be used with DELALL or PICNUM.
DELALL deletes all images on camera. Cannot be used with DELLAST.
EXPOSE=setting shifts exposure in relation to the auto exposure setting:

  • +1

  • +.5

  • 0

  • -.5

  • -1

The setting remains in effect until the exposure is reset or changed again. A manual change on the camera behaves the same.

FLASH=setting sets the flash unit; setting can be

  • AUTO

  • ON

  • OFF

The setting remains in effect until the unit is reset or changed again. A manual change on the camera behaves the same.

PICNUM=n gets picture number n. Cannot be used with TAKEPIC.
PORT=n sets the serial port number. The default is to search for and automatically detect camera.
RES=setting sets the resolution; setting can be

  • HIGH

  • LOW

You can change the resolution only on an empty camera before the pictures are taken.

RESET resets camera to default values. You can reset only an empty camera. Can be used with DELALL to empty and reset camera.
TAKEPIC takes a photo and returns it. Cannot be used with PICNUM.
THUMB returns thumbnail size instead of full image.

Reader Attributes for TWAIN Cameras
Device Type Reader Attributes Comment
CAMERA
DEVICE=CAMERA Required.
Type=char Type of image to generate:

  • BITONAL

  • RGB

  • GRAY

Default = highest supported resolution

SELSRC enables the selection of a data source via the TWAIN Select Source window.
SETCAP enables the setting and modification of capabilities via the selected TWAIN data source's capability window.
SCNAME=char TWAIN Data Source name: Key word that matches the Product name of the camera (if more than one TWAIN device is available). Partial matches are supported -- if the key word matches more than one camera's product name, the first match is selected. This must be specified if you do not want to have to choose the source from the Select Source window. The default is the last device installed or last device selected.

Note:   Product name is the name displayed in the TWAIN Select Source window. It may not be the same as the name of the camera. Use the SELSRC option to see possible values.  [cautionend]



Scanner Support

Support for scanner devices is added through the _READ_ method and the READ command. The OPTIONS string is used to pass information to the device.

Syntax for the image object:

CALL SEND (data-object-id, '_READ_', scanner, options);

Syntax for the IMGOP function:

RC = IMGOP (tid, 'READ', scanner, options);

Scanner indicates which scanner will be used. Two choices are valid: HPSCAN and TWAIN.

The following table describes the attributes for a scanner. When you read images from a scanner, you must include the DEVICE= attribute in the method.

Reader Attributes for HPSCAN Scanners
Device Type Reader Attributes Comment
SCANNER
DEVICE=SCANNER required; supported only under Windows 95, Windows NT, and HP/UX operating systems.
BRIGHT=n sets brightness setting; the default is 0.
CONTRAST=n sets contrast setting; the default is 0. This option is ignored with bitonal images.
DPI=n sets dots per inch; the default is 200.
FEEDER | NOFEEDER specifies how the document is scanned. FEEDER assumes there is a document feeder and produces an error if not. NOFEEDER scans from bed and ignores the feeder if one is attached. If neither attribute is specified, the default is to use the feeder if attached or bed scan if not.
TYPE=type sets type of image to generate; type can be

  • BITONAL (default)

  • CMAP

  • RGB

  • GRAY

UNITS=units sets size units; units can be

  • IN (default)

  • CM

  • MM

  • PIXEL

XDPI=n sets DPI for width only.
XSIZE=d sets width to scan (decimal value); the default is 8.5.
XSTART=d sets starting point of scan; the default is 0.
YDPI=n sets DPI for height only.
YSIZE=d sets height to scan (decimal value); the default is 11.
YSTART=d sets starting point of scan; the default is 0.

Reader Attributes for TWAIN Scanners
Device Type Reader Attributes Comment
SCANNER
DEVICE=SCANNER required; supported only under Windows 95, Windows 32S, and HP/UX operating systems.
BRIGHT=n sets brightness setting; the default is 0.
CONTRAST=n sets contrast setting; the default is 0. This option is ignored with bitonal images.
DPI=n sets dots per inch; the default is 200.
FEEDER | NOFEEDER specifies how the document is scanned. FEEDER assumes there is a document feeder and produces an error if not. NOFEEDER scans from bed and ignores the feeder if one is attached. If neither attribute is specified, the default is to use the feeder if attached or bed scan if not.
TYPE=type sets type of image to generate; type can be

  • BITONAL (default)

  • CMAP

  • RGB

  • GRAY

UNITS=units sets size units; units can be

  • IN (default)

  • CM

  • MM

  • PIXEL

XDPI=n sets DPI for width only.
XSIZE=d sets width to scan (decimal value); the default is 8.5.
XSTART=d sets starting point of scan; the default is 0.
YDPI=n sets DPI for height only.
YSIZE=d sets height to scan (decimal value); the default is 11.
YSTART=d sets starting point of scan; the default is 0.
SELSRC enables the selection of a data source via the TWAIN Select Source window.
SETCAP enables the setting and modification of capabilities via the selected TWAIN data source's capability window.
SCNAME=char TWAIN Data Source name: Key word that matches the Product name of the camera (if more than one TWAIN device is available). Partial matches are supported -- if the key word matches more than one camera's product name, the first match is selected. This must be specified if you do not want to have to choose the source from the Select Source window. The default is the last device installed or last device selected.

Note:   Product name is the name displayed in the TWAIN Select Source window. It may not be the same as the name of the camera. Use the SELSRC option to see possible values.  [cautionend]



Chapter Contents

Previous

Next

Top of Page

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