Package java.awt.image

Examples of java.awt.image.BufferedImage.createGraphics()


    return toBufferedImage(img, scaledSize.getWidth(), scaledSize.getHeight(), BufferedImage.TYPE_INT_RGB);
  }
 
  private static BufferedImage toBufferedImage(Image image, int w, int h, int type) {
    BufferedImage result = new BufferedImage(w, h, type);
    Graphics2D g = result.createGraphics();
    g.drawImage(image, 0, 0, null);
    g.dispose();
    return result;
  }
 
View Full Code Here


            .get(0).rules().get(0), font);
      }
    }
    JComponent c = builder.buildComponent();
    BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D graphics = image.createGraphics();
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.setRenderingHints(renderingHints);
    c.print(graphics);
    return image;
View Full Code Here

    public void generateActual(OutputStream out) throws Exception {
      Rectangle rect = mapContext.getViewport().getScreenArea();
      BufferedImage image = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(),
          BufferedImage.TYPE_4BYTE_ABGR);
      layer.draw(image.createGraphics(), mapContext, mapContext.getViewport());
      ImageIO.write(image, "PNG", out);
    }

  }
View Full Code Here

    public void generateActual(OutputStream out) throws Exception {
      Rectangle rect = mapContext.getViewport().getScreenArea();
      BufferedImage image = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(),
          BufferedImage.TYPE_4BYTE_ABGR);
      layer.draw(image.createGraphics(), mapContext, mapContext.getViewport());
      ImageIO.write(image, "PNG", out);
    }

  }
View Full Code Here

        new ReferencedEnvelope(0, 100, 0, 100, mapContext.getCoordinateReferenceSystem()));
    mapContext.getViewport().setCoordinateReferenceSystem(mapContext.getCoordinateReferenceSystem());
    mapContext.getViewport().setScreenArea(new Rectangle(0, 0, 100, 100));
    GeometryDirectLayer layer = (GeometryDirectLayer) layerFactory.createLayer(mapContext, geo);
    BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR);
    layer.draw(image.createGraphics(), mapContext, mapContext.getViewport());
    new DirectLayerAssert(layer, mapContext).assertEqualImage("polygon.png", writeImages, DELTA);
  }

  private FeatureStyleInfo createPolygonStyle() {
    FeatureStyleInfo style = new FeatureStyleInfo();
View Full Code Here

        switch (element.getScaleImageValue())
        {
          case CLIP:
          {
            BufferedImage bi = new BufferedImage(availableImageWidth, availableImageHeight, BufferedImage.TYPE_INT_ARGB);
            Graphics2D grx = bi.createGraphics();

            int xoffset = (int) (xalignFactor * (availableImageWidth - normalWidth));
            int yoffset = (int) (yalignFactor * (availableImageHeight - normalHeight));

            Shape oldClipShape = grx.getClip();
View Full Code Here

  public static BufferedImage getScaledInstance(BufferedImage image,
      int width, int height) {
    int type = (image.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB
        : BufferedImage.TYPE_INT_ARGB;
    BufferedImage result = new BufferedImage(width, height, type);
    Graphics2D graphics = result.createGraphics();
    graphics.drawImage(
        image.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0,
        0, width, height, null);
    graphics.dispose();
    return result;
View Full Code Here

      AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350);

      BufferedImage bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB);

      axisChart.setGraphics2D(bufferedImage.createGraphics());
      axisChart.render();

      super.setVariableValue("ChartImage", bufferedImage);
    }
    catch(ChartDataException chartDataException)
View Full Code Here

  protected BufferedImage getChartImage(Chart chart) throws JRException
  {
    BufferedImage bufferedImage = new BufferedImage(
        chart.getImageWidth(), chart.getImageHeight(),
        BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics = bufferedImage.createGraphics();
    chart.setGraphics2D(graphics);
    try
    {
      chart.render();
    }
View Full Code Here

       * re-determine the most effective image type like scaleImage(...)
       * has to do.
       */
      BufferedImage rotatedImage = new BufferedImage(newWidth, newHeight,
          result.getType());
      Graphics2D g2d = (Graphics2D) rotatedImage.createGraphics();

      /*
       * Render the resultant image to our new rotatedImage buffer,
       * applying the AffineTransform that we calculated above during
       * rendering so the pixels from the old position to the new
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.