Example usage for java.awt.color ColorSpace getInstance

List of usage examples for java.awt.color ColorSpace getInstance

Introduction

In this page you can find the example usage for java.awt.color ColorSpace getInstance.

Prototype



public static ColorSpace getInstance(int colorspace) 

Source Link

Document

Returns a ColorSpace representing one of the specific predefined color spaces.

Usage

From source file:Main.java

public static void main(String[] args) {

    Color myColor = new Color(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), new float[] { 0.1F, 0.2F, 0.3F },
            0.4F);//  www.  jav a  2s  . c  o  m

    System.out.println(Arrays.toString(myColor.getColorComponents(null)));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorConvertOp op = new ColorConvertOp(cs, null);

    BufferedImage bufferedImage = new BufferedImage(200, 200, BufferedImage.TYPE_BYTE_INDEXED);
    bufferedImage = op.filter(bufferedImage, null);
}

From source file:Main.java

public static void main(String[] args) {

    Color myColor = Color.RED;

    System.out.println(//from   w  ww.j  av  a2  s  . com
            Arrays.toString(myColor.getComponents(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), null)));

}

From source file:Main.java

public static void main(String[] args) {

    Color myColor = Color.RED;

    System.out.println(//  w ww .j a v  a2s  . c  o  m
            Arrays.toString(myColor.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ), null)));

}

From source file:ComponentTest.java

public static void main(String[] args) {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, new int[] { 5, 6, 5 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);

    Color fifty = new Color(cs, new float[] { 1.0f, 1.0f, 1.0f }, 0);
    float[] components = fifty.getComponents(null);
    System.out.print("Original normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();/*from   w  w w . ja  v a 2 s.  c o m*/
    int[] unnormalized = cm.getUnnormalizedComponents(components, 0, null, 0);
    System.out.print("Original unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    Object pixel = cm.getDataElements(unnormalized, 0, (Object) null);
    System.out.print("Pixel samples: ");
    byte[] pixelBytes = (byte[]) pixel;
    for (int i = 0; i < 3; i++)
        System.out.print(pixelBytes[i] + " ");
    System.out.println();

    unnormalized = cm.getComponents(pixel, null, 0);
    System.out.print("Derived unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    components = cm.getNormalizedComponents(unnormalized, 0, null, 0);
    System.out.print("Derived normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel cm = new ComponentColorModel(cs, new int[] { 5, 6, 5 }, false, false, Transparency.OPAQUE,
            DataBuffer.TYPE_BYTE);

    Color fifty = new Color(cs, new float[] { 1.0f, 1.0f, 1.0f }, 0);
    float[] components = fifty.getComponents(null);
    System.out.print("Original normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
    System.out.println();/*from  www .  j a  va 2s  . co m*/
    int[] unnormalized = cm.getUnnormalizedComponents(components, 0, null, 0);
    System.out.print("Original unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();

    Object pixel = cm.getDataElements(unnormalized, 0, (Object) null);
    System.out.print("Pixel samples: ");
    byte[] pixelBytes = (byte[]) pixel;
    for (int i = 0; i < 3; i++)
        System.out.print(pixelBytes[i] + " ");
    System.out.println();

    unnormalized = cm.getComponents(pixel, null, 0);
    System.out.print("Derived unnormalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(unnormalized[i] + " ");
    System.out.println();
    components = cm.getNormalizedComponents(unnormalized, 0, null, 0);
    System.out.print("Derived normalized components: ");
    for (int i = 0; i < 3; i++)
        System.out.print(components[i] + " ");
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedImage master = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
    BufferedImage gray = new BufferedImage(master.getWidth(), master.getHeight(), BufferedImage.TYPE_INT_ARGB);

    ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    op.filter(master, gray);//from www .  j ava 2  s  . com

    // new JLabel(new ImageIcon(master));
    // new JLabel(new ImageIcon(gray));
    ImageIO.write(master, "png", new File("c:/Java_Dev/master.png"));
    ImageIO.write(gray, "png", new File("c:/Java_Dev/gray.png"));
}

From source file:ImageUtil.java

public static BufferedImage desaturate(BufferedImage source) {
    ColorConvertOp colorConvert = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    colorConvert.filter(source, source);

    return source;
}

From source file:org.photovault.dcraw.DCRawReaderOp.java

public DCRawReaderOp(File f, RenderingHints hints) {
    super(null, hints, null, 1, 1, 1, 1);
    file = f;//from  ww w . j  a va2 s  . c  o m
    lrd = lr.libraw_init(0);
    lrd.output_params.half_size = 1;
    lr.libraw_open_file(lrd, f.getAbsolutePath());
    sampleModel = new PixelInterleavedSampleModel(DataBuffer.TYPE_USHORT, lrd.sizes.width, lrd.sizes.height, 1,
            lrd.sizes.width, new int[] { 0 });
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorModel c = new ComponentColorModel(cs, false, false, ColorModel.OPAQUE, DataBuffer.TYPE_USHORT);
    ImageLayout il = new ImageLayout(0, 0, 256, 256, sampleModel, c);
    setImageLayout(il);
    minX = 0;
    minY = 0;
    width = lrd.sizes.width;
    height = lrd.sizes.height;
    bayerfilter = lrd.idata.filters;
    cam_mul = lrd.color.cam_mul;
    setProperty("bayerfilter", lrd.idata.filters);
    setProperty("dcraw_cam_mul", cam_mul);
    setProperty("dcraw_cam_xyz", lrd.color.cam_xyz);
    setProperty("dcraw_rgb_cam", lrd.color.rgb_cam);
    setProperty("dcraw_black", lrd.color.black);
    setProperty("dcraw_max", lrd.color.maximum);
    setProperty("dcraw_black", lrd.color.black);
    setProperty("dcraw_margin_top", lrd.sizes.top_margin);
    setProperty("dcraw_margin_left", lrd.sizes.left_margin);
}

From source file:org.photovault.dcraw.AHDInterpolateOp.java

static private ImageLayout layoutHelper(RenderedImage src, int downSample) {
    int width = src.getWidth() / downSample;
    int height = src.getHeight() / downSample;
    PixelInterleavedSampleModel sampleModel = new PixelInterleavedSampleModel(DataBuffer.TYPE_USHORT, width,
            height, 3, width * 3, new int[] { 0, 1, 2 });
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
    ColorModel c = new ComponentColorModel(cs, false, false, ColorModel.OPAQUE, DataBuffer.TYPE_USHORT);
    ImageLayout il = new ImageLayout(0, 0, 256, 256, sampleModel, c);
    il.setWidth(width);/*  www . ja  v  a2  s  .c  om*/
    il.setHeight(height);
    return il;
}