Package com.google.code.appengine.awt.image

Examples of com.google.code.appengine.awt.image.WritableRaster


        if ((long)width*height > Integer.MAX_VALUE) {
            throw new IllegalArgumentException();
        }
       
        SampleModel sm = sampleModel.createCompatibleSampleModel(width, height);
        WritableRaster writableRaster = Raster.createWritableRaster(sm, new Point(0, 0));
       
        return new BufferedImage(colorModel, writableRaster, colorModel.isAlphaPremultiplied(), new Hashtable());
    }
View Full Code Here


    public void dispose() {
    }

    public Raster getRaster(int x, int y, int w, int h) {
        WritableRaster rast = cm.createCompatibleWritableRaster(w, h);

        int[] buf = ((DataBufferInt)rast.getDataBuffer()).getData();

        int c = x * dy - y * dx - delta;
        int cx = dy;
        int cy = - w * dy - dx;
        int k = 0;
View Full Code Here

                // awt.4A=The dstOut raster is incompatible with dst ColorModel
                throw new IllegalArgumentException(Messages.getString("awt.4A")); //$NON-NLS-1$
            }
            dstOut.setDataElements(0, 0, dstIn);
        }
        WritableRaster src;
        if(srcIn instanceof WritableRaster){
            src = (WritableRaster) srcIn;
        }else{
            src = srcIn.createCompatibleWritableRaster();
            src.setDataElements(0, 0, srcIn);
        }
        srcSurf = new ImageSurface(srcCM, src);
        dstSurf = new ImageSurface(dstCM, dstOut);

        int w = Math.min(srcIn.getWidth(), dstOut.getWidth());
View Full Code Here

        boolean saveAlpha = srcCM.hasAlpha() && dstCM.hasAlpha();
        if (saveAlpha) {
            alpha = new float[src.getWidth()*src.getHeight()];
        }

        WritableRaster wr = src.getRaster();
        int srcDataPos = 0, alphaPos = 0;
        float normalizedVal[];
        for (int row=0, nRows = srcIF.getNumRows(); row<nRows; row++) {
            for (int col=0, nCols = srcIF.getNumCols(); col<nCols; col++) {
                normalizedVal = srcCM.getNormalizedComponents(
                    wr.getDataElements(col, row, null),
                    null, 0);
                // Save alpha channel
                if (saveAlpha) {
                    // We need nColorChannels'th element cause it's nChannels - 1
                    alpha[alphaPos++] = normalizedVal[nColorChannels];
                }
                scaler.scale(normalizedVal, srcChanData, srcDataPos);
                srcDataPos += nColorChannels;
            }
        }

        t.translateColors(srcIF, dstIF);

        nColorChannels = dstCM.getNumColorComponents();
        boolean fillAlpha = dstCM.hasAlpha();
        scaler.loadScalingData(dstCM.getColorSpace()); // output scaling data
        float dstPixel[] = new float[dstCM.getNumComponents()];
        int dstDataPos = 0;
        alphaPos = 0;
        wr = dst.getRaster();

        for (int row=0, nRows = dstIF.getNumRows(); row<nRows; row++) {
            for (int col=0, nCols = dstIF.getNumCols(); col<nCols; col++) {
                scaler.unscale(dstPixel, dstChanData, dstDataPos);
                dstDataPos += nColorChannels;
                if (fillAlpha) {
                    if (saveAlpha) {
                        dstPixel[nColorChannels] = alpha[alphaPos++];
                    } else {
                        dstPixel[nColorChannels] = 1f;
                    }
                }
                wr.setDataElements(col, row,
                        dstCM.getDataElements(dstPixel, 0 , null));
            }
        }
    }
View Full Code Here

                ColorModel srcCM = srcSurf.getColorModel();
                Raster srcR = srcSurf.getRaster().createChild(srcX, srcY,
                        w, h, 0, 0, null);

                ColorModel dstCM = dstSurf.getColorModel();
                WritableRaster dstR = dstSurf.getRaster();

                transformedBlit(srcCM, srcR, 0, 0, dstCM, dstR, dstX, dstY, w, h,
                        sysxform, comp, bgcolor, clip);
               
                Rectangle dirtyReg = JavaBlitter.getBounds2D(sysxform, new Rectangle(dstX, dstY, w, h)).getBounds();
View Full Code Here

            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

    }

    public BufferedImage getBufferedImage(){
        if(image == null){
            ColorModel model = getColorModel();
            WritableRaster wr = getRaster();
            if(model != null && wr != null) {
                image = new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
            }
        }
        return image;
View Full Code Here

    private void forceToIntARGB(){

        int w = raster.getWidth();
        int h = raster.getHeight();

        WritableRaster destRaster = rgbCM.createCompatibleWritableRaster(w, h);

        Object obj = null;
        int pixels[] = new int[w];

        if(cm instanceof IndexColorModel){
            IndexColorModel icm = (IndexColorModel) cm;
            int colorMap[] = new int[icm.getMapSize()];
            icm.getRGBs(colorMap);

            for (int y = 0; y < h; y++) {
                obj = raster.getDataElements(0, y, w, 1, obj);
                byte ba[] = (byte[]) obj;
                for (int x = 0; x < ba.length; x++) {
                    pixels[x] = colorMap[ba[x] & 0xff];
                }
                destRaster.setDataElements(0, y, w, 1, pixels);
            }

        }else{
            for(int y = 0; y < h; y++){
                for(int x = 0; x < w; x++){
                    obj = raster.getDataElements(x, y, obj);
                    pixels[x] = cm.getRGB(obj);
                }
                destRaster.setDataElements(0, y, w, 1, pixels);
            }
        }

        synchronized(this){
            if(imageSurf != null){
View Full Code Here

    }

    public ImageSurface getImageSurface() {
        if (imageSurf == null) {
            ColorModel model = getColorModel();
            WritableRaster wr = getRaster();
            if(model != null && wr != null) {
                imageSurf = new ImageSurface(model, wr);
            }
        }
        return imageSurf;
View Full Code Here

        if(w <= 0 || h <= 0) {
            return;
        }
        PaintContext pc = paint.createContext(null, rec, rec, transform, hints);
        Raster r = pc.getRaster(x, y, w, h);
        WritableRaster wr;
        if(r instanceof WritableRaster){
            wr = (WritableRaster) r;
        }else{
            wr = r.createCompatibleWritableRaster();
            wr.setRect(r);
        }
        Surface srcSurf = new ImageSurface(pc.getColorModel(), wr);
        blitter.blit(0, 0, srcSurf, x, y, dstSurf, w, h,
                composite, null, mra);
        srcSurf.dispose();
View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.image.WritableRaster

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.