下面列出了怎么用sun.awt.image.ToolkitImage的API类实例代码及写法,或者点击链接到github查看源代码。
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
@Override
public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
if (w == 0 || h == 0) {
return true;
}
// Must be a ToolkitImage
if (!(img instanceof ToolkitImage)) {
return true;
}
ToolkitImage tkimg = (ToolkitImage)img;
if (tkimg.hasError()) {
if (o != null) {
o.imageUpdate(img, ImageObserver.ERROR|ImageObserver.ABORT,
-1, -1, -1, -1);
}
return false;
}
ImageRepresentation ir = tkimg.getImageRep();
return ir.prepare(o) & prepareResolutionVariant(img, w, h, o);
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
protected BufferedImage getBufferedImage(Image img) {
if (img instanceof BufferedImage) {
// Otherwise we expect a BufferedImage to behave as a standard BI
return (BufferedImage)img;
} else if (img instanceof ToolkitImage) {
// This can be null if the image isn't loaded yet.
// This is fine as in that case our caller will return
// as it will only draw a fully loaded image
return ((ToolkitImage)img).getBufferedImage();
} else if (img instanceof VolatileImage) {
// VI needs to make a new BI: this is unavoidable but
// I don't expect VI's to be "huge" in any case.
return ((VolatileImage)img).getSnapshot();
} else {
// may be null or may be some non-standard Image which
// shouldn't happen as Image is implemented by the platform
// not by applications
// If you add a new Image implementation to the platform you
// will need to support it here similarly to VI.
return null;
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor, observer);
}
}
@Override
public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
if (w == 0 || h == 0) {
return true;
}
// Must be a ToolkitImage
if (!(img instanceof ToolkitImage)) {
return true;
}
ToolkitImage tkimg = (ToolkitImage)img;
if (tkimg.hasError()) {
if (o != null) {
o.imageUpdate(img, ImageObserver.ERROR|ImageObserver.ABORT,
-1, -1, -1, -1);
}
return false;
}
ImageRepresentation ir = tkimg.getImageRep();
return ir.prepare(o) & prepareResolutionVariant(img, w, h, o);
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgColor, observer);
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int dx, int dy, int sx, int sy, int w, int h,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg,
dx, dy, (dx + w), (dy + h),
sx, sy, (sx + w), (sy + h),
bgColor, observer);
}
}
public boolean scaleImage(SunGraphics2D sg, Image img,
int x, int y,
int width, int height,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return scaleImage(sg, img, x, y, width, height, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, width, height, bgColor,
observer);
}
}
public boolean copyImage(SunGraphics2D sg, Image img,
int x, int y,
Color bgColor,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
return copyImage(sg, img, x, y, bgColor);
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, x, y, bgColor, observer);
}
}
public IconInfo(Image image) {
this.image = image;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
this.width = ir.getWidth();
this.height = ir.getHeight();
} else {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
this.scaledWidth = width;
this.scaledHeight = height;
this.rawLength = width * height + 2;
}
public boolean transformImage(SunGraphics2D sg, Image img,
AffineTransform atfm,
ImageObserver observer) {
if (!(img instanceof ToolkitImage)) {
transformImage(sg, img, 0, 0, atfm, sg.interpolationType);
return true;
} else {
ToolkitImage sunimg = (ToolkitImage)img;
if (!imageReady(sunimg, observer)) {
return false;
}
ImageRepresentation ir = sunimg.getImageRep();
return ir.drawToBufImage(sg, sunimg, atfm, observer);
}
}