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

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

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

BufferedImage.getProperty介绍

[英]Returns a property of the image by name.
[中]按名称返回图像的属性。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

@Override
  public Object getProperty(String name, ImageObserver observer) {
    if ("url".equals(name)) { // NOI18N
      if (url != null) {
        return url;
      } else {
        return imageIcon.getImage().getProperty("url", observer);
      }
    }
    return super.getProperty(name, observer);
  }
}

代码示例来源: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: org.netbeans.api/org-openide-util-ui

@Override
  public Object getProperty(String name, ImageObserver observer) {
    if ("url".equals(name)) { // NOI18N
      if (url != null) {
        return url;
      } else {
        if (imageIcon == null) {
          return null;
        }
        if (imageIcon.getImage() == this) {
          return null;
        }
        return imageIcon.getImage().getProperty("url", observer);
      }
    }
    return super.getProperty(name, observer);
  }
}

代码示例来源: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: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

/** {@inheritDoc} */
@Override
public Object getProperty(String name, ImageObserver observer) {
  return sketch.getProperty(name, observer);
}

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

@Override
public Object getProperty(String name, ImageObserver observer) {
  if (futureImage == null) {
    return empty.getProperty(name, observer);
  }
  return futureImage.getProperty(name, observer);
}

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

@Override
public Object getProperty(String name) {
  return scanBuffer.getProperty(name);
}

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

public Object getProperty(String name) {
  return bi.getProperty(name);
}

代码示例来源: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: org.apache.xmlgraphics/xmlgraphics-commons

public Object getProperty(String name) {
  return bi.getProperty(name);
}

代码示例来源: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: org.apache.xmlgraphics/batik-awt-util

public Object getProperty(String name) {
  return bi.getProperty(name);
}

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

代码示例来源:origin: haraldk/TwelveMonkeys

private void assertHotSpot(final TestData pTestData, final ImageReadParam pParam, final Point pExpected) throws IOException {
  CURImageReader reader = createReader();
  reader.setInput(pTestData.getInputStream());
  BufferedImage image = reader.read(0, pParam);
  // We can only be sure the hotspot is defined, if no param, but if defined, it must be correct
  Object hotspot = image.getProperty("cursor_hotspot");
  if (hotspot != Image.UndefinedProperty || pParam == null) {
    // Typically never happens, because of weirdness with UndefinedProperty
    assertNotNull("Hotspot for cursor not present", hotspot);
    // Image weirdness
    assertTrue("Hotspot for cursor undefined (java.awt.Image.UndefinedProperty)", Image.UndefinedProperty != hotspot);
    assertTrue(String.format("Hotspot not a java.awt.Point: %s", hotspot.getClass()), hotspot instanceof Point);
    assertEquals(pExpected, hotspot);
  }
  assertNotNull("Hotspot for cursor not present", reader.getHotSpot(0));
  assertEquals(pExpected, reader.getHotSpot(0));
}

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

@Override
  public Object getProperty(String name, ImageObserver observer) {
    if ("url".equals(name)) { // NOI18N
      if (url != null) {
        return url;
      } else {
        return imageIcon.getImage().getProperty("url", observer);
      }
    }
    return super.getProperty(name, observer);
  }
}

代码示例来源:origin: senbox-org/s2tbx

public static BufferedImage applyContrast(BufferedImage inputImage) {
  final BufferedImage extrema = ExtremaDescriptor.create(inputImage, null, 1, 1, false, 1, null).getAsBufferedImage();
  double[][] minMax = (double[][]) extrema.getProperty("Extrema");
  double min = minMax[0][0];
  double max = minMax[1][0];
  double dif = max - min;
  return rescale(1.0 / (max - min), min / (max - min), inputImage);
}

相关文章