summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/ImageConverter.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/ImageConverter.java')
-rw-r--r--NET/worlds/scape/ImageConverter.java186
1 files changed, 186 insertions, 0 deletions
diff --git a/NET/worlds/scape/ImageConverter.java b/NET/worlds/scape/ImageConverter.java
new file mode 100644
index 0000000..9848a08
--- /dev/null
+++ b/NET/worlds/scape/ImageConverter.java
@@ -0,0 +1,186 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import java.awt.Image;
+/* */ import java.awt.Toolkit;
+/* */ import java.awt.image.ColorModel;
+/* */ import java.awt.image.DirectColorModel;
+/* */ import java.awt.image.ImageConsumer;
+/* */ import java.awt.image.ImageProducer;
+/* */ import java.awt.image.IndexColorModel;
+/* */ import java.io.PrintStream;
+/* */ import java.util.Hashtable;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class ImageConverter
+/* */ implements ImageConsumer
+/* */ {
+/* */ private String urlName;
+/* */ private String filename;
+/* */ private int width;
+/* */ private int height;
+/* */ private Image image;
+/* */ private boolean done;
+/* */ private boolean ok;
+/* 29 */ private boolean debug = false;
+/* */ private ColorModel model;
+/* 31 */ private int transparentColor = -1;
+/* */ private int hDIB;
+/* */ private int pixelPtr;
+/* */
+/* */ public ImageConverter(String urlName, String filename)
+/* */ {
+/* 37 */ this.urlName = urlName;
+/* 38 */ this.filename = filename;
+/* */ }
+/* */
+/* */
+/* */ static
+/* */ {
+/* 44 */ nativeInit();
+/* */ }
+/* */
+/* */ public synchronized int convert()
+/* */ {
+/* 49 */ this.image = Toolkit.getDefaultToolkit().getImage(this.filename);
+/* 50 */ this.image.getSource().startProduction(this);
+/* */
+/* 52 */ while (!this.done) {
+/* */ try {
+/* 54 */ wait();
+/* */ }
+/* */ catch (InterruptedException localInterruptedException) {}
+/* */ }
+/* 58 */ int textureID = 0;
+/* 59 */ if (this.ok)
+/* 60 */ textureID = convertDIBToTexture();
+/* 61 */ cleanup();
+/* 62 */ return textureID;
+/* */ }
+/* */
+/* */ public void setDimensions(int width, int height)
+/* */ {
+/* 67 */ if (this.debug)
+/* 68 */ System.out.println("Set dimensions: w " + width + " h " + height);
+/* 69 */ this.width = width;
+/* 70 */ this.height = height;
+/* */ }
+/* */
+/* */ public void setProperties(Hashtable<?, ?> props)
+/* */ {
+/* 75 */ if (this.debug) {
+/* 76 */ System.out.println("Set properties");
+/* */ }
+/* */ }
+/* */
+/* */ public void setColorModel(ColorModel model) {
+/* 81 */ if (this.debug) {
+/* 82 */ System.out.println("Set color model: " + model);
+/* */ }
+/* 84 */ this.model = model;
+/* 85 */ assert ((this.width != 0) && (this.height != 0));
+/* 86 */ int[] palette = null;
+/* 87 */ int colors = 0;
+/* 88 */ if ((model instanceof IndexColorModel)) {
+/* 89 */ IndexColorModel im = (IndexColorModel)model;
+/* 90 */ colors = im.getMapSize();
+/* 91 */ this.transparentColor = im.getTransparentPixel();
+/* 92 */ palette = new int[colors * 3];
+/* 93 */ for (int i = 0; i < colors; i++)
+/* 94 */ palette[i] = im.getRGB(i);
+/* */ } else {
+/* 96 */ DirectColorModel dm = (DirectColorModel)model;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 102 */ assert (dm.getBlueMask() == 255);
+/* 103 */ assert (dm.getGreenMask() == 65280);
+/* 104 */ assert (dm.getRedMask() == 16711680);
+/* */ }
+/* 106 */ prepareDIB(this.width, this.height, colors, palette);
+/* */ }
+/* */
+/* */ public void setHints(int hintflags)
+/* */ {
+/* 111 */ if (this.debug) {
+/* 112 */ System.out.println("Set hints: " + (
+/* 113 */ (hintflags & 0x1) != 0 ? " RANDOM " : "") + (
+/* 114 */ (hintflags & 0x2) != 0 ? " TOPDOWNLEFTRIGHT " : "") + (
+/* 115 */ (hintflags & 0x4) != 0 ? " COMPLETESCANS " : "") + (
+/* 116 */ (hintflags & 0x8) != 0 ? " SINGLEPASS " : "") + (
+/* 117 */ (hintflags & 0x10) != 0 ? " SINGLEFRAME " : ""));
+/* */ }
+/* */ }
+/* */
+/* */ public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
+/* */ {
+/* 123 */ if (this.debug)
+/* 124 */ System.out.println("setPixels(byte): x " + x + " y " + y + " w " +
+/* 125 */ w + " h " + h + " model " + model + " off " +
+/* 126 */ off + " scansize " + scansize);
+/* 127 */ assert (model == this.model);
+/* 128 */ setDIBPixelBytes(x, y, w, h, pixels, off, scansize);
+/* */ }
+/* */
+/* */
+/* */ public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
+/* */ {
+/* 134 */ if (this.debug)
+/* 135 */ System.out.println("setPixels(int): x " + x + " y " + y + " w " +
+/* 136 */ w + " h " + h + " model " + model + " off " +
+/* 137 */ off + " scansize " + scansize);
+/* 138 */ assert (model == this.model);
+/* 139 */ setDIBPixelInts(x, y, w, h, pixels, off, scansize);
+/* */ }
+/* */
+/* */ public synchronized void imageComplete(int status)
+/* */ {
+/* 144 */ if (this.debug) {
+/* 145 */ String state = null;
+/* 146 */ switch (status) {
+/* */ case 1:
+/* 148 */ state = "ERROR";
+/* 149 */ break;
+/* */ case 2:
+/* 151 */ state = "SINGLEDONE";
+/* 152 */ break;
+/* */ case 3:
+/* 154 */ state = "STATICDONE";
+/* 155 */ break;
+/* */ case 4:
+/* 157 */ state = "ABORTED";
+/* */ }
+/* */
+/* 160 */ System.out.println("Image complete: " + state);
+/* */ }
+/* 162 */ this.image.getSource().removeConsumer(this);
+/* 163 */ this.image.flush();
+/* 164 */ this.ok = ((status != 1) && (status != 4));
+/* 165 */ this.done = true;
+/* 166 */ notify();
+/* */ }
+/* */
+/* */ public static native void nativeInit();
+/* */
+/* */ private native void prepareDIB(int paramInt1, int paramInt2, int paramInt3, int[] paramArrayOfInt);
+/* */
+/* */ private native void setDIBPixelBytes(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte[] paramArrayOfByte, int paramInt5, int paramInt6);
+/* */
+/* */ private native void setDIBPixelInts(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int[] paramArrayOfInt, int paramInt5, int paramInt6);
+/* */
+/* */ private native int convertDIBToTexture();
+/* */
+/* */ private native void cleanup();
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ImageConverter.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file