RISC World

ArtWorks Made Easy


9: Sprite Handling

Sprites, sometimes called bitmap images, may be regarded as portions of screen, that is. rectangular blocks of the coloured dots called pixels of which the screen is composed. They are very widely used in computer graphics, and since they can be plotted easily on screens they are comparatively simple to interchange between different computer types. They are also the form in which scanners and video digitisers provide their output. Many computer art packages also save their output in sprite format and you are probably familiar with the RISC OS Paint application which allows you to create and edit sprites and also to capture areas of the screen as sprites.

Many sprite formats are in use and applications such Acorn's ChangeFSI are available to convert 'foreign' sprite types to RISC OS sprite format.

Sprites may be any size. Often whole screens are saved, a VGA- standard screen (mode 27 etc.) becoming a sprite that is 640 pixels wide and 480 pixels high. Sprites may be larger than a screen. When an illustration measuring 4x3 inches is scanned at 400 dots per inch the output is obviously a sprite consisting of 1600 x 1200 pixels, and some are very small, just a few pixels per side, such as the characters and icons that appear in the RISC OS desktop.

ArtWorks allows you to import sprites and use them in documents. It also provides a number of operations on whole sprites, but does not allow you to edit the actual pixel structure of a sprite. For that you must at present use a separate sprite editor application such as Paint. It is possible that third-party companies may in future devise 'modules' that can be incorporated into Artworks to provide sprite editing facilities.

It is important to remember that each RISC OS sprite has a name. Often sprites are used in collections and the RISC OS sprite file format allows any number of sprites in a file. Each sprite in a file or in the same reserved area of memory must have a unique name by which it can be identified by applications.

Each sprite also has a screen mode, normally the mode in which it was created. If a sprite's screen mode is not available on your computer, the sprite will be invisible. Each sprite may optionally have a palette which records the composition of the colours it uses and a transparency mask which allows some (or all) of its pixels to be transparent. When a pixel is transparent, it is not plotted, that pixel retaining its previous colour. This gives the impression of a hole or window through which the background can be seen. By making pixels around the edge of a sprite transparent, the sprite may appear to have a shape that is other than rectangular.

Importing Sprites into ArtWorks

There are three ways in which you can import sprites into ArtWorks:

  1. You can drag a sprite file icon into an ArtWorks window. The first sprite in the file will appear in the drawing where you dropped it.
  2. You can drag a sprite file on to the ArtWorks icon on the icon bar. This will open a new drawing window, but no sprite will appear in it. If you click on the Show Sprites item in the File menu, however, the Sprite pool window opens and reveals the presence of the sprites in the file. (This option is greyed out if there are no sprites in the sprite pool.) The Sprite pool window is very like the Sprite file window in Paint in that it shows a small image of every sprite imported into this ArtWorks document.
  3. You can drag a sprite file into the Sprite pool window. All sprites imported into an ArtWorks document (by whichever of the methods described) are stored in an area of the document called the Sprite pool. If your document needs to display the same sprite in more than one place, only one copy of the sprite itself need be stored; in the document ArtWorks simply stores at each location a 'note' of the name of the sprite that appears there. Since some sprites use a lot of memory, this offers the potential for considerable memory savings.

If you import a sprite file containing a sprite which has the same name as a sprite already in the sprite pool, the new sprite will be renamed, normally by appending a digit to the end of its name. This differs from many other applications where a newly imported sprite usually replaces an existing one having the same name.

You may select one or more sprites in the Sprite pool by clicking SELECT on the first item and ADJUST on subsequent items. Various operations may be applied to the selected sprite(s).

Clicking MENU while the pointer is in the Sprite pool window calls up a menu of the following five items

  • Display - This controls the format of the sprite file window and is essentially similar to that of a directory display. The choices are between large icons (the default), small icons and full info. Full info gives a small reproduction of the sprite's design, its name, size in bytes, screen mode, dimensions in pixels, and presence or absence of a transparency mask and a palette.
  • Sprite 'name' - The name is empty if no sprite is selected and replaced by Selection if more than one sprite is selected. Moving right over the arrow calls up a menu of operations performed on the selection; this will be considered later.
  • Select all - This causes all sprites in the pool to be selected.
  • Clear selection - This causes all sprites in the pool to be deselected.
  • Save - This allows you to save all the sprites in the sprite pool as a single sprite file. A conventional save box appears. The file may be saved to disc or into another ArtWorks document in which you want to use the same collection of sprites.

The Selected Sprite Menu

This is the menu that opens if you move right on the second item in the Sprite pool menu when one or more sprites are selected.

  • Info - Leads to the same vital statistics about the sprite as in the 'Full info' option on the display.
  • Save - Allows you to save the individual sprite or selection as a separate sprite file.
  • Rename - Only available if one sprite is selected. Allows you to rename the selected sprite.
  • Copy - Only available if one sprite is selected. Creates a new sprite identical to the selected one. You will be prompted for a name for the new sprite.
  • Remove - Deletes the selected sprite(s) from the sprite pool. You can only delete sprites which do not appear in the document. If you attempt to remove a sprite that does appear, you will be warned to delete it from the document first.

Using Sprites

To use a sprite in the document simply drag it from the Sprite pool window into the document window and drop it at the point where you want it to appear.

When a sprite is in the document, the following operations can be performed on it.

  • It can be moved by dragging, like a shape.
  • It can be rotated using the rotate tool, in just the same way as a shape. This applies even if you are using RISC OS 2 which does not normally support sprite rotation. The sprite rotation routine is provided by ArtWorks itself and so is not dependent on the Operating System.
  • It can be scaled using the scale tool, in just the same way as a shape. This includes being flipped by dragging one side over the opposite side.

Note that if you scale a sprite in a document that is to be printed, the choice of scaling factor is critical. Some sprites, such as monochrome sprites from scanner driver software, contain a half-tone screen made up of clusters of pixels. When this type of sprite is scaled, unsightly Moire fringes (banding or striping) may occur in the printout unless you choose a scaling factor that allows each pixel in the sprite to be reproduced as an equal number of dots by the printer. In general, if you are using a 300 or 600 dots per inch printer you should use scaling factors which are multiples of 30% (use 90% to reproduce the sprite at its natural size) and if you are using a 360 dpi printer, keep to multiples of 25% (100% representing natural size). With other types of sprite, the problems are less pronounced, but noticeable irregularities may result (e.g. in the thicknesses of strokes in characters in screendumps) unless you restrict yourself to the same critical scaling ratios.

The envelope, perspective and blend operations cannot be applied to sprites.

Sprite Info Box

Sprites in ArtWorks have information boxes. An example is shown below.

The top panel of the box provides useful information about the sprite itself. The middle panel provides position and scaling information about the currently selected image of the sprite in the drawing. The fields are all writable and so you may enter values if you wish to move, scale or change the sprite's aspect ratio (.i.e. its height to width ratio), but you must click on the appropriate button either to enter an absolute new width and/or height or to change the scale or aspect.

The bottom panel is concerned with the sprite colours. View is the default setting. Process replaces the two top panels with an RGB colour editor, shown below, which can be used to edit the colours in a sprite. Only the RGB colour model is used, since this is the way in which sprite colours are generally defined.

Contone is short for continuous tone and is only selectable if the sprite is a two-colour type, as obtained from a monochrome scanner. The two colours are defined as the start colour, generally the dark colour or ink colour, and the end colour, that is, the background or paper colour. Intermediate shades are obtained using clustered dithers. The dialogue box, shown in Figure 9.3, allows you to change the two colours in the sprite by choosing alternatives from the regular colour menu (the existing sprite colours are added to the colour menu). You can make a black and white sprite by changing its colours to sepia and cream or to dark brown and pale blue. You can also force such a monochrome sprite on to a spot colour plate. Use a spot colour for the start colour and either white or a tint of the spot colour as the end colour.

Click on View to return to the sprite information.

Display of sprites

The appearance of certain sprites on the screen in ArtWorks can be improved dramatically by allowing the software to introduce dithering. This is enabled by selecting a new option on the ArtWorks document dialogue box, as described in Chapter 11. Sprites that benefit most are contone sprites and those that display colours not available in the current palette. Grey-scale sprites are dithered whether this option is selected or not. Only the screen display is affected, not printouts or the actual sprite structure.