Package java.awt.image

Examples of java.awt.image.ComponentColorModel


  }
 
  public void test_4byte_abgr(TestHarness harness)
  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
    harness.check(img.getColorModel().equals(new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                                     true, false,
                                                                     BufferedImage.TRANSLUCENT,
                                                                     DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                                              10, 10,
View Full Code Here


  }
 
  public void test_4byte_abgr_pre(TestHarness harness)
  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR_PRE);
    harness.check(img.getColorModel().equals(new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                                                     true, true,
                                                                     BufferedImage.TRANSLUCENT,
                                                                     DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
                                                                              10, 10,
View Full Code Here

  }
 
  public void test_byte_gray(TestHarness harness)
  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_BYTE_GRAY);
    harness.check(img.getColorModel().equals(new ComponentColorModel( ColorSpace.getInstance( ColorSpace.CS_GRAY ),
                                                                      new int[]{8}, false, false,
                                                                      Transparency.OPAQUE, DataBuffer.TYPE_BYTE)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
                                                                              10, 10,
                                                                              1, 10, new int[]{ 0 } )));
View Full Code Here

  }
 
  public void test_ushort_gray(TestHarness harness)
  {
    BufferedImage img = new BufferedImage(10, 10, BufferedImage.TYPE_USHORT_GRAY);
    harness.check(img.getColorModel().equals(new ComponentColorModel( ColorSpace.getInstance( ColorSpace.CS_GRAY ),
                                                                      new int[]{16}, false, false,
                                                                      Transparency.OPAQUE, DataBuffer.TYPE_USHORT)));
    harness.check(img.getSampleModel().equals(new PixelInterleavedSampleModel( DataBuffer.TYPE_USHORT,
                                                                              10, 10,
                                                                              1, 10, new int[]{ 0 } )));
View Full Code Here

    }

    @Override
    public BufferedImage toRGBImage(WritableRaster raster) throws IOException
    {
        ColorModel colorModel = new ComponentColorModel(colorSpaceRGB,
                false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType());

        return new BufferedImage(colorModel, raster, false, null);
    }
View Full Code Here

   */
  private static ByteBuffer convertImageData(BufferedImage bufferedImage,
      TextureImpl texture) {

    /** The colour model including alpha for the GL image */
    ColorModel glAlphaColorModel = new ComponentColorModel(ColorSpace
        .getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8, 8, 8 },
        true, false, ComponentColorModel.BITMASK, DataBuffer.TYPE_BYTE);

    /** The colour model for the GL image */
    ColorModel glColorModel = new ComponentColorModel(ColorSpace
        .getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8, 8, 0 },
        false, false, ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE);

    ByteBuffer imageBuffer = null;
    WritableRaster raster;
View Full Code Here

        BufferedImage alpha = null;
        if (bi.getColorModel().hasAlpha())
        {
            // extract the alpha information
            WritableRaster alphaRaster = bi.getAlphaRaster();
            ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),
                    false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            alpha = new BufferedImage(cm, alphaRaster, false, null);
            // create a RGB image without alpha
            image = new BufferedImage(bi.getWidth(), bi.getHeight(), BufferedImage.TYPE_INT_RGB);
            Graphics2D g = image.createGraphics();
View Full Code Here

    }

    private BufferedImage createRGBBufferedImage(ColorSpace cs, byte[] rgb, int width, int height)
    {
        // create a RGB color model
        ColorModel cm = new ComponentColorModel(cs, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
        // create the target raster
        WritableRaster writeableRaster = cm.createCompatibleWritableRaster(width, height);
        // get the data buffer of the raster
        DataBufferByte buffer = (DataBufferByte)writeableRaster.getDataBuffer();
        byte[] bufferData = buffer.getData();
        // copy all the converted data to the raster buffer
        System.arraycopy( rgb, 0,bufferData, 0,rgb.length );
View Full Code Here

        int height = bi.getHeight();
        if (bi.getColorModel().hasAlpha())
        {
            // extract the alpha information
            WritableRaster alphaRaster = bi.getAlphaRaster();
            ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),
                    false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            alphaImage = new BufferedImage(cm, alphaRaster, false, null);
            // create a RGB image without alpha
            rgbImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
            Graphics2D g = rgbImage.createGraphics();
View Full Code Here

     * @throws IOException If there is an error creating the color model.
     */
    public ColorModel createColorModel( int bpc ) throws IOException
    {
        int[] nBits = {bpc, bpc, bpc};
        return new ComponentColorModel( getJavaColorSpace(),
                   nBits,
                   false,
                   false,
                   Transparency.OPAQUE,
                   DataBuffer.TYPE_BYTE);
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.