forked from External/mage
Removed a couple of duplicate files.
This commit is contained in:
parent
8ec8be115c
commit
e8426e6e71
13 changed files with 171 additions and 618 deletions
|
|
@ -1,71 +0,0 @@
|
|||
package org.mage.plugins.card.utils;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
/**
|
||||
* Utility class for creating BufferedImage object from Image instance.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class BufferedImageBuilder {
|
||||
|
||||
private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB;
|
||||
|
||||
/**
|
||||
* Hide constructor
|
||||
*/
|
||||
private BufferedImageBuilder() {
|
||||
|
||||
}
|
||||
|
||||
public static BufferedImage bufferImage(Image image) {
|
||||
return bufferImage(image, DEFAULT_IMAGE_TYPE);
|
||||
}
|
||||
|
||||
public static BufferedImage bufferImage(Image image, int type) {
|
||||
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
|
||||
Graphics2D g = bufferedImage.createGraphics();
|
||||
g.drawImage(image, null, null);
|
||||
//waitForImage(bufferedImage);
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
private void waitForImage(BufferedImage bufferedImage) {
|
||||
final ImageLoadStatus imageLoadStatus = new ImageLoadStatus();
|
||||
bufferedImage.getHeight(new ImageObserver() {
|
||||
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
|
||||
if (infoflags == ALLBITS) {
|
||||
imageLoadStatus.heightDone = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
bufferedImage.getWidth(new ImageObserver() {
|
||||
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
|
||||
if (infoflags == ALLBITS) {
|
||||
imageLoadStatus.widthDone = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ImageLoadStatus {
|
||||
|
||||
public boolean widthDone = false;
|
||||
public boolean heightDone = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import java.net.URL;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.mage.plugins.card.utils.BufferedImageBuilder;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import org.mage.plugins.card.utils.ImageManager;
|
||||
import org.mage.plugins.card.utils.Transparency;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue