Package java.awt

Examples of java.awt.Graphics2D.drawImage()


    BufferedImage resizedImg = new BufferedImage(w, h,
                                                 BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = resizedImg.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.drawImage(srcImg, 0, 0, w, h, null);
    g2.dispose();
    return resizedImg;
  }

}
View Full Code Here


      // Log.log("ServletExtension: i2 size : "+i2.getWidth(comp)+"x"+i2.getHeight(comp));

      dest = new BufferedImage(destWidth, destHeight, BufferedImage.TYPE_INT_RGB);
      Graphics2D big = dest.createGraphics();
      big.drawImage(i2, 0, 0, comp);

      // Log.log("ServletExtension: dest size : "+dest.getWidth()+"x"+dest.getHeight());
    }

    try{
View Full Code Here

            && image.getType() != BufferedImage.TYPE_INT_ARGB) {
          // Transform as TYPE_INT_ARGB or TYPE_INT_RGB (much faster than calling image.getRGB())
          BufferedImage tmp = new BufferedImage(image.getWidth(), image.getHeight(),
              this.texture.getFormat() == Texture.RGBA ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);
          Graphics2D g = (Graphics2D)tmp.getGraphics();
          g.drawImage(image, null, 0, 0);
          g.dispose();
          image = tmp;
        }
        imageBits = (int [])image.getRaster().getDataElements(0, 0, image.getWidth(), image.getHeight(), null);
        this.transparent = image.getTransparency() != BufferedImage.OPAQUE;
View Full Code Here

    }
   
    BufferedImage iconImage = new BufferedImage(imageWithWhiteBackgound.getWidth(), imageWithWhiteBackgound.getHeight(),
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2D = (Graphics2D)iconImage.getGraphics();
    g2D.drawImage(Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(
        imageWithWhiteBackgound.getWidth(), imageWithWhiteBackgound.getHeight(),
        imageWithWhiteBackgoundPixels, 0, imageWithWhiteBackgound.getWidth())), null, null);
    g2D.dispose();

    return iconImage;
View Full Code Here

                }
         
                public void paintIcon(Component c, Graphics g, int x, int y) {
                  Graphics2D g2D = (Graphics2D)g;
                  for (int i = 0; i < 4; i++) {
                    g2D.drawImage(patternImage, x + i * patternImage.getWidth(), y + 1, list);
                  }
                  g2D.setColor(list.getForeground());
                  g2D.drawRect(x, y, getIconWidth() - 2, getIconHeight() - 1);
                }
              });
View Full Code Here

                      BufferedImage image_raw = new BufferedImage(width_new, height_new, BufferedImage.TYPE_INT_RGB);   
                     
                     
                      Graphics2D graphics2D = image_raw.createGraphics();
                      graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
                      graphics2D.drawImage(image, 0, 0, width_new, height_new, null);
                      graphics2D.dispose();
                       
                      //End resize
                       
                        int scaledWidth = width;
View Full Code Here

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_RENDERING,
        RenderingHints.VALUE_RENDER_QUALITY);
    g.setComposite(AlphaComposite.Src);
    g.drawImage(image, 0, 0, width, height, null);
    g.dispose();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(scaledImage, "PNG", baos);
    return new BufferedInputStream(new ByteArrayInputStream(baos.toByteArray()));
  }
View Full Code Here

      //TYPE_BYTE_BINARY //13812--
      //TYPE_BYTE_INDEXED //24545
      BufferedImage image = new BufferedImage(scaledWidth, scaledHeight,BufferedImage.TYPE_3BYTE_BGR);
     
      Graphics2D biContext = image.createGraphics();
      biContext.drawImage(img, 0, 0, null);
     
      ByteArrayOutputStream out = new ByteArrayOutputStream();
     
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam encpar = encoder.getDefaultJPEGEncodeParam(image);
View Full Code Here

      //TYPE_BYTE_BINARY //13812--
      //TYPE_BYTE_INDEXED //24545
      BufferedImage image = new BufferedImage(scaledWidth, scaledHeight,BufferedImage.TYPE_BYTE_BINARY);
     
      Graphics2D biContext = image.createGraphics();
      biContext.drawImage(img, 0, 0, null);
     
      ByteArrayOutputStream out = new ByteArrayOutputStream();
     
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam encpar = encoder.getDefaultJPEGEncodeParam(image);
View Full Code Here

          //BufferedImage.TYPE_INT_RGB
          //TYPE_3BYTE_BGR
          BufferedImage image = new BufferedImage(scaledWidth, scaledHeight,BufferedImage.TYPE_3BYTE_BGR);
         
          Graphics2D biContext = image.createGraphics();
          biContext.drawImage(img, 0, 0, null);
         
//          ByteArrayOutputStream out = new ByteArrayOutputStream();
//         
//          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
//          JPEGEncodeParam encpar = encoder.getDefaultJPEGEncodeParam(image);
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.