Examples of ComponentColorModel


Examples of java.awt.image.ComponentColorModel

    }

    public static ComponentColorModel createComponentColorModel() {
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        int bits[] = {8, 8, 8};
        return new ComponentColorModel(cs, bits, false, false,
                                       Transparency.OPAQUE,
                                       DataBuffer.TYPE_BYTE);
    }
View Full Code Here

Examples of java.awt.image.ComponentColorModel

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

  ComponentColorModel ccm = null;
        int RGBBits[] = null;
        ColorSpace cs = null;
        switch(numBands) {
        case 2: // gray+alpha
            cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
            break;
        case 4: // RGB+alpha
            cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            break;
        default:
            throw new IllegalArgumentException();
        }

        if(dataType == DataBuffer.TYPE_FLOAT) {
            ccm = new FloatDoubleColorModel(cs,
                                            true,
                                            isAlphaPremultiplied,
                                            transparency,
                                            dataType);
        } else { // all other types
            int componentSize = 0;
            switch(dataType) {
            case DataBuffer.TYPE_BYTE:
                componentSize = 8;
                break;
            case DataBuffer.TYPE_USHORT:
            case DataBuffer.TYPE_SHORT:
                componentSize = 16;
                break;
            case DataBuffer.TYPE_INT:
                componentSize = 32;
                break;
            default:
                throw new IllegalArgumentException();
            }

            RGBBits = new int[numBands];
            for(int i = 0; i < numBands; i++) {
                RGBBits[i] = componentSize;
            }

            ccm = new ComponentColorModel(cs,
                                          RGBBits,
                                          true,
                                          isAlphaPremultiplied,
                                          transparency,
                                          dataType);
View Full Code Here

Examples of java.awt.image.ComponentColorModel

                    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

Examples of java.awt.image.ComponentColorModel

     * rgb+alpha <code>ColorModel</code> is returned.
     */
    public static ColorModel createComponentColorModel(SampleModel sm) {
        int type = sm.getDataType();
        int bands = sm.getNumBands();
        ComponentColorModel cm = null;

        if (type == DataBuffer.TYPE_BYTE) {
            switch (bands) {
            case 1:
                cm = colorModelGray8;
View Full Code Here

Examples of java.awt.image.ComponentColorModel

                   ColorSpace cp) {
  if (cp == null)
      return createComponentColorModel(sm);
        int type = sm.getDataType();
  int bands = sm.getNumBands();
  ComponentColorModel cm = null;

  int[] bits = null;
        int transferType = -1;
        boolean hasAlpha = (bands % 2 == 0);
  if (cp instanceof SimpleCMYKColorSpace)
      hasAlpha = false;
        int transparency = hasAlpha ? Transparency.TRANSLUCENT
                                        : Transparency.OPAQUE;
        if (type == DataBuffer.TYPE_BYTE) {
            transferType = DataBuffer.TYPE_BYTE;
            switch (bands) {
                case 1:
        bits = GrayBits8;
        break;
                case 2:
        bits = GrayAlphaBits8;
        break;
                case 3:
        bits = RGBBits8;
        break;
                case 4:
        bits = RGBABits8;
        break;
            }
        } else if (type == DataBuffer.TYPE_USHORT) {
            transferType = DataBuffer.TYPE_USHORT;
            switch (bands) {
                case 1:
        bits = GrayBits16;
        break;
                case 2:
        bits = GrayAlphaBits16;
        break;
                case 3:
        bits = RGBBits16;
        break;
                case 4:
        bits = RGBABits16;
        break;
            }
        } else if (type == DataBuffer.TYPE_INT) {
            transferType = DataBuffer.TYPE_INT;
            switch (bands) {
                case 1:
        bits = GrayBits32;
        break;
                case 2:
        bits = GrayAlphaBits32;
        break;
                case 3:
        bits = RGBBits32;
        break;
                case 4:
        bits = RGBABits32;
        break;
            }
        }

        if (type == DataBuffer.TYPE_FLOAT &&
                   bands >= 1 && bands <= 4) {
            cm = new FloatDoubleColorModel(cp, hasAlpha, false,
                                           transparency,
                                           DataBuffer.TYPE_FLOAT);
        } else {
            cm = new ComponentColorModel(cp, bits, hasAlpha,
                                         false, transparency, transferType);
        }

  return cm;
    }
View Full Code Here

Examples of java.awt.image.ComponentColorModel

        for(int i = 0; i < numBands; i++) {
            bits[i] = dtSize;
        }
        int transparency = hasAlpha ?
            Transparency.TRANSLUCENT : Transparency.OPAQUE;
        ColorModel cm = new ComponentColorModel(cs, bits,
                                                hasAlpha, isAlphaPremultiplied,
                                                transparency,
                                                DataBuffer.TYPE_BYTE);
        il.setColorModel(cm);
View Full Code Here

Examples of java.awt.image.ComponentColorModel

            bits[i] = dataTypeSize;
        }

        switch (dataType) {
        case DataBuffer.TYPE_BYTE:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
        case DataBuffer.TYPE_USHORT:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
        /// case DataBuffer.TYPE_SHORT:
            /// return new ShortComponentColorModel(colorSpace,
                                                /// bits,
                                                /// useAlpha,
                                                /// premultiplied,
                                                /// transparency);
        case DataBuffer.TYPE_INT:
            return new ComponentColorModel(colorSpace,
                                           bits,
                                           useAlpha,
                                           premultiplied,
                                           transparency,
                                           dataType);
View Full Code Here

Examples of java.awt.image.ComponentColorModel

  } else {
      cm = dstParam.getColorModel();
      sm = dstParam.getSampleModel();
  }

  cm  = new ComponentColorModel(rgbColorSpace,
              cm.getComponentSize(),
              cm.hasAlpha() ,
              cm.isAlphaPremultiplied(),
              cm.getTransparency(),
              sm.getDataType())
View Full Code Here

Examples of java.awt.image.ComponentColorModel

     *
     * @param src The image to convert to an alpha channel (mask image)
     */
    public FilterAsAlphaRed(CachableRed src) {
        super(new Any2LumRed(src),src.getBounds(),
              new ComponentColorModel
                  (ColorSpace.getInstance(ColorSpace.CS_GRAY),
                   new int [] {8}, false, false,
                   Transparency.OPAQUE,
                   DataBuffer.TYPE_BYTE),
              new PixelInterleavedSampleModel
View Full Code Here

Examples of java.awt.image.ComponentColorModel

                    (wr.getMinX()-wr.getSampleModelTranslateX(),
                     wr.getMinY()-wr.getSampleModelTranslateY(),
                     wr.getWidth(), wr.getHeight(),
                     0, 0, null);
               
                ColorModel cmna = new ComponentColorModel
                    (ColorSpace.getInstance(ColorSpace.CS_GRAY),
                     new int [] {8}, false, false,
                     Transparency.OPAQUE,
                     DataBuffer.TYPE_BYTE);
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.