Package javax.media.jai

Examples of javax.media.jai.ImageLayout


     */
    private static ImageLayout layoutHelper(String URLSpec,
                                            int level,
                                            int subImage) {
        // Create an ImageLayout by construction or cloning.
        ImageLayout il = new ImageLayout();

        // Set the tile offsets to (0,0).
        il.setTileGridXOffset(0);
        il.setTileGridYOffset(0);

        // Set the tile dimensions.
        il.setTileWidth(TILE_SIZE);
        il.setTileHeight(TILE_SIZE);

        // Set the image origin to (0,0).
        il.setMinX(0);
        il.setMinY(0);

        // Retrieve the number of resolutions available and the maximum
        // width and height (the dimensions of resolution numRes - 1).
        int maxWidth = -1;
        int maxHeight = -1;
        int numRes = -1;
        int resolution = -1;
        String[] cmd = new String[] {"OBJ=Max-size", "OBJ=Resolution-number"};
        InputStream stream = postCommands(URLSpec, cmd);
        String label = null;
        while((label = getLabel(stream)) != null) {
            if(label.equals("max-size")) {
                String data = getDataAsString(stream, false);
                int[] wh = stringToIntArray(data);
                maxWidth = wh[0];
                maxHeight = wh[1];
            } else if(label.equals("resolution-number")) {
                String data = getDataAsString(stream, false);
                numRes = Integer.valueOf(data).intValue();
                if(level < 0) {
                    resolution = 0;
                } else if(level >= numRes) {
                    resolution = numRes - 1;
                } else {
                    resolution = level;
                }
            } else {
                checkError(label, stream, true);
            }
        }
        closeStream(stream);

        // Derive the width and height for this resolution level.
        int w = maxWidth;
        int h = maxHeight;
        for(int i = numRes - 1; i > resolution; i--) {
            w = (w + 1)/2;
            h = (h + 1)/2;
        }
        il.setWidth(w);
        il.setHeight(h);

        // Determine image opacity attributes.
        boolean hasAlpha = false;
        boolean isAlphaPremultiplied = false;
        cmd = new String[] {"OBJ=Colorspace,"+resolution+","+subImage};
        stream = postCommands(URLSpec, cmd);
        int colorSpaceIndex = 0;
        int numBands = 0;
        while((label = getLabel(stream)) != null) {
            if(label.startsWith("colorspace")) {
                int[] ia = stringToIntArray(getDataAsString(stream, false));
                numBands = ia[3];
                switch(ia[2]) {
                case CS_MONOCHROME:
                    colorSpaceIndex = ColorSpace.CS_GRAY;
                    break;
                case CS_PHOTOYCC:
                    colorSpaceIndex = ColorSpace.CS_PYCC;
                    break;
                case CS_NIFRGB:
                    colorSpaceIndex = ColorSpace.CS_sRGB;
                    break;
                default:
                    colorSpaceIndex = numBands < 3 ?
                        ColorSpace.CS_GRAY : ColorSpace.CS_sRGB;
                }
                for(int j = 1; j <= numBands; j++) {
                    if(ia[3+j] == CS_PLANE_ALPHA) {
                        hasAlpha = true;
                    }
                }
                isAlphaPremultiplied = ia[1] == 1;
            } else {
                checkError(label, stream, true);
            }
        }
        closeStream(stream);

        // Set the ColorModel.
        ColorSpace cs = ColorSpace.getInstance(colorSpaceIndex);
        int dtSize = DataBuffer.getDataTypeSize(DataBuffer.TYPE_BYTE);
        int[] bits = new int[numBands];
        for(int i = 0; i < numBands; i++) {
            bits[i] = dtSize;
        }
        int transparency = hasAlpha ?
            Transparency.TRANSLUCENT : Transparency.OPAQUE;
        ColorModel cm = new ComponentColorModel(cs, bits,
                                                hasAlpha, isAlphaPremultiplied,
                                                transparency,
                                                DataBuffer.TYPE_BYTE);
        il.setColorModel(cm);

        // Set the SampleModel.
        int[] bandOffsets = new int[numBands];
        for(int i = 0; i < numBands; i++) {
            bandOffsets[i] = i;
        }
        il.setSampleModel(RasterFactory.createPixelInterleavedSampleModel(
                                            DataBuffer.TYPE_BYTE,
                                            TILE_SIZE,
                                            TILE_SIZE,
                                            numBands,
                                            numBands*TILE_SIZE,
 
View Full Code Here


     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       
        return new BinarizeOpImage(args.getRenderedSource(0),
           renderHints,
           layout,
           args.getDoubleParameter(0));
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       
       
        return new AndConstOpImage(args.getRenderedSource(0),
                                   renderHints,
                                   layout,
View Full Code Here

     * @param paramBlock  The color map and error filter kernel objects.
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        RenderedImage source = paramBlock.getRenderedSource(0);
        LookupTableJAI lookupTable =
            (LookupTableJAI)paramBlock.getObjectParameter(0);
View Full Code Here

     * Creates an affine operation as an instance of AffineOpImage.
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);

        // Get TileCache from renderHints if any.
        TileCache cache = RIFUtil.getTileCacheHint(renderHints);

        // Get BorderExtender from renderHints if any.
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new BandCombineOpImage(args.getRenderedSource(0),
                                      renderHints,
                                      layout,
View Full Code Here

     * @param renderHints  Optionally contains destination image layout.    
     */
    public RenderedImage create(ParameterBlock paramBlock,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new XorOpImage(paramBlock.getRenderedSource(0),
            paramBlock.getRenderedSource(1),
                              renderHints,
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new MultiplyConstOpImage(args.getRenderedSource(0),
                                        renderHints,
                                        layout,
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        return new RescaleOpImage(args.getRenderedSource(0),
                                  renderHints,
                                  layout,
View Full Code Here

     * @param hints  Optionally contains destination image layout.
     */
    public RenderedImage create(ParameterBlock args,
                                RenderingHints renderHints) {
        // Get ImageLayout from renderHints if any.
        ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
       

        /* Invert the constants. */
        double[] constants = (double[])args.getObjectParameter(0);
        int length = constants.length;
View Full Code Here

TOP

Related Classes of javax.media.jai.ImageLayout

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.