Package javax.media.jai

Examples of javax.media.jai.PlanarImage


        // Create a hint containing the layout.
        RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);

        // Dither the image.
        PlanarImage dst = JAI.create(opName, pb, hints);

        //Convert it to a BufferedImage
        return dst;
    }
View Full Code Here


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

    RenderedImage oRenderedImg;
    PlanarImage oPlI;
    RenderedOp oScI;
    ParameterBlock oBlk;
    ImageEncoder oImgEnc;
    ImageDecoder oDecoder;

    Log.out.debug("Begin Picture.drawJAIImage("+sCodec+","+String.valueOf(iThumbWidth)+","+String.valueOf(iThumbHeight)+")");
   
    oDecoder = com.sun.media.jai.codec.ImageCodec.createImageDecoder(sCodec, imgSrc, null);

    oRenderedImg = oDecoder.decodeAsRenderedImage();

    if (sCodec.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);
        ParameterBlockJAI pb = new ParameterBlockJAI( "format" );
        pb.addSource( oRenderedImg );
        oRenderedImg = javax.media.jai.JAI.create( "format", pb, hints );
      } catch (IllegalArgumentException iae) {
      }
      // End increase color depth
    } // gif

    oPlI = PlanarImage.wrapRenderedImage(oRenderedImg);

    int iImageWidth = oPlI.getWidth();
    int iImageHeight = oPlI.getHeight();

    float thumbRatio = ((float) iThumbWidth) / ((float) iThumbHeight);

    float imageRatio = ((float) iImageWidth) / ((float) iImageHeight);
View Full Code Here

        // from the nodes Hashtable and set it as a source
        // in the sources Vector.
        replacedSrcs.add(nodes.get(Long.valueOf(serverNodeDesc)));
    }
      } else {
    PlanarImage pi =
        PlanarImage.wrapRenderedImage((RenderedImage)obj);
    replacedSrcs.add(pi);
      }
  }
 
View Full Code Here

        pbScale.add(0F);
        pbScale.add(0F);
        pbScale.add(rotMinX - imMinX);
        pbScale.add(rotMinY - imMinY);
        pbScale.add(interp);
        PlanarImage intermediateImage =
                        JAI.create("scale", pbScale, hints).getRendering();
                    try {
                        return new PointMapperOpImage(intermediateImage,
                                                      hints,
                                                      transform);
View Full Code Here

      RenderingChangeEvent rce = (RenderingChangeEvent)event;

      // Get index of source which changed.
      int idx = ((RenderedOp)node).getSources().indexOf(rce.getSource());

      PlanarImage oldSrcRendering = (PlanarImage)event.getOldValue();

      Object oldSrc = null;
      String serverNodeDesc = null;
      if (oldSrcRendering instanceof RMIServerProxy) {
View Full Code Here

     * @param id An ID for the source which must be unique across all clients.
     * @param source a RenderedImage source.
     */
    public void setSource(Long id, RenderedImage source)
        throws RemoteException {
            PlanarImage pi = PlanarImage.wrapRenderedImage(source);
            addSource(id, pi, pi);
    }
View Full Code Here

                          RenderContextProxy renderContextProxy)
        throws RemoteException {
            RenderContext renderContext =
                renderContextProxy.getRenderContext();
            RenderedImage r = source.createRendering(renderContext);
            PlanarImage pi = PlanarImage.wrapRenderedImage(r);
            addSource(id, pi, pi);
    }
View Full Code Here

            bits = 16;
        } else if (dataType == DataBuffer.TYPE_INT) {
            bits = 32;
        }

        PlanarImage src = getSource(0);
        int sMinX = src.getMinX();
        int sMinY = src.getMinY();
        int sWidth = src.getWidth();
        int sHeight = src.getHeight();
        int sMaxX = sMinX + sWidth - 1;
        int sMaxY = sMinY + sHeight - 1;

        // Backwards map starting point of destination rectangle
        int[] pt = new int[2];
View Full Code Here

        colorMap = null;
        this.histogramSize = upperBound;
    }

    protected synchronized void train() {
        PlanarImage source = getSourceImage(0);
        if (roi == null)
            roi = new ROIShape(source.getBounds());

        // Cycle throw all source tiles.
        int minTileX = source.getMinTileX();
        int maxTileX = source.getMaxTileX();
        int minTileY = source.getMinTileY();
        int maxTileY = source.getMaxTileY();
        int xStart = source.getMinX();
        int yStart = source.getMinY();

        histogram = new HistogramHash(histogramSize);

        while(true) {
            histogram.init();
            int oldbits = bits;
            mask = (255 << 8 - bits) & 255;
            mask = mask | (mask << 8) | (mask << 16);

            for (int y = minTileY; y <= maxTileY; y++) {
                for (int x = minTileX; x <= maxTileX; x++) {
                    // Determine the required region of this tile.
                    // (Note that getTileRect() instersects tile and
                    // image bounds.)
                    Rectangle tileRect = source.getTileRect(x, y);

                    // Process if and only if within ROI bounds.
                    if (roi.intersects(tileRect)) {

                        // If checking for skipped tiles determine
                        // whether this tile is "hit".
                        if (checkForSkippedTiles &&
                            tileRect.x >= xStart &&
                            tileRect.y >= yStart) {
                            // Determine the offset within the tile.
                            int offsetX =
                                (xPeriod - ((tileRect.x - xStart) % xPeriod)) %
                                xPeriod;
                            int offsetY =
                                (yPeriod - ((tileRect.y - yStart) % yPeriod)) %
                                yPeriod;

                            // Continue with next tile if offset
                            // is larger than either tile dimension.
                            if (offsetX >= tileRect.width ||
                                offsetY >= tileRect.height) {
                                continue;
                            }
                        }

                        // add the histogram.
                        computeHistogram(source.getData(tileRect));
                        if (histogram.isFull())
                            break;
                    }
                }
View Full Code Here

            getTileRect(tileX, tileY).intersection(getBounds());

        //
        // Get source
        //
        PlanarImage src = getSourceImage(0);

        //
        // Determine effective source bounds.
        //
        Rectangle srcRect =
            mapDestRect(destRect, 0).intersection(src.getBounds());

        Raster[] sources = new Raster[1];
        sources[0] = src.getData(srcRect);

        //
        // Compute the destination.
        //
        computeRect(sources, dest, destRect);

        // Recycle the source tile
        if(src.overlapsMultipleTiles(srcRect)) {
            recycleTile(sources[0]);
        }

        return dest;
    }
View Full Code Here

TOP

Related Classes of javax.media.jai.PlanarImage

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.