Class BmpImage


  • public class BmpImage
    extends java.lang.Object
    Reads a BMP image. All types of BMP can be read.

    It is based in the JAI codec.

    • Field Detail

      • inputStream

        private java.io.InputStream inputStream
      • bitmapFileSize

        private long bitmapFileSize
      • bitmapOffset

        private long bitmapOffset
      • compression

        private long compression
      • imageSize

        private long imageSize
      • palette

        private byte[] palette
      • imageType

        private int imageType
      • numBands

        private int numBands
      • isBottomUp

        private boolean isBottomUp
      • bitsPerPixel

        private int bitsPerPixel
      • redMask

        private int redMask
      • greenMask

        private int greenMask
      • blueMask

        private int blueMask
      • alphaMask

        private int alphaMask
      • properties

        public java.util.HashMap<java.lang.String,​java.lang.Object> properties
      • xPelsPerMeter

        private long xPelsPerMeter
      • yPelsPerMeter

        private long yPelsPerMeter
      • width

        int width
      • height

        int height
    • Constructor Detail

      • BmpImage

        BmpImage​(java.io.InputStream is,
                 boolean noHeader,
                 int size)
          throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getImage

        public static Image getImage​(java.net.URL url)
                              throws java.io.IOException
        Reads a BMP from an url.
        Parameters:
        url - the url
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        public static Image getImage​(java.io.InputStream is)
                              throws java.io.IOException
        Reads a BMP from a stream. The stream is not closed.
        Parameters:
        is - the stream
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        public static Image getImage​(java.io.InputStream is,
                                     boolean noHeader,
                                     int size)
                              throws java.io.IOException
        Reads a BMP from a stream. The stream is not closed. The BMP may not have a header and be considered as a plain DIB.
        Parameters:
        is - the stream
        noHeader - true to process a plain DIB
        size - the size of the DIB. Not used for a BMP
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        public static Image getImage​(java.lang.String file)
                              throws java.io.IOException
        Reads a BMP from a file.
        Parameters:
        file - the file
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • getImage

        public static Image getImage​(byte[] data)
                              throws java.io.IOException
        Reads a BMP from a byte array.
        Parameters:
        data - the byte array
        Returns:
        the image
        Throws:
        java.io.IOException - on error
      • process

        protected void process​(java.io.InputStream stream,
                               boolean noHeader)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • getPalette

        private byte[] getPalette​(int group)
      • readPalette

        private void readPalette​(int sizeOfPalette)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • read24Bit

        private void read24Bit​(byte[] bdata)
      • findMask

        private int findMask​(int mask)
      • findShift

        private int findShift​(int mask)
      • decodeRLE

        private byte[] decodeRLE​(boolean is8,
                                 byte[] values)
      • readUnsignedByte

        private int readUnsignedByte​(java.io.InputStream stream)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readUnsignedShort

        private int readUnsignedShort​(java.io.InputStream stream)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readShort

        private int readShort​(java.io.InputStream stream)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readWord

        private int readWord​(java.io.InputStream stream)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • readUnsignedInt

        private long readUnsignedInt​(java.io.InputStream stream)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readInt

        private int readInt​(java.io.InputStream stream)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readDWord

        private long readDWord​(java.io.InputStream stream)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • readLong

        private int readLong​(java.io.InputStream stream)
                      throws java.io.IOException
        Throws:
        java.io.IOException