當前位置: 首頁>>代碼示例>>Java>>正文


Java CompositeContext.compose方法代碼示例

本文整理匯總了Java中java.awt.CompositeContext.compose方法的典型用法代碼示例。如果您正苦於以下問題:Java CompositeContext.compose方法的具體用法?Java CompositeContext.compose怎麽用?Java CompositeContext.compose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.CompositeContext的用法示例。


在下文中一共展示了CompositeContext.compose方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:36,代碼來源:Blit.java

示例2: 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];
        srcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                    w, h, 0, 0, null);
        dstRas = dstRas.createWritableChild(span[0], span[1],
                                            w, h, 0, 0, null);
        ctx.compose(srcRas, dstRas, dstRas);
    }
    ctx.dispose();
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:36,代碼來源:Blit.java

示例3: renderScanline

import java.awt.CompositeContext; //導入方法依賴的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.CompositeContext; //導入方法依賴的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.CompositeContext.compose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。