java.awt.image.BufferedImage.getSource()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中java.awt.image.BufferedImage.getSource()方法的一些代码示例,展示了BufferedImage.getSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedImage.getSource()方法的具体详情如下:
包路径:java.awt.image.BufferedImage
类名称:BufferedImage
方法名:getSource

BufferedImage.getSource介绍

[英]Returns the object that produces the pixels for the image.
[中]返回为图像生成像素的对象。

代码示例

代码示例来源:origin: stackoverflow.com

private Image TransformGrayToTransparency(BufferedImage image)
{
 ImageFilter filter = new RGBImageFilter()
 {
  public final int filterRGB(int x, int y, int rgb)
  {
   return (rgb << 8) & 0xFF000000;
  }
 };
 ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
 return Toolkit.getDefaultToolkit().createImage(ip);
}

代码示例来源:origin: looly/hutool

/**
 * 图像切割(按指定起点坐标和宽高切割)
 * 
 * @param rectangle 矩形对象,表示矩形区域的x,y,width,height
 * @return this
 */
public Img cut(Rectangle rectangle) {
  final BufferedImage srcImage = getValidSrcImg();
  rectangle = fixRectangle(rectangle, srcImage.getWidth(), srcImage.getHeight());
  final ImageFilter cropFilter = new CropImageFilter(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
  final Image image = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(srcImage.getSource(), cropFilter));
  this.targetImage = ImageUtil.toBufferedImage(image);
  return this;
}

代码示例来源:origin: looly/hutool

/**
 * 图像切割(按指定起点坐标和宽高切割)
 * 
 * @param rectangle 矩形对象,表示矩形区域的x,y,width,height
 * @return this
 */
public Img cut(Rectangle rectangle) {
  final BufferedImage srcImage = getValidSrcImg();
  rectangle = fixRectangle(rectangle, srcImage.getWidth(), srcImage.getHeight());
  final ImageFilter cropFilter = new CropImageFilter(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
  final Image image = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(srcImage.getSource(), cropFilter));
  this.targetImage = ImageUtil.toBufferedImage(image);
  return this;
}

代码示例来源:origin: stackoverflow.com

ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
 return Toolkit.getDefaultToolkit().createImage(ip);
ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
 return Toolkit.getDefaultToolkit().createImage(ip);

代码示例来源:origin: cmusphinx/sphinx4

/** Zoom the image, preparing for new display. 
 * @param zoom to set
 **/
protected void zoomSet(float zoom) {
  this.zoom = zoom;
  if (spectrogram != null) {
    int width = spectrogram.getWidth();
    int height = spectrogram.getHeight();
    ImageFilter scaleFilter =
        new ReplicateScaleFilter((int) (zoom * width), height);
    scaledSpectrogram =
        createImage(new FilteredImageSource(spectrogram.getSource(),
            scaleFilter));
    Dimension d = new Dimension((int) (width * zoom), height);
    setMinimumSize(d);
    setMaximumSize(d);
    setPreferredSize(d);
    repaint();
  }
}

代码示例来源:origin: cmusphinx/sphinx4

/** Zoom the image, preparing for new display. 
 * @param zoom a zoom to set
 **/
protected void zoomSet(float zoom) {
  this.zoom = zoom;
  if (spectrogram != null) {
    int width = spectrogram.getWidth();
    int height = spectrogram.getHeight();
    ImageFilter scaleFilter =
        new ReplicateScaleFilter((int) (zoom * width), height);
    scaledSpectrogram =
        createImage(new FilteredImageSource(spectrogram.getSource(),
            scaleFilter));
    Dimension d = new Dimension((int) (width * zoom), height);
    setMinimumSize(d);
    setMaximumSize(d);
    setPreferredSize(d);
    repaint();
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

Image returnImage = Toolkit.getDefaultToolkit().createImage(new java.awt.image.FilteredImageSource(src.getSource(),cropfilter));
dst = ImageConverter.convertImage(returnImage);
origDst = dst;

代码示例来源:origin: cmusphinx/sphinx4

new ReplicateScaleFilter((int) (zoom * width), height);
scaledSpectrogram =
    createImage(new FilteredImageSource(spectrogram.getSource(),
        scaleFilter));
Dimension sz = getSize();

代码示例来源:origin: cmusphinx/sphinx4

new ReplicateScaleFilter((int) (zoom * width), height);
scaledSpectrogram =
    createImage(new FilteredImageSource(spectrogram.getSource(),
        scaleFilter));
Dimension sz = getSize();

代码示例来源:origin: vsch/flexmark-java

ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(ip);

代码示例来源:origin: stackoverflow.com

ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(ip);

代码示例来源:origin: magefree/mage

ImageProducer prod = new FilteredImageSource(originImage.getSource(), new RGBImageFilter() {
  @Override
  public int filterRGB(int x, int y, int rgb) {

代码示例来源:origin: Spoutcraft/LegacyLauncher

@Override
public ImageProducer getSource() {
  if (futureImage == null) {
    return empty.getSource();
  }
  return futureImage.getSource();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

/** {@inheritDoc} */
@Override
public ImageProducer getSource() {
  return sketch == null ? null : sketch.getSource();
}

代码示例来源:origin: igniterealtime/Spark

/**
 * Converts a {@link BufferedImage} to {@link Image}
 * 
 * @param bufferedImage
 *            , the {@link BufferedImage}
 * @return {@link Image}
 */
public static Image toImage(BufferedImage bufferedImage) {
return Toolkit.getDefaultToolkit().createImage(
  bufferedImage.getSource());
}

代码示例来源:origin: org.gatein.captcha/simplecaptcha

public static final void applyFilter(BufferedImage img, ImageFilter filter) {
//        FilteredImageSource src = new FilteredImageSource(img.getSource(), filter);
    Image fImg = Toolkit.getDefaultToolkit().createImage(img.getSource());
    Graphics2D g = img.createGraphics();
    g.drawImage(fImg, 0, 0, null, null);
    g.dispose();
  }
}

代码示例来源:origin: stackoverflow.com

BufferedImage img;//your image
ColorSwapFilter filter = new ColorSwapFilter(...,...);//your colors to be swapped.
ImageProducer producer = img.getSource();
producer = new FilteredImageSource(producer, filter);
Image im = Toolkit.getDefaultToolkit().createImage(producer);

代码示例来源:origin: gamesbyangelina/spritely

private static Image TransformGrayToTransparency(BufferedImage image) {
 ImageFilter filter = new RGBImageFilter() {
  public final int filterRGB(int x, int y, int rgb) {
   if (rgb == 0) {
    return 0;
   }
   return rgb;
  }
 };
 ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
 return Toolkit.getDefaultToolkit().createImage(ip);
}

代码示例来源:origin: tonihele/OpenKeeper

private static Image makeColorTransparent(BufferedImage image) {
  ImageFilter filter = new RGBImageFilter() {
    @Override
    public final int filterRGB(int x, int y, int rgb) {
      return (rgb < 0xFF303030) ? 0x00FFFFFF : rgb;
    }
  };
  ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
  return Toolkit.getDefaultToolkit().createImage(ip);
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

static public Icon createIcon(Icon icon, FilterType filterType) {
  if (icon != null && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
    BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
    icon.paintIcon(DUMMY, img.getGraphics(), 0, 0);
    ImageProducer producer = new FilteredImageSource(img.getSource(), filterType.filter);
    Image resultImage = DUMMY.createImage(producer);
    return new ImageIcon(resultImage);
  }
  return null;
}

相关文章