define shape refactor 1

This commit is contained in:
honfika@gmail.com
2015-05-14 17:01:13 +02:00
parent 90957416c2
commit 74c4d44796
2 changed files with 7 additions and 9 deletions

View File

@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.helpers.ByteArrayRange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -52,7 +51,7 @@ public class DefineShape2Tag extends ShapeTag {
try {
SWFInputStream sis = new SWFInputStream(swf, shapeData.getArray(), 0, shapeData.getPos() + shapeData.getLength());
sis.seek(shapeData.getPos());
shapes = sis.readSHAPEWITHSTYLE(2, false, "shapes");
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
shapeData = null; // not needed anymore, give it to GC
} catch (IOException ex) {
Logger.getLogger(DefineShape2Tag.class.getName()).log(Level.SEVERE, null, ex);
@@ -112,7 +111,7 @@ public class DefineShape2Tag extends ShapeTag {
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
if (!lazy) {
shapes = sis.readSHAPEWITHSTYLE(2, false, "shapes");
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
}
@@ -126,12 +125,11 @@ public class DefineShape2Tag extends ShapeTag {
@Override
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), 2);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}

View File

@@ -51,7 +51,7 @@ public class DefineShapeTag extends ShapeTag {
try {
SWFInputStream sis = new SWFInputStream(swf, shapeData.getArray(), 0, shapeData.getPos() + shapeData.getLength());
sis.seek(shapeData.getPos());
shapes = sis.readSHAPEWITHSTYLE(1, false, "shapes");
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
shapeData = null; // not needed anymore, give it to GC
} catch (IOException ex) {
Logger.getLogger(DefineShapeTag.class.getName()).log(Level.SEVERE, null, ex);
@@ -111,7 +111,7 @@ public class DefineShapeTag extends ShapeTag {
shapeId = sis.readUI16("shapeId");
shapeBounds = sis.readRECT("shapeBounds");
if (!lazy) {
shapes = sis.readSHAPEWITHSTYLE(1, false, "shapes");
shapes = sis.readSHAPEWITHSTYLE(getShapeNum(), false, "shapes");
} else {
shapeData = new ByteArrayRange(data.getArray(), (int) sis.getPos(), sis.available());
}
@@ -129,7 +129,7 @@ public class DefineShapeTag extends ShapeTag {
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
sos.writeSHAPEWITHSTYLE(getShapes(), 1);
sos.writeSHAPEWITHSTYLE(getShapes(), getShapeNum());
} catch (IOException e) {
throw new Error("This should never happen.", e);
}