本文整理汇总了Java中java.awt.image.ColorConvertOp.filter方法的典型用法代码示例。如果您正苦于以下问题:Java ColorConvertOp.filter方法的具体用法?Java ColorConvertOp.filter怎么用?Java ColorConvertOp.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ColorConvertOp
的用法示例。
在下文中一共展示了ColorConvertOp.filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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.");
}
示例3: 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;
}
示例4: 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;
}
示例5: 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");
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例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);
}
示例10: convertCmykToRgb
import java.awt.image.ColorConvertOp; //导入方法依赖的package包/类
private static BufferedImage convertCmykToRgb(Raster cmykRaster, ICC_Profile cmykProfile) throws IOException {
ICC_Profile profile;
if (cmykProfile == null) {
profile = ICC_Profile.getInstance(JpegReader.class.getResourceAsStream("/properties/Generic CMYK Profile.icc"));
} else {
profile = cmykProfile;
}
ICC_ColorSpace cmykCS = new ICC_ColorSpace(profile);
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;
}
示例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(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;
}
示例12: 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;
}
示例13: 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;
}
示例14: adapt
import java.awt.image.ColorConvertOp; //导入方法依赖的package包/类
public IntegralImage adapt(BufferedImage image)
{
Objects.requireNonNull(image, "Source image was null");
// HACK prevent 'java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles' exceptions
// See: http://stackoverflow.com/questions/26535842/multithreaded-jpeg-image-processing-in-java
try {
Class.forName("java.awt.color.ICC_ColorSpace");
Class.forName("sun.java2d.cmm.lcms.LCMS");
} catch (Exception ex) {
throw new IllegalStateException("Cannot load color models");
}
Raster data = image.getData();
if (data.getNumBands() > 1)
{
// convert to grayscale.
ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(colorSpace, null);
image = op.filter(image, null);
}
return IntegralImageImpl.create(data);
}
示例15: menuChangeGreyActionPerformed
import java.awt.image.ColorConvertOp; //导入方法依赖的package包/类
private void menuChangeGreyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuChangeGreyActionPerformed
try {
VentanaInternaImagen vi = (VentanaInternaImagen) selectInternalWindows();
if (vi != null) {
ICC_Profile ip;
ip = ICC_Profile.getInstance(ColorSpace.CS_GRAY);
ColorSpace cs = new ICC_ColorSpace(ip);
ColorConvertOp ccop = new ColorConvertOp(cs, null);
BufferedImage imgdest = ccop.filter(vi.getLienzo().getImageOriginal(), null);
if (imgdest != null) {
vi.getLienzo().setImageOriginal(imgdest);
vi.getLienzo().repaint();
activateFilterColorImage(false);
}
}
} catch (Exception e) {
System.err.println("Error en el contraste");
}
}