当前位置: 首页>>代码示例>>Java>>正文


Java ColorConvertOp类代码示例

本文整理汇总了Java中java.awt.image.ColorConvertOp的典型用法代码示例。如果您正苦于以下问题:Java ColorConvertOp类的具体用法?Java ColorConvertOp怎么用?Java ColorConvertOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ColorConvertOp类属于java.awt.image包,在下文中一共展示了ColorConvertOp类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIcon

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:22,代码来源:AgentNode.java

示例2: getGrayscaleImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:27,代码来源:ImageResource.java

示例3: blackNWhite

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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");
	}
	
}
 
开发者ID:hemantverma1,项目名称:ServerlessPlatform,代码行数:25,代码来源:ImageService.java

示例4: testImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ColConvCCMTest.java

示例5: testSubImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ColConvCCMTest.java

示例6: main

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:InvalidRenderIntentTest.java

示例7: testImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:ColConvDCMTest.java

示例8: testSubImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:ColConvDCMTest.java

示例9: getIcon

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
@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);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:22,代码来源:JSliderOrbit.java

示例10: convertCmykToRgb

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:nkiraly,项目名称:Java-FPDF,代码行数:23,代码来源:JpegReader.java

示例11: convertCmykToRgb

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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;
}
 
开发者ID:lklong,项目名称:imageweb,代码行数:24,代码来源:CmykImageUtil.java

示例12: toRGBImageAWT

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:torakiki,项目名称:sambox,代码行数:25,代码来源:PDColorSpace.java

示例13: getColorImage

import java.awt.image.ColorConvertOp; //导入依赖的package包/类
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);
}
 
开发者ID:torakiki,项目名称:sambox,代码行数:22,代码来源:JPEGFactory.java


注:本文中的java.awt.image.ColorConvertOp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。