Package java.awt.image

Examples of java.awt.image.IndexColorModel


                    for(int j = end; j < 256; j++) {
                        band[j] = (byte)0xFF;
                    }
                }

                il.setColorModel(new IndexColorModel(8, 256,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here


                break;
            }
            // only do this if not copied and expanded
            if ((formatTagID & EXPANSION_MASK) == EXPANDED &&
                theColorModel instanceof IndexColorModel) {
                IndexColorModel icm = (IndexColorModel)theColorModel;
   
                int newNumBands = icm.getNumComponents();
   
                int mapSize = icm.getMapSize();
                int newBandDataOffsets[] = new int[newNumBands];
                int newScanlineStride = rectWidth*newNumBands;
                int newPixelStride = newNumBands;
                byte ctable[][] = new byte[newNumBands][mapSize];
   
                icm.getReds(ctable[0]);
                icm.getGreens(ctable[1]);
                icm.getBlues(ctable[2]);
                byte rtable[] = ctable[0];
                byte gtable[] = ctable[1];
                byte btable[] = ctable[2];
   
                byte atable[] = null;
                if (newNumBands == 4) {
                    icm.getAlphas(ctable[3]);
                    atable = ctable[3];
                }
   
                for (int i = 0; i < newNumBands; i++) {
                    newBandDataOffsets[i] = i;
View Full Code Here

                    cmap[i] = (byte)(255 - i);
                }
            }
        }

        return new IndexColorModel(sampleSize, cmap.length,
                                   cmap, cmap, cmap);
    }
View Full Code Here

                    for(int j = end; j < 256; j++) {
                        band[j] = (byte)0xFF;
                    }
                }

                il.setColorModel(new IndexColorModel(8, 256,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here

    im.getColorModel() instanceof IndexColorModel &&
    config != null &&
    config.containsKey(JAI.KEY_REPLACE_INDEX_COLOR_MODEL) &&
    ((Boolean)config.get(JAI.KEY_REPLACE_INDEX_COLOR_MODEL)).booleanValue()) {

    IndexColorModel icm = (IndexColorModel)im.getColorModel();

    // We need to change the ColorModel to a non IndexColorModel
    // so that operations such as geometric can take place
    // correctly. If the ColorModel is changed the SampleModel
    // needs to be changed too, so that they are compatible
    cm = PlanarImage.getDefaultColorModel(srcSM.getDataType(),
                  icm.getNumComponents());
   
    SampleModel newSM;
    if (cm != null) {
        newSM = cm.createCompatibleSampleModel(srcSM.getWidth(),
                 srcSM.getHeight());
    } else {
        newSM = RasterFactory.createPixelInterleavedSampleModel(
                  srcSM.getDataType(),
                  srcSM.getWidth(),
                  srcSM.getHeight(),
                  icm.getNumComponents());
    }

    il.setSampleModel(newSM);

      } else {
View Full Code Here

         * Note, in this case, the source should have an integral data type.
         * And dest always has data type byte.
         */
        ColorModel srcColorModel = source.getColorModel();
        if (srcColorModel instanceof IndexColorModel) {
            IndexColorModel icm = (IndexColorModel)srcColorModel;
            ctable = new byte[3][icm.getMapSize()];
            icm.getReds(ctable[0]);
            icm.getGreens(ctable[1]);
            icm.getBlues(ctable[2]);
        }
    }
View Full Code Here

                    for(int j = end; j < 256; j++) {
                        band[j] = (byte)0xFF;
                    }
                }

                il.setColorModel(new IndexColorModel(8, 256,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here

        int maxX = rect.x + rect.width;
        int maxY = rect.y + rect.height;

        if(isIndexCM) {
            // Cast the CM and get the size of the ICM tables.
            IndexColorModel icm = (IndexColorModel)colorModel;
            int mapSize = icm.getMapSize();

            // Load the ICM tables.
            byte[] reds = new byte[mapSize];
            icm.getReds(reds);
            byte[] greens = new byte[mapSize];
            icm.getGreens(greens);
            byte[] blues = new byte[mapSize];
            icm.getBlues(blues);
            byte[] alphas = null;
            if(icm.hasAlpha()) {
                alphas = new byte[mapSize];
                icm.getAlphas(alphas);
            }

            // Get the index values.
            int[] indices = raster.getPixels(rect.x, rect.y,
                                             rect.width, rect.height,
View Full Code Here

                    }
                }

                int numBits =
                    sm.getDataType() == DataBuffer.TYPE_BYTE ? 8 : 16;
                il.setColorModel(new IndexColorModel(numBits, maxIndex + 1,
                                                     cmap[0], cmap[1],
                                                     cmap[2]));
            }
        }
View Full Code Here

    public ColorModel getColorModel() {
        if (colorMap == null)
            train();
        if (colorModel == null)
            colorModel =
                new IndexColorModel(8, colorMap.getByteData(0).length,
                                    colorMap.getByteData(0),
                                    colorMap.getByteData(1),
                                    colorMap.getByteData(2));
        return colorModel;
    }
View Full Code Here

TOP

Related Classes of java.awt.image.IndexColorModel

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.