当前位置: 首页>>代码示例>>Java>>正文


Java ColorModel.createCompatibleWritableRaster方法代码示例

本文整理汇总了Java中java.awt.image.ColorModel.createCompatibleWritableRaster方法的典型用法代码示例。如果您正苦于以下问题:Java ColorModel.createCompatibleWritableRaster方法的具体用法?Java ColorModel.createCompatibleWritableRaster怎么用?Java ColorModel.createCompatibleWritableRaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.ColorModel的用法示例。


在下文中一共展示了ColorModel.createCompatibleWritableRaster方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCachedRaster

import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
 * Took this cacheRaster code from GradientPaint. It appears to recycle
 * rasters for use by any other instance, as long as they are sufficiently
 * large.
 */
private static synchronized Raster getCachedRaster(ColorModel cm,
                                                   int w, int h)
{
    if (cm == cachedModel) {
        if (cached != null) {
            Raster ras = (Raster) cached.get();
            if (ras != null &&
                ras.getWidth() >= w &&
                ras.getHeight() >= h)
            {
                cached = null;
                return ras;
            }
        }
    }
    return cm.createCompatibleWritableRaster(w, h);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:MultipleGradientPaintContext.java

示例2: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CGLGraphicsConfig.java

示例3: createCustomBuffer

import java.awt.image.ColorModel; //导入方法依赖的package包/类
private static BufferedImage createCustomBuffer() {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, false, false,
            Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
    WritableRaster wr = cm.createCompatibleWritableRaster(width, height);

    return new BufferedImage(cm, wr, false, null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:RenderToCustomBufferTest.java

示例4: BlitBg

import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public void BlitBg(SurfaceData srcData,
                   SurfaceData dstData,
                   Composite comp,
                   Region clip,
                   int bgArgb,
                   int srcx, int srcy,
                   int dstx, int dsty,
                   int width, int height)
{
    ColorModel dstModel = dstData.getColorModel();
    boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
    if (!dstModel.hasAlpha() && bgHasAlpha) {
        dstModel = ColorModel.getRGBdefault();
    }
    WritableRaster wr =
        dstModel.createCompatibleWritableRaster(width, height);
    boolean isPremult = dstModel.isAlphaPremultiplied();
    BufferedImage bimg =
        new BufferedImage(dstModel, wr, isPremult, null);
    SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
    Color bgColor = new Color(bgArgb, bgHasAlpha);
    SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
                                           defaultFont);
    FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
                                      CompositeType.SrcNoEa,
                                      tmpData.getSurfaceType());
    Blit combineop = Blit.getFromCache(srcData.getSurfaceType(),
                                       CompositeType.SrcOverNoEa,
                                       tmpData.getSurfaceType());
    Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType,
                                    dstData.getSurfaceType());
    fillop.FillRect(sg2d, tmpData, 0, 0, width, height);
    combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null,
                   srcx, srcy, 0, 0, width, height);
    blitop.Blit(tmpData, dstData, comp, clip,
                0, 0, dstx, dsty, width, height);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:39,代码来源:BlitBg.java

示例5: 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

示例6: getCachedRaster

import java.awt.image.ColorModel; //导入方法依赖的package包/类
static synchronized Raster getCachedRaster(ColorModel cm, int w, int h) {
    if (cm == cachedModel) {
        if (cached != null) {
            Raster ras = cached.get();
            if (ras != null &&
                ras.getWidth() >= w &&
                ras.getHeight() >= h)
            {
                cached = null;
                return ras;
            }
        }
    }
    return cm.createCompatibleWritableRaster(w, h);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:GradientPaintContext.java

示例7: createAcceleratedImage

import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
 * Creates a new managed image of the given width and height
 * that is associated with the target Component.
 */
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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:Win32GraphicsConfig.java

示例8: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:CGLGraphicsConfig.java

示例9: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:OpCompatibleImageTest.java

示例10: 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

示例11: createCompatibleTranslucentImage

import java.awt.image.ColorModel; //导入方法依赖的package包/类
public static BufferedImage createCompatibleTranslucentImage(int w, int h) {
  final ColorModel cm = compatTransImage.getColorModel();
  final WritableRaster wr = cm.createCompatibleWritableRaster(w, h);
  return new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:6,代码来源:ImageUtils.java

示例12: createCompatibleImage

import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
 * Returns a {@code BufferedImage} that supports the specified
 * transparency and has a data layout and color model
 * compatible with this {@code GraphicsConfiguration}.  This
 * method has nothing to do with memory-mapping
 * a device. The returned {@code BufferedImage} has a layout and
 * color model that can be optimally blitted to a device
 * with this {@code GraphicsConfiguration}.
 * @param width the width of the returned {@code BufferedImage}
 * @param height the height of the returned {@code BufferedImage}
 * @param transparency the specified transparency mode
 * @return a {@code BufferedImage} whose data layout and color
 * model is compatible with this {@code GraphicsConfiguration}
 * 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:GraphicsConfiguration.java

示例13: 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:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:GraphicsConfiguration.java


注:本文中的java.awt.image.ColorModel.createCompatibleWritableRaster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。