Search in sources :

Example 16 with ImageSize

use of digilib.util.ImageSize in project digilib by robcast.

the class ImageJobDescription method getWx.

/**
 * Return the relative x-offset of the image area.
 * Uses wx parameter.
 * Converts wx in pixels to relative.
 *
 * @return
 * @throws IOException
 */
public Float getWx() throws IOException {
    // logger.debug("get_paramWX()");
    if (paramWX == null) {
        paramWX = getAsFloat("wx");
        if (hasOption(DigilibOption.pxarea)) {
            // area in absolute pixels - convert to relative
            ImageSize imgSize = getHiresSize();
            paramWX = paramWX / imgSize.getWidth();
        } else if (hasOption(DigilibOption.sqarea)) {
            // square full size area
            hiresSize = getHiresSize();
            float aspect = hiresSize.getAspect();
            if (aspect < 1) {
                // portrait
                paramWX = 0f;
            } else {
                // landscape
                paramWX = (1f - (1f / aspect)) / 2f;
            }
        }
    }
    return paramWX;
}
Also used : ImageSize(digilib.util.ImageSize)

Example 17 with ImageSize

use of digilib.util.ImageSize in project digilib by robcast.

the class ImageLoaderDocuImage method getSize.

/* 
     * returns the size of the current image
     * @see digilib.image.DocuImageImpl#getSize()
     */
public ImageSize getSize() {
    if (imageSize == null) {
        int h = 0;
        int w = 0;
        try {
            if (img == null) {
                reader = getReader(input);
                // get size from ImageReader
                h = reader.getHeight(0);
                w = reader.getWidth(0);
            } else {
                // get size from image
                h = img.getHeight();
                w = img.getWidth();
            }
            imageSize = new ImageSize(w, h);
        } catch (IOException e) {
            logger.debug("error in getSize:", e);
        }
    }
    return imageSize;
}
Also used : ImageSize(digilib.util.ImageSize) IOException(java.io.IOException)

Example 18 with ImageSize

use of digilib.util.ImageSize in project digilib by robcast.

the class ImageSet method getNextBigger.

/**
 * Get the next bigger ImageFile than the given size.
 *
 * Returns the ImageFile from the set that has a width or height bigger or
 * equal the given size. Returns null if there isn't any bigger image.
 *
 * @param size
 * @param info
 * @return
 */
public ImageInput getNextBigger(ImageSize size) {
    for (ListIterator<ImageInput> i = getLoresIterator(); i.hasPrevious(); ) {
        ImageInput f = i.previous();
        ImageSize is = f.getSize();
        if (is != null && is.isBiggerThan(size)) {
            return f;
        }
    }
    return null;
}
Also used : ImageSize(digilib.util.ImageSize)

Aggregations

ImageSize (digilib.util.ImageSize)18 ImageInput (digilib.io.ImageInput)6 IOException (java.io.IOException)5 FileOpException (digilib.io.FileOpException)3 ImageSet (digilib.io.ImageSet)2 DocuDirectory (digilib.io.DocuDirectory)1 DocuDirent (digilib.io.DocuDirent)1 ImageFileSet (digilib.io.ImageFileSet)1 Rectangle2D (java.awt.geom.Rectangle2D)1 RandomAccessFile (java.io.RandomAccessFile)1 JsonGenerator (javax.json.stream.JsonGenerator)1 RenderedOp (javax.media.jai.RenderedOp)1 ServletException (javax.servlet.ServletException)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 FormatException (loci.formats.FormatException)1 ImageReader (loci.formats.ImageReader)1 BufferedImageReader (loci.formats.gui.BufferedImageReader)1 ImageInfo (org.devlib.schmidt.imageinfo.ImageInfo)1