java.awt.image.BufferedImage.getPropertyNames()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(154)

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

BufferedImage.getPropertyNames介绍

[英]Returns an array of names recognized by #getProperty(String)or null, if no property names are recognized.
[中]

代码示例

代码示例来源:origin: geotools/geotools

protected BufferedImage getStartImage(BufferedImage copyFrom, int width, int height) {
  Map<String, Object> properties = null;
  if (copyFrom.getPropertyNames() != null) {
    properties = new HashMap<String, Object>();
    for (String name : copyFrom.getPropertyNames()) {
      properties.put(name, copyFrom.getProperty(name));
    }
  }
  SampleModel sm = copyFrom.getSampleModel().createCompatibleSampleModel(width, height);
  WritableRaster raster = Raster.createWritableRaster(sm, null);
  BufferedImage image =
      new BufferedImage(
          copyFrom.getColorModel(),
          raster,
          copyFrom.isAlphaPremultiplied(),
          (Hashtable<?, ?>) properties);
  // white background
  Graphics2D g2D = (Graphics2D) image.getGraphics();
  Color save = g2D.getColor();
  g2D.setColor(Color.WHITE);
  g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
  g2D.setColor(save);
  return image;
}

代码示例来源:origin: geotools/geotools

private BufferedImage getStartImage(BufferedImage copyFrom) {
  Dimension dim = getStartDimension();
  Hashtable<String, Object> properties = null;
  if (copyFrom.getPropertyNames() != null) {
    properties = new Hashtable<String, Object>();
    for (String name : copyFrom.getPropertyNames()) {
      properties.put(name, copyFrom.getProperty(name));
    }
  }
  SampleModel sm =
      copyFrom.getSampleModel()
          .createCompatibleSampleModel((int) dim.getWidth(), (int) dim.getHeight());
  WritableRaster raster = Raster.createWritableRaster(sm, null);
  ColorModel colorModel = copyFrom.getColorModel();
  boolean alphaPremultiplied = copyFrom.isAlphaPremultiplied();
  DataBuffer dataBuffer =
      createDataBufferFilledWithNoDataValues(raster, colorModel.getPixelSize());
  raster = Raster.createWritableRaster(sm, dataBuffer, null);
  BufferedImage image = new BufferedImage(colorModel, raster, alphaPremultiplied, properties);
  if (levelInfo.getNoDataValue() == null) {
    Graphics2D g2D = (Graphics2D) image.getGraphics();
    Color save = g2D.getColor();
    g2D.setColor(backgroundColor);
    g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
    g2D.setColor(save);
  }
  return image;
}

代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas

@Override
public String[] getPropertyNames() {
  return scanBuffer.getPropertyNames();
}

代码示例来源:origin: org.apache.xmlgraphics/batik-awt-util

public String [] getPropertyNames() {
  return bi.getPropertyNames();
}

代码示例来源:origin: org.apache.xmlgraphics/xmlgraphics-commons

public String [] getPropertyNames() {
  return bi.getPropertyNames();
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

public String [] getPropertyNames() {
  return bi.getPropertyNames();
}

代码示例来源:origin: apache/batik

public String [] getPropertyNames() {
  return bi.getPropertyNames();
}

代码示例来源:origin: it.geosolutions.jaiext.utilities/jt-utilities

private static Map getProperties(BufferedImage bi) {
  String[] propertyNames = bi.getPropertyNames();
  if(propertyNames == null) {
    return null;
  }
  Map<String, Object> properties = new HashMap<String, Object>();
  for (String name : bi.getPropertyNames()) {
    properties.put(name, bi.getProperty(name));
  }
  return properties;
}

代码示例来源:origin: geosolutions-it/jai-ext

private static Map getProperties(BufferedImage bi) {
  String[] propertyNames = bi.getPropertyNames();
  if(propertyNames == null) {
    return null;
  }
  Map<String, Object> properties = new HashMap<String, Object>();
  for (String name : bi.getPropertyNames()) {
    properties.put(name, bi.getProperty(name));
  }
  return properties;
}

代码示例来源:origin: com.github.mike10004/commons-imaging

public void dumpBIProps(final String prefix, final BufferedImage src) {
  final String[] keys = src.getPropertyNames();
  if (keys == null) {
    System.out.println(prefix + ": no props");
    return;
  }
  for (final String key : keys) {
    System.out.println(prefix + ": " + key + ": "
        + src.getProperty(key));
  }
}

代码示例来源:origin: org.apache.sanselan/sanselan

public void dumpBIProps(String prefix, BufferedImage src)
{
  String keys[] = src.getPropertyNames();
  if (keys == null)
  {
    System.out.println(prefix + ": no props");
    return;
  }
  for (int i = 0; i < keys.length; i++)
  {
    String key = keys[i];
    System.out.println(prefix + ": " + key + ": "
        + src.getProperty(key));
  }
}

代码示例来源:origin: it.tidalwave.image/image-core

/*******************************************************************************
 *
 *
 ******************************************************************************/
public static Properties getProperties (BufferedImage image)
 {
  Properties properties = new Properties();
  String[] propertyNames = image.getPropertyNames();
  if (propertyNames != null)
   {
    for (int i = 0; i < propertyNames.length; i++)
     {
      String propertyName = propertyNames[i];
      Object propertyValue = image.getProperty(propertyName);
      properties.setProperty(propertyName, propertyValue.toString());
     }
   }
  return properties;
 }

代码示例来源:origin: com.github.sviperll/chicory-core

@Override
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
  if (destCM == null)
    destCM = src.getColorModel();
  WritableRaster raster = src.getRaster().createCompatibleWritableRaster();
  Hashtable<String, Object> properties = new Hashtable<String, Object>();
  for (String name: src.getPropertyNames()) {
    properties.put(name, src.getProperty(name));
  }
  return new BufferedImage(destCM, raster, src.isAlphaPremultiplied(), properties);
}

代码示例来源:origin: com.github.sviperll/chicory-common

@Override
public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
  if (destCM == null)
    destCM = src.getColorModel();
  WritableRaster raster = src.getRaster().createCompatibleWritableRaster();
  Hashtable<String, Object> properties = new Hashtable<String, Object>();
  for (String name: src.getPropertyNames()) {
    properties.put(name, src.getProperty(name));
  }
  return new BufferedImage(destCM, raster, src.isAlphaPremultiplied(), properties);
}

代码示例来源:origin: stackoverflow.com

public static BufferedImage copy(BufferedImage img) {
  Hashtable<?,?> properties = new Hashtable<>();
  for (String propertyName : img.getPropertyNames()) {
    properties.put(propertyName, img.getProperty(propertyName));
  }
  return new BufferedImage(img.getColorModel(),
      img.copyData(null),
      img.isAlphaPremultiplied(), properties);

}

代码示例来源:origin: eseifert/vectorgraphics2d

public BufferedImage createCompatibleDestImage(BufferedImage src,
    ColorModel destCM) {
  if (destCM == null) {
    destCM = src.getColorModel();
  }
  WritableRaster raster = destCM.createCompatibleWritableRaster(
      src.getWidth(), src.getHeight());
  boolean isRasterPremultiplied = destCM.isAlphaPremultiplied();
  Hashtable<String, Object> properties = null;
  if (src.getPropertyNames() != null) {
    properties = new Hashtable<>();
    for (String key : src.getPropertyNames()) {
      properties.put(key, src.getProperty(key));
    }
  }
  BufferedImage bimage = new BufferedImage(destCM, raster,
      isRasterPremultiplied, properties);
  src.copyData(raster);
  return bimage;
}

代码示例来源:origin: org.geotools/gt-geopkg

protected BufferedImage getStartImage(BufferedImage copyFrom, int width, int height) {
  Map<String, Object> properties = null;
  if (copyFrom.getPropertyNames() != null) {
    properties = new HashMap<String, Object>();
    for (String name : copyFrom.getPropertyNames()) {
      properties.put(name, copyFrom.getProperty(name));
    }
  }
  SampleModel sm = copyFrom.getSampleModel().createCompatibleSampleModel(width, height);
  WritableRaster raster = Raster.createWritableRaster(sm, null);
  BufferedImage image =
      new BufferedImage(
          copyFrom.getColorModel(),
          raster,
          copyFrom.isAlphaPremultiplied(),
          (Hashtable<?, ?>) properties);
  // white background
  Graphics2D g2D = (Graphics2D) image.getGraphics();
  Color save = g2D.getColor();
  g2D.setColor(Color.WHITE);
  g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
  g2D.setColor(save);
  return image;
}

代码示例来源:origin: org.geotools/gt-mbtiles

protected BufferedImage getStartImage(BufferedImage copyFrom, int width, int height) {
  Map<String, Object> properties = null;
  if (copyFrom.getPropertyNames() != null) {
    properties = new HashMap<String, Object>();
    for (String name : copyFrom.getPropertyNames()) {
      properties.put(name, copyFrom.getProperty(name));
    }
  }
  SampleModel sm = copyFrom.getSampleModel().createCompatibleSampleModel(width, height);
  WritableRaster raster = Raster.createWritableRaster(sm, null);
  BufferedImage image =
      new BufferedImage(
          copyFrom.getColorModel(),
          raster,
          copyFrom.isAlphaPremultiplied(),
          (Hashtable<?, ?>) properties);
  // white background
  Graphics2D g2D = (Graphics2D) image.getGraphics();
  Color save = g2D.getColor();
  g2D.setColor(Color.WHITE);
  g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
  g2D.setColor(save);
  return image;
}

代码示例来源:origin: org.integratedmodelling/klab-common

/**
 * Make a clone of a buffered image
 * 
 * @param image
 * @return cloned image
 */
public static BufferedImage clone(BufferedImage image) {
  String[] pnames = image.getPropertyNames();
  Hashtable<String, Object> cproperties = new Hashtable<String, Object>();
  if (pnames != null) {
    for (int i = 0; i < pnames.length; i++) {
      cproperties.put(pnames[i], image.getProperty(pnames[i]));
    }
  }
  WritableRaster wr = image.getRaster();
  WritableRaster cwr = wr.createCompatibleWritableRaster();
  cwr.setRect(wr);
  BufferedImage cimage = new BufferedImage(image.getColorModel(), // should
                                  // be
                                  // immutable
  cwr, image.isAlphaPremultiplied(), cproperties);
  return cimage;
}

代码示例来源:origin: com.twelvemonkeys/twelvemonkeys-core

public void testToBufferedImage() {
  BufferedImage sameAsImage = ImageUtil.toBuffered((RenderedImage) mImage);
  BufferedImage bufferedScaled = ImageUtil.toBuffered(mScaled);
  // Should be no need to convert
  assertSame(mImage, sameAsImage);
  // Should have same dimensions
  assertEquals(mScaled.getWidth(null), bufferedScaled.getWidth());
  assertEquals(mScaled.getHeight(null), bufferedScaled.getHeight());
  // Hmmm...
  assertTrue(new Integer(42).equals(bufferedScaled.getProperty("lucky-number"))
        || bufferedScaled.getPropertyNames() == null
        || bufferedScaled.getPropertyNames().length == 0);
}

相关文章