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


Java FilteredImageSource类代码示例

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


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

示例1: applyAlphaChannel

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * All pixels that have the specified color are rendered transparent.
 *
 * @param img
 *          the img
 * @param color
 *          the color
 * @return the image
 */
public static Image applyAlphaChannel(final Image img, final Color color) {
  if (color == null || img == null) {
    return img;
  }

  final ImageFilter filter = new RGBImageFilter() {

    // the color we are looking for... Alpha bits are set to opaque
    public final int markerRGB = color.getRGB() | 0xFF000000;

    @Override
    public final int filterRGB(final int x, final int y, final int rgb) {
      if ((rgb | 0xFF000000) == this.markerRGB) {
        // Mark the alpha bits as zero - transparent
        return 0x00FFFFFF & rgb;
      } else {
        // nothing to do
        return rgb;
      }
    }
  };

  final ImageProducer ip = new FilteredImageSource(img.getSource(), filter);
  return Toolkit.getDefaultToolkit().createImage(ip);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:35,代码来源:ImageProcessing.java

示例2: getGrayscaledImage

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
public BufferedImage getGrayscaledImage(BufferedImage coloredImage) {
    ImageFilter filter = new ImageFilter(){
        public final int filterRGB(int x, int y, int rgb)
        {
            //TODO - optimization? Bit shifts, not this shits
            Color currentColor = new Color(rgb);
            if(currentColor.getRed() < 2 && currentColor.getGreen() < 2 && currentColor.getBlue() < 2) {
                return new Color(rgb).darker().getRGB();
            }

            return Color.WHITE.getRGB();
        }
    };

    ImageProducer producer = new FilteredImageSource(coloredImage.getSource(), filter);
    Image image = Toolkit.getDefaultToolkit().createImage(producer);
    return toBufferedImage(image);
}
 
开发者ID:corydissinger,项目名称:mtgo-best-bot,代码行数:19,代码来源:ImagePreProcessor.java

示例3: getDisabledIcon

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * {@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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:WindowsLookAndFeel.java

示例4: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
public static Image makeColorTransparent(Image im, final Color color) {
    //(C)
    //Copiado da internet: 13/02/2011 - http://www.rgagnon.com/javadetails/java-0265.html e http://www.coderanch.com/t/331731/GUI/java/Resize-ImageIcon
    //

    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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:26,代码来源:TratadorDeImagens.java

示例5: makeColorTransparent

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

示例6: cut

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * 图像切割(指定切片的宽度和高度)
 * @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;
}
 
开发者ID:QianLongGit,项目名称:imageServer,代码行数:31,代码来源:ImageUtil.java

示例7: cut

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * 图像切割(按指定起点坐标和宽高切割)
 * @param srcImg 源图像地址
 * @param outImg 切片后的图像地址
 * @param x 目标切片起点坐标X
 * @param y 目标切片起点坐标Y
 * @param width 目标切片宽度
 * @param height 目标切片高度
 * @param imageType 图片类型
 */
public static void cut(File srcImg, File outImg, int x, int y, int width, int height,String imageType) throws Exception{
	//读取源图像
	BufferedImage bi = ImageIO.read(srcImg);
	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, imageType, outImg);
	}
}
 
开发者ID:tank2140896,项目名称:JavaWeb,代码行数:30,代码来源:ImageUtils.java

示例8: paint

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
@Override
public void paint(Graphics g){
    super.paint(g);
    // Have the extending class draw on an image so that it can be resized as needed
    Image bufferImage = createImage(DRAW_WIDTH, DRAW_HEIGHT);
    // Give control to visualization to draw on buffer
    paintVisualization((Graphics2D)bufferImage.getGraphics());
    int width = getWidth();
    int height = getHeight(); 
    // Scale and resize the image
    ReplicateScaleFilter scale = new ReplicateScaleFilter(width, height);
    FilteredImageSource fis = new FilteredImageSource(bufferImage.getSource(), scale);
    Image croppedImage = createImage(fis);
    g.drawImage(croppedImage, 0, 0, null);
    Toolkit.getDefaultToolkit().sync();
}
 
开发者ID:kurtlewis,项目名称:Visualizer,代码行数:17,代码来源:Visualizer.java

示例9: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
public static Image makeColorTransparent(final BufferedImage im, final Color color) {
	final ImageFilter filter = new RGBImageFilter() {
		// the color we are looking for... Alpha bits are set to opaque
		public int markerRGB = color.getRGB() | 0xFFFFFFFF;

		public final int filterRGB(final int x, final int y, final int rgb) {
			if ((rgb | 0xFF000000) == markerRGB) {
				// Mark the alpha bits as zero - transparent
				return 0x00FFFFFF & rgb;
			} else {
				// nothing to do
				return rgb;
			}
		}
	};

	final ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
	return Toolkit.getDefaultToolkit().createImage(ip);
}
 
开发者ID:SynBioDex,项目名称:SBOLDesigner,代码行数:20,代码来源:Images.java

示例10: setTransparentColor

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * 
 * @param im
 * @param color
 * @return
 */
public static Image setTransparentColor(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;

		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);
}
 
开发者ID:TKnudsen,项目名称:ComplexDataObject,代码行数:27,代码来源:BufferedImageTools.java

示例11: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
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
        @Override
        public int filterRGB(int x, int y, int rgb) {
            int markerRGB = color.getRGB() | 0xFF000000;

            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);
}
 
开发者ID:ZenHarbinger,项目名称:torgo,代码行数:22,代码来源:ImageUtils.java

示例12: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
public static BufferedImage makeColorTransparent(BufferedImage im, final Color color) {
    RGBImageFilter 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;
            }
        }
    };
    ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
    Image image = Toolkit.getDefaultToolkit().createImage(ip);
    BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = bufferedImage.createGraphics();
    g2.drawImage(image, 0, 0, null);
    g2.dispose();
    return bufferedImage;
}
 
开发者ID:kinztechcom,项目名称:OS-Cache-Suite,代码行数:20,代码来源:ImageUtilities.java

示例13: transformColorToTransparency

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
private Image transformColorToTransparency(BufferedImage image, Color color)
{
  ImageFilter filter = new RGBImageFilter()
  {
    public final int filterRGB(int x, int y, int rgb)
    {
    	if (rgb == color.getRGB()) {
    		return new Color(0, 0, 0, 0).getRGB();
    	} else {
    		return rgb;
    	}
    }
  };

  ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
  return Toolkit.getDefaultToolkit().createImage(ip);
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:18,代码来源:ImageInfoReader.java

示例14: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:28,代码来源:GlobalUtil.java

示例15: makeColorTransparent

import java.awt.image.FilteredImageSource; //导入依赖的package包/类
public static Image makeColorTransparent(Image 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;

		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);
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:20,代码来源:OpenSeaMap.java


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