Package java.awt.image

Examples of java.awt.image.BufferedImage


    final double transx = sx1 * scalex;
    final double transy = sy1 * scaley;
    final AffineTransform tx = AffineTransform.getTranslateInstance(dx1 - transx, dy1 - transy);
    tx.scale(scalex, scaley);

    final BufferedImage mask = new BufferedImage(img.getWidth(observer), img.getHeight(observer),
        BufferedImage.TYPE_BYTE_BINARY);
    final Graphics g = mask.getGraphics();
    g.fillRect(sx1, sy1, (int) swidth, (int) sheight);
    drawImage(img, mask, tx, null, observer);
    g.dispose();
    return true;
  }
View Full Code Here


    else if (paint instanceof TexturePaint)
    {
      try
      {
        final TexturePaint tp = (TexturePaint)paint;
        final BufferedImage img = tp.getImage();
        final Rectangle2D rect = tp.getAnchorRect();
        final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
        final PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
        final AffineTransform inverse = this.normalizeMatrix();
        inverse.translate(rect.getX(), rect.getY());
        inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
        final double[] mx = new double[6];
        inverse.getMatrix(mx);
        pattern.setPatternMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]) ;
        image.setAbsolutePosition(0,0);
        pattern.addImage(image);
        if (fill)
            cb.setPatternFill(pattern);
        else
            cb.setPatternStroke(pattern);

      }
      catch (Exception ex)
      {
        if (fill)
        {
          cb.setColorFill(Color.gray);
        }
        else
        {
          cb.setColorStroke(Color.gray);
        }
      }
    }
    else
    {
      try
      {
        int type = BufferedImage.TYPE_4BYTE_ABGR;
        if (paint.getTransparency() == Transparency.OPAQUE)
        {
          type = BufferedImage.TYPE_3BYTE_BGR;
        }
        final BufferedImage img = new BufferedImage((int) width, (int) height, type);
        final Graphics2D g = (Graphics2D) img.getGraphics();
        g.transform(transform);
        final AffineTransform inv = transform.createInverse();
        Shape fillRect = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight());
        fillRect = inv.createTransformedShape(fillRect);
        g.setPaint(paint);
        g.fill(fillRect);
        if (invert)
        {
View Full Code Here

    final Dimension dim = drawable.getSize();

    final int width = Math.max(1, (int) (scale * dim.width));
    final int height = Math.max(1, (int) (scale * dim.height));

    final BufferedImage bi = ImageUtils.createTransparentImage(width, height);
    final Graphics2D graph = bi.createGraphics();
    graph.setBackground(new Color(0, 0, 0, 0));
    graph.setTransform(AffineTransform.getScaleInstance(scale, scale));
    drawable.draw(graph, new Rectangle2D.Float(0, 0, dim.width, dim.height));
    graph.dispose();

View Full Code Here

      final ContentLocation contentLocation = getBodyContentLocation();
      final NameGenerator nameGenerator = getBodyNameGenerator();
      final ContentItem contentItem =
          contentLocation.createItem(nameGenerator.generateName(null, mimeType));
      final BufferedImage image = interceptor.getImage();
      final ImageEncoder imageEncoder = ImageEncoderRegistry.getInstance().createEncoder(mimeType);
      final OutputStream outputStream = contentItem.getOutputStream();
      imageEncoder.encodeImage(image, outputStream, quality, alphaChannel);
      outputStream.close();
    }
View Full Code Here

    }

    public void processLogicalPage(final LogicalPageKey key, final PageDrawable page)
    {
      final Dimension preferredSize = page.getPreferredSize();
      image = new BufferedImage(preferredSize.width, preferredSize.height, BufferedImage.TYPE_INT_ARGB);
      final Graphics2D g2 = image.createGraphics();
      page.draw(g2, new Rectangle2D.Double(0, 0, preferredSize.width, preferredSize.height));
      g2.dispose();
    }
View Full Code Here

   *
   * @param event the report event.
   */
  public void pageStarted(final ReportEvent event)
  {
    final BufferedImage image = new BufferedImage(150, 50, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g2 = image.createGraphics();
    final JButton bt = new JButton("A Button");
    bt.setSize(90, 20);
    final JRadioButton radio = new JRadioButton("A radio button");
    radio.setSize(100, 20);

View Full Code Here

      final int numberOfPages = prc.getNumberOfPages();
      for (int i = 0; i < numberOfPages; i++)
      {
        final String fileNameFormated =
            MessageFormat.format(fileName, new Object[]{new Integer(i)});
        final BufferedImage image = createImage(report.getPageDefinition());

        final Rectangle rect = new Rectangle(0, 0, image.getWidth(), image.getHeight());
        // prepare the image by filling it ...
        final Graphics2D g2 = image.createGraphics();
        g2.setPaint(Color.white);
        g2.fill(rect);

        final PageDrawable pageDrawable = prc.getPageDrawable(i);
        pageDrawable.draw(g2, rect);
View Full Code Here

    final PageFormat pf = pd.getPageFormat(0);

    final double width = pf.getWidth();
    final double height = pf.getHeight();
    //write the report to the temp file
    return new BufferedImage
        ((int) width, (int) height, BufferedImage.TYPE_BYTE_INDEXED);
  }
View Full Code Here

    {
      final Icon errorIcon = getErrorIcon();
      final int width = errorIcon.getIconWidth();
      final int height = errorIcon.getIconHeight();

      final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
      emptyIcon = new ImageIcon(bi);
    }
    return emptyIcon;
  }
View Full Code Here

    final double height = 400;

    final WaitingImageObserver obs = new WaitingImageObserver(source);
    obs.waitImageLoaded();

    final BufferedImage bImage = new BufferedImage((int) (width * scale), (int) (height * scale), BufferedImage.TYPE_INT_ARGB);

    final Graphics2D graph = bImage.createGraphics();
    graph.setTransform(AffineTransform.getScaleInstance(scale, scale));
    graph.drawImage(source, AffineTransform.getScaleInstance(scale, scale), null);
    graph.dispose();
    return bImage;
  }
View Full Code Here

TOP

Related Classes of java.awt.image.BufferedImage

Copyright © 2018 www.massapicom. 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.