com.drew.metadata.Directory.getIntArray()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(174)

本文整理了Java中com.drew.metadata.Directory.getIntArray()方法的一些代码示例,展示了Directory.getIntArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Directory.getIntArray()方法的具体详情如下:
包路径:com.drew.metadata.Directory
类名称:Directory
方法名:getIntArray

Directory.getIntArray介绍

[英]Gets the specified tag's value as an int array, if possible. Only supported where the tag is set as String, Integer, int[], byte[] or Rational[].
[中]如果可能,将指定标记的值作为int数组获取。仅当标记设置为String、Integer、int[]、byte[]或Rational[]时才受支持。

代码示例

代码示例来源:origin: drewnoakes/metadata-extractor

@Nullable
public String getComponentConfigurationDescription()
{
  int[] components = _directory.getIntArray(TAG_COMPONENTS_CONFIGURATION);
  if (components == null)
    return null;
  String[] componentStrings = {"", "Y", "Cb", "Cr", "R", "G", "B"};
  StringBuilder componentConfig = new StringBuilder();
  for (int i = 0; i < Math.min(4, components.length); i++) {
    int j = components[i];
    if (j > 0 && j < componentStrings.length) {
      componentConfig.append(componentStrings[j]);
    }
  }
  return componentConfig.toString();
}

代码示例来源:origin: drewnoakes/metadata-extractor

@Nullable
public String getYCbCrSubsamplingDescription()
{
  int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING);
  if (positions == null || positions.length < 2)
    return null;
  if (positions[0] == 2 && positions[1] == 1) {
    return "YCbCr4:2:2";
  } else if (positions[0] == 2 && positions[1] == 2) {
    return "YCbCr4:2:0";
  } else {
    return "(Unknown)";
  }
}

代码示例来源:origin: drewnoakes/metadata-extractor

@Nullable
protected String getVersionBytesDescription(final int tagType, int majorDigits)
{
  int[] values = _directory.getIntArray(tagType);
  return values == null ? null : convertBytesToVersionString(values, majorDigits);
}

代码示例来源:origin: drewnoakes/metadata-extractor

@Nullable
public String getReferenceBlackWhiteDescription()
{
  // For some reason, sometimes this is read as a long[] and
  // getIntArray isn't able to deal with it
  int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE);
  if (ints==null || ints.length < 6)
  {
    Object o = _directory.getObject(TAG_REFERENCE_BLACK_WHITE);
    if (o != null && (o instanceof long[]))
    {
      long[] longs = (long[])o;
      if (longs.length < 6)
        return null;
      ints = new int[longs.length];
      for (int i = 0; i < longs.length; i++)
        ints[i] = (int)longs[i];
    }
    else
      return null;
  }
  int blackR = ints[0];
  int whiteR = ints[1];
  int blackG = ints[2];
  int whiteG = ints[3];
  int blackB = ints[4];
  int whiteB = ints[5];
  return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB);
}

代码示例来源: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: apache/tika

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    //TODO: after upgrading metadataextractor, swap out
    //magic number with ExifDirectoryBase.TAG_PAGE_NUMBER
    if (directory.containsTag(297)) {
      int[] pageNums = directory.getIntArray(297);
      //pages can be in any order, take the max
      if (pageNums != null && pageNums.length > 1) {
        Integer curr = metadata.getInt(TIFF.EXIF_PAGE_COUNT);
        if (curr == null || curr < pageNums[1]) {
          metadata.set(TIFF.EXIF_PAGE_COUNT, pageNums[1]);
        }
      }
    }
  }
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

@Nullable
public String getYCbCrSubsamplingDescription()
{
  int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING);
  if (positions == null || positions.length < 2)
    return null;
  if (positions[0] == 2 && positions[1] == 1) {
    return "YCbCr4:2:2";
  } else if (positions[0] == 2 && positions[1] == 2) {
    return "YCbCr4:2:0";
  } else {
    return "(Unknown)";
  }
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

@Nullable
public String getComponentConfigurationDescription()
{
  int[] components = _directory.getIntArray(TAG_COMPONENTS_CONFIGURATION);
  if (components == null)
    return null;
  String[] componentStrings = {"", "Y", "Cb", "Cr", "R", "G", "B"};
  StringBuilder componentConfig = new StringBuilder();
  for (int i = 0; i < Math.min(4, components.length); i++) {
    int j = components[i];
    if (j > 0 && j < componentStrings.length) {
      componentConfig.append(componentStrings[j]);
    }
  }
  return componentConfig.toString();
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

@Nullable
protected String getVersionBytesDescription(final int tagType, int majorDigits)
{
  int[] values = _directory.getIntArray(tagType);
  return values == null ? null : convertBytesToVersionString(values, majorDigits);
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

@Nullable
public String getReferenceBlackWhiteDescription()
{
  // For some reason, sometimes this is read as a long[] and
  // getIntArray isn't able to deal with it
  int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE);
  if (ints==null || ints.length < 6)
  {
    Object o = _directory.getObject(TAG_REFERENCE_BLACK_WHITE);
    if (o != null && (o instanceof long[]))
    {
      long[] longs = (long[])o;
      if (longs.length < 6)
        return null;
      ints = new int[longs.length];
      for (int i = 0; i < longs.length; i++)
        ints[i] = (int)longs[i];
    }
    else
      return null;
  }
  int blackR = ints[0];
  int whiteR = ints[1];
  int blackG = ints[2];
  int whiteG = ints[3];
  int blackB = ints[4];
  int whiteB = ints[5];
  return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB);
}

代码示例来源:origin: org.apache.tika/tika-parsers

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    //TODO: after upgrading metadataextractor, swap out
    //magic number with ExifDirectoryBase.TAG_PAGE_NUMBER
    if (directory.containsTag(297)) {
      int[] pageNums = directory.getIntArray(297);
      //pages can be in any order, take the max
      if (pageNums != null && pageNums.length > 1) {
        Integer curr = metadata.getInt(TIFF.EXIF_PAGE_COUNT);
        if (curr == null || curr < pageNums[1]) {
          metadata.set(TIFF.EXIF_PAGE_COUNT, pageNums[1]);
        }
      }
    }
  }
}

代码示例来源: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));
}

相关文章