Examples of DirectColorModel


Examples of java.awt.image.DirectColorModel

                    xpmHeader.width, xpmHeader.height, 1, null);
            bpp = 16;
        }
        else
        {
            colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
                    0x000000ff, 0xff000000);
            raster = WritableRaster.createPackedRaster(DataBuffer.TYPE_INT,
                    xpmHeader.width, xpmHeader.height,
                    new int[]{0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, null);
            bpp = 32;
View Full Code Here

Examples of java.awt.image.DirectColorModel

    height = component.getHeight();
    size = width * height;
    pixels = new int[size];
    zBuffer = new float[size];
    image = Toolkit.getDefaultToolkit().createImage(this);
    colormodel = new DirectColorModel(32, 0x000000FF, 0x0000FF00,
        0x00FF0000, 0xFF000000);
    consumer = null;
    lastColor = new N3ColorRGBA(1, 1, 1);
    lastUV = new N3TexCoord2D(0, 0);
    lastVertex = null;
View Full Code Here

Examples of java.awt.image.DirectColorModel

            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof DirectColorModel) {
            DirectColorModel cm = (DirectColorModel)colorModel;
            out.writeInt(COLORMODEL_DIRECT);
            boolean csSerialized =
                serializeColorSpace(cm.getColorSpace(), out);
            if(!csSerialized) {
                out.writeBoolean(cm.hasAlpha());
            }
            out.writeInt(cm.getPixelSize());
            out.writeInt(cm.getRedMask());
            out.writeInt(cm.getGreenMask());
            out.writeInt(cm.getBlueMask());
            if(csSerialized || cm.hasAlpha()) {
                out.writeInt(cm.getAlphaMask());
            }
            if(csSerialized) {
                out.writeBoolean(cm.isAlphaPremultiplied());
                // Create a SampleModel to get the transferType. This is
                // absurd but is the only apparent way to retrieve this
                // value.
                SampleModel sm = cm.createCompatibleSampleModel(1, 1);
                out.writeInt(sm.getTransferType());
            }
        } else {
            throw new RuntimeException(JaiI18N.getString("ColorModelState0"));
        }
View Full Code Here

Examples of java.awt.image.DirectColorModel

                                    in.readInt());
            break;
        case COLORMODEL_DIRECT:
            if((cs = deserializeColorSpace(in)) != null) {
                colorModel =
                    new DirectColorModel(cs, in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt(),
                                         in.readInt(), in.readBoolean(),
                                         in.readInt());
            } else if(in.readBoolean()) {
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt(),
                                         in.readInt());
            } else {
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt());
            }
            break;
        default:
            // NB: Should never get here.
View Full Code Here

Examples of java.awt.image.DirectColorModel

            // Create a SampleModel to get the transferType. This is
            // absurd but is the only apparent way to retrieve this value.
            SampleModel sm = cm.createCompatibleSampleModel(1, 1);
            out.writeInt(sm.getTransferType());
        } else if(colorModel instanceof DirectColorModel) {
            DirectColorModel cm = (DirectColorModel)colorModel;
            out.writeInt(COLORMODEL_DIRECT);
            boolean csSerialized =
                serializeColorSpace(cm.getColorSpace(), out);
            if(!csSerialized) {
                out.writeBoolean(cm.hasAlpha());
            }
            out.writeInt(cm.getPixelSize());
            out.writeInt(cm.getRedMask());
            out.writeInt(cm.getGreenMask());
            out.writeInt(cm.getBlueMask());
            if(csSerialized || cm.hasAlpha()) {
                out.writeInt(cm.getAlphaMask());
            }
            if(csSerialized) {
                out.writeBoolean(cm.isAlphaPremultiplied());
                // Create a SampleModel to get the transferType. This is
                // absurd but is the only apparent way to retrieve this
                // value.
                SampleModel sm = cm.createCompatibleSampleModel(1, 1);
                out.writeInt(sm.getTransferType());
            }
        } else {
            throw new RuntimeException(JaiI18N.getString("ColorModelProxy0"));
        }
View Full Code Here

Examples of java.awt.image.DirectColorModel

                                    in.readInt());
            break;
        case COLORMODEL_DIRECT:
            if((cs = deserializeColorSpace(in)) != null) {
                colorModel =
                    new DirectColorModel(cs, in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt(),
                                         in.readInt(), in.readBoolean(),
                                         in.readInt());
            } else if(in.readBoolean()) {
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt(),
                                         in.readInt());
            } else {
                colorModel =
                    new DirectColorModel(in.readInt(), in.readInt(),
                                         in.readInt(), in.readInt());
            }
            break;
        default:
            // NB: Should never get here.
View Full Code Here

Examples of java.awt.image.DirectColorModel

    new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
            width, height,
            new int[] {redMask, greenMask, blueMask});

      colorModel =
    new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
             16, redMask, greenMask, blueMask, 0,
             false, DataBuffer.TYPE_USHORT);
  } else if (bitsPerPixel == 32) {
      numBands = alphaMask == 0 ? 3 : 4;

            // The number of bands in the SampleModel is determined by
            // the length of the mask array passed in.
            int[] bitMasks = numBands == 3 ?
                new int[] {redMask, greenMask, blueMask} :
                new int[] {redMask, greenMask, blueMask, alphaMask};

      sampleModel =
          new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
             width, height,
             bitMasks);

      colorModel =
    new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
             32, redMask, greenMask, blueMask, alphaMask,
             false, DataBuffer.TYPE_INT);
  } else {
      numBands = 3;
      // Create SampleModel
View Full Code Here

Examples of java.awt.image.DirectColorModel

            int bits = 0;
            for (int i = 0; i < sampleSize.length; i++) {
                bits += sampleSize[i];
            }

            return new DirectColorModel(bits, rmask, gmask, bmask, amask);

        } else if (ImageUtil.isBinary(sm)) {
            byte[] comp = new byte[] { (byte)0x00, (byte)0xFF };

            return new IndexColorModel(1, 2, comp, comp, comp);
View Full Code Here

Examples of java.awt.image.DirectColorModel

                PackedColorModel pcm = (PackedColorModel)bi.getColorModel();
                int bits =
                    pcm.getComponentSize(0) +
                    pcm.getComponentSize(1) +
                    pcm.getComponentSize(2);
                DirectColorModel dcm = new DirectColorModel(bits,
                                                            pcm.getMask(0),
                                                            pcm.getMask(1),
                                                            pcm.getMask(2));
                bi = new BufferedImage(dcm, rgbRas, false, null);
            }
View Full Code Here

Examples of java.awt.image.DirectColorModel

        return new Image(_display, image(((JavaImage)image).bufferedImage()));
    }

    public ImageData image (BufferedImage image) {
        if (image.getColorModel() instanceof DirectColorModel) {
            DirectColorModel cmodel = (DirectColorModel)image.getColorModel();
            PaletteData palette = new PaletteData(
                cmodel.getRedMask(), cmodel.getGreenMask(), cmodel.getBlueMask());
            ImageData data = new ImageData(image.getWidth(), image.getHeight(),
                cmodel.getPixelSize(), palette);
            for (int y = 0; y < data.height; y++) {
                for (int x = 0; x < data.width; x++) {
                    int rgb = image.getRGB(x, y);
                    int pixel = palette.getPixel(
                        new RGB((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF));
                    data.setPixel(x, y, pixel);
                    if (cmodel.hasAlpha()) data.setAlpha(x, y, (rgb >> 24) & 0xFF);
                }
            }
            return data;

        } else if (image.getColorModel() instanceof IndexColorModel) {
            IndexColorModel cmodel = (IndexColorModel)image.getColorModel();
            int size = cmodel.getMapSize();
            byte[] reds = new byte[size];
            byte[] greens = new byte[size];
            byte[] blues = new byte[size];
            cmodel.getReds(reds);
            cmodel.getGreens(greens);
            cmodel.getBlues(blues);
            RGB[] rgbs = new RGB[size];
            for (int ii = 0; ii < rgbs.length; ii++) {
                rgbs[ii] = new RGB(reds[ii] & 0xFF, greens[ii] & 0xFF, blues[ii] & 0xFF);
            }
            PaletteData palette = new PaletteData(rgbs);
            ImageData data = new ImageData(
                image.getWidth(), image.getHeight(), cmodel.getPixelSize(), palette);
            data.transparentPixel = cmodel.getTransparentPixel();
            WritableRaster raster = image.getRaster();
            int[] pixelArray = new int[1];
            for (int y = 0; y < data.height; y++) {
                for (int x = 0; x < data.width; x++) {
                    raster.getPixel(x, y, pixelArray);
                    data.setPixel(x, y, pixelArray[0]);
                }
            }
            return data;
        } else if (image.getColorModel() instanceof ComponentColorModel) {
            ComponentColorModel cmodel = (ComponentColorModel)image.getColorModel();
            PaletteData palette = new PaletteData(0x0000FF, 0x00FF00, 0xFF0000); // BGR
            ImageData data = new ImageData(image.getWidth(), image.getHeight(), 24, palette);
            if (cmodel.hasAlpha()) data.alphaData = new byte[image.getWidth() * image.getHeight()];
            WritableRaster raster = image.getRaster();
            int[] pixelArray = new int[4];
            for (int y = 0; y < data.height; y++) {
                for (int x = 0; x < data.width; x++) {
                    raster.getPixel(x, y, pixelArray);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.