loci.formats
Class BMPReader

java.lang.Object
  extended byloci.formats.FormatHandler
      extended byloci.formats.FormatReader
          extended byloci.formats.BMPReader

public class BMPReader
extends FormatReader

BMPReader is the file format reader for Microsoft Bitmap (BMP) files. See http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/ for a nice description of the BMP file format.


Field Summary
protected  int bpp
          Number of bits per pixel.
protected  int compression
          Compression type: 0 = no compression 1 = 8 bit run length encoding 2 = 4 bit run length encoding 3 = RGB bitmap with mask
protected  int height
          Image height.
protected  RandomAccessFile in
          Current file.
protected  boolean littleEndian
          Flag indicating whether current file is little endian.
protected  int offset
          Offset to the image data.
protected  byte[][] palette
          The palette for indexed color images.
protected  int width
          Image width.
 
Fields inherited from class loci.formats.FormatReader
DEBUG, DEBUG_LEVEL, metadata, ome
 
Fields inherited from class loci.formats.FormatHandler
chooser, currentId, filters, format, suffixes
 
Constructor Summary
BMPReader()
          Constructs a new BMP reader.
 
Method Summary
 void close()
          Closes any open files.
 int getImageCount(String id)
          Determines the number of images in the given BMP file.
protected  void initFile(String id)
          Initializes the given BMP file.
 boolean isThisType(byte[] block)
          Checks if the given block is a valid header for a BMP file.
static void main(String[] args)
           
 BufferedImage open(String id, int no)
          Obtains the specified image from the given BMP file.
 
Methods inherited from class loci.formats.FormatReader
createFilters, getMetadata, getMetadataValue, getOMENode, open, testRead
 
Methods inherited from class loci.formats.FormatHandler
getFileChooser, getFileFilters, getFormat, getSuffixes, isThisType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected RandomAccessFile in
Current file.


littleEndian

protected boolean littleEndian
Flag indicating whether current file is little endian.


offset

protected int offset
Offset to the image data.


width

protected int width
Image width.


height

protected int height
Image height.


bpp

protected int bpp
Number of bits per pixel.


palette

protected byte[][] palette
The palette for indexed color images.


compression

protected int compression
Compression type: 0 = no compression 1 = 8 bit run length encoding 2 = 4 bit run length encoding 3 = RGB bitmap with mask

Constructor Detail

BMPReader

public BMPReader()
Constructs a new BMP reader.

Method Detail

isThisType

public boolean isThisType(byte[] block)
Checks if the given block is a valid header for a BMP file.

Specified by:
isThisType in class FormatReader

getImageCount

public int getImageCount(String id)
                  throws FormatException,
                         IOException
Determines the number of images in the given BMP file.

Specified by:
getImageCount in class FormatReader
Throws:
FormatException
IOException

open

public BufferedImage open(String id,
                          int no)
                   throws FormatException,
                          IOException
Obtains the specified image from the given BMP file.

Specified by:
open in class FormatReader
Throws:
FormatException
IOException

close

public void close()
           throws FormatException,
                  IOException
Closes any open files.

Specified by:
close in class FormatReader
Throws:
FormatException
IOException

initFile

protected void initFile(String id)
                 throws FormatException,
                        IOException
Initializes the given BMP file.

Overrides:
initFile in class FormatReader
Throws:
FormatException
IOException

main

public static void main(String[] args)
                 throws FormatException,
                        IOException
Throws:
FormatException
IOException