TransparentFilter.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:vassal 作者:
/**
 * For the given input color, return the color that this color
 * will map to in an offscreen image created by the given Component
 */
public static int getOffscreenEquivalent(int color, Component obs) {
  Image im = obs.createImage(1, 1);
  Graphics2D g = (Graphics2D) im.getGraphics();
  g.setColor(new java.awt.Color(color));
  g.fillRect(0, 0, 1, 1);
  g.dispose();

  int[] bg = new int[1];
  PixelGrabber pg = new PixelGrabber(im, 0, 0, 1, 1, bg, 0, 1);
  try {
    pg.grabPixels();
  }
  catch (InterruptedException ex) {
    logger.error("", ex);
  }
  return bg[0];
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号