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


Java Image.getSource方法代码示例

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


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

示例1: applyAlphaChannel

import java.awt.Image; //导入方法依赖的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: makeColorTransparent

import java.awt.Image; //导入方法依赖的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

示例3: main

import java.awt.Image; //导入方法依赖的package包/类
public static void main(String args[]) {
  final Image unrotated = Toolkit.getDefaultToolkit().getImage("ASL/images/Climb1d.gif");

  ImageFilter filter = new RotateFilter(-60.0);
  ImageProducer producer = new FilteredImageSource(unrotated.getSource(), filter);
  final Image rotated = new javax.swing.JLabel().createImage(producer);
  javax.swing.JFrame f = new javax.swing.JFrame() {
    private static final long serialVersionUID = 1L;

    public void paint(Graphics g) {
      g.setColor(Color.blue);
      g.fillRect(0, 0, getSize().width, getSize().height);
      g.drawImage(rotated, 100, 100, this);
      g.drawImage(unrotated, 0, 0, this);
      g.drawImage(unrotated,
                  100 + unrotated.getWidth(this),
                  unrotated.getHeight(this),
                  100, 0,
                  0, 0,
                  0 + unrotated.getWidth(this),
                  unrotated.getHeight(this),
                  this);
    }
  };
  f.setSize(300, 300);
  f.setVisible(true);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:28,代码来源:RotateFilter.java

示例4: OctreeQuantizer

import java.awt.Image; //导入方法依赖的package包/类
/**
 * Create a new octree and insert image data. This constructor is mostly
 * used by OctreeFilter.
 * @param im The image that provides pixel data to construct the tree
 */
public OctreeQuantizer(Image im)
{
  this();

  // first retrieve the pixels
  ImageLoader il = new ImageLoader(im);
  il.start();
  if(!il.waitFor()){
    throw new IllegalArgumentException(_LOG.getMessage(
      "PROBLEM_LOADING"));
  }
  int width = im.getWidth(il);
  int height = im.getHeight(il);
  int[] pixels = new int[width*height]; // going to hold all
  // the image's pixels
  
  PixelGrabber grabber = new PixelGrabber(im.getSource(), 0, 0,
                                          width, height,
                                          pixels, 0, width);
  try // get the pixels
  { 
    grabber.grabPixels();
  } 
  catch (InterruptedException e) 
  {
    throw new IllegalArgumentException(_LOG.getMessage(
      "GRABBING_PIXELS"));
  } 
  if ((grabber.getStatus() & ImageObserver.ABORT) != 0) 
  {
    throw new IllegalArgumentException(_LOG.getMessage(
      "ERROR_FETCHING_IMAGE", new Object[]{pixels.length,width,height}));
  }

  // add all pixels to the tree.
  for (int i = 0; i < pixels.length; i++)
    addColor(pixels[i]);

}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:45,代码来源:OctreeQuantizer.java

示例5: createFilteredImage

import java.awt.Image; //导入方法依赖的package包/类
/**
 * Given an image and a filter, creates the resulting image.
 * @param baseImage the base image
 * @param imageFilter the image filter
 */
public static Image createFilteredImage(
  Image       baseImage,
  ImageFilter imageFilter
  )
{
  // get the filtered image producer
  ImageProducer producer = new FilteredImageSource(baseImage.getSource(),
                                                   imageFilter);

  // return the filtered image
  return Toolkit.getDefaultToolkit().createImage(producer);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:ImageUtils.java

示例6: test

import java.awt.Image; //导入方法依赖的package包/类
public static void test(MyImageFilter testFilter) {
    Image image = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
    FilteredImageSource filtered =
            new FilteredImageSource(image.getSource(), testFilter);

    Image img = Toolkit.getDefaultToolkit().createImage(filtered);

    BufferedImage buffImage = new BufferedImage(img.getWidth(null),
            img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ImageFilterTest.java

示例7: createDisabledImage

import java.awt.Image; //导入方法依赖的package包/类
static Image createDisabledImage(Image img) {
    ImageProducer prod = new FilteredImageSource(img.getSource(), DISABLED_BUTTON_FILTER);
    return Toolkit.getDefaultToolkit().createImage(prod);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ImageUtilities.java

示例8: MultiResolutionToolkitImage

import java.awt.Image; //导入方法依赖的package包/类
public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
    super(lowResolutionImage.getSource());
    this.resolutionVariant = resolutionVariant;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:MultiResolutionToolkitImage.java

示例9: PixelGrabber

import java.awt.Image; //导入方法依赖的package包/类
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image.  The pixels are
 * accumulated in the original ColorModel if the same ColorModel
 * is used for every call to setPixels, otherwise the pixels are
 * accumulated in the default RGB ColorModel.  If the forceRGB
 * parameter is true, then the pixels will be accumulated in the
 * default RGB ColorModel anyway.  A buffer is allocated by the
 * PixelGrabber to hold the pixels in either case.  If {@code (w < 0)} or
 * {@code (h < 0)}, then they will default to the remaining width and
 * height of the source data when that information is delivered.
 * @param img the image to retrieve the image data from
 * @param x the x coordinate of the upper left corner of the rectangle
 * of pixels to retrieve from the image, relative to the default
 * (unscaled) size of the image
 * @param y the y coordinate of the upper left corner of the rectangle
 * of pixels to retrieve from the image
 * @param w the width of the rectangle of pixels to retrieve
 * @param h the height of the rectangle of pixels to retrieve
 * @param forceRGB true if the pixels should always be converted to
 * the default RGB ColorModel
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    boolean forceRGB)
{
    producer = img.getSource();
    dstX = x;
    dstY = y;
    dstW = w;
    dstH = h;
    if (forceRGB) {
        imageModel = ColorModel.getRGBdefault();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:PixelGrabber.java


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