本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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]);
}
示例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);
}
示例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);
}
示例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);
}
示例8: MultiResolutionToolkitImage
import java.awt.Image; //导入方法依赖的package包/类
public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
super(lowResolutionImage.getSource());
this.resolutionVariant = resolutionVariant;
}
示例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();
}
}