Package ae.java.awt.image

Examples of ae.java.awt.image.ColorModel


     * @see ImageConsumer
     * @see ColorModel#getRGBdefault
     */
    public void setColorModel(ColorModel model) {
        if (canFilterIndexColorModel && (model instanceof IndexColorModel)) {
            ColorModel newcm = filterIndexColorModel((IndexColorModel)model);
            substituteColorModel(model, newcm);
            consumer.setColorModel(newcm);
        } else {
            consumer.setColorModel(ColorModel.getRGBdefault());
        }
View Full Code Here


                           int bgArgb,
                           int srcx, int srcy,
                           int dstx, int dsty,
                           int width, int height)
        {
            ColorModel dstModel = dstData.getColorModel();
            boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
            if (!dstModel.hasAlpha() && bgHasAlpha) {
                dstModel = ColorModel.getRGBdefault();
            }
            WritableRaster wr =
                dstModel.createCompatibleWritableRaster(width, height);
            boolean isPremult = dstModel.isAlphaPremultiplied();
            BufferedImage bimg =
                new BufferedImage(dstModel, wr, isPremult, null);
            SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
            Color bgColor = new Color(bgArgb, bgHasAlpha);
            SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
View Full Code Here

    }

    public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                                int[] abox) {
        RenderingHints hints = sg.getRenderingHints();
        ColorModel model = sg.getDeviceColorModel();
        PaintContext paintContext =
            sg.paint.createContext(model, devR, s.getBounds2D(),
                                   sg.cloneTransform(),
                                   hints);
        CompositeContext compositeContext =
View Full Code Here

        PaintContext paintCtxt = context.paintCtxt;
        CompositeContext compCtxt = context.compCtxt;
        SunGraphics2D sg = context.sunG2D;

        Raster srcRaster = paintCtxt.getRaster(x, y, w, h);
        ColorModel paintModel = paintCtxt.getColorModel();

        Raster dstRaster;
        Raster dstIn;
        WritableRaster dstOut;

        SurfaceData sd = sg.getSurfaceData();
        dstRaster = sd.getRaster(x, y, w, h);
        if (dstRaster instanceof WritableRaster && atile == null) {
            dstOut = (WritableRaster) dstRaster;
            dstOut = dstOut.createWritableChild(x, y, w, h, 0, 0, null);
            dstIn = dstOut;
        } else {
            dstIn = dstRaster.createChild(x, y, w, h, 0, 0, null);
            dstOut = dstIn.createCompatibleWritableRaster();
        }

        compCtxt.compose(srcRaster, dstIn, dstOut);

        if (dstRaster != dstOut && dstOut.getParent() != dstRaster) {
            if (dstRaster instanceof WritableRaster && atile == null) {
                ((WritableRaster) dstRaster).setDataElements(x, y, dstOut);
            } else {
                ColorModel cm = sg.getDeviceColorModel();
                BufferedImage resImg =
                    new BufferedImage(cm, dstOut,
                                      cm.isAlphaPremultiplied(),
                                      null);
                SurfaceData resData = BufImgSurfaceData.createData(resImg);
                if (atile == null) {
                    Blit blit = Blit.getFromCache(resData.getSurfaceType(),
                                                  CompositeType.SrcNoEa,
View Full Code Here

            if (srcData == null || lastRas == null) {
                srcData = null;
                lastRas = null;
            }
        }
        ColorModel paintModel = context.paintModel;

        for (int rely = 0; rely < h; rely += TILE_SIZE) {
            int ty = y + rely;
            int th = Math.min(h-rely, TILE_SIZE);
            for (int relx = 0; relx < w; relx += TILE_SIZE) {
                int tx = x + relx;
                int tw = Math.min(w-relx, TILE_SIZE);

                Raster srcRaster = paintCtxt.getRaster(tx, ty, tw, th);
                if ((srcRaster.getMinX() != 0) || (srcRaster.getMinY() != 0)) {
                    srcRaster = srcRaster.createTranslatedChild(0, 0);
                }
                if (lastRas != srcRaster) {
                    lastRas = srcRaster;
                    context.lastRaster = new WeakReference(lastRas);
                    // REMIND: This will fail for a non-Writable raster!
                    BufferedImage bImg =
                        new BufferedImage(paintModel,
                                          (WritableRaster) srcRaster,
                                          paintModel.isAlphaPremultiplied(),
                                          null);
                    srcData = BufImgSurfaceData.createData(bImg);
                    context.lastData = new WeakReference(srcData);
                    context.lastMask = null;
                    context.lastBlit = null;
                }

                if (atile == null) {
                    if (context.lastBlit == null) {
                        CompositeType comptype = sg.imageComp;
                        if (CompositeType.SrcOverNoEa.equals(comptype) &&
                            paintModel.getTransparency() == Transparency.OPAQUE)
                        {
                            comptype = CompositeType.SrcNoEa;
                        }
                        context.lastBlit =
                            Blit.getFromCache(srcData.getSurfaceType(),
                                              comptype,
                                              dstData.getSurfaceType());
                    }
                    context.lastBlit.Blit(srcData, dstData,
                                          sg.composite, null,
                                          0, 0, tx, ty, tw, th);
                } else {
                    if (context.lastMask == null) {
                        CompositeType comptype = sg.imageComp;
                        if (CompositeType.SrcOverNoEa.equals(comptype) &&
                            paintModel.getTransparency() == Transparency.OPAQUE)
                        {
                            comptype = CompositeType.SrcNoEa;
                        }
                        context.lastMask =
                            MaskBlit.getFromCache(srcData.getSurfaceType(),
View Full Code Here

    public void Blit(SurfaceData src, SurfaceData dst,
                     Composite comp, Region clip,
                     int srcx, int srcy, int dstx, int dsty, int w, int h)
    {
        Raster srcRast = src.getRaster(srcx, srcy, w, h);
        ColorModel srcCM = src.getColorModel();

        Raster dstRast = dst.getRaster(dstx, dsty, w, h);
        IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
        int[] dstPix = icr.getDataStorage();

        Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                         srcx, srcy,
                                                         dstx, dsty, w, h);
        SpanIterator si = roi.getSpanIterator();

        Object srcPix = null;

        int dstScan = icr.getScanlineStride();
        // assert(icr.getPixelStride() == 1);
        srcx -= dstx;
        srcy -= dsty;
        int span[] = new int[4];
        while (si.nextSpan(span)) {
            int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
            for (int y = span[1]; y < span[3]; y++) {
                int off = rowoff;
                for (int x = span[0]; x < span[2]; x++) {
                    srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
                    dstPix[off++] = srcCM.getRGB(srcPix);
                }
                rowoff += dstScan;
            }
        }
        // Pixels in the dest were modified directly, we must
View Full Code Here

        IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
        int[] srcPix = icr.getDataStorage();

        WritableRaster dstRast =
            (WritableRaster) dst.getRaster(dstx, dsty, w, h);
        ColorModel dstCM = dst.getColorModel();

        Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                         srcx, srcy,
                                                         dstx, dsty, w, h);
        SpanIterator si = roi.getSpanIterator();

        Object dstPix = null;

        int srcScan = icr.getScanlineStride();
        // assert(icr.getPixelStride() == 1);
        srcx -= dstx;
        srcy -= dsty;
        int span[] = new int[4];
        while (si.nextSpan(span)) {
            int rowoff = (icr.getDataOffset(0) +
                          (srcy + span[1]) * srcScan +
                          (srcx + span[0]));
            for (int y = span[1]; y < span[3]; y++) {
                int off = rowoff;
                for (int x = span[0]; x < span[2]; x++) {
                    dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
                    dstRast.setDataElements(x, y, dstPix);
                }
                rowoff += srcScan;
            }
        }
View Full Code Here

        IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
        int[] srcPix = icr.getDataStorage();

        WritableRaster dstRast =
            (WritableRaster) dst.getRaster(dstx, dsty, w, h);
        ColorModel dstCM = dst.getColorModel();

        Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                         srcx, srcy,
                                                         dstx, dsty, w, h);
        SpanIterator si = roi.getSpanIterator();

        int xorrgb = ((XORComposite)comp).getXorColor().getRGB();
        Object xorPixel = dstCM.getDataElements(xorrgb, null);

        Object srcPixel = null;
        Object dstPixel = null;

        int srcScan = icr.getScanlineStride();
        // assert(icr.getPixelStride() == 1);
        srcx -= dstx;
        srcy -= dsty;
        int span[] = new int[4];
        while (si.nextSpan(span)) {
            int rowoff = (icr.getDataOffset(0) +
                          (srcy + span[1]) * srcScan +
                          (srcx + span[0]));
            for (int y = span[1]; y < span[3]; y++) {
                int off = rowoff;
                for (int x = span[0]; x < span[2]; x++) {
                    // REMIND: alpha bits of the destination pixel are
                    // currently altered by the XOR operation, but
                    // should be left untouched
                    srcPixel = dstCM.getDataElements(srcPix[off++], srcPixel);
                    dstPixel = dstRast.getDataElements(x, y, dstPixel);

                    switch (dstCM.getTransferType()) {
                    case DataBuffer.TYPE_BYTE:
                        byte[] bytesrcarr = (byte[]) srcPixel;
                        byte[] bytedstarr = (byte[]) dstPixel;
                        byte[] bytexorarr = (byte[]) xorPixel;
                        for (int i = 0; i < bytedstarr.length; i++) {
View Full Code Here

    }

    static PixelWriter createSolidPixelWriter(SunGraphics2D sg2d,
                                              SurfaceData sData)
    {
        ColorModel dstCM = sData.getColorModel();
        Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

        return new SolidPixelWriter(srcPixel);
    }
View Full Code Here

    }

    static PixelWriter createXorPixelWriter(SunGraphics2D sg2d,
                                            SurfaceData sData)
    {
        ColorModel dstCM = sData.getColorModel();

        Object srcPixel = dstCM.getDataElements(sg2d.eargb, null);

        XORComposite comp = (XORComposite)sg2d.getComposite();
        int xorrgb = comp.getXorColor().getRGB();
        Object xorPixel = dstCM.getDataElements(xorrgb, null);

        switch (dstCM.getTransferType()) {
        case DataBuffer.TYPE_BYTE:
            return new XorPixelWriter.ByteData(srcPixel, xorPixel);
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_USHORT:
            return new XorPixelWriter.ShortData(srcPixel, xorPixel);
View Full Code Here

TOP

Related Classes of ae.java.awt.image.ColorModel

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.