本文整理汇总了Java中java.awt.PaintContext.getColorModel方法的典型用法代码示例。如果您正苦于以下问题:Java PaintContext.getColorModel方法的具体用法?Java PaintContext.getColorModel怎么用?Java PaintContext.getColorModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.PaintContext
的用法示例。
在下文中一共展示了PaintContext.getColorModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillMultiRectAreaPaint
import java.awt.PaintContext; //导入方法依赖的package包/类
/**
* This method fills the given MultiRectArea with any paint.
* @param mra MultiRectArea to fill
*/
protected void fillMultiRectAreaPaint(MultiRectArea mra) {
Rectangle rec = mra.getBounds();
int x = rec.x;
int y = rec.y;
int w = rec.width;
int h = rec.height;
if(w <= 0 || h <= 0) {
return;
}
PaintContext pc = paint.createContext(null, rec, rec, transform, hints);
Raster r = pc.getRaster(x, y, w, h);
WritableRaster wr;
if(r instanceof WritableRaster){
wr = (WritableRaster) r;
}else{
wr = r.createCompatibleWritableRaster();
wr.setRect(r);
}
Surface srcSurf = new ImageSurface(pc.getColorModel(), wr);
blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
composite, null, mra);
srcSurf.dispose();
}
示例2: TileContext
import java.awt.PaintContext; //导入方法依赖的package包/类
public TileContext(SunGraphics2D sg, PaintContext pc) {
sunG2D = sg;
paintCtxt = pc;
paintModel = pc.getColorModel();
dstData = sg.getSurfaceData();
synchronized (AlphaPaintPipe.class) {
if (cachedLastColorModel != null &&
cachedLastColorModel.get() == paintModel)
{
this.lastRaster = cachedLastRaster;
this.lastData = cachedLastData;
}
}
}
示例3: renderScanline
import java.awt.PaintContext; //导入方法依赖的package包/类
/**
* Paints a scanline between x0 and x1. Override this when your backend
* can efficiently draw/fill horizontal lines.
*
* @param x0 the left offset
* @param x1 the right offset
* @param y the scanline
*/
public void renderScanline(int y, ScanlineCoverage c)
{
PaintContext pCtx = getPaintContext();
int x0 = c.getMinX();
int x1 = c.getMaxX();
Raster paintRaster = pCtx.getRaster(x0, y, x1 - x0, 1);
// Do the anti aliasing thing.
float coverageAlpha = 0;
float maxCoverage = c.getMaxCoverage();
ColorModel cm = pCtx.getColorModel();
DataBuffer db = paintRaster.getDataBuffer();
Point loc = new Point(paintRaster.getMinX(), paintRaster.getMinY());
SampleModel sm = paintRaster.getSampleModel();
WritableRaster writeRaster = Raster.createWritableRaster(sm, db, loc);
WritableRaster alphaRaster = cm.getAlphaRaster(writeRaster);
int pixel;
ScanlineCoverage.Iterator iter = c.iterate();
while (iter.hasNext())
{
ScanlineCoverage.Range range = iter.next();
coverageAlpha = range.getCoverage() / maxCoverage;
if (coverageAlpha < 1.0)
{
for (int x = range.getXPos(); x < range.getXPosEnd(); x++)
{
pixel = alphaRaster.getSample(x, y, 0);
pixel = (int) (pixel * coverageAlpha);
alphaRaster.setSample(x, y, 0, pixel);
}
}
}
ColorModel paintColorModel = pCtx.getColorModel();
CompositeContext cCtx = composite.createContext(paintColorModel,
getColorModel(),
renderingHints);
WritableRaster raster = getDestinationRaster();
WritableRaster targetChild = raster.createWritableTranslatedChild(-x0, -y);
cCtx.compose(paintRaster, targetChild, targetChild);
updateRaster(raster, x0, y, x1 - x0, 1);
cCtx.dispose();
}
示例4: renderScanline
import java.awt.PaintContext; //导入方法依赖的package包/类
/**
* Paints a scanline between x0 and x1. Override this when your backend
* can efficiently draw/fill horizontal lines.
*
* @param x0 the left offset
* @param x1 the right offset
* @param y the scanline
*/
public void renderScanline(int y, ScanlineCoverage c)
{
PaintContext pCtx = getPaintContext();
int x0 = c.getMinX();
int x1 = c.getMaxX();
Raster paintRaster = pCtx.getRaster(x0, y, x1 - x0, 1);
// Do the anti aliasing thing.
float coverageAlpha = 0;
float maxCoverage = c.getMaxCoverage();
ColorModel cm = pCtx.getColorModel();
DataBuffer db = paintRaster.getDataBuffer();
Point loc = new Point(paintRaster.getMinX(), paintRaster.getMinY());
SampleModel sm = paintRaster.getSampleModel();
WritableRaster writeRaster = Raster.createWritableRaster(sm, db, loc);
WritableRaster alphaRaster = cm.getAlphaRaster(writeRaster);
int pixel;
ScanlineCoverage.Iterator iter = c.iterate();
while (iter.hasNext())
{
ScanlineCoverage.Range range = iter.next();
coverageAlpha = range.getCoverage() / maxCoverage;
if (coverageAlpha < 1.0)
{
for (int x = range.getXPos(); x < range.getXPosEnd(); x++)
{
pixel = alphaRaster.getSample(x, y, 0);
pixel = (int) (pixel * coverageAlpha);
alphaRaster.setSample(x, y, 0, pixel);
}
}
}
ColorModel paintColorModel = pCtx.getColorModel();
CompositeContext cCtx = composite.createContext(paintColorModel,
getColorModel(),
renderingHints);
WritableRaster raster = getDestinationRaster();
WritableRaster targetChild = raster.createWritableTranslatedChild(-x0, -y);
cCtx.compose(paintRaster, targetChild, targetChild);
updateRaster(raster, x0, y, x1 - x0, 1);
cCtx.dispose();
}