Package digilib.image

Interface DocuImage

All Known Implementing Classes:
DocuImageImpl, ImageInfoDocuImage, ImageLoaderDocuImage

public interface DocuImage
The basic class for the representation of a digilib image. The actual image object is hidden in the class, only methods for loading, manipulation, and saving are exported. This strategy enables implementations using different toolkits that rely on different image base classes (like JIMI, Java2D and JAI).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Operations for colorOps.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Changes the colors of the current image.
    void
    crop(int xoff, int yoff, int width, int height)
    Crops the current image.
    void
    cropAndScale(int x_off, int y_off, int width, int height, double scale, int qual)
    Crops and scales the current image.
    void
    Frees all resources bound to the DocuImage.
    void
    enhance(float mult, float add)
    Enhances brightness and contrast of the current image.
    void
    enhanceRGB(float[] rgbm, float[] rgba)
    Manipulates the colors of the current image.
    returns the underlying image as java.awt.Image (if possible, or null)
    Return String representation of implementation specific image hacks.
    int
    The height of the current image in pixel.
    Returns the image specific hint with the given key.
    The mime-type of the image, i.e.
    int
    Returns the interpolation quality.
    The size of the current image in pixel.
    Returns the list of supported image formats.
    returns the version of the DocuImage implementation.
    int
    The width of the current image in pixel.
    Check image size and type and store in ImageInput ii
    boolean
    This DocuImage supports the loadSubImage operation.
    void
    Loads an image file into the Object.
    void
    loadSubimage(ImageInput ii, Rectangle region, int subsample)
    Load only a subsampled region of the image file.
    void
    mirror(double angle)
    Mirrors the current image.
    void
    rotate(double angle)
    Rotates the current image.
    void
    scale(double scaleX, double scaleY)
    Scales the current image.
    void
    setHacks(String hackString)
    Set implementation specific image hacks.
    void
    setHint(String key, Object value)
    Set optional image specific hints with additional information.
    void
    setQuality(int quality)
    Sets the interpolation quality.
    void
    Set preferred image reader classes.
    void
    Set preferred image writer classes.
    void
    Writes the current image to an OutputStream.
  • Method Details

    • loadImage

      void loadImage(ImageInput ii) throws FileOpException
      Loads an image file into the Object.
      Parameters:
      ii - Image File.
      Throws:
      FileOpException - Exception thrown if any error occurs.
    • isSubimageSupported

      boolean isSubimageSupported()
      This DocuImage supports the loadSubImage operation.
      Returns:
      if loadSubImage is supported
    • loadSubimage

      void loadSubimage(ImageInput ii, Rectangle region, int subsample) throws FileOpException
      Load only a subsampled region of the image file.
      Parameters:
      ii - the ImageInput
      region - the region
      subsample - the subsample
      Throws:
      FileOpException - on error
    • writeImage

      void writeImage(String mt, OutputStream ostream) throws ImageOpException, FileOpException
      Writes the current image to an OutputStream. The image is encoded to the mime-type mt and sent to the output stream ostream. Currently only mime-types "image/jpeg", "image/png" and "image/webp" are supported.
      Parameters:
      mt - mime-type of the image to be sent.
      ostream - OutputStream where the image is sent.
      Throws:
      ImageOpException - Exception in other cases.
      FileOpException - Exception on sending data
    • getWidth

      int getWidth()
      The width of the current image in pixel.
      Returns:
      Image width in pixels.
    • getHeight

      int getHeight()
      The height of the current image in pixel.
      Returns:
      Image height in pixels.
    • getSize

      ImageSize getSize()
      The size of the current image in pixel.
      Returns:
      the ImageSize
    • getMimetype

      String getMimetype()
      The mime-type of the image, i.e. the mime-type of the input that was read.
      Returns:
      String the mime-type of this image.
    • crop

      void crop(int xoff, int yoff, int width, int height) throws ImageOpException
      Crops the current image. Cuts out a region of the size width x height at the offset xoff, yoff from the current image and replaces the current image with the result.
      Parameters:
      xoff - X offset of crop region
      yoff - Y offset of crop region
      width - width of crop region
      height - height of crop region
      Throws:
      ImageOpException - on error
    • scale

      void scale(double scaleX, double scaleY) throws ImageOpException
      Scales the current image. Replaces the current image with an image scaled by the factor scale.
      Parameters:
      scaleX - the scaleX
      scaleY - the scaleY
      Throws:
      ImageOpException - on error
    • cropAndScale

      void cropAndScale(int x_off, int y_off, int width, int height, double scale, int qual) throws ImageOpException
      Crops and scales the current image. The current image is cropped to a rectangle of width, height at position x_off, y_off. The resulting image is scaled by the factor scale using the interpolation quality qual (0=worst).
      Parameters:
      x_off - x offset of the crop rectangle in pixel.
      y_off - y offset of the crop rectangle in pixel.
      width - width of the crop rectangle in pixel.
      height - height of the crop rectangle in pixel.
      scale - scaling factor.
      qual - interpolation quality (0=worst).
      Throws:
      ImageOpException - exception thrown on any error.
    • rotate

      void rotate(double angle) throws ImageOpException
      Rotates the current image. Replaces the current image with a rotated image. The image is rotated around the center by the angle given in degrees [0, 360] clockwise. Image size and aspect ratio are likely to change.
      Parameters:
      angle - rotation angle in degree
      Throws:
      ImageOpException - on error
    • mirror

      void mirror(double angle) throws ImageOpException
      Mirrors the current image. Replaces the current image with a mirrored image. The mirror axis goes through the center of the image and is rotated by angle degrees. Currently only horizontal and vertical mirroring (0 and 90 degree) are supported.
      Parameters:
      angle - angle of mirror axis
      Throws:
      ImageOpException - on error
    • enhance

      void enhance(float mult, float add) throws ImageOpException
      Enhances brightness and contrast of the current image. Replaces the current image with a brightness and contrast enhanced image. Contrast is enhanced by multiplying the pixel value with the constant mult. Brightness is enhanced by adding the constant add to the pixel value. Operation: p1 = (p0*mult)+add.
      Parameters:
      mult - multiplicative constant for contrast enhancement
      add - additive constant for brightness enhancement
      Throws:
      ImageOpException - on error
    • enhanceRGB

      void enhanceRGB(float[] rgbm, float[] rgba) throws ImageOpException
      Manipulates the colors of the current image. Replaces the current image with a color modified image. For the red, green and blue color channels all pixel values are multiplied by the constant m and added to the constant a. Operation: p1 = (p0*m)+a.
      Parameters:
      rgbm - multiplicative constants for red, green, blue
      rgba - additive constant for red, green, blue
      Throws:
      ImageOpException - on error
    • colorOp

      void colorOp(DocuImage.ColorOp op) throws ImageOpException
      Changes the colors of the current image. Changes the colors of the current image. Operations are instances of ColorOp: GRAYSCALE: cast color image to grayscale NTSC_GRAY: convert color image to grayscale using NTSC formula INVERT: invert colors (every channel separately) MAP_GRAY_BGR: false color image from grayscale (0: blue, 128: green, 255: red)
      Parameters:
      op - the ColorOp
      Throws:
      ImageOpException - on error
    • getQuality

      int getQuality()
      Returns the interpolation quality.
      Returns:
      int the quality
    • setQuality

      void setQuality(int quality)
      Sets the interpolation quality.
      Parameters:
      quality - The quality to set
    • dispose

      void dispose()
      Frees all resources bound to the DocuImage. Things that should be freed are image objects and open files.
    • identify

      ImageInput identify(ImageInput ii) throws IOException
      Check image size and type and store in ImageInput ii
      Parameters:
      ii - the ImageInput
      Returns:
      the ImageInput
      Throws:
      IOException - on error
    • getSupportedFormats

      Iterator<String> getSupportedFormats()
      Returns the list of supported image formats.
      Returns:
      the list of supported image formats
    • getAwtImage

      Image getAwtImage()
      returns the underlying image as java.awt.Image (if possible, or null)
      Returns:
      the Image
    • getVersion

      String getVersion()
      returns the version of the DocuImage implementation.
      Returns:
      the version
    • setHacks

      void setHacks(String hackString)
      Set implementation specific image hacks. Sets static class members. Needs to be called only once per class. Format: comma separated key=value pairs (no spaces!).
      Parameters:
      hackString - the hackString
    • getHacksAsString

      String getHacksAsString()
      Return String representation of implementation specific image hacks.
      Returns:
      the hackstring
    • setHint

      void setHint(String key, Object value)
      Set optional image specific hints with additional information.
      Parameters:
      key - the key
      value - the value
    • getHint

      Object getHint(String key)
      Returns the image specific hint with the given key.
      Parameters:
      key - the key
      Returns:
      the hint
    • setReaderClasses

      void setReaderClasses(Map<String,String> typeClassMap)
      Set preferred image reader classes. Configured with a Map containing content-type and class-name. Sets static class members. Needs to be called only once per class.
      Parameters:
      typeClassMap -
    • setWriterClasses

      void setWriterClasses(Map<String,String> typeClassMap)
      Set preferred image writer classes. Configured with a Map containing content-type and class-name. Sets static class members. Needs to be called only once per class.
      Parameters:
      typeClassMap -