small fixes

This commit is contained in:
Honfika
2014-02-28 23:44:23 +01:00
parent 9dbf70e335
commit 69cf07b3b4
6 changed files with 41 additions and 32 deletions

View File

@@ -822,7 +822,12 @@ public class SWFInputStream extends InputStream {
@Override
public Tag call() throws Exception {
return SWFInputStream.resolveTag(swf, tag, version, level, parallel, skipUnusualTags, gfx);
try {
return SWFInputStream.resolveTag(swf, tag, version, level, parallel, skipUnusualTags, gfx);
} catch (EndOfStreamException ex) {
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, null, ex);
return tag;
}
}
}
@@ -1303,6 +1308,7 @@ public class SWFInputStream extends InputStream {
try {
return resolveTag(swf, ret, version, level, parallel, skipUnusualTags, gfx);
} catch (EndOfStreamException ex) {
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, null, ex);
return ret;
}
}

View File

@@ -321,7 +321,7 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, int miterLimit) {
finalizePath();
thickness /= unitDivisor;
lineColor = color.toColor();
lineColor = color == null ? null : color.toColor();
int capStyle = BasicStroke.CAP_ROUND;
switch (startCaps) {
case LINESTYLE2.NO_CAP:

View File

@@ -637,13 +637,9 @@ public class DefineEditTextTag extends TextTag implements DrawableTag {
tr.textHeight = fontHeight;
tr.styleFlagsHasYOffset = true;
tr.yOffset = fontHeight;
String txt;
if (html) {
txt = getInnerText(initialText);
} else {
txt = initialText;
}
String txt = getText();
tr.glyphEntries = new GLYPHENTRY[txt.length()];
int width = 0;
for (int i = 0; i < txt.length(); i++) {
char c = txt.charAt(i);
Character nextChar = null;
@@ -665,28 +661,30 @@ public class DefineEditTextTag extends TextTag implements DrawableTag {
advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), (int) (fontHeight / SWF.unitDivisor), c, nextChar));
}
tr.glyphEntries[i].glyphAdvance = advance;
width += advance;
}
switch (align) {
case 1: // right
tr.styleFlagsHasXOffset = true;
tr.xOffset = bounds.getWidth() - width;
break;
case 2: // center
tr.styleFlagsHasXOffset = true;
tr.xOffset = (int) ((bounds.getWidth() - width) / 2);
break;
case 3: // justify
// todo;
break;
}
if (hasTextColor) {
tr.styleFlagsHasColor = true;
tr.textColorA = textColor;
}
textRecords.add(tr);
staticTextToImage(swf, characters, textRecords, 1, image, getTextMatrix(), transformation);
staticTextToImage(swf, characters, textRecords, 2, image, getTextMatrix(), transformation);
}
}
private String getInnerText(String html) {
String result = "";
boolean inTag = false;
for (int i = 0; i < html.length(); i++) {
char c = html.charAt(i);
if (c == '<') {
inTag = true;
} else if (inTag && c == '>') {
inTag = false;
} else if (!inTag) {
result += c;
}
}
return result;
}
@Override
public Point getImagePos(int frame, Map<Integer, CharacterTag> characters, Stack<Integer> visited) {
return new Point(bounds.Xmin / SWF.unitDivisor, bounds.Ymin / SWF.unitDivisor);

View File

@@ -93,7 +93,7 @@ public class DefineFont3Tag extends FontTag {
@Override
public double getGlyphAdvance(int glyphIndex) {
if (fontFlagsHasLayout) {
if (fontFlagsHasLayout && glyphIndex != -1) {
return fontAdvanceTable.get(glyphIndex) / SWF.unitDivisor;
} else {
return -1;
@@ -423,6 +423,9 @@ public class DefineFont3Tag extends FontTag {
@Override
public int getGlyphKerningAdjustment(List<Tag> tags, int glyphIndex, int nextGlyphIndex) {
if (glyphIndex == -1 || nextGlyphIndex == -1) {
return 0;
}
char c1 = glyphToChar(tags, glyphIndex);
char c2 = glyphToChar(tags, nextGlyphIndex);
int kerningAdjustment = 0;

View File

@@ -327,7 +327,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
placeFlagHasFilterList = sis.readUB(1) == 1;
depth = sis.readUI16();
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
if (placeFlagHasClassName) {
className = sis.readString();
}
if (placeFlagHasCharacter) {
@@ -464,7 +464,7 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
@Override
public String getClassName() {
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
if (placeFlagHasClassName) {
return className;
}
return null;

View File

@@ -231,10 +231,12 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
Matrix matTr = Matrix.getTranslateInstance(x, y);
mat = mat.concatenate(matTr);
mat = mat.concatenate(Matrix.getScaleInstance(rat));
// shapeNum: 1
SHAPE shape = glyphs.get(entry.glyphIndex);
BitmapExporter.exportTo(swf, shape, textColor, image, mat);
x += entry.glyphAdvance;
if (entry.glyphIndex != -1) {
// shapeNum: 1
SHAPE shape = glyphs.get(entry.glyphIndex);
BitmapExporter.exportTo(swf, shape, textColor, image, mat);
x += entry.glyphAdvance;
}
}
}
}