previous chapter contents page top page next chapter

Image

October 5, 1992
last updated September 30, 1993

Defined in Image.Def 
Inherits from Linkable
Inherits Interface from Pixels, HasDigest



Class Description

Most viewable objects, including stamps, buttons, and gadgets, use a bitmap to describe their appearance on the screen. These bitmaps are instances of class Image. Image objects include other information that's used when drawing the objects they're associated with, such as the image's size and center point.


Version note: This chapter is under construction. Watch out for falling girders. Use caution. And take the following advice to heart:


Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Using a Image Object

Most viewables include a reference to an object of class Image that defines the object's appearance. When you create one of these viewables, you'll specify the image to be used by the viewable. Image objects consist of bitmaps with additional supporting information.

You can put a new image into the Macintosh-resident version of Magic Cap by using standard Macintosh copy and paste, like this:

  1. Select and copy the item using the appropriate Macintosh application.

  2. Start Magic Cap, or click on its window to bring it to the front if it's already running.

  3. Select Paste from the Edit menu, or type Command-V. You'll create a new image and an image coupon. Use the image coupon to apply the image to viewable objects.

Every viewable that uses an image displays its image in an image coupon when you tinker with it. You can apply one viewable's image to another by tinkering with the first viewable, dragging its image coupon out of the tinkering window, closing the tinkering window, then dragging the image coupon to the desired viewable and dropping it in.

You can also connect a viewable to an image in your package's instance definition file. Every viewable that uses an image has an image field to refer to it. To make the viewable use a particular image, just put that image in the viewable's image field in your instance definition file.

When you see an image in an instance definition file, you'll find that most of the definition is taken up by data that describes the image's bitmap. This information looks daunting, but it's generated automatically by ObjectMaker when you decompile your objects to text, so you'll never have to construct it yourself.

Magic Cap includes many images that you can use. These images are defined as indexicals, which gives you access to them from your package. For example, indexical {6,53} is a birthday card image. For a complete list of indexical images you can use, as well as all other indexicals, see the Indexicals.h file, especially list 6.

Programming Information

Instantiate: sometimes
Subclass: rarely
Call its methods: rarely

You'll create objects of class Image if you ever paste images into the Macintosh-based version of Magic Cap. You can see the text description of these images when you decompile objects with ObjectMaker. You'll probably never create a text description of an image yourself, although you might modify an image description created by ObjectMaker.

Methods you might call

The Image class has the following methods you might call:

Method Description
image geometry
Thickness Return the size of the image relative to the origin
BorderThickness Return the thickness of the border around content; always returns 0; override to implement borders
RepeatThickness Thickness of repeat area within border; always returns 0; override to change
ImageBoundsBox Determine a bounding box for the image, centered on the supplied position dot
ImageBoundsBoxRotated Determine a bounding box for the image given a rotation
ImageContentBox Always empty; override to change
ImageBoundsDot
Drawing the image
DrawImageScaled Draw the image with the given modifications
DrawImageInBox
DrawImageRotated
DrawImageRotatedColored
DrawImagedRotatedShadow
DrawBorder Draw the image's border
DrawComplexBorderShadow
Manipulating the image
ChangeImage Replace the image with a new image, in the same object, setting flags appropriately
FinePointing Returns the value of the flag imagefinepointingbit
SetFinePointing Sets the imagefinepointingbit to the given boolean
ShrinkImage Shrink the image <<how much?>>

Methods you might override

Whenever you create a subclass of the Image class, you should override the following methods:

Method Description
DrawImage Draw the image

Description of fields

The Image class defines the following fields:

Field Type Description
Inherited from SingleLinkable:
next Object Next item in list
Inherited from Linkable:
previous Object Previous item in list
Defined by Image:
imageFlags Unsigned Various flags for image
imageSize PixelDot Size of image in pixels
resolution UnsignedShort Microns per bit ??
depth UnsignedShort Bits per pixel of image
centerPt PixelDot Center of image in pixels
crc32 Unsigned Computed checksum of image

The bitmap for an image is contained in the variable-length data at the end of the object, not in any of the object's fields.

Image Flag Descriptions

rectImage

#define rectImageBit31
#define rectImageMask0x80000000

This flag is set if the image is rectangular.

hasMask

#define hasMaskBit30
#define hasMaskMask0x40000000

This flag is set if mask data is appended to the image.

allBlack

#define allBlackBit29
#define allBlackMask0x20000000

This bit is set if the image is all black.

containsName

#define containsNameBit28 
#define containsNameMask0x10000000

Set this flag if the image displays its own name, so a label would be unecessary.

packed

#define packedBit23
#define packedMask0x00800000

This flag is true if the image data has been packed with PackBytes.

aligned32

#define aligned32Bit22
#define aligned32Mask0x00400000

This flag is true if rowBytes is a multiple of 4 bytes.

imageFinePointing

#define imageFinePointingBit21
#define imageFinePointingMask0x00200000

Set this flag if the system should use the image mask for hit-testing this image.

orientation

/* bits of orientation */
#define rotateBit      2
#define hFlipBit      1
#define vFlipBit      0
/* image orientation bitMasks */
#define rotateMask      (1 << rotateBit)
#define hFlipMask      (1 << hFlipBit)
#define vFlipMask      (1 << vFlipBit)

Method Descriptions

GetThickness

operation GetThickness(VAR thickness: Box)

call: sometimes
Override: rarely

Call GetThickness to return the width and height of the image in microns.