本文整理汇总了Java中java.awt.image.ColorModel.isAlphaPremultiplied方法的典型用法代码示例。如果您正苦于以下问题:Java ColorModel.isAlphaPremultiplied方法的具体用法?Java ColorModel.isAlphaPremultiplied怎么用?Java ColorModel.isAlphaPremultiplied使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ColorModel
的用法示例。
在下文中一共展示了ColorModel.isAlphaPremultiplied方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAcceleratedImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public Image createAcceleratedImage(Component target,
int width, int height)
{
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr = model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied());
}
示例2: createBufferedImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/** Creates BufferedImage with Transparency.TRANSLUCENT */
static final java.awt.image.BufferedImage createBufferedImage(int width, int height) {
if (Utilities.isMac()) {
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
}
ColorModel model = colorModel(java.awt.Transparency.TRANSLUCENT);
java.awt.image.BufferedImage buffImage = new java.awt.image.BufferedImage(
model, model.createCompatibleWritableRaster(width, height), model.isAlphaPremultiplied(), null
);
return buffImage;
}
示例3: createBufferedImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/** Creates BufferedImage 16x16 and Transparency.BITMASK */
private static final BufferedImage createBufferedImage(int width, int height) {
ColorModel model = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().getColorModel(Transparency.BITMASK);
BufferedImage buffImage = new BufferedImage(model,
model.createCompatibleWritableRaster(width, height), model.isAlphaPremultiplied(), null);
return buffImage;
}
示例4: createAcceleratedImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
public Image createAcceleratedImage(Component target,
int width, int height)
{
// As of 1.7 we no longer create pmoffscreens here...
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr =
model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied());
}
示例5: deepCopy
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Create a duplicate of a BufferedImage.
* @param bi
* @return the copied image.
*/
private static BufferedImage deepCopy(BufferedImage bi) {
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(null);
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
示例6: glitchPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public byte[] glitchPixels(byte[] inputImageBytes) throws Exception
{
int audioBitRate = ((Integer) getPixelGlitchParameters().get("bitRateBlend")).intValue();
float bitRateBlend = (float) audioBitRate / 10;
if(bitRateBlend < 0.1F || bitRateBlend > 0.9F)
{
return null;
}
BufferedImage inputImage = ImageUtil.getImageFromBytes(inputImageBytes);
InputStream imageInputStream = new ByteArrayInputStream(inputImageBytes);
AudioInputStream distortionAudioStream = new AudioInputStream(imageInputStream, new AudioFormat(AudioFormat.Encoding.ULAW, ThreadLocalRandom.current().nextInt(8000, 20000), 8, 5, 9, ThreadLocalRandom.current().nextInt(8000, 20000), true), inputImageBytes.length);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AudioSystem.write(distortionAudioStream, Type.WAVE, outputStream);
BufferedImage outputImage = new BufferedImage(inputImage.getWidth(), inputImage.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
byte[] imageData = ((DataBufferByte) outputImage.getRaster().getDataBuffer()).getData();
System.arraycopy(outputStream.toByteArray(),0,imageData,0,outputStream.toByteArray().length);
int[] abgrOffsets = {3, 2, 1, 0};
DataBuffer outputBuffer = new DataBufferByte(imageData, imageData.length);
WritableRaster raster = Raster.createInterleavedRaster(outputBuffer, inputImage.getWidth(), inputImage.getHeight(), 4 * inputImage.getWidth(), 4, abgrOffsets, null);
ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
BufferedImage rasterizedImage = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null);
rasterizedImage = resizeImage(rasterizedImage, inputImage.getWidth() * 4, inputImage.getHeight() * 4);
Graphics2D g2d = rasterizedImage.createGraphics();
g2d.setComposite(AlphaComposite.SrcOver.derive(bitRateBlend));
g2d.drawImage(inputImage, 0, 0, null);
g2d.dispose();
rasterizedImage = rasterizedImage.getSubimage(0, 0, inputImage.getWidth(), inputImage.getHeight());
return ImageUtil.getImageBytes(rasterizedImage);
}
示例7: getPixelFormatForColorModel
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private int getPixelFormatForColorModel( ColorModel cm ){
if( cm == null ){
return DEFAULT_PIXEL_FORMAT; // TODO is PixelFormat.Canonical better here?
}
int bpp = cm.getPixelSize();
int[] sizes = cm.getComponentSize();
switch( bpp ){
case 1: return PixelFormat.Undefined; // Indexed is invalid and there is no 1bpp
case 4: return PixelFormat.Format4bppIndexed;
case 8: return PixelFormat.Format8bppIndexed;
case 16:
if( sizes.length <= 1) {
return PixelFormat.Format16bppGrayScale;
}
if( sizes.length == 3 ){
if( sizes[0] == 5 && sizes[2] == 5 ){
return sizes[1] == 5 ? PixelFormat.Format16bppRgb555 : PixelFormat.Format16bppRgb565;
}
}
if( sizes.length == 4 && cm.hasAlpha() ){
return PixelFormat.Format16bppArgb1555;
}
break;
case 24:
return PixelFormat.Format24bppRgb;
case 32:
if(!cm.hasAlpha()){
return PixelFormat.Format32bppRgb;
} else {
return cm.isAlphaPremultiplied() ? PixelFormat.Format32bppPArgb : PixelFormat.Format32bppArgb;
}
case 48:
return PixelFormat.Format48bppRgb;
case 64:
return cm.isAlphaPremultiplied() ? PixelFormat.Format64bppPArgb : PixelFormat.Format64bppArgb;
}
return PixelFormat.Undefined;
}
示例8: createCompatibleImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public BufferedImage createCompatibleImage(int width, int height) {
ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
WritableRaster
raster = model.createCompatibleWritableRaster(width, height);
return new BufferedImage(model, raster, model.isAlphaPremultiplied(),
null);
}
示例9: createAcceleratedImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Creates a new hidden-acceleration image of the given width and height
* that is associated with the target Component.
*/
@Override
public Image createAcceleratedImage(Component target,
int width, int height)
{
ColorModel model = getColorModel(Transparency.OPAQUE);
WritableRaster wr =
model.createCompatibleWritableRaster(width, height);
return new OffScreenImage(target, model, wr,
model.isAlphaPremultiplied());
}
示例10: deepCopy
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private static BufferedImage deepCopy(BufferedImage bi) {
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(null);
return new BufferedImage(cm, raster, isAlphaPremultiplied, null)
.getSubimage(0, 0, bi.getWidth(), bi.getHeight());
}
示例11: createCompatible
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private BufferedImage createCompatible(ColorModel cm, int w, int h) {
return new BufferedImage (cm,
cm.createCompatibleWritableRaster(w, h),
cm.isAlphaPremultiplied(), null);
}
示例12: createCompatibleImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Returns a <code>BufferedImage</code> that supports the specified
* transparency and has a data layout and color model
* compatible with this <code>GraphicsConfiguration</code>. This
* method has nothing to do with memory-mapping
* a device. The returned <code>BufferedImage</code> has a layout and
* color model that can be optimally blitted to a device
* with this <code>GraphicsConfiguration</code>.
* @param width the width of the returned <code>BufferedImage</code>
* @param height the height of the returned <code>BufferedImage</code>
* @param transparency the specified transparency mode
* @return a <code>BufferedImage</code> whose data layout and color
* model is compatible with this <code>GraphicsConfiguration</code>
* and also supports the specified transparency.
* @throws IllegalArgumentException if the transparency is not a valid value
* @see Transparency#OPAQUE
* @see Transparency#BITMASK
* @see Transparency#TRANSLUCENT
*/
public BufferedImage createCompatibleImage(int width, int height,
int transparency)
{
if (getColorModel().getTransparency() == transparency) {
return createCompatibleImage(width, height);
}
ColorModel cm = getColorModel(transparency);
if (cm == null) {
throw new IllegalArgumentException("Unknown transparency: " +
transparency);
}
WritableRaster wr = cm.createCompatibleWritableRaster(width, height);
return new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
}
示例13: createColorModelCompatibleImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* <p>Returns a new <code>BufferedImage</code> using the same color model
* as the image passed as a parameter. The returned image is only compatible
* with the image passed as a parameter. This does not mean the returned
* image is compatible with the hardware.</p>
*
* @param image the reference image from which the color model of the new
* image is obtained
* @return a new <code>BufferedImage</code>, compatible with the color model
* of <code>image</code>
*/
public static BufferedImage createColorModelCompatibleImage(BufferedImage image) {
ColorModel cm = image.getColorModel();
return new BufferedImage(cm,
cm.createCompatibleWritableRaster(image.getWidth(),
image.getHeight()),
cm.isAlphaPremultiplied(), null);
}
示例14: createCompatibleImage
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Returns a {@link BufferedImage} with a data layout and color model
* compatible with this <code>GraphicsConfiguration</code>. This
* method has nothing to do with memory-mapping
* a device. The returned <code>BufferedImage</code> has
* a layout and color model that is closest to this native device
* configuration and can therefore be optimally blitted to this
* device.
* @param width the width of the returned <code>BufferedImage</code>
* @param height the height of the returned <code>BufferedImage</code>
* @return a <code>BufferedImage</code> whose data layout and color
* model is compatible with this <code>GraphicsConfiguration</code>.
*/
public BufferedImage createCompatibleImage(int width, int height) {
ColorModel model = getColorModel();
WritableRaster raster =
model.createCompatibleWritableRaster(width, height);
return new BufferedImage(model, raster,
model.isAlphaPremultiplied(), null);
}