本文整理汇总了Java中org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType.SHORT属性的典型用法代码示例。如果您正苦于以下问题:Java FieldType.SHORT属性的具体用法?Java FieldType.SHORT怎么用?Java FieldType.SHORT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType
的用法示例。
在下文中一共展示了FieldType.SHORT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldValue
public int[] getFieldValue(final TagInfoShortOrLong tag, final boolean mustExist)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
} else {
return null;
}
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
} else {
return null;
}
}
final byte[] bytes = field.getByteArrayValue();
if (field.getFieldType() == FieldType.SHORT) {
return ByteConversions.toUInt16s(bytes, field.getByteOrder());
} else {
return ByteConversions.toInts(bytes, field.getByteOrder());
}
}
示例2: add
public void add(final TagInfoShort tagInfo, final short... 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.SHORT,
values.length, bytes);
add(tiffOutputField);
}
示例3: add
public void add(final TagInfoShort tagInfo, final short 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.SHORT, 1, bytes);
add(tiffOutputField);
}
示例4: TagInfoShort
public TagInfoShort(final String name, final int tag, final int length, final TiffDirectoryType directoryType) {
super(name, tag, FieldType.SHORT, length, directoryType);
}
示例5: TagInfoShorts
public TagInfoShorts(final String name, final int tag, final int length, final TiffDirectoryType directoryType) {
super(name, tag, FieldType.SHORT, length, directoryType);
}
示例6: TagInfoShort
public TagInfoShort(final String name, final int tag, final TiffDirectoryType directoryType) {
super(name, tag, FieldType.SHORT, 1, directoryType);
}