Package java.awt

Examples of java.awt.Graphics2D.drawImage()


            Composite oldComposite = g2.getComposite();

            if(opacity != 1.0f) {
                g2.setComposite(AlphaComposite.SrcOver.derive(opacity));
            }
            g2.drawImage(image, null, x, y);

            g2.setComposite(oldComposite);
        }
    }
View Full Code Here


            @Override
            protected void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D)g;
                g2.setColor(Color.black);
                g2.fillRect(0, 0, getWidth(), getHeight());
                g2.drawImage(image, null, 0, 0);
                g2.setColor(Color.white);
                g2.setFont(font);
                g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                g2.drawString("lightweight overlay", 100, 200);
            }
View Full Code Here

        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(new JPanel() {
            @Override
            protected void paintChildren(Graphics g) {
                Graphics2D g2 = (Graphics2D)g;
                g2.drawImage(img, null, 0, 0);
            }

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(img.getWidth(), img.getHeight());
View Full Code Here

        }

        @Override
        public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.drawImage(image, null, 0, 0);
            // You could draw on top of the image here...
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            g2.setColor(Color.red);
            g2.setComposite(AlphaComposite.SrcOver.derive(0.3f));
View Full Code Here

          final BufferedImage bi = new BufferedImage(
              img.getWidth(null), img.getHeight(null),
              BufferedImage.TYPE_INT_RGB);

          final Graphics2D g2 = bi.createGraphics();
          g2.drawImage(img, 0, 0, null);
          g2.dispose();
          ImageIO.write(bi, "jpg", new File(Constants.DATA_PATH
              + "livestream/art.jpg"));
        } catch (final IOException e) {
          // TODO Auto-generated catch block
View Full Code Here

      // We do not need to pass in an ImageObserver, because we are working
      // with BufferedImages. ImageObservers only need to be used when
      // the image to be drawn is being loaded asynchronously. See
      // http://java.sun.com/docs/books/tutorial/2d/images/drawimage.html
      // for more information.
      g2d.drawImage(imageRect.image, imageRect.left, 0, null);
    }
    g2d.dispose();

    return bundledImage;
  }
View Full Code Here

        BufferedImage scaledRndMap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = scaledRndMap.createGraphics();
        try {
          g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
              RenderingHints.VALUE_INTERPOLATION_BICUBIC);
          g.drawImage(rndMap, 0, 0, width, height, 0, 0, frequencyX, frequencyY, null);
        }
        finally {
          g.dispose();
        }
        mainGr.drawImage(scaledRndMap, null, 0, 0);
View Full Code Here

        graphics.setComposite(AlphaComposite.Clear);
        graphics.fillRect(0, 0, original.getWidth(), original.getHeight());

        // Add the original image
        graphics.setComposite(AlphaComposite.Src);
        graphics.drawImage(original, 0, 0, null);

        // Merge in the color filter
        graphics.setComposite(new MultiplyBlendComposite(alpha));
        graphics.drawImage(colorBlend, 0, 0, null);
        graphics.dispose();
View Full Code Here

        graphics.setComposite(AlphaComposite.Src);
        graphics.drawImage(original, 0, 0, null);

        // Merge in the color filter
        graphics.setComposite(new MultiplyBlendComposite(alpha));
        graphics.drawImage(colorBlend, 0, 0, null);
        graphics.dispose();

        return image;
    }
View Full Code Here

      int imgH = bgImg.getHeight();

      if ((float)w/h < (float)imgW/imgH) {
        int tw = h * imgW/ imgH;
        int th = h;
        gg.drawImage(bgImg, (w-tw)/2, 0, tw, th, null);
      } else {
        int tw = w;
        int th = w * imgH / imgW;
        gg.drawImage(bgImg, 0, (h-th)/2, tw, th, null);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.