下面列出了java.awt.image.FilteredImageSource#java.awt.image.ImageFilter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
@Override
public Icon getDisabledIcon( JComponent component, Icon icon ) {
if( icon instanceof ImageIcon ) {
Object grayFilter = UIManager.get( "Component.grayFilter" );
ImageFilter filter = (grayFilter instanceof ImageFilter)
? (ImageFilter) grayFilter
: GrayFilter.createDisabledIconFilter( isDark() ); // fallback
Function<Image, Image> mapper = img -> {
ImageProducer producer = new FilteredImageSource( img.getSource(), filter );
return Toolkit.getDefaultToolkit().createImage( producer );
};
Image image = ((ImageIcon)icon).getImage();
return new ImageIconUIResource( MultiResolutionImageSupport.map( image, mapper ) );
}
return null;
}
/**
* Make a color of a image transparent
*
* @param im The image
* @param color The color
* @return Result image
*/
public static Image makeColorTransparent(BufferedImage im, final Color color) {
ImageFilter filter = new RGBImageFilter() {
// the color we are looking for... Alpha bits are set to opaque
public int markerRGB = color.getRGB() | 0xFF000000;
@Override
public final int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;
} else {
// nothing to do
return rgb;
}
}
};
ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(ip);
}
/**
* http://stackoverflow.com/questions/665406/how-to-make-a-color-transparent-in-a-bufferedimage-and-save-as-png
*
* @param image the image
* @return the image
*/
public static Image whiteToTransparent(@NotNull BufferedImage image) {
ImageFilter filter = new RGBImageFilter() {
int markerRGB = JBColor.WHITE.getRGB() | 0xFF000000;
@Override
public final int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;
} else {
// nothing to do
return rgb;
}
}
};
ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(ip);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
@SuppressWarnings("deprecation")
protected void buildInitialFactories() {
int minWordLength = 7;
int maxWordLength = 7;
int fontSize = 36;
int imageWidth = 300;
int imageHeight = 90;
WordGenerator wordGenerator = new RandomWordGenerator("0123456789ABCDEFGHIJKLTYREWSZabcdefghjkmnpqrstuvwxyz");
TextPaster randomPaster = new DecoratedRandomTextPaster(
minWordLength,
maxWordLength,
new RandomListColorGenerator(new Color[]{
new Color(23, 170, 27), new Color(220, 34, 11),
new Color(23, 67, 172)}), new TextDecorator[]{});
BackgroundGenerator background = new UniColorBackgroundGenerator(imageWidth, imageHeight, Color.GREEN);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[]{new Font("Calibri", Font.BOLD, fontSize),
new Font("Times New Roman", Font.PLAIN, fontSize),
new Font("Arial", Font.BOLD, fontSize)});
ImageDeformation postDef = new ImageDeformationByFilters(new ImageFilter[]{});
ImageDeformation backDef = new ImageDeformationByFilters(new ImageFilter[]{});
ImageDeformation textDef = new ImageDeformationByFilters(new ImageFilter[]{});
WordToImage word2image = new DeformedComposedWordToImage(font,
background, randomPaster, backDef, textDef, postDef);
addFactory(new GimpyFactory(wordGenerator, word2image));
}
public static BufferedImage makeColorTransparent(BufferedImage im, final Color color) {
ImageFilter filter = new RGBImageFilter() {
public int markerRGB = color.getRGB() | 0xFF000000;
public final int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
return 0x00FFFFFF & rgb;
} else {
return rgb;
}
}
};
return imageToBufferedImage(
Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(im.getSource(), filter)));
}
/**
* 图像切割(指定切片的宽度和高度)
* @param bi 原图像
* @param x 裁剪原图像起点坐标X
* @param y 裁剪原图像起点坐标Y
* @param width 目标切片宽度
* @param height 目标切片高度
* @return
*/
public static BufferedImage cut(BufferedImage bi,int x, int y, int width, int height) {
BufferedImage tag = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = tag.createGraphics();
tag = g2.getDeviceConfiguration().createCompatibleImage(width, height,
Transparency.TRANSLUCENT);
g2.dispose();
g2 = tag.createGraphics();
int srcWidth = bi.getHeight(); // 源图宽度
int srcHeight = bi.getWidth(); // 源图高度
if (srcWidth > 0 && srcHeight > 0) {
ImageFilter cropFilter = new CropImageFilter(x, y, width, height);
Image img = Toolkit.getDefaultToolkit().createImage(
new FilteredImageSource(bi.getSource(),cropFilter));
g2.drawImage(img, 0, 0, width, height, null); // 绘制切割后的图
g2.dispose();
}
return tag;
}
/**
* {@inheritDoc}
*
* @since 1.6
*/
public Icon getDisabledIcon(JComponent component, Icon icon) {
// if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
// client property set to Boolean.TRUE, then use the new
// hi res algorithm for creating the disabled icon (used
// in particular by the WindowsFileChooserUI class)
if (icon != null
&& component != null
&& Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
&& icon.getIconWidth() > 0
&& icon.getIconHeight() > 0) {
BufferedImage img = new BufferedImage(icon.getIconWidth(),
icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(component, img.getGraphics(), 0, 0);
ImageFilter filter = new RGBGrayFilter();
ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
Image resultImage = component.createImage(producer);
return new ImageIconUIResource(resultImage);
}
return super.getDisabledIcon(component, icon);
}
/**
* Loads an image of available resolution (1x, 2x, ...) and scales to address the provided scale context.
* Then wraps the image with {@link JBHiDPIScaledImage} if necessary.
*/
@Nullable
public static Image loadFromUrl(@Nonnull URL url, final boolean allowFloatScaling, boolean useCache, Supplier<ImageFilter>[] filters, final JBUI.ScaleContext ctx) {
// We can't check all 3rd party plugins and convince the authors to add @2x icons.
// In IDE-managed HiDPI mode with scale > 1.0 we scale images manually.
return ImageDescList.create(url.toString(), null, UIUtil.isUnderDarcula(), allowFloatScaling, ctx).load(ImageConverterChain.create().
withFilter(filters).
with(new ImageConverter() {
@Override
public Image convert(Image source, ImageDesc desc) {
if (source != null && desc.type != SVG) {
double scale = adjustScaleFactor(allowFloatScaling, ctx.getScale(PIX_SCALE));
if (desc.scale > 1) scale /= desc.scale; // compensate the image original scale
source = scaleImage(source, scale);
}
return source;
}
}).
withHiDPI(ctx), useCache);
}
private static Image postProcessImage(final Graphics2D g, final BufferedImage img, final Point textPos,
final Color bgColor, final Color fgColor) {
if (experimentalAntialiasingEnabled) {
final BufferedImage destImg = getImage(g);
ImageFilter filter = new AntialiasingImageFilter(destImg, textPos.x, textPos.y, fgColor, bgColor);
return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(img.getSource(), filter));
} else {
return img;
}
}
@Override
protected void buildInitialFactories() {
// 图片和字体大小设置
int minWordLength = 4;
int maxWordLength = 5;
int fontSize = 20;
int imageWidth = 100;
int imageHeight = 36;
WordGenerator dictionnaryWords = new ComposeDictionaryWordGenerator(
new FileDictionary("toddlist"));
// word2image components
TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength,
maxWordLength, new RandomListColorGenerator(new Color[]{
new Color(23, 170, 27), new Color(220, 34, 11),
new Color(23, 67, 172)}), new TextDecorator[]{});
BackgroundGenerator background = new UniColorBackgroundGenerator(
imageWidth, imageHeight, Color.white);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[]{new Font("nyala", Font.BOLD, fontSize),
new Font("Bell MT", Font.PLAIN, fontSize),
new Font("Credit valley", Font.BOLD, fontSize)});
ImageDeformation postDef = new ImageDeformationByFilters(
new ImageFilter[]{});
ImageDeformation backDef = new ImageDeformationByFilters(
new ImageFilter[]{});
ImageDeformation textDef = new ImageDeformationByFilters(
new ImageFilter[]{});
WordToImage word2image = new DeformedComposedWordToImage(font,
background, randomPaster, backDef, textDef, postDef);
addFactory(new GimpyFactory(dictionnaryWords, word2image));
}
@Nullable
public static Image loadFromUrl(@Nonnull URL url, boolean allowFloatScaling, final ImageFilter filter) {
return loadFromUrl(url, allowFloatScaling, true, new Supplier[]{new Supplier() {
@Override
public Object get() {
return filter;
}
}}, JBUI.ScaleContext.create());
}
public ImageConverterChain withFilter(final Supplier<ImageFilter> filter) {
return with(new ImageConverter() {
@Override
public Image convert(Image source, ImageDesc desc) {
return ImageUtil.filter(source, filter.get());
}
});
}
@Nullable
public static Image loadFromUrl(@NotNull URL url, boolean allowFloatScaling, ImageFilter filter) {
final float scaleFactor = calcScaleFactor(allowFloatScaling);
// We can't check all 3rd party plugins and convince the authors to add @2x icons.
// (scaleFactor > 1.0) != isRetina() => we should scale images manually.
// Note we never scale images on Retina displays because scaling is handled by the system.
final boolean scaleImages = (scaleFactor > 1.0f) && !UIUtil.isRetina();
// For any scale factor > 1.0, always prefer retina images, because downscaling
// retina images provides a better result than upscaling non-retina images.
final boolean loadRetinaImages = UIUtil.isRetina() || scaleImages;
return ImageDescList.create(url.toString(), null, UIUtil.isUnderDarcula(), loadRetinaImages, allowFloatScaling).load(
ImageConverterChain.create().
withFilter(filter).
withRetina().
with(new ImageConverter() {
public Image convert(Image source, ImageDesc desc) {
if (source != null && scaleImages /*&& desc.type != ImageDesc.Type.SVG*/) {
if (desc.path.contains("@2x"))
return scaleImage(source, scaleFactor / 2.0f); // divide by 2.0 as Retina images are 2x the resolution.
else
return scaleImage(source, scaleFactor);
}
return source;
}
}));
}
public static void setFilter(ImageFilter filter) {
if (!Registry.is("color.blindness.icon.filter")) {
filter = null;
}
if (IMAGE_FILTER != filter) {
IMAGE_FILTER = filter;
clearCache();
}
}
private Image makeColorTransparent(Image image, Color color) {
final int markerRGB = color.getRGB() | 0xFF000000;
ImageFilter filter = new RGBImageFilter() {
@Override
public int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
return 0x00FFFFFF & rgb; // set alpha to 0
}
return rgb;
}
};
return ImageUtil.filter(image, filter);
}
protected void buildInitialFactories() {
int minWordLength = 4;
int maxWordLength = 5;
/*int fontSize = 50;
int imageWidth = 250;
int imageHeight = 100;*/
int fontSize = 30;
int imageWidth = 120;
int imageHeight = 50;
WordGenerator dictionnaryWords = new ComposeDictionaryWordGenerator(new FileDictionary("toddlist"));
// word2image components
TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength,
maxWordLength, new RandomListColorGenerator(new Color[] {
new Color(23, 170, 27), new Color(220, 34, 11),
new Color(23, 67, 172) }), new TextDecorator[] {});
BackgroundGenerator background = new UniColorBackgroundGenerator(
imageWidth, imageHeight, Color.white);
// ColorGenerator colorGenerator=new RandomListColorGenerator(new Color[]{new Color(235, 234, 235),new Color(255, 255, 255)});
// BackgroundGenerator background=new FunkyBackgroundGenerator(imageWidth, imageHeight,colorGenerator);
FontGenerator font = new RandomFontGenerator(fontSize, fontSize,
new Font[] { new Font("nyala", Font.BOLD, fontSize),
new Font("Bell MT", Font.PLAIN, fontSize),
new Font("Credit valley", Font.BOLD, fontSize) });
ImageDeformation postDef = new ImageDeformationByFilters(
new ImageFilter[] {});
ImageDeformation backDef = new ImageDeformationByFilters(
new ImageFilter[] {});
ImageDeformation textDef = new ImageDeformationByFilters(
new ImageFilter[] {});
WordToImage word2image = new DeformedComposedWordToImage(font,
background, randomPaster, backDef, textDef, postDef);
addFactory(new GimpyFactory(dictionnaryWords, word2image));
}
public static Image loadFromStream(@Nonnull final InputStream inputStream, final int scale, final ImageFilter filter) {
Image image = load(inputStream, scale);
ImageDesc desc = new ImageDesc("", null, scale, IMG);
return ImageConverterChain.create().withFilter(new Supplier<ImageFilter>() {
@Override
public ImageFilter get() {
return filter;
}
}).withRetina().convert(image, desc);
}
/**
* 图像切割(按指定起点坐标和宽高切割)
* @param srcImageFile 源图像地址
* @param result 切片后的图像地址
* @param x 目标切片起点坐标X
* @param y 目标切片起点坐标Y
* @param width 目标切片宽度
* @param height 目标切片高度
*/
public final static void cut(String srcImageFile, String result,
int x, int y, int width, int height) {
try {
// 读取源图像
BufferedImage bi = ImageIO.read(new File(srcImageFile));
int srcWidth = bi.getHeight(); // 源图宽度
int srcHeight = bi.getWidth(); // 源图高度
if (srcWidth > 0 && srcHeight > 0) {
Image image = bi.getScaledInstance(srcWidth, srcHeight,
Image.SCALE_DEFAULT);
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
ImageFilter cropFilter = new CropImageFilter(x, y, width, height);
Image img = Toolkit.getDefaultToolkit().createImage(
new FilteredImageSource(image.getSource(),
cropFilter));
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(img, 0, 0, width, height, null); // 绘制切割后的图
g.dispose();
// 输出为文件
ImageIO.write(tag, "JPEG", new File(result));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void applyTransparency( final UIColor background ){
ImageFilter filter = new RGBImageFilter() {
public int markerRGB = (((AWTColor)background).getHandle().getRGB() | 0xFF000000);
public final int filterRGB(int x, int y, int rgb) {
if ( ( rgb | 0xFF000000 ) == markerRGB ) {
return 0x00FFFFFF & rgb;
}
return rgb;
}
};
this.handle = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(this.handle.getSource(), filter));
}
public EmptyFilteredImage(ImageProducer imgSource) {
filter = new ImageFilter();
producer = new FilteredImageSource(imgSource, filter);
}
public EmptyFilteredImage(ImageProducer imgSource) {
filter = new ImageFilter();
producer = new FilteredImageSource(imgSource, filter);
}
private BufferedImage createGhostImage(Image image) {
ImageFilter filter = new GrayFilter(true, 50);
ImageProducer producer = new FilteredImageSource(image.getSource(), filter);
Image toolkitImage = Toolkit.getDefaultToolkit().createImage(producer);
return ImageUtils.toBufferedImage(toolkitImage);
}