Java 类java.awt.image.ColorConvertOp 实例源码

项目:Pogamut3    文件:AgentNode.java   
@Override
public Image getIcon(int type) {
    if(agentIcon == null) {
        agentIcon = loadAgentIcon();
    }

    IAgentState agentState = agent.getState().getFlag();

    if (isEndState(agentState)) {
        // return grayscale icon
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
        ColorConvertOp op = new ColorConvertOp(cs, null);

        return op.filter((BufferedImage) agentIcon, null);
    } else {
        // use badge to indicate state of the agent
        Image badge = getBadgeIcon(agentState);

        return ImageUtilities.mergeImages(agentIcon, badge, 4, 4);
    }
}
项目:freecol    文件:ImageResource.java   
/**
 * Gets a grayscale version of the image of the given size.
 * 
 * @param d The requested size.
 * @return The {@code BufferedImage}.
 */
public BufferedImage getGrayscaleImage(Dimension d) {
    final BufferedImage cached = grayscaleImages.get(d);
    if (cached != null) return cached;
    final BufferedImage im = getImage(d);
    if (im == null) return null;
    int width = im.getWidth();
    int height = im.getHeight();
    // TODO: Find out why making a copy is necessary here to prevent
    //       images from getting too dark.
    BufferedImage srcImage = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = srcImage.createGraphics();
    g.drawImage(im, 0, 0, null);
    g.dispose();
    ColorConvertOp filter = new ColorConvertOp(
        ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    final BufferedImage grayscaleImage = filter.filter(srcImage, null);
    grayscaleImages.put(d, grayscaleImage);
    return grayscaleImage;
}
项目:ServerlessPlatform    文件:ImageService.java   
public void blackNWhite(String link, String email) throws Exception{
    try{
        download(link);
        doLogging("Request came for blackNWhite ", "INFO");
        String outPath=null;
        String fileName=null;
        String imageName = null;
        int lastSlashIndex = link.lastIndexOf('/');
        imageName = link.substring(lastSlashIndex + 1);
        String path = Path+imageName;
        BufferedImage src = ImageIO.read(new File(path));
        ColorConvertOp op =new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
        BufferedImage dest = op.filter(src, null);
        fileName = path.substring(path.lastIndexOf("/")+1);
        path = path.substring(0, path.lastIndexOf("/")+1);
        outPath=path+"BNW_"+fileName;
        ImageIO.write(dest, "jpg", new File(outPath));
        sendMail(outPath, email);
    }
    catch(Exception e){
        doLogging("Failed somewhere "+e.getMessage()+e.getStackTrace(), "Error");
    }

}
项目:jdk8u-jdk    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u-jdk    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u-jdk    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:jdk8u-jdk    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u-jdk    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:openjdk-jdk10    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk-jdk10    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk-jdk10    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:openjdk-jdk10    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk-jdk10    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:FreeCol    文件:ImageResource.java   
/**
 * Gets a grayscale version of the image of the given size.
 * 
 * @param d The requested size.
 * @return The {@code BufferedImage}.
 */
public BufferedImage getGrayscaleImage(Dimension d) {
    final BufferedImage cached = grayscaleImages.get(d);
    if (cached != null) return cached;
    final BufferedImage im = getImage(d);
    if (im == null) return null;
    int width = im.getWidth();
    int height = im.getHeight();
    // TODO: Find out why making a copy is necessary here to prevent
    //       images from getting too dark.
    BufferedImage srcImage = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = srcImage.createGraphics();
    g.drawImage(im, 0, 0, null);
    g.dispose();
    ColorConvertOp filter = new ColorConvertOp(
        ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    final BufferedImage grayscaleImage = filter.filter(srcImage, null);
    grayscaleImages.put(d, grayscaleImage);
    return grayscaleImage;
}
项目:openjdk9    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk9    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk9    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:openjdk9    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:openjdk9    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:orbit-image-analysis    文件:JSliderOrbit.java   
@Override
protected Icon getIcon ()
{
    // TODO Use that to get the state (-> highlight or not)
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker();
    // stateTransitionTracker.getModelStateInfo().getCurrModelState();

    final Icon icon = super.getIcon();
    final BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
    final Graphics iconGraphics = image.createGraphics();
    icon.paintIcon(slider, iconGraphics, 0, 0);
    // Make it brighter (very simple approach)
    final RescaleOp rescaleOp = new RescaleOp(2.0f, 50, null);
    rescaleOp.filter(image, image);

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

    return new ImageIcon(image);
}
项目:jdk8u_jdk    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u_jdk    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u_jdk    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:jdk8u_jdk    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:jdk8u_jdk    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:lookaside_java-1.8.0-openjdk    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:lookaside_java-1.8.0-openjdk    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:lookaside_java-1.8.0-openjdk    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:lookaside_java-1.8.0-openjdk    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:lookaside_java-1.8.0-openjdk    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:Java-FPDF    文件:JpegReader.java   
public static BufferedImage convertCmykToRgb(Raster cmykRaster, ICC_Profile cmykProfile) throws IOException {
    if (cmykProfile == null)
        cmykProfile = ICC_Profile.getInstance(JpegReader.class.getResourceAsStream("/ISOcoated_v2_300_eci.icc"));

    if (cmykProfile.getProfileClass() != ICC_Profile.CLASS_DISPLAY) {
        byte[] profileData = cmykProfile.getData();

        if (profileData[ICC_Profile.icHdrRenderingIntent] == ICC_Profile.icPerceptual) {
            intToBigEndian(ICC_Profile.icSigDisplayClass, profileData, ICC_Profile.icHdrDeviceClass); // Header is first

            cmykProfile = ICC_Profile.getInstance(profileData);
        }
    }

    ICC_ColorSpace cmykCS = new ICC_ColorSpace(cmykProfile);
    BufferedImage rgbImage = new BufferedImage(cmykRaster.getWidth(), cmykRaster.getHeight(), BufferedImage.TYPE_INT_RGB);
    WritableRaster rgbRaster = rgbImage.getRaster();
    ColorSpace rgbCS = rgbImage.getColorModel().getColorSpace();
    ColorConvertOp cmykToRgb = new ColorConvertOp(cmykCS, rgbCS, null);
    cmykToRgb.filter(cmykRaster, rgbRaster);
    return rgbImage;
}
项目:imageweb    文件:CmykImageUtil.java   
public static BufferedImage convertCmykToRgb(Raster cmykRaster, ICC_Profile cmykProfile) throws IOException {
    if (cmykProfile == null){
        cmykProfile = ICC_Profile.getInstance(CmykImageUtil.class.getResourceAsStream("/ISOcoated_v2_300_eci.icc"));
    }

    if (cmykProfile.getProfileClass() != ICC_Profile.CLASS_DISPLAY) {
        byte[] profileData = cmykProfile.getData();

        if (profileData[ICC_Profile.icHdrRenderingIntent] == ICC_Profile.icPerceptual) {
            intToBigEndian(ICC_Profile.icSigDisplayClass, profileData, ICC_Profile.icHdrDeviceClass); // Header is first

            cmykProfile = ICC_Profile.getInstance(profileData);
        }
    }

    ICC_ColorSpace cmykCS = new ICC_ColorSpace(cmykProfile);
    BufferedImage rgbImage = new BufferedImage(cmykRaster.getWidth(), cmykRaster.getHeight(), BufferedImage.TYPE_INT_RGB);
    WritableRaster rgbRaster = rgbImage.getRaster();
    ColorSpace rgbCS = rgbImage.getColorModel().getColorSpace();
    ColorConvertOp cmykToRgb = new ColorConvertOp(cmykCS, rgbCS, null);
    cmykToRgb.filter(cmykRaster, rgbRaster);
    return rgbImage;
}
项目:infobip-open-jdk-8    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:infobip-open-jdk-8    文件:ColConvCCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy,
                             int dataType, int rBits, int gBits,
                             int bBits, int cs, BufferedImage gldImage,
                             double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(subSrc, subDst);
    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:infobip-open-jdk-8    文件:InvalidRenderIntentTest.java   
public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);

    byte[] raw_data = pSRGB.getData();

    setRenderingIntent(0x1000000, raw_data);

    ICC_Profile p = ICC_Profile.getInstance(raw_data);

    ICC_ColorSpace cs = new ICC_ColorSpace(p);

    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs,
            ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);

    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
项目:infobip-open-jdk-8    文件:ColConvDCMTest.java   
static boolean testImage(int type, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
{
    BufferedImage src = ImageFactory.createDCMImage(type, cs);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);

    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}
项目:infobip-open-jdk-8    文件:ColConvDCMTest.java   
static boolean testSubImage(int x0, int y0, int dx, int dy, int type,
                            int rBits, int gBits, int bBits,
                            int cs, BufferedImage gldImage,
                            double accuracy)
{
   BufferedImage src = ImageFactory.createDCMImage(type, cs);
   BufferedImage subSrc = src.getSubimage(x0, y0, dx, dy);
   BufferedImage dst = ImageFactory.createDstImage(
       BufferedImage.TYPE_INT_RGB);
   BufferedImage subDst = dst.getSubimage(x0, y0, dx, dy);

   ColorConvertOp op = new ColorConvertOp(null);

   op.filter(subSrc, subDst);

   ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                             bBits);
   boolean result = cmp.compare(subDst, gldImage, x0, y0, dx, dy);
   if (!result) {
       System.err.println(cmp.getStat());
   }
   return result;
}
项目:sambox    文件:PDColorSpace.java   
/**
 * Returns the (A)RGB equivalent of the given raster, using the given AWT color space to perform the conversion.
 * 
 * @param raster the source raster
 * @param colorSpace the AWT
 * @return an (A)RGB buffered image
 */
protected BufferedImage toRGBImageAWT(WritableRaster raster, ColorSpace colorSpace)
{
    //
    // WARNING: this method is performance sensitive, modify with care!
    //

    // ICC Profile color transforms are only fast when performed using ColorConvertOp
    ColorModel colorModel = new ComponentColorModel(colorSpace, 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;
}
项目:sambox    文件:JPEGFactory.java   
private static BufferedImage getColorImage(BufferedImage image)
{
    if (!image.getColorModel().hasAlpha())
    {
        return image;
    }

    if (image.getColorModel().getColorSpace().getType() != ColorSpace.TYPE_RGB)
    {
        throw new UnsupportedOperationException("only RGB color spaces are implemented");
    }

    // create an RGB image without alpha
    // BEWARE: the previous solution in the history
    // g.setComposite(AlphaComposite.Src) and g.drawImage()
    // didn't work properly for TYPE_4BYTE_ABGR.
    // alpha values of 0 result in a black dest pixel!!!
    BufferedImage rgbImage = new BufferedImage(image.getWidth(), image.getHeight(),
            BufferedImage.TYPE_3BYTE_BGR);
    return new ColorConvertOp(null).filter(image, rgbImage);
}
项目:jdk8u-dev-jdk    文件:ColConvCCMTest.java   
static boolean testImage(int dataType, int rBits, int gBits, int bBits,
                          int cs, BufferedImage gldImage,
                          double accuracy)
 {
    BufferedImage src = ImageFactory.createCCMImage(cs, dataType);
    BufferedImage dst = ImageFactory.createDstImage(
        BufferedImage.TYPE_INT_RGB);
    ColorConvertOp op = new ColorConvertOp(null);
    op.filter(src, dst);

    ImageComparator cmp = new ImageComparator(accuracy, rBits, gBits,
                                              bBits);
    boolean result = cmp.compare(gldImage, dst);
    if (!result) {
        System.err.println(cmp.getStat());
    }
    return result;
}