本文整理了Java中java.awt.image.BufferedImage.isAlphaPremultiplied()
方法的一些代码示例,展示了BufferedImage.isAlphaPremultiplied()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedImage.isAlphaPremultiplied()
方法的具体详情如下:
包路径:java.awt.image.BufferedImage
类名称:BufferedImage
方法名:isAlphaPremultiplied
暂无
代码示例来源:origin: runelite/runelite
private static BufferedImage rgbaToIndexedBufferedImage(final BufferedImage sourceBufferedImage)
{
final BufferedImage indexedImage = new BufferedImage(
sourceBufferedImage.getWidth(),
sourceBufferedImage.getHeight(),
BufferedImage.TYPE_BYTE_INDEXED);
final ColorModel cm = indexedImage.getColorModel();
final IndexColorModel icm = (IndexColorModel) cm;
final int size = icm.getMapSize();
final byte[] reds = new byte[size];
final byte[] greens = new byte[size];
final byte[] blues = new byte[size];
icm.getReds(reds);
icm.getGreens(greens);
icm.getBlues(blues);
final WritableRaster raster = indexedImage.getRaster();
final int pixel = raster.getSample(0, 0, 0);
final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel);
final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null);
resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null);
return resultIndexedImage;
}
代码示例来源:origin: haraldk/TwelveMonkeys
/**
* Creates a copy of the given image, with a solid background
*
* @param pOriginal the original image
* @param pBackground the background color
* @return a new {@code BufferedImage}
*/
private static BufferedImage createSolid(BufferedImage pOriginal, Color pBackground) {
// Create a temporary image of same dimension and type
BufferedImage solid = new BufferedImage(pOriginal.getColorModel(), pOriginal.copyData(null), pOriginal.isAlphaPremultiplied(), null);
Graphics2D g = solid.createGraphics();
try {
// Clear in background color
g.setColor(pBackground);
g.setComposite(AlphaComposite.DstOver);// Paint "underneath"
g.fillRect(0, 0, pOriginal.getWidth(), pOriginal.getHeight());
}
finally {
g.dispose();
}
return solid;
}
代码示例来源: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: geotools/geotools
colorModel,
(WritableRaster) scaledImageRaster,
image.isAlphaPremultiplied(),
null);
return scaledImage;
代码示例来源:origin: stackoverflow.com
static BufferedImage switchPalette(BufferedImage bi,
IndexColorModel icm) {
WritableRaster wr = bi.getRaster();
boolean bAlphaPremultiplied = bi.isAlphaPremultiplied();
return new BufferedImage(icm, wr, bAlphaPremultiplied, new Hashtable());
}
代码示例来源:origin: stackoverflow.com
public static BufferedImage deepCopyImage(BufferedImage bF){
ColorModel cm = bF.getColorModel();
boolean alphaPre = bF.isAlphaPremultiplied();
WritableRaster wR = bF.copyData(null);
return new BufferedImage(cm, wR, alphaPre, null);
}
代码示例来源:origin: geogebra/geogebra
public ImageD(BufferedImage image) {
super(image.getColorModel(), image.copyData(null),
image.isAlphaPremultiplied(), null);
}
代码示例来源:origin: threerings/playn
@Override
public Image snapshot() {
ColorModel cm = img.getColorModel();
boolean isAlphaPremultiplied = img.isAlphaPremultiplied();
WritableRaster raster = img.copyData(null);
BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
return new JavaStaticImage(ctx, snap, scale);
}
代码示例来源: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.googlecode.playn/playn-java
@Override
public Image snapshot() {
ColorModel cm = img.getColorModel();
boolean isAlphaPremultiplied = img.isAlphaPremultiplied();
WritableRaster raster = img.copyData(null);
BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
return new JavaStaticImage(ctx, snap, scale);
}
代码示例来源:origin: lbalazscs/Pixelitor
public static BufferedImage copyImage(BufferedImage src) {
assert src != null;
WritableRaster raster = null;
try {
raster = src.copyData(null);
} catch (OutOfMemoryError e) {
Dialogs.showOutOfMemoryDialog(e);
}
return new BufferedImage(src.getColorModel(), raster, src.isAlphaPremultiplied(), null);
}
代码示例来源: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: jtrfp/terminal-recall
private BufferedImage [] getSpecialRAWImage(String name, Color [] palette, int upscalePowerOfTwo) throws IllegalAccessException, FileLoadException, IOException{
RAWFile dat = getRAW(name);
dat.setPalette(palette);
BufferedImage [] segs = dat.asSegments(upscalePowerOfTwo);
for(BufferedImage seg:segs){
Graphics g = seg.getGraphics();
BufferedImage scaled = new BufferedImage(seg.getColorModel(),seg.copyData(null),seg.isAlphaPremultiplied(),null);
g.drawImage(scaled.getScaledInstance(seg.getWidth()-2, seg.getHeight()-2, Image.SCALE_AREA_AVERAGING), 1, 1, seg.getWidth()-2, seg.getHeight()-2, null);
g.dispose();
}
return segs;
}
代码示例来源: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: io.playn/playn-java-base
@Override
public Image snapshot() {
BufferedImage bmp = ((JavaImage)image).bufferedImage();
ColorModel cm = bmp.getColorModel();
boolean isAlphaPremultiplied = bmp.isAlphaPremultiplied();
WritableRaster raster = bmp.copyData(null);
BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
return new JavaImage(gfx, image.scale(), snap, "<canvas>");
}
代码示例来源:origin: playn/playn
@Override
public Image snapshot() {
BufferedImage bmp = ((JavaImage)image).bufferedImage();
ColorModel cm = bmp.getColorModel();
boolean isAlphaPremultiplied = bmp.isAlphaPremultiplied();
WritableRaster raster = bmp.copyData(null);
BufferedImage snap = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
return new JavaImage(gfx, image.scale(), snap, "<canvas>");
}
代码示例来源:origin: org.apache.xmlgraphics/batik-awt-util
public void fixAlpha(BufferedImage bi) {
if ((!bi.getColorModel().hasAlpha()) ||
(!bi.isAlphaPremultiplied()))
// No need to fix alpha if it isn't premultiplied...
return;
if (GraphicsUtil.is_INT_PACK_Data(bi.getSampleModel(), true))
fixAlpha_INT_PACK(bi.getRaster());
else
fixAlpha_FALLBACK(bi.getRaster());
}
代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik
public void fixAlpha(BufferedImage bi) {
if ((!bi.getColorModel().hasAlpha()) ||
(!bi.isAlphaPremultiplied()))
// No need to fix alpha if it isn't premultiplied...
return;
if (GraphicsUtil.is_INT_PACK_Data(bi.getSampleModel(), true))
fixAlpha_INT_PACK(bi.getRaster());
else
fixAlpha_FALLBACK(bi.getRaster());
}
代码示例来源:origin: apache/batik
public void fixAlpha(BufferedImage bi) {
if ((!bi.getColorModel().hasAlpha()) ||
(!bi.isAlphaPremultiplied()))
// No need to fix alpha if it isn't premultiplied...
return;
if (GraphicsUtil.is_INT_PACK_Data(bi.getSampleModel(), true))
fixAlpha_INT_PACK(bi.getRaster());
else
fixAlpha_FALLBACK(bi.getRaster());
}
内容来源于网络,如有侵权,请联系作者删除!