當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorModel.isAlphaPremultiplied方法代碼示例

本文整理匯總了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());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:CGLGraphicsConfig.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ImageUtilities.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:GraphicsTestCase.java

示例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());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:X11GraphicsConfig.java

示例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);
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:12,代碼來源:MMapServer.java

示例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);
}
 
開發者ID:scriptkittie,項目名稱:GlitchKernel,代碼行數:32,代碼來源:DataAsSound.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:ImageRepresentation.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:CGLGraphicsConfig.java

示例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());
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:GLXGraphicsConfig.java

示例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());
}
 
開發者ID:tomwhite,項目名稱:set-game,代碼行數:8,代碼來源:PlaySet.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:OpCompatibleImageTest.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,代碼來源:GraphicsConfiguration.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:EffectUtils.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:GraphicsConfiguration.java


注:本文中的java.awt.image.ColorModel.isAlphaPremultiplied方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。