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