Java Code Examples for java.awt.Image#getSource()

The following examples show how to use java.awt.Image#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageFilterTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: MultiResolutionToolkitImage.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
    super(lowResolutionImage.getSource());
    this.resolutionVariant = resolutionVariant;
}
 
Example 3
Source File: ImageInfoReader.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
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);
}
 
Example 4
Source File: MultiResolutionToolkitImage.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
    super(lowResolutionImage.getSource());
    this.resolutionVariant = resolutionVariant;
}
 
Example 5
Source File: ImageLoader.java    From pumpernickel with MIT License 4 votes vote down vote up
protected static BufferedImage createImage(Image i, String description) {
	ImageLoader l = new ImageLoader(i.getSource(), null, null, description);
	return l.getImage();
}
 
Example 6
Source File: BackgroundPainter.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
private Image filterImage(Image sourceImage, ImageFilter imageFilter) {
	ImageProducer ip = new FilteredImageSource(sourceImage.getSource(), imageFilter);
	return Toolkit.getDefaultToolkit().createImage(ip);
}
 
Example 7
Source File: ImageHelper.java    From binnavi with Apache License 2.0 4 votes vote down vote up
public static Image filterImage(final Image inImage, final ImageFilter filter) {
  final ImageProducer imageProducer = new FilteredImageSource(inImage.getSource(), filter);
  return Toolkit.getDefaultToolkit().createImage(imageProducer);
}
 
Example 8
Source File: MultiResolutionToolkitImage.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public MultiResolutionToolkitImage(Image lowResolutionImage, Image resolutionVariant) {
    super(lowResolutionImage.getSource());
    this.resolutionVariant = resolutionVariant;
}
 
Example 9
Source File: PixelGrabber.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * 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();
    }
}
 
Example 10
Source File: PixelGrabber.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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();
    }
}
 
Example 11
Source File: PixelGrabber.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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();
    }
}
 
Example 12
Source File: PixelGrabber.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * 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 (w < 0) or
 * (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();
    }
}
 
Example 13
Source File: PixelGrabber.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * 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();
    }
}
 
Example 14
Source File: PixelGrabber.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 15
Source File: PixelGrabber.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 16
Source File: PixelGrabber.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 17
Source File: PixelGrabber.java    From jdk-1.7-annotated with Apache License 2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 18
Source File: PixelGrabber.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 19
Source File: PixelGrabber.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}
 
Example 20
Source File: PixelGrabber.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 * section of pixels from the specified image into the given array.
 * The pixels are stored into the array in the default RGB ColorModel.
 * The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 * (x, y, w, h) is stored in the array at
 * {@code pix[(j - y) * scansize + (i - x) + off]}.
 * @see ColorModel#getRGBdefault
 * @param img the image to retrieve pixels 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 pix the array of integers which are to be used to hold the
 * RGB pixels retrieved from the image
 * @param off the offset into the array of where to store the first pixel
 * @param scansize the distance from one row of pixels to the next in
 * the array
 */
public PixelGrabber(Image img, int x, int y, int w, int h,
                    int[] pix, int off, int scansize) {
    this(img.getSource(), x, y, w, h, pix, off, scansize);
}