Package java.awt.image

Examples of java.awt.image.RenderedImage


        }

        SeekableStream ss = SeekableStream.wrapInputStream(fileURL.openStream(),
                true);
        XTIFFImageDecoder xtffImageDecoder = new XTIFFImageDecoder(ss, new XTIFFDecodeParam());
        RenderedImage ri = xtffImageDecoder.decodeAsRenderedImage();
        BufferedImage bi = new BufferedImage(ri.getColorModel(), ri.copyData(null), false, new Hashtable());
        ss.close();
        return bi;
    }
View Full Code Here


    if (DebugFile.trace) {
      DebugFile.writeln("Begin Image.dimensionsJAI()");
      DebugFile.incIdent();
    }

    RenderedImage oImg;
    com.sun.media.jai.codec.ImageDecoder oDecoder;

    if (DebugFile.trace) DebugFile.writeln("new FileInputStream(" + getStringNull(DB.path_image,"null") + ")");

    FileInputStream oInputStream = new FileInputStream(getString(DB.path_image));

    oDecoder = com.sun.media.jai.codec.ImageCodec.createImageDecoder(getImageCodec(), oInputStream, null);

    oImg = oDecoder.decodeAsRenderedImage();

    iDimX = oImg.getWidth();
    iDimY = oImg.getHeight();

    oInputStream.close();

    bRetVal = true;
View Full Code Here

  private void drawJAIImage(OutputStream outStr, int iThumbWidth, int iThumbHeight, float fQuality)
    throws IOException, InterruptedException, NullPointerException, IllegalArgumentException {

    com.sun.media.jai.codec.ImageDecoder oDecoder;
    RenderedImage oRenderedImg;
    javax.media.jai.PlanarImage oPlI;
    javax.media.jai.PlanarImage oScI;
    ParameterBlock oBlk;
    com.sun.media.jai.codec.ImageEncoder oImgEnc;
    String sInputURI;
    InputStream oInputStream;
    URL oURI;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin Image.drawJAIImage([OutputStream], " + String.valueOf(iThumbWidth) + "," + String.valueOf(iThumbHeight) + "," + String.valueOf(fQuality) + ")");
      DebugFile.incIdent();
    }

    sInputURI = getString(DB.path_image);

    if (sInputURI.startsWith("http://") || sInputURI.startsWith("https://")) {

      if (DebugFile.trace) DebugFile.writeln("new URL(" + sInputURI + ")");

      oURI = new URL(sInputURI);
      oInputStream = oURI.openStream();
    }
    else {
      if (DebugFile.trace) DebugFile.writeln("new FileInputStream(" + sInputURI + ")");

      try {
        oInputStream = new FileInputStream(sInputURI);
      } catch (FileNotFoundException fnf) {
        if (DebugFile.trace) DebugFile.decIdent();
        throw new FileNotFoundException(fnf.getMessage());
      }
    }

    oDecoder = com.sun.media.jai.codec.ImageCodec.createImageDecoder(getImageCodec(), oInputStream, null);

    oRenderedImg = oDecoder.decodeAsRenderedImage();

    if (getImageType().equals("gif")) {
      // Increase color depth to 16M RGB
      try {
        javax.media.jai.ImageLayout layout = new javax.media.jai.ImageLayout();

        ColorModel cm = new ComponentColorModel (ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                 new int[] {8,8,8}, false, false,
                                                 Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
        layout.setColorModel(cm);
        layout.setSampleModel(cm.createCompatibleSampleModel(oRenderedImg.getWidth(),oRenderedImg.getHeight()));
        RenderingHints hints = new RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, layout);
        javax.media.jai.ParameterBlockJAI pb = new javax.media.jai.ParameterBlockJAI( "format" );
        pb.addSource( oRenderedImg );
        oRenderedImg = javax.media.jai.JAI.create( "format", pb, hints );
      } catch (IllegalArgumentException iae) {
        if (DebugFile.trace) DebugFile.writeln(iae.getMessage() + " " + oRenderedImg.getColorModel().getClass().getName() + " " + oRenderedImg.getSampleModel().getClass().getName());
      }
      // End increase color depth
    } // gif

    oPlI = javax.media.jai.PlanarImage.wrapRenderedImage(oRenderedImg);
View Full Code Here

      throw new InstantiationException("ImageCodec.createImageEncoder("+getImageCodec()+")");
    }
    if (USE_JAI==iImagingLibrary) {

      RenderedImage oRImg = javax.media.jai.JAI.create("awtimage", oImg);

      if (null==oEnc) {
        if (DebugFile.trace) DebugFile.incIdent();
        throw new InstantiationException("JAI.create(awtimage, "+oImg.getClass().getName()+")");
      }
View Full Code Here

     *
     * @param renderContext The RenderContext to use to perform the rendering.
     * @return a RenderedImage containing the desired output image.
     */
    public RenderedImage createRendering(RenderContext renderContext) {
        RenderedImage image = null;
        RenderContext rcOut = null;

        // Clone the original ParameterBlock; if the ParameterBlock
        // contains RenderableImage sources, they will be replaced by
        // RenderedImages.
        ParameterBlock renderedParamBlock = (ParameterBlock)paramBlock.clone();
        Vector sources = getRenderableSources();

        try {
            // This assumes that if there is no renderable source, that there
            // is a rendered source in paramBlock
           
            if (sources != null) {
                Vector renderedSources = new Vector();
                for (int i = 0; i < sources.size(); i++) {
                    rcOut = myCRIF.mapRenderContext(i, renderContext,
                                                    paramBlock, this);
                    RenderedImage rdrdImage =
                       ((RenderableImage)sources.elementAt(i)).createRendering(rcOut);
                    if (rdrdImage == null) {
                        return null;
                    }
                   
View Full Code Here

          if (future.isDone()) {
            try {
              ImageResult result;
              result = future.get();
              // create a rendered image
              RenderedImage image = JAI.create("stream", new ByteArraySeekableStream(result.getImage()));
              // convert to common direct colormodel (some images have their own indexed color model)
              RenderedImage colored = toDirectColorModel(image);

              // translate to the correct position in the tile grid
              double xOffset = result.getRasterImage().getCode().getX() * tileWidth - pixelBounds.getX();
              double yOffset;
              // TODO: in some cases, the y-index is up (e.g. WMS), should be down for
              // all layers !!!!
              if (isYIndexUp(tiles)) {
                yOffset = result.getRasterImage().getCode().getY() * tileHeight - pixelBounds.getY();
              } else {
                yOffset = (pixelBounds.getMaxY() - (result.getRasterImage().getCode().getY() + 1)
                    * tileHeight);
              }
              log.debug("adding to(" + xOffset + "," + yOffset + "), url = "
                  + result.getRasterImage().getUrl());
              RenderedImage translated = TranslateDescriptor.create(colored, (float) xOffset,
                  (float) yOffset, new InterpolationNearest(), null);
              images.add(translated);
            } catch (ExecutionException e) {
              addLoadError(graphics, (ImageException) (e.getCause()), viewport);
            } catch (InterruptedException e) {
View Full Code Here

*
*/
public class WriteImageStep extends AbstractRasterizingStep {

  public void execute(PipelineContext context, RasterizingContainer response) throws GeomajasException {
    RenderedImage image = context.get(RasterizingPipelineCode.RENDERED_IMAGE, RenderedImage.class);
    ByteArrayOutputStream imageStream = new ByteArrayOutputStream(10 * 1024);
    try {
      ImageIO.write(image, "PNG", imageStream);
    } catch (IOException e) {
      throw new RasterException(RasterException.IMAGE_WRITING_FAILED, e);
View Full Code Here

            if (future.isDone()) {
              try {
                ImageResult result;
                result = future.get();
                // create a rendered image
                RenderedImage image = JAI.create("stream", new ByteArraySeekableStream(result
                    .getImage()));
                // convert to common direct colormodel (some images have their own indexed color model)
                RenderedImage colored = toDirectColorModel(image);

                // translate to the correct position in the tile grid
                double xOffset = result.getRasterImage().getCode().getX() * imageWidth
                    - pixelBounds.getX();
                double yOffset = 0;
                // TODO: in some cases, the y-index is up (e.g. WMS), should be down for
                // all layers !!!!
                if (isYIndexUp(tiles)) {
                  yOffset = result.getRasterImage().getCode().getY() * imageHeight
                      - pixelBounds.getY();
                } else {
                  yOffset = (float) (pixelBounds.getMaxY() - (result.getRasterImage().getCode()
                      .getY() + 1)
                      * imageHeight);
                }
                log.debug("adding to(" + xOffset + "," + yOffset + "), url = "
                    + result.getRasterImage().getUrl());
                RenderedImage translated = TranslateDescriptor.create(colored, (float) xOffset,
                    (float) yOffset, new InterpolationNearest(), null);
                images.add(translated);
              } catch (ExecutionException e) {
                addLoadError(context, (ImageException) (e.getCause()));
              } catch (InterruptedException e) {
View Full Code Here

      if (imagePath == null) {
        if (texture.getUserData() instanceof URL && transparency == 1) {
          imagePath = texture.getUserData().toString();
        } else {
          ImageComponent2D imageComponent = (ImageComponent2D)texture.getImage(0);
          RenderedImage image = imageComponent.getRenderedImage();
          if (transparency < 1) {
            // Compute a partially transparent image
            BufferedImage transparentImage = new BufferedImage(image.getWidth(),
                image.getHeight(), BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2D = (Graphics2D)transparentImage.getGraphics();
            g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transparency));
            g2D.drawRenderedImage(image, null);
            g2D.dispose();
            image = transparentImage;
View Full Code Here

              if (monitor.isCanceled()) {
                Platform.getJobManager().cancel(ExporterBase.EXPORT_JOB_FAMILY);
                return Status.CANCEL_STATUS;
              }
                try {
                    RenderedImage ganttChartImage = getGanttChart().getRenderedImage(
                            new GanttExportSettings(true, true, true, true));
                    state.ganttChartImageFile = File.createTempFile(
                            "ganttchart", ".jpg");
                    ImageIO.write(ganttChartImage, JPG_FORMAT_NAME,
                            state.ganttChartImageFile);
View Full Code Here

TOP

Related Classes of java.awt.image.RenderedImage

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.