• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ScanlineCoverage类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中gnu.java.awt.java2d.ScanlineCoverage的典型用法代码示例。如果您正苦于以下问题:Java ScanlineCoverage类的具体用法?Java ScanlineCoverage怎么用?Java ScanlineCoverage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ScanlineCoverage类属于gnu.java.awt.java2d包,在下文中一共展示了ScanlineCoverage类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renderScanline

点赞 2

import gnu.java.awt.java2d.ScanlineCoverage; //导入依赖的package包/类
@Override
public void renderScanline(int y, ScanlineCoverage c)
{
  if (y >= xdrawable.height)
    return;

  // TODO: Handle Composite and Paint.
  ScanlineCoverage.Iterator iter = c.iterate();
  int coverageAlpha = 0;
  int maxCoverage = c.getMaxCoverage();
  while (iter.hasNext())
    {
      ScanlineCoverage.Range range = iter.next();

      coverageAlpha = range.getCoverage();
      int x0 = range.getXPos();
      int l = range.getLength();
      if (coverageAlpha == c.getMaxCoverage())
        {
          // Simply paint the current color over the existing pixels.
          xdrawable.fill_rectangle(xgc, x0, y, l, 1);
        }
      else if (coverageAlpha > 0)
        {
          // Composite the current color with the existing pixels.
          int x1 = x0 + l;
          x0 = Math.min(Math.max(0, x0), xdrawable.width - 1);
          x1 = Math.min(Math.max(0, x1), xdrawable.width - 1);
          if ((x1 - x0) < 1)
            continue;
          l = x1 - x0;
          gnu.x11.image.ZPixmap existing = (ZPixmap)
          xdrawable.image(x0, y, l, 1, 0xFFFFFFFF,
                          gnu.x11.image.Image.Format.ZPIXMAP);
          for (int x = 0; x < l; x++)
            {
              Color col = getColor();
              if (col == null)
                {
                  col = Color.BLACK;
                }
              int red = col.getRed();
              int green = col.getGreen();
              int blue = col.getBlue();
              int redOut = existing.get_red(x, 0);
              int greenOut = existing.get_green(x, 0);
              int blueOut = existing.get_blue(x, 0);
              int outAlpha = maxCoverage - coverageAlpha;
              redOut = redOut * outAlpha + red * coverageAlpha;
              redOut = redOut / maxCoverage;
              greenOut = greenOut * outAlpha + green * coverageAlpha;
              greenOut = greenOut / maxCoverage;
              blueOut = blueOut * outAlpha + blue * coverageAlpha;
              blueOut = blueOut / maxCoverage;
              existing.set(x, 0, redOut, greenOut, blueOut);
            }
          xdrawable.put_image(xgc, existing, x0, y);
        }
    }
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:61,
代码来源:XGraphics2D.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)