Java BufferedImage Operation findLegacyColorModel(BufferedImage image)

Here you can find the source of findLegacyColorModel(BufferedImage image)

Description

find Legacy Color Model

License

Open Source License

Declaration

public static ColorModel findLegacyColorModel(BufferedImage image) 

Method Source Code

//package com.java2s;

import java.awt.Transparency;
import java.awt.color.ColorSpace;

import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBuffer;

public class Main {
    public final static ColorModel COLOR_MODEL_RGBA = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8, 8, 8 }, true, false,
            Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
    public final static ColorModel COLOR_MODEL_RGB = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8, 8, 0 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);
    public final static ColorModel COLOR_MODEL_GRAY = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] { 8 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);
    public final static ColorModel COLOR_MODEL_ALPHA = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] { 0, 0, 0, 8 }, true, false,
            Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

    public static ColorModel findLegacyColorModel(boolean inColor, boolean hasAlpha) {
        ColorModel colorModel = null;

        return colorModel;
    }//from  www . j  a v  a  2s. c  o m

    public static ColorModel findLegacyColorModel(BufferedImage image) {
        ColorModel sourceColorModel = image.getColorModel();
        boolean inColor = (sourceColorModel.getColorSpace().getType() != ColorSpace.TYPE_GRAY);
        boolean hasAlpha = sourceColorModel.hasAlpha();

        if (inColor) {
            if (hasAlpha) {
                return COLOR_MODEL_RGBA;
            } else {
                return COLOR_MODEL_RGB;
            }
        } else {
            if (hasAlpha) {
                return COLOR_MODEL_ALPHA;
            } else {
                return COLOR_MODEL_GRAY;
            }
        }
    }
}

Related

  1. fakeAOI(final BufferedImage pImage, final Rectangle pSourceRegion)
  2. findavg(BufferedImage bimg)
  3. findColor(BufferedImage image, int startX, int startY, int dirX, int dirY, int colorIndex)
  4. findDifference(BufferedImage img2, BufferedImage img1)
  5. findDominantColor(BufferedImage paramBufferedImage)
  6. findLegendLH(BufferedImage bufferedImage)
  7. findTranslation(AffineTransform at, BufferedImage bi)
  8. fixImage(BufferedImage img, String ext)
  9. floatBufferToGrayBufferedImage(FloatBuffer floatBuffer, BufferedImage bi)