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

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


            else
                return new ComponentColorModel(cs, ccm.hasAlpha(), ccm
                        .isAlphaPremultiplied(), ccm.getTransparency(), ccm
                        .getTransferType());
        } else if (old_cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) old_cm;

            int old_mask = dcm.getRedMask() | dcm.getGreenMask()
                    | dcm.getBlueMask() | dcm.getAlphaMask();

            int old_bits = count_bits_in_mask(old_mask);

            return new DirectColorModel(cs, old_bits, dcm.getRedMask(), dcm
                    .getGreenMask(), dcm.getBlueMask(), dcm.getAlphaMask(), dcm
                    .isAlphaPremultiplied(), dcm.getTransferType());
        }
        // else if (old_cm instanceof PackedColorModel)
        // {
        // PackedColorModel pcm = (PackedColorModel) old_cm;
        //
View Full Code Here


    public static ImageTypeSpecifier createPacked(final ColorSpace colorSpace,
                    final int redMask, final int greenMask, final int blueMask,
                    final int alphaMask, final int transferType,
                    final boolean isAlphaPremultiplied) {
        final ColorModel model = new DirectColorModel(colorSpace, 32, redMask,
                        greenMask, blueMask, alphaMask, isAlphaPremultiplied,
                        transferType);
        return new ImageTypeSpecifier(model, model.createCompatibleSampleModel(
            1, 1));
    }
View Full Code Here

        ColorModel cm;

        protected ColorPaintContext(int rgb) {
            rgbValue = rgb;
            if((rgb & 0xFF000000) == 0xFF000000){
                cm = new DirectColorModel(24, 0xFF0000, 0xFF00, 0xFF);
            } else {
                cm = ColorModel.getRGBdefault();
            }
        }
View Full Code Here

    private void createRaster(){
        try{
            raster = cm.createCompatibleWritableRaster(width, height);
            isIntRGB = false;
            if(cm instanceof DirectColorModel){
                DirectColorModel dcm = (DirectColorModel) cm;
                if(dcm.getTransferType() == DataBuffer.TYPE_INT &&
                        dcm.getRedMask() == 0xff0000 &&
                        dcm.getGreenMask() == 0xff00 &&
                        dcm.getBlueMask() == 0xff){
                    isIntRGB = true;
                }
            }
        }catch(Exception e){
            cm = ColorModel.getRGBdefault();
View Full Code Here

        int csType = cs.getType();
        SampleModel sm = raster.getSampleModel();

        if(csType == ColorSpace.TYPE_RGB){
            if(cm instanceof DirectColorModel){
                DirectColorModel dcm = (DirectColorModel) cm;
                switch (transferType) {
                case DataBuffer.TYPE_INT:
                    if (dcm.getRedMask() == RED_MASK &&
                            dcm.getGreenMask() == GREEN_MASK &&
                            dcm.getBlueMask() == BLUE_MASK) {
                        if (!hasAlpha) {
                            return BufferedImage.TYPE_INT_RGB;
                        }
                        if (dcm.getAlphaMask() == ALPHA_MASK) {
                            if (dcm.isAlphaPremultiplied()) {
                                return BufferedImage.TYPE_INT_ARGB_PRE;
                            }
                            return BufferedImage.TYPE_INT_ARGB;
                        }
                        return BufferedImage.TYPE_CUSTOM;
                    } else if (dcm.getRedMask() == RED_BGR_MASK &&
                            dcm.getGreenMask() == GREEN_BGR_MASK &&
                            dcm.getBlueMask() == BLUE_BGR_MASK) {
                        if (!hasAlpha) {
                            return BufferedImage.TYPE_INT_BGR;
                        }
                    } else {
                        return BufferedImage.TYPE_CUSTOM;
                    }
                case DataBuffer.TYPE_USHORT:
                    if (dcm.getRedMask() == RED_555_MASK &&
                            dcm.getGreenMask() == GREEN_555_MASK &&
                            dcm.getBlueMask() == BLUE_555_MASK && !hasAlpha) {
                        return BufferedImage.TYPE_USHORT_555_RGB;
                    } else if (dcm.getRedMask() == RED_565_MASK &&
                            dcm.getGreenMask() == GREEN_565_MASK &&
                            dcm.getBlueMask() == BLUE_565_MASK) {
                        return BufferedImage.TYPE_USHORT_565_RGB;
                    }
                default:
                    return BufferedImage.TYPE_CUSTOM;
                }
View Full Code Here

                throw new UnsupportedOperationException(Messages.getString("awt.214")); //$NON-NLS-1$
            }

        }

        return new DirectColorModel(cs, pixel_bits, componentMasks[0],
                componentMasks[1], componentMasks[2], componentMasks[3],
                isAlphaPremultiplied, transferType);
    }
View Full Code Here

        ColorModel model;
        if (forceARGB || transparency == Transparency.TRANSLUCENT) {
            model = ColorModel.getRGBdefault();
        } else if (transparency == Transparency.BITMASK) {
            model = new DirectColorModel(25, 0x00ff0000, 0x0000ff00,
                    0x000000ff, 0x01000000);
        } else {
            model = new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff);
        }

        int w = raster.getWidth();
        int h = raster.getHeight();
View Full Code Here

    public BufferedImage(int width, int height, int imageType) {

        switch (imageType) {
        case TYPE_INT_RGB:
            cm = new DirectColorModel(24, RED_MASK, GREEN_MASK, BLUE_MASK);
            raster = cm.createCompatibleWritableRaster(width, height);
            break;

        case TYPE_INT_ARGB:
            cm = ColorModel.getRGBdefault();
            raster = cm.createCompatibleWritableRaster(width, height);
            break;

        case TYPE_INT_ARGB_PRE:
            cm = new DirectColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    32,
                    RED_MASK,
                    GREEN_MASK,
                    BLUE_MASK,
                    ALPHA_MASK,
                    true,
                    DataBuffer.TYPE_INT);

            raster = cm.createCompatibleWritableRaster(width, height);
            break;

        case TYPE_INT_BGR:
            cm = new DirectColorModel(24,
                    RED_BGR_MASK,
                    GREEN_BGR_MASK,
                    BLUE_BGR_MASK);

            raster = cm.createCompatibleWritableRaster(width, height);
            break;

        case TYPE_3BYTE_BGR: {
            int bits[] = { 8, 8, 8 };
            int bandOffsets[] = { 2, 1, 0 };
            cm = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    bits,
                    false,
                    false,
                    Transparency.OPAQUE,
                    DataBuffer.TYPE_BYTE);

            raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                    width, height, width * 3, 3, bandOffsets, null);
            }
            break;

        case TYPE_4BYTE_ABGR: {
            int bits[] = { 8, 8, 8, 8 };
            int bandOffsets[] = { 3, 2, 1, 0 };
            cm = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    bits,
                    true,
                    false,
                    Transparency.TRANSLUCENT,
                    DataBuffer.TYPE_BYTE);

            raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                    width, height, width * 4, 4, bandOffsets, null);
            }
            break;

        case TYPE_4BYTE_ABGR_PRE: {
            int bits[] = { 8, 8, 8, 8 };
            int bandOffsets[] = { 3, 2, 1, 0 };
            cm = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    bits,
                    true,
                    true,
                    Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

            raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                    width, height, width * 4, 4, bandOffsets, null);
            }
            break;

        case TYPE_USHORT_565_RGB:
            cm = new DirectColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    16,
                    RED_565_MASK,
                    GREEN_565_MASK,
                    BLUE_565_MASK,
                    0,
                    false,
                    DataBuffer.TYPE_USHORT);

            raster = cm.createCompatibleWritableRaster(width, height);
            break;

        case TYPE_USHORT_555_RGB:
            cm = new DirectColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    15,
                    RED_555_MASK,
                    GREEN_555_MASK,
                    BLUE_555_MASK,
View Full Code Here

        return numColorComponents;
    }

    public static ColorModel getRGBdefault() {
        if (RGBdefault == null) {
            RGBdefault = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
                    0x000000ff, 0xff000000);
        }
        return RGBdefault;
    }
View Full Code Here

TOP

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

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.