Exemplo n.º 1
0
 private void captureScreen(IScreen scr) {
   ScreenImage simg = scr.capture();
   scr_img = simg.getImage();
   darker_factor = 0.6f;
   RescaleOp op = new RescaleOp(darker_factor, 0, null);
   scr_img_darker = op.filter(scr_img, null);
 }
Exemplo n.º 2
0
  public static BufferedImage doContrast(BufferedImage img, float f) {
    float brightenFactor = 1 + f;

    RescaleOp op = new RescaleOp(brightenFactor, 0, null);
    img = op.filter(img, img);

    return img;
  }
Exemplo n.º 3
0
 private static ImageIcon makeRolloverIcon(ImageIcon srcIcon) {
   RescaleOp op =
       new RescaleOp(new float[] {1.2f, 1.2f, 1.2f, 1f}, new float[] {0f, 0f, 0f, 0f}, null);
   BufferedImage img =
       new BufferedImage(
           srcIcon.getIconWidth(), srcIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
   Graphics g = img.getGraphics();
   // g.drawImage(srcIcon.getImage(), 0, 0, null);
   srcIcon.paintIcon(null, g, 0, 0);
   g.dispose();
   return new ImageIcon(op.filter(img, null));
 }
Exemplo n.º 4
0
 private BufferedImage windowWithRasterOp(
     BufferedImage srcImg, float windowLocation, float windowWidth) {
   // final int windowedImageBandValuesCount = 256;  // for BufferedImage.TYPE_INT_RGB
   // final float windowedImageBandValuesCount = 1.0F;
   // final float windowedImageBandValuesCount = 65535F;
   // final float windowedImageBandValuesCount = 4095F;
   final float windowedImageBandValuesCount =
       (1 << srcImg.getColorModel().getComponentSize(0)) - 1;
   float scale = windowedImageBandValuesCount / windowWidth;
   float offset = (windowWidth / 2 - windowLocation) * scale;
   RescaleOp rescaleOp = new RescaleOp(scale, offset, null);
   return rescaleOp.filter(srcImg, null);
 }
Exemplo n.º 5
0
 /** Takes a snapshot of the screen, fades it, and sets it as the background. */
 public static void snapshot() {
   Dimension dim = getInstance().component.getPreferredSize();
   java.awt.Rectangle rect = new java.awt.Rectangle(0, 0, dim.width, dim.height);
   BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = image.getGraphics();
   g.setColor(java.awt.Color.WHITE);
   g.fillRect(0, 0, rect.width, rect.height);
   g.setColor(java.awt.Color.BLACK);
   getInstance().component.paintComponent(g);
   float factor = 0.8f;
   float base = 255f * (1f - factor);
   RescaleOp op = new RescaleOp(factor, base, null);
   BufferedImage filteredImage =
       new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
   op.filter(image, filteredImage);
   getInstance().background = filteredImage;
   getInstance().component.repaint();
 }
  /**
   * Creates BufferedImage for hwComponentType at path of size. If marked, the result image is
   * brighter by 50%.
   *
   * @param hwComponentType
   * @param path
   * @param width
   * @param marked
   * @return
   */
  protected BufferedImage createImage(
      HwTypeEnum hwComponentType, String path, Integer width, boolean marked) {

    BufferedImage bi = null;

    Image tmp = null;

    try {
      // loads image from path and scales it to desired size
      tmp = getScaledImage(path, width);
    } catch (IOException ex) {
      try {
        // load default image
        tmp = getScaledImage(getImagePath(hwComponentType), width);
      } catch (IOException ex1) {
        // should never happen, all hwComponentType default icons are in .jar as a resource
      }
    }

    // create new buffered image to paint on
    bi = new BufferedImage(tmp.getWidth(null), tmp.getHeight(null), BufferedImage.TYPE_INT_ARGB);

    // create graphics and set hints
    Graphics2D graphics2D = bi.createGraphics();
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.setRenderingHint(
        RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

    // draw image
    graphics2D.drawImage(tmp, 0, 0, null);

    // if marked, draw transparent white rectangle over
    if (marked) {
      rescaleOp.filter(bi, bi);
    }

    graphics2D.dispose();

    return bi;
  }
Exemplo n.º 7
0
 public BufferedImage getBrighten() {
   RescaleOp rop = new RescaleOp(1.0F, 0.0F, null);
   return this.image = rop.filter(this.image, null);
 }
Exemplo n.º 8
0
 /**
  * @time : 11:08:58 AM Sep 10, 2015 @Description : For static snapshot, we are used to put a dark
  *     image as back image. So the original image should be darken.
  */
 public void darkScreenImage() {
   RescaleOp ro = new RescaleOp(0.9f, 0, null);
   whiteImage = ro.filter(screenImage, null);
 }
Exemplo n.º 9
0
 @Override
 public void paint(Graphics g) {
   RescaleOp ro = new RescaleOp(0.8f, 0, null);
   tempImage = ro.filter(image, null);
   g.drawImage(tempImage, 0, 0, this);
 }