本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}