us.zuercher.gpx2map.image
Interface Image

All Known Subinterfaces:
NetpbmImage
All Known Implementing Classes:
AbstractNetpbmImage, GenericImage, PamImage, PpmImage

public interface Image

Image represents any type of image support by sub-packages of us.zuercher.gpx2map.image.

Author:
Stephan Zuercher

Method Summary
 void close()
          Closes the image file.
 int getDepth()
          Returns the image's raster depth.
 int getHeight()
          Returns the image's height.
 int[][] getNextRasterLine()
          Reads the next raster line from the image.
 int[][][] getRaster()
          Returns an array of rasters for this image.
 int getWidth()
          Returns the image's width.
 boolean hasAlphaChannel()
          Returns true if the NetpbmImage implementation supports alpha-channel values.
 

Method Detail

hasAlphaChannel

boolean hasAlphaChannel()
Returns true if the NetpbmImage implementation supports alpha-channel values.

Returns:
true if the Image implementation supports alpha-channel values.

getWidth

int getWidth()
Returns the image's width.

Returns:
the image's width.

getHeight

int getHeight()
Returns the image's height.

Returns:
the image's height.

getDepth

int getDepth()
Returns the image's raster depth. If hasAlphaChannel() is false, this value is 1 (grayscale) or 3 (RGB color). If the image has an alpha channel, this value is 2 (grayscale + alpha) or 4 (RGB color + alpha).

Returns:
the image's raster depth

getRaster

int[][][] getRaster()
                    throws IOException
Returns an array of rasters for this image. Each raster is itself an array of pixel data. The rank of the pixel data array is always at least getDepth(). The alpha channel, if present uses the last channel (e.g. getDepth() - 1).

The following pseudo-code shows the dimensions of the array:

     int h = image.getHeight();
     int w = image.getWidth();
     int c = image.getDepth();
   
     int[][][] rasterData = new int[h][w][c];
 

Note: Either this method or getNextRasterLine() may be used to retrieve raster data. They cannot be combined.

Returns:
an array of rasters for this image.
Throws:
IOException - if there's an error reading raster data for the image

getNextRasterLine

int[][] getNextRasterLine()
                          throws IOException
Reads the next raster line from the image. Note that the array returned by this method may be re-used for each subsequent call to this method. If you need to keep a copy of the raster line beyond the next call to this method, make a copy of it.

The dimension of the second rank of the array is always at least the image's depth. Although it may be larger, extra elements should be ignored. If hasAlphaChannel() returns true, the last channel (based on getDepth()) is the alpha channel.

Once all raster lines have been read, you should release resources by calling close().

Note: Either this method or getRaster() may be used to retrieve raster data. They cannot be combined.

Returns:
next raster line or null if EOF
Throws:
IOException - on file error

close

void close()
           throws IOException
Closes the image file.

Throws:
IOException - if there's an error closing the file