本文整理了Java中com.drew.metadata.Directory.getByteArray()
方法的一些代码示例,展示了Directory.getByteArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Directory.getByteArray()
方法的具体详情如下:
包路径:com.drew.metadata.Directory
类名称:Directory
方法名:getByteArray
[英]Gets the specified tag's value as an byte array, if possible. Only supported where the tag is set as String, Integer, int[], byte[] or Rational[].
[中]如果可能,以字节数组的形式获取指定标记的值。仅当标记设置为String、Integer、int[]、byte[]或Rational[]时才受支持。
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
protected String getByteLengthDescription(final int tagType)
{
byte[] bytes = _directory.getByteArray(tagType);
if (bytes == null)
return null;
return String.format("(%d byte%s)", bytes.length, bytes.length == 1 ? "" : "s");
}
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
public String getString(int tagType, String charset)
{
byte[] bytes = getByteArray(tagType);
if (bytes==null)
return null;
try {
return new String(bytes, charset);
} catch (UnsupportedEncodingException e) {
return null;
}
}
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
protected String getStringFromBytes(int tag, Charset cs)
{
byte[] values = _directory.getByteArray(tag);
if (values == null)
return null;
try {
return new String(values, cs.name()).trim();
} catch (UnsupportedEncodingException e) {
return null;
}
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** The Windows specific tags uses plain Unicode. */
@Nullable
private String getUnicodeDescription(int tag)
{
byte[] bytes = _directory.getByteArray(tag);
if (bytes == null)
return null;
try {
// Decode the unicode string and trim the unicode zero "\0" from the end.
return new String(bytes, "UTF-16LE").trim();
} catch (UnsupportedEncodingException ex) {
return null;
}
}
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
protected String get7BitStringFromBytes(final int tagType)
{
final byte[] bytes = _directory.getByteArray(tagType);
if (bytes == null)
return null;
int length = bytes.length;
for (int index = 0; index < bytes.length; index++) {
int i = bytes[index] & 0xFF;
if (i == 0 || i > 0x7F) {
length = index;
break;
}
}
return new String(bytes, 0, length);
}
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
protected String getEncodedTextDescription(int tagType)
byte[] commentBytes = _directory.getByteArray(tagType);
if (commentBytes == null)
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
public String getCfaPattern2Description()
{
byte[] values = _directory.getByteArray(TAG_CFA_PATTERN_2);
if (values == null)
return null;
int[] repeatPattern = _directory.getIntArray(TAG_CFA_REPEAT_PATTERN_DIM);
if (repeatPattern == null)
return String.format("Repeat Pattern not found for CFAPattern (%s)", super.getDescription(TAG_CFA_PATTERN_2));
if (repeatPattern.length == 2 && values.length == (repeatPattern[0] * repeatPattern[1]))
{
int[] intpattern = new int[2 + values.length];
intpattern[0] = repeatPattern[0];
intpattern[1] = repeatPattern[1];
for (int i = 0; i < values.length; i++)
intpattern[i + 2] = values[i] & 0xFF; // convert the values[i] byte to unsigned
return formatCFAPattern(intpattern);
}
return String.format("Unknown Pattern (%s)", super.getDescription(TAG_CFA_PATTERN_2));
}
代码示例来源:origin: drewnoakes/metadata-extractor
byte[] values = _directory.getByteArray(tagType);
if (values == null)
return null;
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
protected String getByteLengthDescription(final int tagType)
{
byte[] bytes = _directory.getByteArray(tagType);
if (bytes == null)
return null;
return String.format("(%d byte%s)", bytes.length, bytes.length == 1 ? "" : "s");
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
protected String getStringFromBytes(int tag, Charset cs)
{
byte[] values = _directory.getByteArray(tag);
if (values == null)
return null;
try {
return new String(values, cs.name()).trim();
} catch (UnsupportedEncodingException e) {
return null;
}
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
public String getString(int tagType, String charset)
{
byte[] bytes = getByteArray(tagType);
if (bytes==null)
return null;
try {
return new String(bytes, charset);
} catch (UnsupportedEncodingException e) {
return null;
}
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
/** The Windows specific tags uses plain Unicode. */
@Nullable
private String getUnicodeDescription(int tag)
{
byte[] bytes = _directory.getByteArray(tag);
if (bytes == null)
return null;
try {
// Decode the unicode string and trim the unicode zero "\0" from the end.
return new String(bytes, "UTF-16LE").trim();
} catch (UnsupportedEncodingException ex) {
return null;
}
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
protected String get7BitStringFromBytes(final int tagType)
{
final byte[] bytes = _directory.getByteArray(tagType);
if (bytes == null)
return null;
int length = bytes.length;
for (int index = 0; index < bytes.length; index++) {
int i = bytes[index] & 0xFF;
if (i == 0 || i > 0x7F) {
length = index;
break;
}
}
return new String(bytes, 0, length);
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
public String getUserCommentDescription()
byte[] commentBytes = _directory.getByteArray(TAG_USER_COMMENT);
if (commentBytes == null)
return null;
代码示例来源:origin: au.org.ala/image-utils
@Override
public void extractMetadata(byte[] bytes, Map<String, String> md) {
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(bytes));
try {
Metadata metadata = ImageMetadataReader.readMetadata(bis, false);
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
String key = tag.getTagName();
if (md.containsKey(key)) {
key = String.format("%s (%s)", tag.getTagName(), tag.getDirectoryName());
}
String value = directory.getDescription(tag.getTagType());
if (StringUtils.isNotEmpty(value) && value.startsWith("[") && value.endsWith("bytes]")) {
byte[] tagBytes = directory.getByteArray(tag.getTagType());
value = Base64.encodeBase64String(tagBytes);
}
md.put(key, value);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
@Nullable
public String getCfaPattern2Description()
{
byte[] values = _directory.getByteArray(TAG_CFA_PATTERN_2);
if (values == null)
return null;
int[] repeatPattern = _directory.getIntArray(TAG_CFA_REPEAT_PATTERN_DIM);
if (repeatPattern == null)
return String.format("Repeat Pattern not found for CFAPattern (%s)", super.getDescription(TAG_CFA_PATTERN_2));
if (repeatPattern.length == 2 && values.length == (repeatPattern[0] * repeatPattern[1]))
{
int[] intpattern = new int[2 + values.length];
intpattern[0] = repeatPattern[0];
intpattern[1] = repeatPattern[1];
for (int i = 0; i < values.length; i++)
intpattern[i + 2] = values[i] & 0xFF; // convert the values[i] byte to unsigned
return formatCFAPattern(intpattern);
}
return String.format("Unknown Pattern (%s)", super.getDescription(TAG_CFA_PATTERN_2));
}
代码示例来源:origin: com.drewnoakes/metadata-extractor
byte[] values = _directory.getByteArray(tagType);
if (values == null)
return null;
内容来源于网络,如有侵权,请联系作者删除!