Examples of XTIFFField


Examples of org.libtiff.jai.codec.XTIFFField

    /**
     * The initialization method particular to Fax decoding.
     */
    public void initializeDecoding() {

        XTIFFField fillOrderField = directory.getField(XTIFF.TIFFTAG_FILL_ORDER);
        if (fillOrderField != null) {
            fillOrder = fillOrderField.getAsInt(0);
        } else {
            // Default Fill Order
            fillOrder = 1;
        }
        // Fax T.4 compression options
        if (compression == 3) {
            XTIFFField t4OptionsField = directory.getField(XTIFF.TIFFTAG_T4_OPTIONS);
            if (t4OptionsField != null) {
                tiffT4Options = t4OptionsField.getAsLong(0);
            } else {
                // Use default value
                tiffT4Options = 0;
            }
        }

        // Fax T.6 compression options
        if (compression == 4) {
            XTIFFField t6OptionsField = directory.getField(XTIFF.TIFFTAG_T6_OPTIONS);
            if (t6OptionsField != null) {
                tiffT6Options = t6OptionsField.getAsLong(0);
            } else {
                // Use default value
                tiffT6Options = 0;
            }
        }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

        height = (int) dir.getFieldAsLong(XTIFF.TIFFTAG_IMAGE_LENGTH);

        photometric_interp = (int) dir.getFieldAsLong(XTIFF.TIFFTAG_PHOTOMETRIC_INTERPRETATION);

        // Read the TIFFTAG_BITS_PER_SAMPLE field
        XTIFFField bitsField = dir.getField(XTIFF.TIFFTAG_BITS_PER_SAMPLE);

        if (bitsField == null) {
            // Default
            bitsPerSample = new char[1];
            bitsPerSample[0] = 1;
        } else {
            bitsPerSample = bitsField.getAsChars();
        }

        for (int i = 1; i < bitsPerSample.length; i++) {
            if (bitsPerSample[i] != bitsPerSample[1]) {
                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder19"));
            }
        }

        // Get the number of samples per pixel
        XTIFFField sfield = dir.getField(XTIFF.TIFFTAG_SAMPLES_PER_PIXEL);
        if (sfield == null) {
            samplesPerPixel = 1;
        } else {
            samplesPerPixel = (int) sfield.getAsLong(0);
        }

        // Figure out if any extra samples are present.
        XTIFFField efield = dir.getField(XTIFF.TIFFTAG_EXTRA_SAMPLES);
        if (efield == null) {
            extraSamples = 0;
        } else {
            extraSamples = (int) efield.getAsLong(0);
        }

        // Read the TIFFTAG_SAMPLE_FORMAT tag to see whether the data might be
        // signed or floating point
        XTIFFField sampleFormatField = dir.getField(XTIFF.TIFFTAG_SAMPLE_FORMAT);

        if (sampleFormatField != null) {
            sampleFormat = sampleFormatField.getAsChars();

            // Check that all the samples have the same format
            for (int l = 1; l < sampleFormat.length; l++) {
                if (sampleFormat[l] != sampleFormat[0]) {
                    throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder20"));
                }
            }

        } else {
            sampleFormat = new char[] { 1 };
        }

        if (sampleFormat[0] == 1 || sampleFormat[0] == 4) {

            // Unsigned or unknown
            if (bitsPerSample[0] == 8) {
                dataType = DataBuffer.TYPE_BYTE;
            } else if (bitsPerSample[0] == 16) {
                dataType = DataBuffer.TYPE_USHORT;
            } else if (bitsPerSample[0] == 32) {
                dataType = DataBuffer.TYPE_INT;
            }

        } else if (sampleFormat[0] == 2) {
            // Signed

            if (bitsPerSample[0] == 1 || bitsPerSample[0] == 4
                    || bitsPerSample[0] == 8) {

                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder21"));

            } else if (bitsPerSample[0] == 16) {
                dataType = DataBuffer.TYPE_SHORT;
            } else if (bitsPerSample[0] == 32) {
                dataType = DataBuffer.TYPE_INT;
            }

        } else if (sampleFormat[0] == 3) {
            // Floating point
            // dataType = DataBuffer.TYPE_FLOAT;
            throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder22"));
        }

        if (dir.getField(XTIFF.TIFFTAG_TILE_WIDTH) != null) {
            // Image is in tiled format
            tileWidth = (int) dir.getFieldAsLong(XTIFF.TIFFTAG_TILE_WIDTH);
            tileHeight = (int) dir.getFieldAsLong(XTIFF.TIFFTAG_TILE_LENGTH);
            tileOffsets = (dir.getField(XTIFF.TIFFTAG_TILE_OFFSETS)).getAsLongs();
            tileByteCounts = dir.getField(XTIFF.TIFFTAG_TILE_BYTE_COUNTS)
                    .getAsLongs();

        } else {

            // Image is in stripped format, looks like tiles to us
            tileWidth = width;
            XTIFFField field = dir.getField(XTIFF.TIFFTAG_ROWS_PER_STRIP);
            if (field == null) {
                // Default is infinity (2^32 -1), basically the entire image
                // TODO: Can do a better job of tiling here
                tileHeight = height;
            } else {
                long l = field.getAsLong(0);
                long infinity = 1;
                infinity = (infinity << 32) - 1;
                if (l == infinity) {
                    // 2^32 - 1 (effectively infinity, entire image is 1 strip)
                    tileHeight = height;
                } else {
                    tileHeight = (int) l;
                }
            }

            XTIFFField tileOffsetsField = dir.getField(XTIFF.TIFFTAG_STRIP_OFFSETS);
            if (tileOffsetsField == null) {
                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder11"));
            } else {
                tileOffsets = tileOffsetsField.getAsLongs();
            }

            XTIFFField tileByteCountsField = dir.getField(XTIFF.TIFFTAG_STRIP_BYTE_COUNTS);
            if (tileByteCountsField == null) {
                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder12"));
            } else {
                tileByteCounts = tileByteCountsField.getAsLongs();
            }
        }
    }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

        case XTIFF.PHOTOMETRIC_PALETTE:

            image_type = XTIFF.TYPE_PALETTE;

            // Get the colormap
            XTIFFField cfield = dir.getField(XTIFF.TIFFTAG_COLORMAP);
            if (cfield == null) {
                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder2"));
            } else {
                colormap = cfield.getAsChars();
            }

            // Could be either 1 or 3 bands depending on whether we use
            // IndexColorModel or not.
            if (decodePaletteAsShorts) {
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

        }

        if (isTiled) {
            tileWidth = 16L;
            tileLength = 16L;
            XTIFFField fld = directory.getField(XTIFF.TIFFTAG_TILE_WIDTH);
            if (fld != null)
                tileWidth = (int) fld.getAsLong(0);
            fld = directory.getField(XTIFF.TIFFTAG_TILE_LENGTH);
            if (fld != null)
                tileLength = (int) fld.getAsLong(0);
        } else {
            // Default strip is 8 rows.
            tileLength = 8L;
            // tileWidth of strip is width

            tileWidth = width;
            XTIFFField fld = directory.getField(TIFFImageDecoder.TIFF_ROWS_PER_STRIP);
            if (fld != null)
                tileLength = fld.getAsLong(0);
        }

        numTiles = (int) Math.ceil((double) length / (double) tileLength)
                * (int) Math.ceil((double) width / (double) tileWidth);

View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

        int numEntries = fields.length;

        long offsetBeyondIFD = currentOffset + 12 * numEntries + 4 + 2;
        Vector tooBig = new Vector();

        XTIFFField field;
        int tag;
        int type;
        int count;

        // Write number of fields in the IFD
        writeUnsignedShort(numEntries);

        for (int i = 0; i < numEntries; i++) {

            field = fields[i];

            // 12 byte field entry TIFFField

            // byte 0-1 Tag that identifies a field
            tag = field.getTag();
            writeUnsignedShort(tag);

            // byte 2-3 The field type
            type = field.getType();
            writeUnsignedShort(type);

            // bytes 4-7 the number of values of the indicated type
            count = field.getCount();
            writeLong(count);

            // bytes 8 - 11 the value offset
            if (count * sizeOfType[type] > 4) {

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.