Visibility Color

Introduction

Overview of the changes

Print objects

Image support

Over-layed Objects

Color Palettes

Image enquiry

Memory

Demonstration methods.

Introduction

The following is a list of the changes between previous versions of Visibility and the latest version that incorporates color and image capability. Please note that for backward compatibility, no changes have been made to the interfaces that existed in previous releases.

Overview of the changes

The following are the major changes to Visibility with regard to color and image support:

Print objects

Additional methods have been added to the Class methods for all print objects. These provide for the addition of a color choice, as appropriate.

There is an additional Class variable that provides for the definition of the color or colors to be regarded as white. The importance of this will be discussed later in the section on black and white printing.

Image support

Support is provided for the import of images using the standard VisualAge provided import and DeviceIndependentImage methods. The import mechanisim will manage all types of file format without reference to file name, for instance. Thus, if there is a JPEG that is called myImage.xxx, Visibility Color will still recognise it as a JPEG, in spite of the xxx suffix. Further, to this, Visibility Color is able to determine that an image file is not available in the path given. In this circumstance, it will replace the image with that of an open box with a cross – to show a missing image. Support is provided for the following file formats:

Placing the image

The image object is given a target rectangle that defines the print area for its placement. How it appears within that rectangle is defined by an additional parameter that uses an atom as a selector. These atoms are as follows:

##left

Place the image scaled to the largest size possible without exceeding the target rectangle and retaining the correct proportions with the top left hand corner of the image at the top left hand corner of that rectangle. The image will fill one of the dimensions but will not fill the other if the proportions of the given rectangle are different from that of the image.

Examples

##right

As for ##left but placed at the top right hand corner.

Examples

##center

As for ##left but centered in the rectangle (only in the x direction).

Examples

##stretch

Place the image to fill the destination rectangle. This means that, if required, the image will be distorted to fit.

Examples

##tiled

Place the image, retaining its original size, as often as possible in the given rectangle such as to completely fill the area. Part images may be required to completely fill the area in any given direction.

Examples

Image = 600 @ 600 pixels; target area
is 900 @ 1200 pixels. 4 images will be
placed as follows:

      1. origin 0 @ 0 and placed in an
        area 600 @ 600
      2. origin 600 @ 0 and cropped to
        300 @ 600.
      3. origin 600 @ 0 and placed in an
        area 600 @ 600
      4. origin 600 @ 600 and cropped to
        300 @ 600.

Adding Borders

Borders may be added to all image placement objects. Both the color and the width of the border may be defined.

Over-layed Objects

If, during the definition process, you overlay one object partially on to of another, the resulting printed output will result in the top object being printed fully, whilst the bottom object will only have the areas that show printed. Thus if you overlay one colored box on top of another such that the top one completely covers the bottom one, the final result will be the top one only. This process is known as ‘knock out’ in the printing trade.

Placing yellow text on top of a red box does not result in orange text but yellow text with the red underneath removed. If you wish to merge colors in that fashion, we are sorry to say that you must do this yourself.

Color Palettes

Color definition is a complex process. Each printer object has a palette attached. A palette is a series of pre-defined colors. Images have their own palettes but these are defined by the contents of the image so we are only concerned with the other print objects.

Defining Palettes

Visibility Color aids you in defining palettes. Defining colors is a complex process and you are advised to study the sections in the IBM Smalltalk Programmers Reference (V4.0) covering ‘Specifying Colors’, starting on page 138 and ‘Using Palettes’ starting on page 140.

Visibility Color provides demonstration methods that give examples of how to define palettes.

There are two Visibility Color specific methods that set the palette for the page (ignoring the palettes for any images). These are:

makePalette:aList.

This takes a list of color objects which constitute the red, green and blue components of the color. The example method in VisibilityDemo that describes this process is makeTestPalette.

makeNamedPalette:aList

This takes a list of color names taken from the internal color dictionary supplied with VA. The example method in VisibilityDemo that describes this process is makeNamedTestPalette.

Black and White printers

Currently, black and white printer drivers, such as normal laser printers, will reject color information other than for black and white, resulting in a walkback. To avoid this problem, Visibility Color checks the color depth of the printer and, if it is 2, will translate all colors to black. Unfortunately, if you wished to use ‘inverse text’; i.e. white text on a black background, this process will result in black text on a black background (reminiscent of the ‘Heart of Gold’ in The Hitchhikers Guide to the Galaxy – if you are an aficionado of that novel). To get around this problem, Visibility Color allows you to define the current white. As you may have a range of colors that you wish to see in reverse, you can also provide an array of colors that should be regarded as white (ordered collections etc. will also be accepted). Thus, if you have text in yellow, orange and white that you wish to ‘knock out’ you can define these in the white class variable.

Again, an example is provided in the demonstration class.

Image enquiry

Because you may need to make decisions based upon the size of an image, for instance, adding an image to the page can be a two stage process.

The simplest way to place an image is to use the single Visibility Color image method that loads a file from disk and then uses it. However the image can be loaded into a VisibilityImage object first. This will answer all of the normal methods for images, such as size and so on. Once you have this image, you can then build the rectangle for the bounding box, for instance. You can the create the Graphics objects using the pre-loaded image.

There is also a mechanism for loading a DeviceIndependentImage so that you can take a screen grab, for instance, and load that directly into a Graphics object.

Memory

Graphics images can be very large. Do not be confused by the file size as a JPEG for instance incorporates compression so a 300K file may actually be as large as 7 – 8MB when uncompressed. Always bear in mind that a full color 11" * 6 ½" image can be as large as 40MB!

There are two effects that result from this.

When reading in a file, it must be uncompressed. Thus, a 300K JPEG can take a while to load.

When loading images in memory, do not forget that they will require lots of it. Printing 4 different 6"*4" photos (eah of 6MB in size) will result in at least 24MB of memory being needed in addition to that required by the current VA program. This can result in large amounts of swapping to disk.

It is for this reason that there is a separate loadImage method. If you wish to use multiple copies of the same image, you should use this mechanism as it then only takes up one block of memory. If you load it three times, it will require three times the memory.

The DeviceIndependentImage class has mechanisims available for the re-sampling of images so that they take up less memory when they get smaller. You should consider using these methods in addition to just resizing the image into a rectangle. A future release of Visibility Color will provide these facilities as part of the standard interface.

Lastly, remember that the final print file will be large so it will take a while to print. Also remember if your printer is accessed over a slow network, that this will also affect the printing speed.

You may care to reflect that the recommended memory requirements for Adobe Photoshop starts at 24MB, just for the program and can get as great as 64MB if you wish to manipulate large images – so be warned.

Demonstration methods.

There are three additional demonstration class methods in VisibilityDemo that show you how to use Visibility Color.

stretchTestOn:aPrinter

This method uses a gif, supplied, called tile.gif. It places this image onto the page in the various modes available.

paletteTestOn:aPrinter

This method demonstrates the use of a tiled image as a background and the means of printing text in a variety of colours using a palette created using RGB values.

namedPaletteTestOn:aPrinter

This method demonstrates the use of a tiled image as a background and the means of printing text in a variety of colours using a palette created using color names from the pool dictionary.

colorDemoOn:aPrinter

This method creates a newsletter type layout that comprises of a stretched image, a similar area tiled with the same image, a word wrapped area using text in a single color and then a box containing text in the range of colors available from the palette.