Examples of XTIFFField


Examples of org.libtiff.jai.codec.XTIFFField

        int indx = 4;
        char numDoubles = 0;
        char tag = 0;
        char valueOrOffset = 0;
        while (it.hasNext()) {
            XTIFFField geoKey = (XTIFFField) it.next();
            switch (geoKey.getType()) {
            case XTIFFField.TIFF_SHORT:
                // short values are stored in the valueOrOffset
                tag = 0;
                valueOrOffset = (char) geoKey.getAsInt(0);
                break;
            case XTIFFField.TIFF_DOUBLE:
                tag = (char) XTIFF.TIFFTAG_GEO_DOUBLE_PARAMS;
                doubles[numDoubles] = geoKey.getAsDouble(0);
                valueOrOffset = numDoubles++;
                break;
            case XTIFFField.TIFF_ASCII:
                // strings are '|' pipe delimited
                tag = (char) XTIFF.TIFFTAG_GEO_ASCII_PARAMS;
                valueOrOffset = (char) strings.length();
                strings = strings + geoKey.getAsString(0) + "|";
                break;
            } // switch
            keys[indx++] = (char) geoKey.getTag();
            keys[indx++] = tag;
            keys[indx++] = (char) geoKey.getCount();
            keys[indx++] = valueOrOffset;
        } // while

        // Add the Directory tag
        addField(XTIFF.TIFFTAG_GEO_KEY_DIRECTORY,
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

                             int valueOrOffset) throws java.io.IOException {
        int type = XTIFFField.TIFF_SHORT;
        Object value = null;
        if (tiffTag > 0) {
            // Values are in another tag:
            XTIFFField values = getField(tiffTag);
            if (values != null) {
                type = values.getType();
                if (type == XTIFFField.TIFF_ASCII) {
                    String svalue = values.getAsString(0)
                            .substring(valueOrOffset,
                                    valueOrOffset + valueCount - 1);
                    value = new String[] { svalue };
                } else if (type == XTIFFField.TIFF_DOUBLE) {
                    // we shouldn't have valueCount != 1 here
                    double dvalue = values.getAsDouble(valueOrOffset);
                    value = new double[] { dvalue };
                }
            } else {
                throw new java.io.IOException("GeoTIFF tag not found");
            } // values tag found
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     * TIFF fields.
     */
    private void readGeoKeys() throws java.io.IOException {

        // read in the keys
        XTIFFField geoKeyTag = getField(XTIFF.TIFFTAG_GEO_KEY_DIRECTORY);
        if (geoKeyTag != null) {
            char[] keys = geoKeyTag.getAsChars();

            // Set up header info
            keyDirectoryVersion = keys[0]; // should be 1 forever.
            majorRevision = keys[1]; // currently 1
            minorRevision = keys[2]; // 0,1, or 2...
            numberOfKeys = keys[3];

            // Parse out keys and values
            for (int i = 4; i < keys.length; i += 4) {
                int keyID = keys[i];
                int tiffTag = keys[i + 1];
                int valueCount = keys[i + 2];
                int valueOrOffset = keys[i + 3];
                storeGeoKey(keyID, tiffTag, valueCount, valueOrOffset);
            }

        }

        // set up the values stored in tags
        // read in the data stored as real tags
        XTIFFField matrixTag = getField(XTIFF.TIFFTAG_GEO_TRANS_MATRIX);
        XTIFFField tiepointTag = getField(XTIFF.TIFFTAG_GEO_TIEPOINTS);
        XTIFFField scaleTag = getField(XTIFF.TIFFTAG_GEO_PIXEL_SCALE);
        if (tiepointTag != null) {
            tiepoints = tiepointTag.getAsDoubles();
        }
        if (scaleTag != null) {
            scales = scaleTag.getAsDoubles();
        }
        if (matrixTag != null) {
            matrix = matrixTag.getAsDoubles();
        }
    } // readGeoKeys
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

    /**
     * Add a geoKey to the directory
     */
    public void addGeoKey(int key, int type, int count, Object data) {
        XTIFFField geoKey = createField(key, type, count, data);
        addGeoKey(geoKey);
    }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     *
     * @param tagNumber
     * @return XTIFFField, or null if not found in file.
     */
    public XTIFFField getFieldWithTag(int tagNumber) {
        XTIFFField ret = null;
        XTIFFField[] gtfFields = gtfDirectory.getFields();
        for (int i = 0; i < gtfFields.length; i++) {
            XTIFFField xtff = gtfFields[i];
            int tag = xtff.getTag();
            if (tag == tagNumber) {
                ret = xtff;
                break;
            }
        }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     * @return XTIFFField, or null if not found in file.
     */
    protected XTIFFField getGeoFieldForCode(int code) {
        if (geoKeys != null) {
            for (int i = 0; i < geoKeys.length; i++) {
                XTIFFField f = geoKeys[i];
                if (f.getTag() == code) {
                    return f;
                }
            }
        }
        return null;
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     *
     * @param codeFromKeyRegistry
     * @return the code value, or -1 if not found.
     */
    protected int getGeoKeyIntValue(int codeFromKeyRegistry) {
        XTIFFField field = getGeoFieldForCode(codeFromKeyRegistry);

        if (field != null) {
            int type = field.getType();
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("field type is " + getStringOfType(type));
            }
            if (type == XTIFFField.TIFF_SHORT) {
                return field.getAsInt(0);
            }
        }
        return -1;
    }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     *
     * @param tiffCode
     * @return the code value, or -1 if not found.
     */
    protected int getFieldIntValue(int tiffCode) {
        XTIFFField field = getFieldWithTag(tiffCode);

        if (field != null) {
            int type = field.getType();
            if (type == XTIFFField.TIFF_SHORT) {
                return field.getAsInt(0);
            }
        }
        return -1;
    }
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

     */
    public void dumpTags(XTIFFField[] gtfFields) {

        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < gtfFields.length; i++) {
            XTIFFField xtff = gtfFields[i];

            int type = xtff.getType();
            int tag = xtff.getTag();
            buf.append("\n\tfield (" + i + ") - " + tag + " ("
                    + KeyRegistry.getKey(KeyRegistry.GEOKEY, tag) + "): [");

            switch (type) {
            case XTIFFField.TIFF_ASCII:
                String[] fieldStrings = xtff.getAsStrings();
                for (int j = 0; j < fieldStrings.length; j++) {
                    buf.append(fieldStrings[j]);
                    if (j < fieldStrings.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_DOUBLE:
                double[] fieldDoubles = xtff.getAsDoubles();
                for (int j = 0; j < fieldDoubles.length; j++) {
                    buf.append(fieldDoubles[j]);
                    if (j < fieldDoubles.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_FLOAT:
                double[] fieldFloats = xtff.getAsDoubles();
                for (int j = 0; j < fieldFloats.length; j++) {
                    buf.append(fieldFloats[j]);
                    if (j < fieldFloats.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_BYTE:
            case XTIFFField.TIFF_SBYTE:
                byte[] fieldBytes = xtff.getAsBytes();
                for (int j = 0; j < fieldBytes.length; j++) {
                    buf.append(fieldBytes[j]);
                    if (j < fieldBytes.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_SSHORT:
                short[] fieldShorts = xtff.getAsShorts();
                for (int j = 0; j < fieldShorts.length; j++) {
                    buf.append(fieldShorts[j]);
                    if (j < fieldShorts.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_LONG:
            case XTIFFField.TIFF_SHORT:
                long[] fieldLongs = xtff.getAsLongs();
                for (int j = 0; j < fieldLongs.length; j++) {
                    buf.append(fieldLongs[j]);
                    if (j < fieldLongs.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_SLONG:
                int[] fieldInts = xtff.getAsInts();
                for (int j = 0; j < fieldInts.length; j++) {
                    buf.append(fieldInts[j]);
                    if (j < fieldInts.length - 1) {
                        buf.append(", ");
                    }
                }
                buf.append("]");
                break;
            case XTIFFField.TIFF_RATIONAL:
                long[][] fieldRationals = xtff.getAsRationals();
                for (int k = 0; k < fieldRationals.length; k++) {
                    buf.append("\n\t");
                    for (int j = 0; j < fieldRationals[0].length; j++) {
                        buf.append(fieldRationals[k][j]);
                        if (j < fieldRationals[k].length - 1) {
                            buf.append(", ");
                        }
                    }
                }
                buf.append("\n]");
                break;
            case XTIFFField.TIFF_SRATIONAL:
                int[][] fieldSRationals = xtff.getAsSRationals();
                for (int k = 0; k < fieldSRationals.length; k++) {
                    buf.append("\n\t");
                    for (int j = 0; j < fieldSRationals[0].length; j++) {
                        buf.append(fieldSRationals[k][j]);
                        if (j < fieldSRationals[k].length - 1) {
View Full Code Here

Examples of org.libtiff.jai.codec.XTIFFField

    /**
     * The initialization method particular to LZW decoding.
     */
    public void initializeDecoding() {
        // Get the number of samples per pixel
        XTIFFField sfield = directory.getField(XTIFF.TIFFTAG_SAMPLES_PER_PIXEL);
        if (sfield == null) {
            samplesPerPixel = 1;
        } else {
            samplesPerPixel = (int) sfield.getAsLong(0);
        }
        XTIFFField predictorField = directory.getField(XTIFF.TIFFTAG_PREDICTOR);

        if (predictorField == null) {
            predictor = 1;
        } else {
            predictor = predictorField.getAsInt(0);
            if (predictor != 1 && predictor != 2) {
                throw new RuntimeException(JaiI18N.getString("XTIFFImageDecoder16"));
            }
            if (predictor == 2 && bitsPerSample[0] != 8) {
                throw new RuntimeException(bitsPerSample[0]
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.