Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.swt.graphics
Class ImageLoader

    java.lang.Object
      org.eclipse.swt.graphics.ImageLoader

public class ImageLoader
extends Object

Instances of this class are used to load images from, and save images to, a file or stream.

Currently supported image formats are:

- BMP (Windows Bitmap)
- ICO (Windows Icon)
- JPEG
- GIF
- PNG

`ImageLoaders` can be used to:

- load/save single images in all formats
- load/save multiple images (GIF/ICO)
- load/save animated GIF images
- load interlaced GIF/PNG images
- load progressive JPEG images

Field Summary
`int` | `backgroundPixel` the background pixel for the logical screen (this corresponds to the GIF89a Background Color Index value).
`ImageData[]` | `data` the array of ImageData objects in this ImageLoader.
`int` | `logicalScreenHeight` the height of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Height value)
`int` | `logicalScreenWidth` the width of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Width value)
`int` | `repeatCount` the number of times to repeat the display of a sequence of animated images (this corresponds to the commonly-used GIF application extension for "NETSCAPE 2.0 01")

Constructor Summary
`ImageLoader()` Construct a new empty ImageLoader.

Method Summary
`void` | `addImageLoaderListener(ImageLoaderListener listener)` Adds a listener to receive image loader events.
`boolean` | `hasListeners()` Returns `true` if the receiver has image loader listeners, and `false` otherwise.
`ImageData[]` | `load(InputStream stream)` Loads an array of `ImageData` objects from the specified input stream.
`ImageData[]` | `load(String filename)` Loads an array of `ImageData` objects from the file with the specified name.
`void` | `notifyListeners(ImageLoaderEvent event)` Notifies all image loader listeners that an image loader event has occurred.
`void` | `removeImageLoaderListener(ImageLoaderListener listener)` Removes a listener that was receiving image loader events.
`void` | `save(OutputStream stream, int format)` Saves the image data in this ImageLoader to the specified stream.
`void` | `save(String filename, int format)` Saves the image data in this ImageLoader to a file with the specified name.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### data

    public ImageData[] data

  the array of ImageData objects in this ImageLoader. This array is read in when the load method is called, and it is written out when the save method is called

### logicalScreenWidth

    public int logicalScreenWidth

  the width of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Width value)

### logicalScreenHeight

    public int logicalScreenHeight

  the height of the logical screen on which the images reside, in pixels (this corresponds to the GIF89a Logical Screen Height value)

### backgroundPixel

    public int backgroundPixel

  the background pixel for the logical screen (this corresponds to the GIF89a Background Color Index value). The default is -1 which means 'unspecified background'

### repeatCount

    public int repeatCount

  the number of times to repeat the display of a sequence of animated images (this corresponds to the commonly-used GIF application extension for "NETSCAPE 2.0 01")

Constructor Detail

### ImageLoader

    public ImageLoader()

  Construct a new empty ImageLoader.

Method Detail

### load

    public ImageData[] load(InputStream stream)

  Loads an array of `ImageData` objects from the specified input stream. Throws an error if either an error occurs while loading the images, or if the images are not of a supported type. Returns the loaded image data array.

  Parameters:
    `stream` - the input stream to load the images from
  Returns:
    an array of `ImageData` objects loaded from the specified input stream
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the stream is null
    `SWTException` -
    - ERROR_INVALID_IMAGE - if the image file contains invalid data
    - ERROR_IO - if an input/output error occurs while reading data

### load

    public ImageData[] load(String filename)

  Loads an array of `ImageData` objects from the file with the specified name. Throws an error if either an error occurs while loading the images, or if the images are not of a supported type. Returns the loaded image data array.

  Parameters:
    `filename` - the name of the file to load the images from
  Returns:
    an array of `ImageData` objects loaded from the specified file
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the file name is null
    `SWTException` -
    - ERROR_INVALID_IMAGE - if the image file contains invalid data
    - ERROR_IO - if an IO error occurs while reading data

### save

    public void save(OutputStream stream,
                     int format)

  Saves the image data in this ImageLoader to the specified stream. The format parameter can have one of the following values:
  `IMAGE_BMP`
    Windows BMP file format, no compression
  `IMAGE_BMP_RLE`
    Windows BMP file format, RLE compression if appropriate
  `IMAGE_GIF`
    GIF file format
  `IMAGE_ICO`
    Windows ICO file format
  `IMAGE_JPEG`
    JPEG file format
  `IMAGE_PNG`
    PNG file format

  Parameters:
    `stream` - the output stream to write the images to
    `format` - the format to write the images in
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the stream is null
    `SWTException` -
    - ERROR_INVALID_IMAGE if the image data contains invalid data
    - ERROR_IO if an IO error occurs while writing to the stream

### save

    public void save(String filename,
                     int format)

  Saves the image data in this ImageLoader to a file with the specified name. The format parameter can have one of the following values:
  `IMAGE_BMP`
    Windows BMP file format, no compression
  `IMAGE_BMP_RLE`
    Windows BMP file format, RLE compression if appropriate
  `IMAGE_GIF`
    GIF file format
  `IMAGE_ICO`
    Windows ICO file format
  `IMAGE_JPEG`
    JPEG file format
  `IMAGE_PNG`
    PNG file format

  Parameters:
    `filename` - the name of the file to write the images to
    `format` - the format to write the images in
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the file name is null
    `SWTException` -
    - ERROR_INVALID_IMAGE if the image data contains invalid data
    - ERROR_IO if an IO error occurs while writing to the file

### addImageLoaderListener

    public void addImageLoaderListener(ImageLoaderListener listener)

  Adds a listener to receive image loader events.

  An ImageLoaderListener should be added before invoking one of the receiver's load methods. The listener's `imageDataLoaded` method is called when image data has been partially loaded, as is supported by interlaced GIF/PNG or progressive JPEG images.

  Parameters:
    `listener` - the ImageLoaderListener to add
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the listener is null
  See Also:
    `ImageLoaderListener`, `ImageLoaderEvent`

### removeImageLoaderListener

    public void removeImageLoaderListener(ImageLoaderListener listener)

  Removes a listener that was receiving image loader events.

  Parameters:
    `listener` - the ImageLoaderListener to remove
  Throws:
    `IllegalArgumentException` -
    - ERROR_NULL_ARGUMENT - if the listener is null
  See Also:
    `addImageLoaderListener(ImageLoaderListener)`

### hasListeners

    public boolean hasListeners()

  Returns `true` if the receiver has image loader listeners, and `false` otherwise.

  Returns:
    `true` if there are `ImageLoaderListener`s, and `false` otherwise
  See Also:
    `addImageLoaderListener(ImageLoaderListener)`, `removeImageLoaderListener(ImageLoaderListener)`

### notifyListeners

    public void notifyListeners(ImageLoaderEvent event)

  Notifies all image loader listeners that an image loader event has occurred. Pass the specified event object to each listener.

  Parameters:
    `event` - the `ImageLoaderEvent` to send to each `ImageLoaderListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.