1 Clazz.declarePackage ("javajs.img");
2 Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.CRCEncoder", ["java.util.zip.CRC32", "javajs.util.AU"], function () {
3 c$ = Clazz.decorateAsClass (function () {
11 Clazz.instantialize (this, arguments);
12 }, javajs.img, "CRCEncoder", javajs.img.ImageEncoder);
13 Clazz.prepareFields (c$, function () {
14 this.int2 = Clazz.newByteArray (2, 0);
15 this.int4 = Clazz.newByteArray (4, 0);
17 Clazz.makeConstructor (c$,
19 Clazz.superConstructor (this, javajs.img.CRCEncoder, []);
20 this.pngBytes = Clazz.newByteArray (250, 0);
21 this.crc = new java.util.zip.CRC32 ();
23 Clazz.defineMethod (c$, "setData",
26 this.dataLen = b.length;
27 this.startPos = this.bytePos = pt;
29 Clazz.defineMethod (c$, "getBytes",
31 return (this.dataLen == this.pngBytes.length ? this.pngBytes : javajs.util.AU.arrayCopyByte (this.pngBytes, this.dataLen));
33 Clazz.defineMethod (c$, "writeCRC",
36 this.crc.update (this.pngBytes, this.startPos, this.bytePos - this.startPos);
37 this.writeInt4 (this.crc.getValue ());
39 Clazz.defineMethod (c$, "writeInt2",
41 this.int2[0] = ((n >> 8) & 0xff);
42 this.int2[1] = (n & 0xff);
43 this.writeBytes (this.int2);
45 Clazz.defineMethod (c$, "writeInt4",
47 javajs.img.CRCEncoder.getInt4 (n, this.int4);
48 this.writeBytes (this.int4);
50 c$.getInt4 = Clazz.defineMethod (c$, "getInt4",
52 int4[0] = ((n >> 24) & 0xff);
53 int4[1] = ((n >> 16) & 0xff);
54 int4[2] = ((n >> 8) & 0xff);
57 Clazz.defineMethod (c$, "writeByte",
59 var temp = Clazz.newByteArray (-1, [b]);
60 this.writeBytes (temp);
62 Clazz.defineMethod (c$, "writeString",
64 this.writeBytes (s.getBytes ());
66 Clazz.defineMethod (c$, "writeBytes",
68 var newPos = this.bytePos + data.length;
69 this.dataLen = Math.max (this.dataLen, newPos);
70 if (newPos > this.pngBytes.length) this.pngBytes = javajs.util.AU.arrayCopyByte (this.pngBytes, newPos + 16);
71 System.arraycopy (data, 0, this.pngBytes, this.bytePos, data.length);
72 this.bytePos = newPos;