當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldType.BYTE屬性代碼示例

本文整理匯總了Java中org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType.BYTE屬性的典型用法代碼示例。如果您正苦於以下問題:Java FieldType.BYTE屬性的具體用法?Java FieldType.BYTE怎麽用?Java FieldType.BYTE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType的用法示例。


在下文中一共展示了FieldType.BYTE屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValue

@Override
public String getValue(final TiffField entry) throws ImageReadException {
    if (entry.getFieldType() != FieldType.BYTE) {
        throw new ImageReadException("Text field not encoded as bytes.");
    }
    try {
        return new String(entry.getByteArrayValue(), "UTF-16LE");
    } catch (final UnsupportedEncodingException cannotHappen) {
        return null;
    }
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:11,代碼來源:TagInfoXpString.java

示例2: add

public void add(final TagInfoByte tagInfo, final byte... values)
        throws ImageWriteException {
    if (tagInfo.length > 0 && tagInfo.length != values.length) {
        throw new ImageWriteException("Tag expects " + tagInfo.length
                + " value(s), not " + values.length);
    }
    final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
    final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
            tagInfo, FieldType.BYTE, values.length,
            bytes);
    add(tiffOutputField);
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:12,代碼來源:TiffOutputDirectory.java

示例3: getValue

@Override
public String getValue(final TiffField entry) throws ImageReadException {
    if (entry.getFieldType() != FieldType.BYTE) {
        throw new ImageReadException("Text field not encoded as bytes.");
    }
    final byte[] bytes = entry.getByteArrayValue();
    final int length;
    if (bytes.length >= 2 && bytes[bytes.length - 1] == 0 && bytes[bytes.length - 2] == 0) {
        length = bytes.length - 2;
    } else {
        length = bytes.length;
    }
    return new String(bytes, 0, length, StandardCharsets.UTF_16LE);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:14,代碼來源:TagInfoXpString.java

示例4: add

public void add(final TagInfoByte tagInfo, final byte value)
        throws ImageWriteException {
    if (tagInfo.length != 1) {
        throw new ImageWriteException("Tag expects " + tagInfo.length
                + " value(s), not 1");
    }
    final byte[] bytes = tagInfo.encodeValue(byteOrder, value);
    final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
            tagInfo, FieldType.BYTE, bytes.length, bytes);
    add(tiffOutputField);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:11,代碼來源:TiffOutputDirectory.java

示例5: TagInfoXpString

public TagInfoXpString(final String name, final int tag, final int length,
        final TiffDirectoryType directoryType) {
    super(name, tag, FieldType.BYTE, length, directoryType);
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:4,代碼來源:TagInfoXpString.java

示例6: TagInfoByte

public TagInfoByte(final String name, final int tag, final int length, final TiffDirectoryType directoryType) {
    super(name, tag, FieldType.BYTE, length, directoryType);
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:3,代碼來源:TagInfoByte.java

示例7: TagInfoXpString

public TagInfoXpString(final String name, final int tag, final TiffDirectoryType directoryType) {
    super(name, tag, FieldType.BYTE, LENGTH_UNKNOWN, directoryType);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:3,代碼來源:TagInfoXpString.java

示例8: TagInfoBytes

public TagInfoBytes(final String name, final int tag, final int length, final TiffDirectoryType directoryType) {
    super(name, tag, FieldType.BYTE, length, directoryType);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:3,代碼來源:TagInfoBytes.java

示例9: TagInfoByte

public TagInfoByte(final String name, final int tag, final TiffDirectoryType directoryType) {
    super(name, tag, FieldType.BYTE, 1, directoryType);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:3,代碼來源:TagInfoByte.java

示例10: getValue

@Override
public String getValue(final TiffField entry) throws ImageReadException {
    if (entry.getFieldType() == FieldType.ASCII) {
        final Object object = FieldType.ASCII.getValue(entry);
        if (object instanceof String) {
            return (String) object;
        } else if (object instanceof String[]) {
            // Use of arrays with the ASCII type
            // should be extremely rare, and use of
            // ASCII type in GPS fields should be
            // forbidden. So assume the 2 never happen
            // together and return incomplete strings if they do.
            return ((String[]) object)[0];
        } else {
            throw new ImageReadException("Unexpected ASCII type decoded");
        }
    } else if (entry.getFieldType() == FieldType.UNDEFINED) {
        /* later */
    } else if (entry.getFieldType() == FieldType.BYTE) {
        /* later */
    } else {
        Debug.debug("entry.type: " + entry.getFieldType());
        Debug.debug("entry.directoryType: " + entry.getDirectoryType());
        Debug.debug("entry.type: " + entry.getDescriptionWithoutValue());
        Debug.debug("entry.type: " + entry.getFieldType());
        throw new ImageReadException("GPS text field not encoded as bytes.");
    }

    final byte[] bytes = entry.getByteArrayValue();
    if (bytes.length < 8) {
        // try ASCII, with NO prefix.
        return new String(bytes, StandardCharsets.US_ASCII);
    }

    for (final TextEncoding encoding : TEXT_ENCODINGS) {
        if (BinaryFunctions.compareBytes(bytes, 0, encoding.prefix, 0,
                encoding.prefix.length)) {
            try {
                final String decodedString = new String(
                        bytes, encoding.prefix.length,
                        bytes.length - encoding.prefix.length,
                        encoding.encodingName);
                final byte[] reEncodedBytes = decodedString.getBytes(
                        encoding.encodingName);
                if (BinaryFunctions.compareBytes(bytes, encoding.prefix.length,
                        reEncodedBytes, 0,
                        reEncodedBytes.length)) {
                    return decodedString;
                }
            } catch (final UnsupportedEncodingException e) {
                throw new ImageReadException(e.getMessage(), e);
            }
        }
    }

    // try ASCII, with NO prefix.
    return new String(bytes, StandardCharsets.US_ASCII);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:58,代碼來源:TagInfoGpsText.java


注:本文中的org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType.BYTE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。