本文整理匯總了Java中java.awt.CompositeContext類的典型用法代碼示例。如果您正苦於以下問題:Java CompositeContext類的具體用法?Java CompositeContext怎麽用?Java CompositeContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompositeContext類屬於java.awt包,在下文中一共展示了CompositeContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Blit
import java.awt.CompositeContext; //導入依賴的package包/類
public void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel srcCM = srcData.getColorModel();
ColorModel dstCM = dstData.getColorModel();
// REMIND: Should get RenderingHints from sg2d
CompositeContext ctx = comp.createContext(srcCM, dstCM,
new RenderingHints(null));
Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
WritableRaster dstRas =
(WritableRaster) dstData.getRaster(dstx, dsty, width, height);
if (clip == null) {
clip = Region.getInstanceXYWH(dstx, dsty, width, height);
}
int span[] = {dstx, dsty, dstx+width, dsty+height};
SpanIterator si = clip.getSpanIterator(span);
srcx -= dstx;
srcy -= dsty;
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
w, h, 0, 0, null);
WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
w, h, 0, 0, null);
ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
}
ctx.dispose();
}
示例2: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
@Override
public final CompositeContext createContext(final ColorModel srcColorModel,
final ColorModel dstColorModel, final RenderingHints hints) {
return new CompositeContext() {
@Override
public final void dispose() {
// NOP
}
@Override
public final void compose(final Raster src, final Raster dstIn, final WritableRaster dstOut) {
final Rectangle inBounds = dstIn.getBounds();
final Rectangle outBounds = dstOut.getBounds();
for (int yIn = inBounds.y, yOut = outBounds.y; yIn < inBounds.y + inBounds.height; ++yIn, ++yOut) {
for (int xIn = inBounds.x, xOut = outBounds.x; xIn < inBounds.x + inBounds.width; ++xIn, ++xOut) {
final int[] datum = (int[]) dstIn.getDataElements(xIn, yIn, null);
datum[0] = (datum[0] & 0xFF000000) | (~datum[0] & 0x00FFFFFF);
dstOut.setDataElements(xOut, yOut, datum);
}
}
}
};
}
示例3: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
@Override
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints arg2) {
switch (mode) {
case MULTIPLY:
return new MultiplyContext();
// Modes with significant creation overhead (lookup tables). Cache those
case SOFT_LIGHT:
CompositeContext ctx = cache.get(Mode.SOFT_LIGHT);
if (ctx == null) {
ctx = new BlendContext(mode, color);
cache.put(Mode.SOFT_LIGHT, ctx);
}
return ctx;
default:
return new BlendContext(mode, color);
}
}
示例4: startSequence
import java.awt.CompositeContext; //導入依賴的package包/類
@Override
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
int[] abox) {
// warning: clone map:
RenderingHints hints = sg.getRenderingHints();
ColorModel model = sg.getDeviceColorModel();
PaintContext paintContext =
sg.paint.createContext(model, devR, s.getBounds2D(),
sg.cloneTransform(),
hints);
CompositeContext compositeContext =
sg.composite.createContext(paintContext.getColorModel(), model,
hints);
// BlendComposite matcher: classpath independent so use String.equals()
boolean blendComposite = "sun.java2d.pipe.BlendComposite".equals(sg.composite.getClass().getName());
// use ThreadLocal (to reduce memory footprint):
final TileContext tc = tileContextThreadLocal.get();
tc.init(sg, paintContext, compositeContext, model, blendComposite);
return tc;
}
示例5: blendMode
import java.awt.CompositeContext; //導入依賴的package包/類
/**
* ( begin auto-generated from blendMode.xml ) This is a new reference entry for Processing 2.0.
* It will be updated shortly. ( end auto-generated )
*
* @webref Rendering
* @param mode
* the blending mode to use
*/
@Override
public void blendMode(final int mode) {
if (mode == PConstants.BLEND) {
g2.setComposite(defaultComposite);
} else {
g2.setComposite(new Composite() {
@Override
public CompositeContext createContext(final ColorModel srcColorModel, final ColorModel dstColorModel,
final RenderingHints hints) {
return new BlendingContext(mode);
}
});
}
}
示例6: TileContext
import java.awt.CompositeContext; //導入依賴的package包/類
public TileContext(SunGraphics2D sg, PaintContext pCtx,
CompositeContext cCtx, ColorModel cModel) {
sunG2D = sg;
paintCtxt = pCtx;
compCtxt = cCtx;
compModel = cModel;
}
示例7: startSequence
import java.awt.CompositeContext; //導入依賴的package包/類
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
int[] abox) {
RenderingHints hints = sg.getRenderingHints();
ColorModel model = sg.getDeviceColorModel();
PaintContext paintContext =
sg.paint.createContext(model, devR, s.getBounds2D(),
sg.cloneTransform(),
hints);
CompositeContext compositeContext =
sg.composite.createContext(paintContext.getColorModel(), model,
hints);
return new TileContext(sg, paintContext, compositeContext, model);
}
示例8: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
@Override
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints)
{
return new CustomCompositeContext();
}
示例9: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints) {
if (isRgbColorModel(srcColorModel) && isRgbColorModel(dstColorModel)) {
return new BlendingRgbContext(this);
} else if (isBgrColorModel(srcColorModel) && isBgrColorModel(dstColorModel)) {
return new BlendingBgrContext(this);
}
throw new RasterFormatException("Incompatible color models");
}
示例10: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
/**
* Creates a context object for performing the compositing
* operation. Several contexts may co-exist for one composite; each
* context may simultaneously be called from concurrent threads.
*
* @param srcColorModel the color model of the source.
* @param dstColorModel the color model of the destination.
* @param hints hints for choosing between rendering alternatives.
*/
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints)
{
if (IntContext.isSupported(srcColorModel, dstColorModel, hints))
return new IntContext(srcColorModel, xorColor);
return new GeneralContext(srcColorModel, dstColorModel, xorColor);
}
示例11: FilterContext
import java.awt.CompositeContext; //導入依賴的package包/類
public FilterContext(ColorModel dstModel, CompositeContext ctx, BufferedImageOp filter) {
Contract.asNotNull(dstModel, "dstModel cannot be null");
Contract.asNotNull(ctx, "context cannot be null");
this.dstModel = dstModel;
this.ctx = ctx;
this.filter = filter;
}
示例12: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints) {
if (isRgbColorModel(srcColorModel) && isRgbColorModel(dstColorModel)) {
return new BlendingRgbContext(this);
} else if (isBgrColorModel(srcColorModel) && isBgrColorModel(dstColorModel)) {
return new BlendingBgrContext(this);
}
throw new RasterFormatException("Incompatible color models:\n " + srcColorModel + "\n " + dstColorModel);
}
示例13: init
import java.awt.CompositeContext; //導入依賴的package包/類
void init(SunGraphics2D sg, PaintContext pCtx,
CompositeContext cCtx, ColorModel cModel,
boolean blendComposite, boolean extraAlpha)
{
sunG2D = sg;
paintCtxt = pCtx;
compCtxt = cCtx;
compModel = cModel;
isBlendComposite = blendComposite;
hasExtraAlpha = extraAlpha;
}
示例14: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
@Override
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel, RenderingHints hints) {
// use ThreadLocal (to reduce memory footprint):
final BlendingContext bc = blendContextThreadLocal.get();
bc.init(this);
return bc;
}
示例15: createContext
import java.awt.CompositeContext; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints) {
if (!checkComponentsOrder(srcColorModel) ||
!checkComponentsOrder(dstColorModel)) {
throw new RasterFormatException("Incompatible color models");
}
return new BlendingContext(this);
}