Package java.awt.image

Examples of java.awt.image.ComponentColorModel


    /**
     * Create a new texture loader based on the game panel
     */
    public TextureLoader() {
        glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                            new int[] {8,8,8,8},
                                            true,
                                            false,
                                            ComponentColorModel.TRANSLUCENT,
                                            DataBuffer.TYPE_BYTE);

        glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                            new int[] {8,8,8,0},
                                            false,
                                            false,
                                            ComponentColorModel.OPAQUE,
                                            DataBuffer.TYPE_BYTE);
View Full Code Here


                                                               int dataType,
                                                               boolean hasAlpha,
                                                               boolean isAlphaPremultiplied,
                                                               int transparency) {

        ComponentColorModel ccm = null;
        int RGBBits[][] = new int[3][];

        RGBBits[0] = new int[] { 8, 8, 8, 8 }; // Byte
        RGBBits[1] = new int[] { 16, 16, 16, 16 }; // Short
        RGBBits[2] = new int[] { 16, 16, 16, 16 }; // UShort
        RGBBits[2] = new int[] { 32, 32, 32, 32 }; // Int

        ccm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), RGBBits[dataType], hasAlpha, isAlphaPremultiplied, transparency, dataType);
        return ccm;
    }
View Full Code Here

    if (getImageType().equals("gif")) {
      // Increase color depth to 16M RGB
      try {
        javax.media.jai.ImageLayout layout = new javax.media.jai.ImageLayout();

        ColorModel cm = new ComponentColorModel (ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                 new int[] {8,8,8}, false, false,
                                                 Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
        layout.setColorModel(cm);
        layout.setSampleModel(cm.createCompatibleSampleModel(oRenderedImg.getWidth(),oRenderedImg.getHeight()));
        RenderingHints hints = new RenderingHints(javax.media.jai.JAI.KEY_IMAGE_LAYOUT, layout);
        javax.media.jai.ParameterBlockJAI pb = new javax.media.jai.ParameterBlockJAI( "format" );
        pb.addSource( oRenderedImg );
        oRenderedImg = javax.media.jai.JAI.create( "format", pb, hints );
      } catch (IllegalArgumentException iae) {
View Full Code Here

          final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
          // construction borrowed from BufferedImage constructor, for BufferedImage.TYPE_3BYTE_BGR
                  final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
                  int[] nBits = {8, 8, 8};
                  //int[] bOffs = {2, 1, 0};
                  final ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false,
                                                       Transparency.OPAQUE,
                                                       DataBuffer.TYPE_BYTE);
                  final BufferedImage bi = new BufferedImage(colorModel, r, false, null);
          return bi;
        }
        else if (bitsPerPixel == 32)
        {
          final DataBufferByte db = new DataBufferByte(new byte[][] {bytes}, bytes.length);
          final ComponentSampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, w, h, pixelStride, lineStride, new int[] {redMask - 1, greenMask -1, blueMask -1, 3})// TODO: what to do with alpha?
          final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
          // construction borrowed from BufferedImage constructor, for BufferedImage.TYPE_4BYTE_ABGR
                  final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
                  int[] nBits = {8, 8, 8, 8};
                  //int[] bOffs = {3, 2, 1, 0};
                  final ColorModel colorModel = new ComponentColorModel(cs, nBits, true, false,
                                                       Transparency.TRANSLUCENT,
                                                       DataBuffer.TYPE_BYTE);
                  final BufferedImage bi = new BufferedImage(colorModel, r, false, null);
          return bi;
        }
View Full Code Here

    }
    else
   
      if (bi.getColorModel() instanceof ComponentColorModel && bi.getSampleModel() instanceof ComponentSampleModel)
      {
        final ComponentColorModel componentColorModel = (ComponentColorModel) bi.getColorModel();
        final ComponentSampleModel componentSampleModel = (ComponentSampleModel) bi.getSampleModel();
        final int[] offsets = componentSampleModel.getBandOffsets();
        if (dataBuffer instanceof DataBufferInt)
        {
          // TODO: untested
View Full Code Here

    public ColorModel deriveColorModel(ColorModel old_cm, ColorSpace cs,
            boolean force_no_alpha) throws ImagingOpException {

        if (old_cm instanceof ComponentColorModel) {
            ComponentColorModel ccm = (ComponentColorModel) old_cm;
            // ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            if (force_no_alpha)
                return new ComponentColorModel(cs, false, false,
                        ComponentColorModel.OPAQUE, ccm.getTransferType());
            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()
View Full Code Here

            }
            DataBufferByte dataBuffer = new DataBufferByte(image, image[0].length);
            WritableRaster raster = WritableRaster.createBandedRaster(dataBuffer,
                    xSize, ySize, xSize, new int[]{0,1,2},
                    new int[]{0,0,0}, null);
            ColorModel colorModel = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(colorModel, raster,
                    colorModel.isAlphaPremultiplied(), new Properties());
        }
        else if ((pcxHeader.bitsPerPixel == 24 && pcxHeader.nPlanes == 1) ||
                (pcxHeader.bitsPerPixel == 32 && pcxHeader.nPlanes == 1))
        {
            int rowLength = 3 * xSize;
            byte[] image = new byte[rowLength * ySize];
            for (int y = 0; y < ySize; y++)
            {
                readScanLine(pcxHeader, is, scanline);
                if (pcxHeader.bitsPerPixel == 24)
                    System.arraycopy(scanline, 0, image, y*rowLength, rowLength);
                else
                {
                    for (int x = 0; x < xSize; x++)
                    {
                        image[y*rowLength + 3*x] = scanline[4*x];
                        image[y*rowLength + 3*x + 1] = scanline[4*x + 1];
                        image[y*rowLength + 3*x + 2] = scanline[4*x + 2];
                    }
                }
            }
            DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
            WritableRaster raster = WritableRaster.createInterleavedRaster(
                    dataBuffer, xSize, ySize, rowLength, 3,
                    new int[]{2,1,0}, null);
            ColorModel colorModel = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(colorModel, raster,
                    colorModel.isAlphaPremultiplied(), new Properties());
        }
        else
        {
            throw new ImageReadException("Invalid/unsupported image with bitsPerPixel "
                    + pcxHeader.bitsPerPixel + " and planes " + pcxHeader.nPlanes);
View Full Code Here

     * @throws IOException If there is an error creating the color model.
     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {
        int[] nbBits = { bpc, bpc, bpc };
        ComponentColorModel componentColorModel =
                new ComponentColorModel( createColorSpace(),
                                         nbBits,
                                         false,                    
                                         false,             
                                         Transparency.OPAQUE,
                                         DataBuffer.TYPE_BYTE );
View Full Code Here

     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        int[] nBits = {bpc};
        ColorModel colorModel = new ComponentColorModel(cs, nBits, false,false,
                Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
        return colorModel;

    }
View Full Code Here

                }

                ColorModel cm = null;
                WritableRaster wr = null;
                if (depth() == IPL_DEPTH_8U || depth() == IPL_DEPTH_8S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_BYTE, width(), height(), nChannels(), widthStep(),
                            offsets), null);
                } else if (depth() == IPL_DEPTH_16U) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_USHORT, width(), height(), nChannels(), widthStep()/2,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_16S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_SHORT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_SHORT, width(), height(), nChannels(), widthStep()/2,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_32S) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_INT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_INT, width(), height(), nChannels(), widthStep()/4,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_32F) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_FLOAT, width(), height(), nChannels(), widthStep()/4,
                            offsets), null);
                } else if (depth() == IPL_DEPTH_64F) {
                    cm = new ComponentColorModel(cs, alpha,
                            false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
                    wr = Raster.createWritableRaster(new ComponentSampleModel(
                            DataBuffer.TYPE_DOUBLE, width(), height(), nChannels(), widthStep()/8,
                            offsets), null);
                }
View Full Code Here

TOP

Related Classes of java.awt.image.ComponentColorModel

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.