Package java.awt.image

Examples of java.awt.image.ColorConvertOp


                                  null);

        // System.out.println("src: " + srcBI.getWidth() + "x" +
        //                    srcBI.getHeight());

        ColorConvertOp op = new ColorConvertOp(dstCM.getColorSpace(),
                                               null);
        dstBI = op.filter(srcBI, null);

        // System.out.println("After filter:");

        WritableRaster wr00 = wr.createWritableTranslatedChild(0,0);
        for (int i=0; i<dstCM.getColorSpace().getNumComponents(); i++)
View Full Code Here


             *                    srcBI.getHeight());
             * System.out.println("dst: " + dstBI.getWidth() + "x" +
             *                    dstBI.getHeight());
             */

            ColorConvertOp op = new ColorConvertOp(null);
            op.filter(srcBI, dstBI);

            if (dstCM.hasAlpha())
                copyBand(srcWr, srcSM.getNumBands()-1,
                         wr,    getSampleModel().getNumBands()-1);
        }
View Full Code Here

            false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType());

        BufferedImage src = new BufferedImage(colorModel, raster, false, null);
        BufferedImage dest = new BufferedImage(raster.getWidth(), raster.getHeight(),
                                               BufferedImage.TYPE_INT_RGB);
        ColorConvertOp op = new ColorConvertOp(null);
        op.filter(src, dest);
        return dest;
    }
View Full Code Here

                (DataBuffer.TYPE_BYTE, argbWR.getWidth(), argbWR.getHeight(),
                 sRGBCompCM.getNumComponents(), new Point(0, 0));

            BufferedImage sRGBImage = new BufferedImage
                (sRGBCompCM, wr, false, null);
            ColorConvertOp colorConvertOp = new ColorConvertOp(null);
            colorConvertOp.filter(newImg, sRGBImage);

            /**
             * Integrate alpha back into the image if there is any
             */
            if (imgCM.hasAlpha()){
View Full Code Here

     
      BufferedImage image1=null, image2 = null;
      image1 = graph.getImage();
      image2 = image1.getSubimage(275, 150, 250, 300);
      ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
      ColorConvertOp op = new ColorConvertOp(cs, null)
      image1 = op.filter(image2, null);
      BufferedImage image3 = image1.getSubimage(0, 0, 125, 150);
      File outputfile = new File("C://temp.png");
      JFileChooser jf = new JFileChooser();
      jf.setMultiSelectionEnabled(false);
      jf.showSaveDialog(jPanelImagem);
View Full Code Here

    // Create an image to work on
    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
    Graphics2D g = (Graphics2D)img.getGraphics();
    g.draw(new Line2D.Double(0, 0, 20, 20));
   
    ColorConvertOp op = new ColorConvertOp(null);
   
    // Src and dst images can be the same (unlike some other Ops)
    try
    {
      op.filter(img, img);
      harness.check(true);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Src and dst are different sizes (not allowed, unlike some other Ops)
    BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    try
    {
      op.filter(img, dst);
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
   
    // Dst cannot be null for this ColorConvertOp
    try
    {
      op.filter(img, null);
      harness.check(false);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
View Full Code Here

    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
    Graphics2D g = (Graphics2D)img.getGraphics();
    g.draw(new Line2D.Double(0, 0, 20, 20));
   
    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorConvertOp op = new ColorConvertOp(cs, null);
   
    // Check null destination
    try
    {
      BufferedImage dst = op.filter(img, null);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      // Any other checks to run?  Show the data was filtered properly?
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Check non-null destination
    try
    {
      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
      dst = op.filter(img, dst);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      // Any other checks to run?
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Can we introduce an alpha?
    try
    {
      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
      dst = op.filter(img, dst);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      // Any other checks to run?
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    // Different destination type: this should end up as GRAY, via RGB
    // (but how can I test the intermediate step?)
    try
    {
      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY);
      dst = op.filter(img, dst);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_GRAY);
      // Any other checks to run?
    }
    catch (IllegalArgumentException e)
    {
View Full Code Here

   
    ColorSpace cs1 = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
    //ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_PYCC);
       // PYCC is not implemented
    ColorSpace cs2 = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorConvertOp op = new ColorConvertOp(cs1, cs2, null);

    // Simpler tests (ie, src != dest) are skipped, assume they work here if
    // they worked earlier
   
    try
    {
      BufferedImage dst = op.filter(img, null);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      // PYCC would have been ColorSpace.TYPE_3CLR
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
    }
  
    try
    {
      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB_PRE);
      op.filter(img, dst);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(true);
View Full Code Here

    g.draw(new Line2D.Double(0, 0, 20, 20));
   
    ICC_Profile[] profile = new ICC_Profile[] {ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB),
                                               ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ),
                                               ICC_Profile.getInstance(ColorSpace.CS_sRGB)};
    ColorConvertOp op = new ColorConvertOp(profile, null);
   
    try
    {
      BufferedImage dst = op.filter(img, null);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
    }
   
    try
    {
      BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY);
      dst = op.filter(img, dst);
      harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_GRAY);
    }
    catch (IllegalArgumentException e)
    {
      harness.check(false);
View Full Code Here

    harness.checkPoint("getPoint2D");
   
    //  This is a simple test; the Op should not change the
    // geometry of the raster
   
    ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                           null);
    Point2D dest = null;
    dest = op.getPoint2D(new Point2D.Double(3, 3), dest);
    harness.check(dest, new Point2D.Double(3, 3));
  }
View Full Code Here

TOP

Related Classes of java.awt.image.ColorConvertOp

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.