本文整理汇总了Java中java.awt.MediaTracker.removeImage方法的典型用法代码示例。如果您正苦于以下问题:Java MediaTracker.removeImage方法的具体用法?Java MediaTracker.removeImage怎么用?Java MediaTracker.removeImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.MediaTracker
的用法示例。
在下文中一共展示了MediaTracker.removeImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testToolkitMultiResolutionImageLoad
import java.awt.MediaTracker; //导入方法依赖的package包/类
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {
MediaTracker tracker = new MediaTracker(new JPanel());
tracker.addImage(image, 0);
tracker.waitForID(0);
if (tracker.isErrorAny()) {
throw new RuntimeException("Error during image loading");
}
tracker.removeImage(image, 0);
testImageLoaded(image);
int w = image.getWidth(null);
int h = image.getHeight(null);
Image resolutionVariant = ((MultiResolutionImage) image)
.getResolutionVariant(2 * w, 2 * h);
if (image == resolutionVariant) {
throw new RuntimeException("Resolution variant is not loaded");
}
testImageLoaded(resolutionVariant);
}
示例2: testToolkitMultiResolutionImageLoad
import java.awt.MediaTracker; //导入方法依赖的package包/类
static void testToolkitMultiResolutionImageLoad(Image image)
throws Exception {
MediaTracker tracker = new MediaTracker(new JPanel());
tracker.addImage(image, 0);
tracker.waitForID(0);
if (tracker.isErrorAny()) {
throw new RuntimeException("Error during image loading");
}
tracker.removeImage(image, 0);
testImageLoaded(image);
int w = image.getWidth(null);
int h = image.getHeight(null);
Image resolutionVariant = ((MultiResolutionImage) image)
.getResolutionVariant(2 * w, 2 * h);
if (image == resolutionVariant) {
throw new RuntimeException("Resolution variant is not loaded");
}
testImageLoaded(resolutionVariant);
}
示例3: prepareImages
import java.awt.MediaTracker; //导入方法依赖的package包/类
public void prepareImages() {
if (prepared) {
return;
}
MediaTracker mt = new MediaTracker(this);
for (int i = 0; i < images.length; i++) {
mt.addImage(images[i], i);
}
try {
mt.waitForAll();
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 0; i < images.length; i++) {
mt.removeImage(images[i], i);
}
if (params.scaleFactor != 1) {
// TODO: scale if needed
logger.unimplemented("image_scaling");
}
prepared = true;
}
示例4: pingstat
import java.awt.MediaTracker; //导入方法依赖的package包/类
static private void pingstat() {
final int i = (int) (100.0 * ThreadLocalRandom.current().nextDouble());
try {
final URL url = new URL("http://c.statcounter.com/9994681/0/14bb645e/1/?reco=" + i + "");
url.openConnection().setConnectTimeout(5000);
final Image image = Toolkit.getDefaultToolkit().createImage(url);
final MediaTracker mediatracker = new MediaTracker(app);
mediatracker.addImage(image, 0);
mediatracker.waitForID(0);
mediatracker.removeImage(image, 0);
} catch (final Exception ignored) {
}
}
示例5: ensureImageLoaded
import java.awt.MediaTracker; //导入方法依赖的package包/类
public static void ensureImageLoaded(final Image anImage) {
final MediaTracker tracker = new MediaTracker(component);
tracker.addImage(anImage, 1);
try {
tracker.waitForAll();
tracker.removeImage(anImage);
} catch (final InterruptedException ignored) {
Thread.currentThread().interrupt();
}
}
示例6: paint
import java.awt.MediaTracker; //导入方法依赖的package包/类
public void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
//
// Load Image
//
Image image = Toolkit.getDefaultToolkit().createImage("test-resources/org/apache/batik/svggen/resources/vangogh.png");
MediaTracker tracker = new MediaTracker(new Button(""));
tracker.addImage(image, 0);
try{
tracker.waitForAll();
}catch(InterruptedException e){
tracker.removeImage(image);
image = null;
}finally {
if(image != null)
tracker.removeImage(image);
if(tracker.isErrorAny())
image = null;
if(image != null){
if(image.getWidth(null)<0 ||
image.getHeight(null)<0)
image = null;
}
}
if(image == null){
throw new Error("Could not load image");
}
BufferedImage bi = new BufferedImage(image.getWidth(null),
image.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D ig = bi.createGraphics();
ig.drawImage(image, 0, 0, null);
byte[] lookup = new byte[256];
for(int i=0; i<256; i++)
lookup[i] = (byte)(255 - i);
LookupTable table = new ByteLookupTable(0, lookup);
java.awt.image.LookupOp inverter = new java.awt.image.LookupOp(table, null);
// Simply paint the image without and with the lookup filter
g.setPaint(Color.black);
g.drawString("Normal / Inverted", 10, 20);
g.drawImage(image, 10, 30, null);
g.drawImage(bi, inverter, 10 + bi.getWidth() + 10, 30);
}
示例7: paint
import java.awt.MediaTracker; //导入方法依赖的package包/类
public void paint(Graphics2D g) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
//
// Load Image
//
Image image = Toolkit.getDefaultToolkit().createImage("test-resources/org/apache/batik/svggen/resources/vangogh.jpg");
MediaTracker tracker = new MediaTracker(new Button(""));
tracker.addImage(image, 0);
try{
tracker.waitForAll();
}catch(InterruptedException e){
tracker.removeImage(image);
image = null;
}finally {
if(image != null)
tracker.removeImage(image);
if(tracker.isErrorAny())
image = null;
if(image != null){
if(image.getWidth(null)<0 ||
image.getHeight(null)<0)
image = null;
}
}
if(image == null){
throw new Error("Could not load image");
}
BufferedImage bi = new BufferedImage(image.getWidth(null),
image.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D ig = bi.createGraphics();
ig.drawImage(image, 0, 0, null);
java.awt.image.RescaleOp brighten = new java.awt.image.RescaleOp(1.5f, 0, null);
java.awt.image.RescaleOp darken = new java.awt.image.RescaleOp(.6f, 0, null);
// Simply paint the image without and with rescale filters
g.setPaint(Color.black);
g.drawString("Brighter / Normal / Darker", 10, 20);
g.drawImage(bi, brighten, 10, 30);
g.drawImage(image, 10 + bi.getWidth() + 10, 30, null);
g.drawImage(bi, darken, 10 + 2*(bi.getWidth() + 10), 30);
g.translate(0, bi.getHeight() + 30 + 20);
g.drawString("Rescale Red / Green / Blue", 10, 20);
java.awt.image.RescaleOp redStress = new java.awt.image.RescaleOp(new float[]{ 2.0f, 1.0f, 1.0f },
new float[]{ 0, 0, 0 }, null);
java.awt.image.RescaleOp greenStress = new java.awt.image.RescaleOp(new float[]{ 1.0f, 2.0f, 1.0f },
new float[]{ 0, 0, 0 }, null);
java.awt.image.RescaleOp blueStress = new java.awt.image.RescaleOp(new float[]{ 1.0f, 1.0f, 2.0f },
new float[]{ 0, 0, 0 }, null);
g.drawImage(bi, redStress, 10, 30);
g.drawImage(bi, greenStress, 10 + bi.getWidth() + 10, 30);
g.drawImage(bi, blueStress, 10 + 2*(bi.getWidth() + 10), 30);
}