MathWizz wrote:
I have good news and bad news. The bad news is that the player doesn't fix references to other objects properly and will need to be completely recoded. The good news is that I have recoded it. Now to move on to decoding images, decoding sounds, or writing classes (sprites, stage, watchers.)
Read the image code and put it into a variable called image , put the file extension into a variable called imageExt, and do this:
document.write('<img src="data:image/' + imageExt + ';base64,' + image + '">');
Offline
cocolover76 wrote:
MathWizz wrote:
I have good news and bad news. The bad news is that the player doesn't fix references to other objects properly and will need to be completely recoded. The good news is that I have recoded it. Now to move on to decoding images, decoding sounds, or writing classes (sprites, stage, watchers.)
Read the image code and put it into a variable called image , put the file extension into a variable called imageExt, and do this:
Code:
document.write('<img src="data:image/' + imageExt + ';base64,' + image + '">');
Unfortunately, due to the way morphic works, it is slightly more complicated than that to get everything to work with everything else.
Offline
rookwood101 wrote:
cocolover76 wrote:
MathWizz wrote:
I have good news and bad news. The bad news is that the player doesn't fix references to other objects properly and will need to be completely recoded. The good news is that I have recoded it. Now to move on to decoding images, decoding sounds, or writing classes (sprites, stage, watchers.)
Read the image code and put it into a variable called image , put the file extension into a variable called imageExt, and do this:
Code:
document.write('<img src="data:image/' + imageExt + ';base64,' + image + '">');Unfortunately, due to the way morphic works, it is slightly more complicated than that to get everything to work with everything else.
Why does everyone think jQuery, image tags, and events work in canvas?
Offline
I'm checking this out. I have dropping binary images onto canvas in my background.
Offline
Hey math, where's the binary costume data located?
I've noticed in your code you use many statements to fill a class. Why don't you just add them all right in?
You:
function Person(){ } Person.prototype.phrase = "hello"; Person.prototype.sayhello = function(){say(this.phrase);};
Why not:
function Person(){ this.phrase = "hello"; this.sayhello = function(){ this.say(this.phrase); } }
Offline
midnightleopard wrote:
Hey math, where's the binary costume data located?
It's all in a Form in a field named 'bits'.
midnightleopard wrote:
I've noticed in your code you use many statements to fill a class. Why don't you just add them all right in?
You:Code:
function Person(){ } Person.prototype.phrase = "hello"; Person.prototype.sayhello = function(){say(this.phrase);};Why not:
Code:
function Person(){ this.phrase = "hello"; this.sayhello = function(){ this.say(this.phrase); } }
I was wondering why I did that myself yesterday. If you look at morphic.js, all of the classes are like that so I am just following his example.
Last edited by MathWizz (2011-12-03 10:16:21)
Offline
midnightleopard wrote:
rookwood101 wrote:
cocolover76 wrote:
Read the image code and put it into a variable called image , put the file extension into a variable called imageExt, and do this:Code:
document.write('<img src="data:image/' + imageExt + ';base64,' + image + '">');Unfortunately, due to the way morphic works, it is slightly more complicated than that to get everything to work with everything else.
Why does everyone think jQuery, image tags, and events work in canvas?
It was just some code so you'd believe me.
Just make an ImageMorph or something.
Offline
MathWizz wrote:
Code:
var image = new Image(); image.src = <base64 encoded image here> image.onload = function() { //insert drawing code here }
var image = new Image(); image.src = "data:image/" + imageExt + ";base64," + image image.onload = function() { //insert drawing code here }
Offline
MathWizz wrote:
I was wondering why I did that myself yesterday. If you look at morphic.js, all of the classes are like that so I am just following his example.
Well, we've gotten to far to stop, but it makes it alot harder to understand.
Offline
Ok, time to decode images.
Java:
void buildImagesAndSounds() throws IOException { for (int i = 0; i < this.objTable.length; i++) { int j = ((Number)this.objTable[i][1]).intValue(); Object[] arrayOfObject; if ((j == 34) || (j == 35)) { arrayOfObject = (Object[])this.objTable[i][0]; int k = ((Number)arrayOfObject[0]).intValue(); int m = ((Number)arrayOfObject[1]).intValue(); int n = ((Number)arrayOfObject[2]).intValue(); int[] arrayOfInt = decodePixels(this.objTable[((Ref)arrayOfObject[4]).index][0]); MemoryImageSource localMemoryImageSource = null; this.objTable[i][0] = empty; Object[] localObject2; Object localObject1; if (n <= 8) { if (arrayOfObject[5] != null) { localObject2 = (Object[])this.objTable[((Ref)arrayOfObject[5]).index][0]; localObject1 = customColorMap(n, localObject2); } else localObject1 = squeakColorMap(n); localMemoryImageSource = new MemoryImageSource(k, m, (ColorModel)localObject1, rasterToByteRaster(arrayOfInt, k, m, n), 0, k); } if (n == 16) localMemoryImageSource = new MemoryImageSource(k, m, raster16to32(arrayOfInt, k, m), 0, k); if (n == 32) localMemoryImageSource = new MemoryImageSource(k, m, rasterAddAlphaTo32(arrayOfInt), 0, k); if (localMemoryImageSource != null) { localObject1 = new int[k * m]; localObject2 = new PixelGrabber(localMemoryImageSource, 0, 0, k, m, localObject1, 0, k); try { ((PixelGrabber)localObject2).grabPixels(); } catch (InterruptedException localInterruptedException) { } BufferedImage localBufferedImage = new BufferedImage(k, m, 2); localBufferedImage.getRaster().setDataElements(0, 0, k, m, localObject1); this.objTable[i][0] = localBufferedImage; } } if (j == 109) { arrayOfObject = this.objTable[((Ref)this.objTable[i][6]).index]; this.objTable[i][0] = new ScratchSound(((Number)this.objTable[i][7]).intValue(), (byte[])arrayOfObject[0]); } } } int[] decodePixels(Object paramObject) throws IOException { if ((paramObject instanceof int[])) return (int[])paramObject; DataInputStream localDataInputStream = new DataInputStream(new ByteArrayInputStream((byte[])paramObject)); int i = decodeInt(localDataInputStream); int[] arrayOfInt = new int[i]; int j = 0; int m; int i2; int i3; while (((localDataInputStream.available() > 0 ? 1 : 0) & (j < i ? 1 : 0)) != 0) { int k = decodeInt(localDataInputStream); m = k >> 2; int n = k & 0x3; switch (n) { case 0: j += m; break; case 1: int i1 = localDataInputStream.readUnsignedByte(); i2 = i1 << 24 | i1 << 16 | i1 << 8 | i1; for (i3 = 0; i3 < m;) { arrayOfInt[(j++)] = i2; i3++; i2 = localDataInputStream.readInt(); for (i3 = 0; i3 < m; ) { arrayOfInt[(j++)] = i2; i3++; for (i3 = 0; i3 < m; i3++) { i2 = localDataInputStream.readUnsignedByte() << 24; i2 |= localDataInputStream.readUnsignedByte() << 16; i2 |= localDataInputStream.readUnsignedByte() << 8; i2 |= localDataInputStream.readUnsignedByte(); arrayOfInt[(j++)] = i2; } } } case 2: case 3: } } return arrayOfInt; } int decodeInt(DataInputStream paramDataInputStream) throws IOException { int i = paramDataInputStream.readUnsignedByte(); if (i <= 223) return i; if (i <= 254) return (i - 224) * 256 + paramDataInputStream.readUnsignedByte(); return paramDataInputStream.readInt(); } int[] rasterAddAlphaTo32(int[] paramArrayOfInt) { for (int i = 0; i < paramArrayOfInt.length; i++) { int j = paramArrayOfInt[i]; if (j != 0) paramArrayOfInt[i] = (0xFF000000 | j); } return paramArrayOfInt; } int[] raster16to32(int[] paramArrayOfInt, int paramInt1, int paramInt2) { int[] arrayOfInt = new int[paramInt1 * paramInt2]; int i2 = (paramInt1 + 1) / 2; for (int i3 = 0; i3 < paramInt2; i3++) { int i = 16; for (int i4 = 0; i4 < paramInt1; i4++) { int j = paramArrayOfInt[(i3 * i2 + i4 / 2)] >> i & 0xFFFF; int k = (j >> 10 & 0x1F) << 3; int m = (j >> 5 & 0x1F) << 3; int n = (j & 0x1F) << 3; int i1 = k + m + n == 0 ? 0 : 0xFF000000 | k << 16 | m << 8 | n; arrayOfInt[(i3 * paramInt1 + i4)] = i1; i = i == 16 ? 0 : 16; } } return arrayOfInt; } byte[] rasterToByteRaster(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3) { byte[] arrayOfByte = new byte[paramInt1 * paramInt2]; int i = paramArrayOfInt.length / paramInt2; int j = (1 << paramInt3) - 1; int k = 32 / paramInt3; for (int m = 0; m < paramInt2; m++) { for (int n = 0; n < paramInt1; n++) { int i1 = paramArrayOfInt[(m * i + n / k)]; int i2 = paramInt3 * (k - n % k - 1); arrayOfByte[(m * paramInt1 + n)] = (byte)(i1 >> i2 & j); } } return arrayOfByte; } IndexColorModel squeakColorMap(int paramInt) { int i = paramInt == 1 ? -1 : 0; return new IndexColorModel(paramInt, 256, squeakColors, 0, false, i); } IndexColorModel customColorMap(int paramInt, Object[] paramArrayOfObject) { byte[] arrayOfByte = new byte[4 * paramArrayOfObject.length]; int i = 0; for (int j = 0; j < paramArrayOfObject.length; j++) { Color localColor = (Color)this.objTable[((Ref)paramArrayOfObject[j]).index][0]; arrayOfByte[(i++)] = (byte)localColor.getRed(); arrayOfByte[(i++)] = (byte)localColor.getGreen(); arrayOfByte[(i++)] = (byte)localColor.getBlue(); arrayOfByte[(i++)] = (byte)localColor.getAlpha(); } return new IndexColorModel(paramInt, paramArrayOfObject.length, arrayOfByte, 0, true, 0); } void fixSounds() { int i = 0; int k; for (int j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if ((k == 109) && (((ScratchSound)this.objTable[j][0]).isByteReversed())) i = 1; } if (i == 0) return; for (j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if (k == 109) ((ScratchSound)this.objTable[j][0]).reverseBytes(); } } void uncompressMedia() { for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); int k = -1; if (j >= 100) k = ((Number)arrayOfObject[2]).intValue(); if ((j == 162) && (k >= 4)) { if ((arrayOfObject[7] instanceof byte[])) { BufferedImage localBufferedImage = jpegDecode((byte[])arrayOfObject[7]); if (localBufferedImage != null) { if ((arrayOfObject[4] instanceof Image)) ((Image)arrayOfObject[4]).flush(); arrayOfObject[4] = localBufferedImage; arrayOfObject[7] = empty; } } if ((arrayOfObject[8] instanceof BufferedImage)) { arrayOfObject[4] = arrayOfObject[8]; arrayOfObject[8] = empty; } } if ((j != 164) || (k < 2) || (!(arrayOfObject[9] instanceof byte[]))) continue; int m = ((Number)arrayOfObject[7]).intValue(); int n = ((Number)arrayOfObject[8]).intValue(); byte[] arrayOfByte = (byte[])arrayOfObject[9]; int i1 = (arrayOfByte.length * 8 + (n - 1)) / n; int[] arrayOfInt = new ADPCMDecoder(arrayOfByte, n).decode(i1); arrayOfObject[4] = new ScratchSound(m, arrayOfInt); Object[] tmp261_260 = (arrayOfObject[9] = = empty); arrayOfObject[8] = tmp261_260; arrayOfObject[7] = tmp261_260; } } void canonicalizeMedia() { Vector localVector1 = new Vector(100); Vector localVector2 = new Vector(100); for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); Object localObject; if (j == 162) localObject = (BufferedImage)arrayOfObject[4]; if (j == 164) localObject = (ScratchSound)arrayOfObject[4]; } } BufferedImage jpegDecode(byte[] paramArrayOfByte) { Toolkit localToolkit = Toolkit.getDefaultToolkit(); Image localImage = localToolkit.createImage(paramArrayOfByte); MediaTracker localMediaTracker = new MediaTracker(canvas); localMediaTracker.addImage(localImage, 0); try { localMediaTracker.waitForID(0); } catch (InterruptedException localInterruptedException) { } if (localImage == null) return null; int i = localImage.getWidth(null); int j = localImage.getHeight(null); BufferedImage localBufferedImage = new BufferedImage(i, j, 2); Graphics localGraphics = localBufferedImage.getGraphics(); localGraphics.drawImage(localImage, 0, 0, i, j, null); localGraphics.dispose(); localImage.flush(); return localBufferedImage; }
Ok. I'll work on something else now... Jk. *sigh*
Offline
MathWizz wrote:
Ok, time to decode images.
Java:Code:
void buildImagesAndSounds() throws IOException { for (int i = 0; i < this.objTable.length; i++) { int j = ((Number)this.objTable[i][1]).intValue(); Object[] arrayOfObject; if ((j == 34) || (j == 35)) { arrayOfObject = (Object[])this.objTable[i][0]; int k = ((Number)arrayOfObject[0]).intValue(); int m = ((Number)arrayOfObject[1]).intValue(); int n = ((Number)arrayOfObject[2]).intValue(); int[] arrayOfInt = decodePixels(this.objTable[((Ref)arrayOfObject[4]).index][0]); MemoryImageSource localMemoryImageSource = null; this.objTable[i][0] = empty; Object[] localObject2; Object localObject1; if (n <= 8) { if (arrayOfObject[5] != null) { localObject2 = (Object[])this.objTable[((Ref)arrayOfObject[5]).index][0]; localObject1 = customColorMap(n, localObject2); } else localObject1 = squeakColorMap(n); localMemoryImageSource = new MemoryImageSource(k, m, (ColorModel)localObject1, rasterToByteRaster(arrayOfInt, k, m, n), 0, k); } if (n == 16) localMemoryImageSource = new MemoryImageSource(k, m, raster16to32(arrayOfInt, k, m), 0, k); if (n == 32) localMemoryImageSource = new MemoryImageSource(k, m, rasterAddAlphaTo32(arrayOfInt), 0, k); if (localMemoryImageSource != null) { localObject1 = new int[k * m]; localObject2 = new PixelGrabber(localMemoryImageSource, 0, 0, k, m, localObject1, 0, k); try { ((PixelGrabber)localObject2).grabPixels(); } catch (InterruptedException localInterruptedException) { } BufferedImage localBufferedImage = new BufferedImage(k, m, 2); localBufferedImage.getRaster().setDataElements(0, 0, k, m, localObject1); this.objTable[i][0] = localBufferedImage; } } if (j == 109) { arrayOfObject = this.objTable[((Ref)this.objTable[i][6]).index]; this.objTable[i][0] = new ScratchSound(((Number)this.objTable[i][7]).intValue(), (byte[])arrayOfObject[0]); } } } int[] decodePixels(Object paramObject) throws IOException { if ((paramObject instanceof int[])) return (int[])paramObject; DataInputStream localDataInputStream = new DataInputStream(new ByteArrayInputStream((byte[])paramObject)); int i = decodeInt(localDataInputStream); int[] arrayOfInt = new int[i]; int j = 0; int m; int i2; int i3; while (((localDataInputStream.available() > 0 ? 1 : 0) & (j < i ? 1 : 0)) != 0) { int k = decodeInt(localDataInputStream); m = k >> 2; int n = k & 0x3; switch (n) { case 0: j += m; break; case 1: int i1 = localDataInputStream.readUnsignedByte(); i2 = i1 << 24 | i1 << 16 | i1 << 8 | i1; for (i3 = 0; i3 < m;) { arrayOfInt[(j++)] = i2; i3++; i2 = localDataInputStream.readInt(); for (i3 = 0; i3 < m; ) { arrayOfInt[(j++)] = i2; i3++; for (i3 = 0; i3 < m; i3++) { i2 = localDataInputStream.readUnsignedByte() << 24; i2 |= localDataInputStream.readUnsignedByte() << 16; i2 |= localDataInputStream.readUnsignedByte() << 8; i2 |= localDataInputStream.readUnsignedByte(); arrayOfInt[(j++)] = i2; } } } case 2: case 3: } } return arrayOfInt; } int decodeInt(DataInputStream paramDataInputStream) throws IOException { int i = paramDataInputStream.readUnsignedByte(); if (i <= 223) return i; if (i <= 254) return (i - 224) * 256 + paramDataInputStream.readUnsignedByte(); return paramDataInputStream.readInt(); } int[] rasterAddAlphaTo32(int[] paramArrayOfInt) { for (int i = 0; i < paramArrayOfInt.length; i++) { int j = paramArrayOfInt[i]; if (j != 0) paramArrayOfInt[i] = (0xFF000000 | j); } return paramArrayOfInt; } int[] raster16to32(int[] paramArrayOfInt, int paramInt1, int paramInt2) { int[] arrayOfInt = new int[paramInt1 * paramInt2]; int i2 = (paramInt1 + 1) / 2; for (int i3 = 0; i3 < paramInt2; i3++) { int i = 16; for (int i4 = 0; i4 < paramInt1; i4++) { int j = paramArrayOfInt[(i3 * i2 + i4 / 2)] >> i & 0xFFFF; int k = (j >> 10 & 0x1F) << 3; int m = (j >> 5 & 0x1F) << 3; int n = (j & 0x1F) << 3; int i1 = k + m + n == 0 ? 0 : 0xFF000000 | k << 16 | m << 8 | n; arrayOfInt[(i3 * paramInt1 + i4)] = i1; i = i == 16 ? 0 : 16; } } return arrayOfInt; } byte[] rasterToByteRaster(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3) { byte[] arrayOfByte = new byte[paramInt1 * paramInt2]; int i = paramArrayOfInt.length / paramInt2; int j = (1 << paramInt3) - 1; int k = 32 / paramInt3; for (int m = 0; m < paramInt2; m++) { for (int n = 0; n < paramInt1; n++) { int i1 = paramArrayOfInt[(m * i + n / k)]; int i2 = paramInt3 * (k - n % k - 1); arrayOfByte[(m * paramInt1 + n)] = (byte)(i1 >> i2 & j); } } return arrayOfByte; } IndexColorModel squeakColorMap(int paramInt) { int i = paramInt == 1 ? -1 : 0; return new IndexColorModel(paramInt, 256, squeakColors, 0, false, i); } IndexColorModel customColorMap(int paramInt, Object[] paramArrayOfObject) { byte[] arrayOfByte = new byte[4 * paramArrayOfObject.length]; int i = 0; for (int j = 0; j < paramArrayOfObject.length; j++) { Color localColor = (Color)this.objTable[((Ref)paramArrayOfObject[j]).index][0]; arrayOfByte[(i++)] = (byte)localColor.getRed(); arrayOfByte[(i++)] = (byte)localColor.getGreen(); arrayOfByte[(i++)] = (byte)localColor.getBlue(); arrayOfByte[(i++)] = (byte)localColor.getAlpha(); } return new IndexColorModel(paramInt, paramArrayOfObject.length, arrayOfByte, 0, true, 0); } void fixSounds() { int i = 0; int k; for (int j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if ((k == 109) && (((ScratchSound)this.objTable[j][0]).isByteReversed())) i = 1; } if (i == 0) return; for (j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if (k == 109) ((ScratchSound)this.objTable[j][0]).reverseBytes(); } } void uncompressMedia() { for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); int k = -1; if (j >= 100) k = ((Number)arrayOfObject[2]).intValue(); if ((j == 162) && (k >= 4)) { if ((arrayOfObject[7] instanceof byte[])) { BufferedImage localBufferedImage = jpegDecode((byte[])arrayOfObject[7]); if (localBufferedImage != null) { if ((arrayOfObject[4] instanceof Image)) ((Image)arrayOfObject[4]).flush(); arrayOfObject[4] = localBufferedImage; arrayOfObject[7] = empty; } } if ((arrayOfObject[8] instanceof BufferedImage)) { arrayOfObject[4] = arrayOfObject[8]; arrayOfObject[8] = empty; } } if ((j != 164) || (k < 2) || (!(arrayOfObject[9] instanceof byte[]))) continue; int m = ((Number)arrayOfObject[7]).intValue(); int n = ((Number)arrayOfObject[8]).intValue(); byte[] arrayOfByte = (byte[])arrayOfObject[9]; int i1 = (arrayOfByte.length * 8 + (n - 1)) / n; int[] arrayOfInt = new ADPCMDecoder(arrayOfByte, n).decode(i1); arrayOfObject[4] = new ScratchSound(m, arrayOfInt); Object[] tmp261_260 = (arrayOfObject[9] = = empty); arrayOfObject[8] = tmp261_260; arrayOfObject[7] = tmp261_260; } } void canonicalizeMedia() { Vector localVector1 = new Vector(100); Vector localVector2 = new Vector(100); for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); Object localObject; if (j == 162) localObject = (BufferedImage)arrayOfObject[4]; if (j == 164) localObject = (ScratchSound)arrayOfObject[4]; } } BufferedImage jpegDecode(byte[] paramArrayOfByte) { Toolkit localToolkit = Toolkit.getDefaultToolkit(); Image localImage = localToolkit.createImage(paramArrayOfByte); MediaTracker localMediaTracker = new MediaTracker(canvas); localMediaTracker.addImage(localImage, 0); try { localMediaTracker.waitForID(0); } catch (InterruptedException localInterruptedException) { } if (localImage == null) return null; int i = localImage.getWidth(null); int j = localImage.getHeight(null); BufferedImage localBufferedImage = new BufferedImage(i, j, 2); Graphics localGraphics = localBufferedImage.getGraphics(); localGraphics.drawImage(localImage, 0, 0, i, j, null); localGraphics.dispose(); localImage.flush(); return localBufferedImage; }Ok. I'll work on something else now... Jk. *sigh*
jeeze could that be simplified?
I.E: Does it have any x = null; x.prototype.y = z;?
Offline
midnightleopard wrote:
MathWizz wrote:
Ok, time to decode images.
Java:Code:
void buildImagesAndSounds() throws IOException { for (int i = 0; i < this.objTable.length; i++) { int j = ((Number)this.objTable[i][1]).intValue(); Object[] arrayOfObject; if ((j == 34) || (j == 35)) { arrayOfObject = (Object[])this.objTable[i][0]; int k = ((Number)arrayOfObject[0]).intValue(); int m = ((Number)arrayOfObject[1]).intValue(); int n = ((Number)arrayOfObject[2]).intValue(); int[] arrayOfInt = decodePixels(this.objTable[((Ref)arrayOfObject[4]).index][0]); MemoryImageSource localMemoryImageSource = null; this.objTable[i][0] = empty; Object[] localObject2; Object localObject1; if (n <= 8) { if (arrayOfObject[5] != null) { localObject2 = (Object[])this.objTable[((Ref)arrayOfObject[5]).index][0]; localObject1 = customColorMap(n, localObject2); } else localObject1 = squeakColorMap(n); localMemoryImageSource = new MemoryImageSource(k, m, (ColorModel)localObject1, rasterToByteRaster(arrayOfInt, k, m, n), 0, k); } if (n == 16) localMemoryImageSource = new MemoryImageSource(k, m, raster16to32(arrayOfInt, k, m), 0, k); if (n == 32) localMemoryImageSource = new MemoryImageSource(k, m, rasterAddAlphaTo32(arrayOfInt), 0, k); if (localMemoryImageSource != null) { localObject1 = new int[k * m]; localObject2 = new PixelGrabber(localMemoryImageSource, 0, 0, k, m, localObject1, 0, k); try { ((PixelGrabber)localObject2).grabPixels(); } catch (InterruptedException localInterruptedException) { } BufferedImage localBufferedImage = new BufferedImage(k, m, 2); localBufferedImage.getRaster().setDataElements(0, 0, k, m, localObject1); this.objTable[i][0] = localBufferedImage; } } if (j == 109) { arrayOfObject = this.objTable[((Ref)this.objTable[i][6]).index]; this.objTable[i][0] = new ScratchSound(((Number)this.objTable[i][7]).intValue(), (byte[])arrayOfObject[0]); } } } int[] decodePixels(Object paramObject) throws IOException { if ((paramObject instanceof int[])) return (int[])paramObject; DataInputStream localDataInputStream = new DataInputStream(new ByteArrayInputStream((byte[])paramObject)); int i = decodeInt(localDataInputStream); int[] arrayOfInt = new int[i]; int j = 0; int m; int i2; int i3; while (((localDataInputStream.available() > 0 ? 1 : 0) & (j < i ? 1 : 0)) != 0) { int k = decodeInt(localDataInputStream); m = k >> 2; int n = k & 0x3; switch (n) { case 0: j += m; break; case 1: int i1 = localDataInputStream.readUnsignedByte(); i2 = i1 << 24 | i1 << 16 | i1 << 8 | i1; for (i3 = 0; i3 < m;) { arrayOfInt[(j++)] = i2; i3++; i2 = localDataInputStream.readInt(); for (i3 = 0; i3 < m; ) { arrayOfInt[(j++)] = i2; i3++; for (i3 = 0; i3 < m; i3++) { i2 = localDataInputStream.readUnsignedByte() << 24; i2 |= localDataInputStream.readUnsignedByte() << 16; i2 |= localDataInputStream.readUnsignedByte() << 8; i2 |= localDataInputStream.readUnsignedByte(); arrayOfInt[(j++)] = i2; } } } case 2: case 3: } } return arrayOfInt; } int decodeInt(DataInputStream paramDataInputStream) throws IOException { int i = paramDataInputStream.readUnsignedByte(); if (i <= 223) return i; if (i <= 254) return (i - 224) * 256 + paramDataInputStream.readUnsignedByte(); return paramDataInputStream.readInt(); } int[] rasterAddAlphaTo32(int[] paramArrayOfInt) { for (int i = 0; i < paramArrayOfInt.length; i++) { int j = paramArrayOfInt[i]; if (j != 0) paramArrayOfInt[i] = (0xFF000000 | j); } return paramArrayOfInt; } int[] raster16to32(int[] paramArrayOfInt, int paramInt1, int paramInt2) { int[] arrayOfInt = new int[paramInt1 * paramInt2]; int i2 = (paramInt1 + 1) / 2; for (int i3 = 0; i3 < paramInt2; i3++) { int i = 16; for (int i4 = 0; i4 < paramInt1; i4++) { int j = paramArrayOfInt[(i3 * i2 + i4 / 2)] >> i & 0xFFFF; int k = (j >> 10 & 0x1F) << 3; int m = (j >> 5 & 0x1F) << 3; int n = (j & 0x1F) << 3; int i1 = k + m + n == 0 ? 0 : 0xFF000000 | k << 16 | m << 8 | n; arrayOfInt[(i3 * paramInt1 + i4)] = i1; i = i == 16 ? 0 : 16; } } return arrayOfInt; } byte[] rasterToByteRaster(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3) { byte[] arrayOfByte = new byte[paramInt1 * paramInt2]; int i = paramArrayOfInt.length / paramInt2; int j = (1 << paramInt3) - 1; int k = 32 / paramInt3; for (int m = 0; m < paramInt2; m++) { for (int n = 0; n < paramInt1; n++) { int i1 = paramArrayOfInt[(m * i + n / k)]; int i2 = paramInt3 * (k - n % k - 1); arrayOfByte[(m * paramInt1 + n)] = (byte)(i1 >> i2 & j); } } return arrayOfByte; } IndexColorModel squeakColorMap(int paramInt) { int i = paramInt == 1 ? -1 : 0; return new IndexColorModel(paramInt, 256, squeakColors, 0, false, i); } IndexColorModel customColorMap(int paramInt, Object[] paramArrayOfObject) { byte[] arrayOfByte = new byte[4 * paramArrayOfObject.length]; int i = 0; for (int j = 0; j < paramArrayOfObject.length; j++) { Color localColor = (Color)this.objTable[((Ref)paramArrayOfObject[j]).index][0]; arrayOfByte[(i++)] = (byte)localColor.getRed(); arrayOfByte[(i++)] = (byte)localColor.getGreen(); arrayOfByte[(i++)] = (byte)localColor.getBlue(); arrayOfByte[(i++)] = (byte)localColor.getAlpha(); } return new IndexColorModel(paramInt, paramArrayOfObject.length, arrayOfByte, 0, true, 0); } void fixSounds() { int i = 0; int k; for (int j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if ((k == 109) && (((ScratchSound)this.objTable[j][0]).isByteReversed())) i = 1; } if (i == 0) return; for (j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if (k == 109) ((ScratchSound)this.objTable[j][0]).reverseBytes(); } } void uncompressMedia() { for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); int k = -1; if (j >= 100) k = ((Number)arrayOfObject[2]).intValue(); if ((j == 162) && (k >= 4)) { if ((arrayOfObject[7] instanceof byte[])) { BufferedImage localBufferedImage = jpegDecode((byte[])arrayOfObject[7]); if (localBufferedImage != null) { if ((arrayOfObject[4] instanceof Image)) ((Image)arrayOfObject[4]).flush(); arrayOfObject[4] = localBufferedImage; arrayOfObject[7] = empty; } } if ((arrayOfObject[8] instanceof BufferedImage)) { arrayOfObject[4] = arrayOfObject[8]; arrayOfObject[8] = empty; } } if ((j != 164) || (k < 2) || (!(arrayOfObject[9] instanceof byte[]))) continue; int m = ((Number)arrayOfObject[7]).intValue(); int n = ((Number)arrayOfObject[8]).intValue(); byte[] arrayOfByte = (byte[])arrayOfObject[9]; int i1 = (arrayOfByte.length * 8 + (n - 1)) / n; int[] arrayOfInt = new ADPCMDecoder(arrayOfByte, n).decode(i1); arrayOfObject[4] = new ScratchSound(m, arrayOfInt); Object[] tmp261_260 = (arrayOfObject[9] = = empty); arrayOfObject[8] = tmp261_260; arrayOfObject[7] = tmp261_260; } } void canonicalizeMedia() { Vector localVector1 = new Vector(100); Vector localVector2 = new Vector(100); for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); Object localObject; if (j == 162) localObject = (BufferedImage)arrayOfObject[4]; if (j == 164) localObject = (ScratchSound)arrayOfObject[4]; } } BufferedImage jpegDecode(byte[] paramArrayOfByte) { Toolkit localToolkit = Toolkit.getDefaultToolkit(); Image localImage = localToolkit.createImage(paramArrayOfByte); MediaTracker localMediaTracker = new MediaTracker(canvas); localMediaTracker.addImage(localImage, 0); try { localMediaTracker.waitForID(0); } catch (InterruptedException localInterruptedException) { } if (localImage == null) return null; int i = localImage.getWidth(null); int j = localImage.getHeight(null); BufferedImage localBufferedImage = new BufferedImage(i, j, 2); Graphics localGraphics = localBufferedImage.getGraphics(); localGraphics.drawImage(localImage, 0, 0, i, j, null); localGraphics.dispose(); localImage.flush(); return localBufferedImage; }Ok. I'll work on something else now... Jk. *sigh*
jeeze could that be simplified?
I.E: Does it have any x = null; x.prototype.y = z;?
Umm... Well, they're just methods that need to be translated from Java to JavaScript.
Offline
MathWizz wrote:
Ok, time to decode images.
Good luck with that one. It took me a while to do, but sadly I modeled my code after the Squeak source, not the Java. I don't think it's that similar, but if it helps you:
- Form stores 32-bit words (split these into bytes to avoid arithmetic rounding errors) compressed into a ByteArray, decompressed in both the static & instance methods of Bitmap. These correspond to pixel values in the Form's depth, look into Color's static methods (I think #pixelValue:depth:)
- ColorForm stores bytes containing color array indices (remember to subtract one from this because Squeak arrays are 1-based) which are also compressed. These point to colors in the colors array, which has 2^depth colors.
For some reason, I had to render ColorForms in rows, and Forms in columns (this might be a bug in my code, though)
Offline
nXIII wrote:
MathWizz wrote:
Ok, time to decode images.
Good luck with that one. It took me a while to do, but sadly I modeled my code after the Squeak source, not the Java. I don't think it's that similar, but if it helps you:
- Form stores 32-bit words (split these into bytes to avoid arithmetic rounding errors) compressed into a ByteArray, decompressed in both the static & instance methods of Bitmap. These correspond to pixel values in the Form's depth, look into Color's static methods (I think #pixelValue:depth:)
- ColorForm stores bytes containing color array indices (remember to subtract one from this because Squeak arrays are 1-based) which are also compressed. These point to colors in the colors array, which has 2^depth colors.
For some reason, I had to render ColorForms in rows, and Forms in columns (this might be a bug in my code, though)
Are you saying you already accomplished this?!?! Thanks for the hints anyway.
Offline
MathWizz wrote:
midnightleopard wrote:
MathWizz wrote:
Ok, time to decode images.
Java:Code:
void buildImagesAndSounds() throws IOException { for (int i = 0; i < this.objTable.length; i++) { int j = ((Number)this.objTable[i][1]).intValue(); Object[] arrayOfObject; if ((j == 34) || (j == 35)) { arrayOfObject = (Object[])this.objTable[i][0]; int k = ((Number)arrayOfObject[0]).intValue(); int m = ((Number)arrayOfObject[1]).intValue(); int n = ((Number)arrayOfObject[2]).intValue(); int[] arrayOfInt = decodePixels(this.objTable[((Ref)arrayOfObject[4]).index][0]); MemoryImageSource localMemoryImageSource = null; this.objTable[i][0] = empty; Object[] localObject2; Object localObject1; if (n <= 8) { if (arrayOfObject[5] != null) { localObject2 = (Object[])this.objTable[((Ref)arrayOfObject[5]).index][0]; localObject1 = customColorMap(n, localObject2); } else localObject1 = squeakColorMap(n); localMemoryImageSource = new MemoryImageSource(k, m, (ColorModel)localObject1, rasterToByteRaster(arrayOfInt, k, m, n), 0, k); } if (n == 16) localMemoryImageSource = new MemoryImageSource(k, m, raster16to32(arrayOfInt, k, m), 0, k); if (n == 32) localMemoryImageSource = new MemoryImageSource(k, m, rasterAddAlphaTo32(arrayOfInt), 0, k); if (localMemoryImageSource != null) { localObject1 = new int[k * m]; localObject2 = new PixelGrabber(localMemoryImageSource, 0, 0, k, m, localObject1, 0, k); try { ((PixelGrabber)localObject2).grabPixels(); } catch (InterruptedException localInterruptedException) { } BufferedImage localBufferedImage = new BufferedImage(k, m, 2); localBufferedImage.getRaster().setDataElements(0, 0, k, m, localObject1); this.objTable[i][0] = localBufferedImage; } } if (j == 109) { arrayOfObject = this.objTable[((Ref)this.objTable[i][6]).index]; this.objTable[i][0] = new ScratchSound(((Number)this.objTable[i][7]).intValue(), (byte[])arrayOfObject[0]); } } } int[] decodePixels(Object paramObject) throws IOException { if ((paramObject instanceof int[])) return (int[])paramObject; DataInputStream localDataInputStream = new DataInputStream(new ByteArrayInputStream((byte[])paramObject)); int i = decodeInt(localDataInputStream); int[] arrayOfInt = new int[i]; int j = 0; int m; int i2; int i3; while (((localDataInputStream.available() > 0 ? 1 : 0) & (j < i ? 1 : 0)) != 0) { int k = decodeInt(localDataInputStream); m = k >> 2; int n = k & 0x3; switch (n) { case 0: j += m; break; case 1: int i1 = localDataInputStream.readUnsignedByte(); i2 = i1 << 24 | i1 << 16 | i1 << 8 | i1; for (i3 = 0; i3 < m;) { arrayOfInt[(j++)] = i2; i3++; i2 = localDataInputStream.readInt(); for (i3 = 0; i3 < m; ) { arrayOfInt[(j++)] = i2; i3++; for (i3 = 0; i3 < m; i3++) { i2 = localDataInputStream.readUnsignedByte() << 24; i2 |= localDataInputStream.readUnsignedByte() << 16; i2 |= localDataInputStream.readUnsignedByte() << 8; i2 |= localDataInputStream.readUnsignedByte(); arrayOfInt[(j++)] = i2; } } } case 2: case 3: } } return arrayOfInt; } int decodeInt(DataInputStream paramDataInputStream) throws IOException { int i = paramDataInputStream.readUnsignedByte(); if (i <= 223) return i; if (i <= 254) return (i - 224) * 256 + paramDataInputStream.readUnsignedByte(); return paramDataInputStream.readInt(); } int[] rasterAddAlphaTo32(int[] paramArrayOfInt) { for (int i = 0; i < paramArrayOfInt.length; i++) { int j = paramArrayOfInt[i]; if (j != 0) paramArrayOfInt[i] = (0xFF000000 | j); } return paramArrayOfInt; } int[] raster16to32(int[] paramArrayOfInt, int paramInt1, int paramInt2) { int[] arrayOfInt = new int[paramInt1 * paramInt2]; int i2 = (paramInt1 + 1) / 2; for (int i3 = 0; i3 < paramInt2; i3++) { int i = 16; for (int i4 = 0; i4 < paramInt1; i4++) { int j = paramArrayOfInt[(i3 * i2 + i4 / 2)] >> i & 0xFFFF; int k = (j >> 10 & 0x1F) << 3; int m = (j >> 5 & 0x1F) << 3; int n = (j & 0x1F) << 3; int i1 = k + m + n == 0 ? 0 : 0xFF000000 | k << 16 | m << 8 | n; arrayOfInt[(i3 * paramInt1 + i4)] = i1; i = i == 16 ? 0 : 16; } } return arrayOfInt; } byte[] rasterToByteRaster(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3) { byte[] arrayOfByte = new byte[paramInt1 * paramInt2]; int i = paramArrayOfInt.length / paramInt2; int j = (1 << paramInt3) - 1; int k = 32 / paramInt3; for (int m = 0; m < paramInt2; m++) { for (int n = 0; n < paramInt1; n++) { int i1 = paramArrayOfInt[(m * i + n / k)]; int i2 = paramInt3 * (k - n % k - 1); arrayOfByte[(m * paramInt1 + n)] = (byte)(i1 >> i2 & j); } } return arrayOfByte; } IndexColorModel squeakColorMap(int paramInt) { int i = paramInt == 1 ? -1 : 0; return new IndexColorModel(paramInt, 256, squeakColors, 0, false, i); } IndexColorModel customColorMap(int paramInt, Object[] paramArrayOfObject) { byte[] arrayOfByte = new byte[4 * paramArrayOfObject.length]; int i = 0; for (int j = 0; j < paramArrayOfObject.length; j++) { Color localColor = (Color)this.objTable[((Ref)paramArrayOfObject[j]).index][0]; arrayOfByte[(i++)] = (byte)localColor.getRed(); arrayOfByte[(i++)] = (byte)localColor.getGreen(); arrayOfByte[(i++)] = (byte)localColor.getBlue(); arrayOfByte[(i++)] = (byte)localColor.getAlpha(); } return new IndexColorModel(paramInt, paramArrayOfObject.length, arrayOfByte, 0, true, 0); } void fixSounds() { int i = 0; int k; for (int j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if ((k == 109) && (((ScratchSound)this.objTable[j][0]).isByteReversed())) i = 1; } if (i == 0) return; for (j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if (k == 109) ((ScratchSound)this.objTable[j][0]).reverseBytes(); } } void uncompressMedia() { for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); int k = -1; if (j >= 100) k = ((Number)arrayOfObject[2]).intValue(); if ((j == 162) && (k >= 4)) { if ((arrayOfObject[7] instanceof byte[])) { BufferedImage localBufferedImage = jpegDecode((byte[])arrayOfObject[7]); if (localBufferedImage != null) { if ((arrayOfObject[4] instanceof Image)) ((Image)arrayOfObject[4]).flush(); arrayOfObject[4] = localBufferedImage; arrayOfObject[7] = empty; } } if ((arrayOfObject[8] instanceof BufferedImage)) { arrayOfObject[4] = arrayOfObject[8]; arrayOfObject[8] = empty; } } if ((j != 164) || (k < 2) || (!(arrayOfObject[9] instanceof byte[]))) continue; int m = ((Number)arrayOfObject[7]).intValue(); int n = ((Number)arrayOfObject[8]).intValue(); byte[] arrayOfByte = (byte[])arrayOfObject[9]; int i1 = (arrayOfByte.length * 8 + (n - 1)) / n; int[] arrayOfInt = new ADPCMDecoder(arrayOfByte, n).decode(i1); arrayOfObject[4] = new ScratchSound(m, arrayOfInt); Object[] tmp261_260 = (arrayOfObject[9] = = empty); arrayOfObject[8] = tmp261_260; arrayOfObject[7] = tmp261_260; } } void canonicalizeMedia() { Vector localVector1 = new Vector(100); Vector localVector2 = new Vector(100); for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); Object localObject; if (j == 162) localObject = (BufferedImage)arrayOfObject[4]; if (j == 164) localObject = (ScratchSound)arrayOfObject[4]; } } BufferedImage jpegDecode(byte[] paramArrayOfByte) { Toolkit localToolkit = Toolkit.getDefaultToolkit(); Image localImage = localToolkit.createImage(paramArrayOfByte); MediaTracker localMediaTracker = new MediaTracker(canvas); localMediaTracker.addImage(localImage, 0); try { localMediaTracker.waitForID(0); } catch (InterruptedException localInterruptedException) { } if (localImage == null) return null; int i = localImage.getWidth(null); int j = localImage.getHeight(null); BufferedImage localBufferedImage = new BufferedImage(i, j, 2); Graphics localGraphics = localBufferedImage.getGraphics(); localGraphics.drawImage(localImage, 0, 0, i, j, null); localGraphics.dispose(); localImage.flush(); return localBufferedImage; }Ok. I'll work on something else now... Jk. *sigh*
jeeze could that be simplified?
I.E: Does it have any x = null; x.prototype.y = z;?Umm... Well, they're just methods that need to be translated from Java to JavaScript.
oh. I thought that was just ridiculously weird javascript. I guess not.
Offline
MathWizz wrote:
Ok, time to decode images.
Java:Code:
void buildImagesAndSounds() throws IOException { for (int i = 0; i < this.objTable.length; i++) { int j = ((Number)this.objTable[i][1]).intValue(); Object[] arrayOfObject; if ((j == 34) || (j == 35)) { arrayOfObject = (Object[])this.objTable[i][0]; int k = ((Number)arrayOfObject[0]).intValue(); int m = ((Number)arrayOfObject[1]).intValue(); int n = ((Number)arrayOfObject[2]).intValue(); int[] arrayOfInt = decodePixels(this.objTable[((Ref)arrayOfObject[4]).index][0]); MemoryImageSource localMemoryImageSource = null; this.objTable[i][0] = empty; Object[] localObject2; Object localObject1; if (n <= 8) { if (arrayOfObject[5] != null) { localObject2 = (Object[])this.objTable[((Ref)arrayOfObject[5]).index][0]; localObject1 = customColorMap(n, localObject2); } else localObject1 = squeakColorMap(n); localMemoryImageSource = new MemoryImageSource(k, m, (ColorModel)localObject1, rasterToByteRaster(arrayOfInt, k, m, n), 0, k); } if (n == 16) localMemoryImageSource = new MemoryImageSource(k, m, raster16to32(arrayOfInt, k, m), 0, k); if (n == 32) localMemoryImageSource = new MemoryImageSource(k, m, rasterAddAlphaTo32(arrayOfInt), 0, k); if (localMemoryImageSource != null) { localObject1 = new int[k * m]; localObject2 = new PixelGrabber(localMemoryImageSource, 0, 0, k, m, localObject1, 0, k); try { ((PixelGrabber)localObject2).grabPixels(); } catch (InterruptedException localInterruptedException) { } BufferedImage localBufferedImage = new BufferedImage(k, m, 2); localBufferedImage.getRaster().setDataElements(0, 0, k, m, localObject1); this.objTable[i][0] = localBufferedImage; } } if (j == 109) { arrayOfObject = this.objTable[((Ref)this.objTable[i][6]).index]; this.objTable[i][0] = new ScratchSound(((Number)this.objTable[i][7]).intValue(), (byte[])arrayOfObject[0]); } } } int[] decodePixels(Object paramObject) throws IOException { if ((paramObject instanceof int[])) return (int[])paramObject; DataInputStream localDataInputStream = new DataInputStream(new ByteArrayInputStream((byte[])paramObject)); int i = decodeInt(localDataInputStream); int[] arrayOfInt = new int[i]; int j = 0; int m; int i2; int i3; while (((localDataInputStream.available() > 0 ? 1 : 0) & (j < i ? 1 : 0)) != 0) { int k = decodeInt(localDataInputStream); m = k >> 2; int n = k & 0x3; switch (n) { case 0: j += m; break; case 1: int i1 = localDataInputStream.readUnsignedByte(); i2 = i1 << 24 | i1 << 16 | i1 << 8 | i1; for (i3 = 0; i3 < m;) { arrayOfInt[(j++)] = i2; i3++; i2 = localDataInputStream.readInt(); for (i3 = 0; i3 < m; ) { arrayOfInt[(j++)] = i2; i3++; for (i3 = 0; i3 < m; i3++) { i2 = localDataInputStream.readUnsignedByte() << 24; i2 |= localDataInputStream.readUnsignedByte() << 16; i2 |= localDataInputStream.readUnsignedByte() << 8; i2 |= localDataInputStream.readUnsignedByte(); arrayOfInt[(j++)] = i2; } } } case 2: case 3: } } return arrayOfInt; } int decodeInt(DataInputStream paramDataInputStream) throws IOException { int i = paramDataInputStream.readUnsignedByte(); if (i <= 223) return i; if (i <= 254) return (i - 224) * 256 + paramDataInputStream.readUnsignedByte(); return paramDataInputStream.readInt(); } int[] rasterAddAlphaTo32(int[] paramArrayOfInt) { for (int i = 0; i < paramArrayOfInt.length; i++) { int j = paramArrayOfInt[i]; if (j != 0) paramArrayOfInt[i] = (0xFF000000 | j); } return paramArrayOfInt; } int[] raster16to32(int[] paramArrayOfInt, int paramInt1, int paramInt2) { int[] arrayOfInt = new int[paramInt1 * paramInt2]; int i2 = (paramInt1 + 1) / 2; for (int i3 = 0; i3 < paramInt2; i3++) { int i = 16; for (int i4 = 0; i4 < paramInt1; i4++) { int j = paramArrayOfInt[(i3 * i2 + i4 / 2)] >> i & 0xFFFF; int k = (j >> 10 & 0x1F) << 3; int m = (j >> 5 & 0x1F) << 3; int n = (j & 0x1F) << 3; int i1 = k + m + n == 0 ? 0 : 0xFF000000 | k << 16 | m << 8 | n; arrayOfInt[(i3 * paramInt1 + i4)] = i1; i = i == 16 ? 0 : 16; } } return arrayOfInt; } byte[] rasterToByteRaster(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3) { byte[] arrayOfByte = new byte[paramInt1 * paramInt2]; int i = paramArrayOfInt.length / paramInt2; int j = (1 << paramInt3) - 1; int k = 32 / paramInt3; for (int m = 0; m < paramInt2; m++) { for (int n = 0; n < paramInt1; n++) { int i1 = paramArrayOfInt[(m * i + n / k)]; int i2 = paramInt3 * (k - n % k - 1); arrayOfByte[(m * paramInt1 + n)] = (byte)(i1 >> i2 & j); } } return arrayOfByte; } IndexColorModel squeakColorMap(int paramInt) { int i = paramInt == 1 ? -1 : 0; return new IndexColorModel(paramInt, 256, squeakColors, 0, false, i); } IndexColorModel customColorMap(int paramInt, Object[] paramArrayOfObject) { byte[] arrayOfByte = new byte[4 * paramArrayOfObject.length]; int i = 0; for (int j = 0; j < paramArrayOfObject.length; j++) { Color localColor = (Color)this.objTable[((Ref)paramArrayOfObject[j]).index][0]; arrayOfByte[(i++)] = (byte)localColor.getRed(); arrayOfByte[(i++)] = (byte)localColor.getGreen(); arrayOfByte[(i++)] = (byte)localColor.getBlue(); arrayOfByte[(i++)] = (byte)localColor.getAlpha(); } return new IndexColorModel(paramInt, paramArrayOfObject.length, arrayOfByte, 0, true, 0); } void fixSounds() { int i = 0; int k; for (int j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if ((k == 109) && (((ScratchSound)this.objTable[j][0]).isByteReversed())) i = 1; } if (i == 0) return; for (j = 0; j < this.objTable.length; j++) { k = ((Number)this.objTable[j][1]).intValue(); if (k == 109) ((ScratchSound)this.objTable[j][0]).reverseBytes(); } } void uncompressMedia() { for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); int k = -1; if (j >= 100) k = ((Number)arrayOfObject[2]).intValue(); if ((j == 162) && (k >= 4)) { if ((arrayOfObject[7] instanceof byte[])) { BufferedImage localBufferedImage = jpegDecode((byte[])arrayOfObject[7]); if (localBufferedImage != null) { if ((arrayOfObject[4] instanceof Image)) ((Image)arrayOfObject[4]).flush(); arrayOfObject[4] = localBufferedImage; arrayOfObject[7] = empty; } } if ((arrayOfObject[8] instanceof BufferedImage)) { arrayOfObject[4] = arrayOfObject[8]; arrayOfObject[8] = empty; } } if ((j != 164) || (k < 2) || (!(arrayOfObject[9] instanceof byte[]))) continue; int m = ((Number)arrayOfObject[7]).intValue(); int n = ((Number)arrayOfObject[8]).intValue(); byte[] arrayOfByte = (byte[])arrayOfObject[9]; int i1 = (arrayOfByte.length * 8 + (n - 1)) / n; int[] arrayOfInt = new ADPCMDecoder(arrayOfByte, n).decode(i1); arrayOfObject[4] = new ScratchSound(m, arrayOfInt); Object[] tmp261_260 = (arrayOfObject[9] = = empty); arrayOfObject[8] = tmp261_260; arrayOfObject[7] = tmp261_260; } } void canonicalizeMedia() { Vector localVector1 = new Vector(100); Vector localVector2 = new Vector(100); for (int i = 0; i < this.objTable.length; i++) { Object[] arrayOfObject = this.objTable[i]; int j = ((Number)arrayOfObject[1]).intValue(); Object localObject; if (j == 162) localObject = (BufferedImage)arrayOfObject[4]; if (j == 164) localObject = (ScratchSound)arrayOfObject[4]; } } BufferedImage jpegDecode(byte[] paramArrayOfByte) { Toolkit localToolkit = Toolkit.getDefaultToolkit(); Image localImage = localToolkit.createImage(paramArrayOfByte); MediaTracker localMediaTracker = new MediaTracker(canvas); localMediaTracker.addImage(localImage, 0); try { localMediaTracker.waitForID(0); } catch (InterruptedException localInterruptedException) { } if (localImage == null) return null; int i = localImage.getWidth(null); int j = localImage.getHeight(null); BufferedImage localBufferedImage = new BufferedImage(i, j, 2); Graphics localGraphics = localBufferedImage.getGraphics(); localGraphics.drawImage(localImage, 0, 0, i, j, null); localGraphics.dispose(); localImage.flush(); return localBufferedImage; }Ok. I'll work on something else now... Jk. *sigh*
I am ultimately sorry, but we are working with Javascript.
Offline
cocolover76 wrote:
MathWizz wrote:
*stuff*
I am ultimately sorry, but we are working with Javascript.
*ahem* I am the one that has created the whole player to this date (with the exception of morphic.js) and I am being told that I am programming in JavaScript?
...
Last edited by MathWizz (2011-12-06 18:08:45)
Offline
MathWizz wrote:
cocolover76 wrote:
MathWizz wrote:
*stuff*
I am ultimately sorry, but we are working with Javascript.
*ahem* I am the one that has created the whole player to this date (with the exception of morphic.js) and I am being told that I am programming in JavaScript?
...
who added cocolover to the team?
(Just asking, I don't adding you.)
Offline
Hey MathWhiz? Do you know if it would be possible to write it (well, the entire project in general, but the image-thing in particular) in JavaScript? How would you access the image data (assuming it's possible)?
Offline
MoreGamesNow wrote:
Hey MathWhiz? Do you know if it would be possible to write it (well, the entire project in general, but the image-thing in particular) in JavaScript? How would you access the image data (assuming it's possible)?
Are you asking if it is possible to read images (such as costumes) from a Scratch file in JavaScript? That's what I am trying to figure out right now.
Offline
MathWizz wrote:
Are you asking if it is possible to read images (such as costumes) from a Scratch file in JavaScript? That's what I am trying to figure out right now.
Darn it! And yes, that was what i was asking How are you getting the Scratch code with Java (my experience with Java is pretty much zero, so if it isn't possible to give me a simple answer, just say so )?
Offline