Loading Image Files

Changed in breve 2.0

The methods used for loading images have been changed from breve 1.x, so pay close attention to this section if you're updating your simulation from a previous version of breve.

breve can use image files to display objects as bitmaps, texture objects, and to display objects as lightmaps. These techniques are described later in the chapter. This section describes how image files can be loaded into breve.

breve supports three image file formats: 1) SGI, 2) JPEG, 3) PNG. Though JPEG is the most common, most graphics programs can output images in all three formats. Specifically, the shareware program Graphic Converter can convert between the three formats.

PNG is the preferred image format—it allows more control over how the image is loaded into a texture. Support for the SGI format is provided for backward compatibility. Support for the JPEG format is provided because it is somewhat more common than PNG.

Prior to version 2.0, breve required all images loaded into breve to be square, and for the length of the sides of the images must be a power of two (for example, 256x256 or 128x128). This is no longer strictly required, though it may still be preferable. breve will automatically surround the image with a transparent border in order to fulfill the size requirements.

Images are loaded using the class Image. To load an image file, create a new instance of the class Image, and load a file with the load method:

        image = new Image.
        image load file "myimage.png".

Once an image file has been loaded, it can be used as a bitmap, texture or lightmap, as described later in this chapter.