當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。