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


Java PaintContext.getColorModel方法代码示例

本文整理汇总了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();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:CommonGraphics2D.java

示例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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:AlphaPaintPipe.java

示例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();
}
 
开发者ID:vilie,项目名称:javify,代码行数:53,代码来源:AbstractGraphics2D.java

示例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();
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:53,代码来源:AbstractGraphics2D.java


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