diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java index 4d0e7b4b5..370b2081a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/svg/SvgImporter.java @@ -196,6 +196,9 @@ public class SvgImporter { st.shapes = shapes; if (!fill) { st.shapeBounds = shapes.getBounds(st.getShapeNum()); + if (st instanceof DefineShape4Tag) { + ((DefineShape4Tag)st).edgeBounds = shapes.getEdgeBounds(); + } } st.setModified(true); @@ -516,7 +519,7 @@ public class SvgImporter { x0 = x; y0 = y; } - applyStyleGradients(SHAPERECORD.getBounds(newRecords, shapes.lineStyles, shapeNum), scrStyle, transform2, shapeNum, style); + applyStyleGradients(SHAPERECORD.getBounds(newRecords, shapes.lineStyles, shapeNum, false), scrStyle, transform2, shapeNum, style); shapes.shapeRecords.addAll(newRecords); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 73adc79b2..b71fbc29b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -334,7 +334,7 @@ public abstract class TextTag extends DrawableTag { LINESTYLEARRAY lsa = new LINESTYLEARRAY(); lsa.lineStyles = new LINESTYLE[0]; lsa.lineStyles2 = new LINESTYLE2[0]; - RECT rect = SHAPERECORD.getBounds(glyphs.get(entry.glyphIndex).shapeRecords, lsa, 1); + RECT rect = SHAPERECORD.getBounds(glyphs.get(entry.glyphIndex).shapeRecords, lsa, 1, false); rect.Xmax = (int) Math.round(((double) rect.Xmax * textHeight) / (font.getDivider() * 1024)); rect.Xmin = (int) Math.round(((double) rect.Xmin * textHeight) / (font.getDivider() * 1024)); rect.Ymax = (int) Math.round(((double) rect.Ymax * textHeight) / (font.getDivider() * 1024)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java index 610d288d1..bc7837092 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -77,7 +77,11 @@ public class SHAPE implements NeedsCharacters, Serializable { LINESTYLEARRAY lsa = new LINESTYLEARRAY(); lsa.lineStyles = new LINESTYLE[0]; lsa.lineStyles2 = new LINESTYLE2[0]; - return SHAPERECORD.getBounds(shapeRecords, lsa, shapeNum); + return SHAPERECORD.getBounds(shapeRecords, lsa, shapeNum, false); + } + + public RECT getEdgeBounds() { + return SHAPERECORD.getBounds(shapeRecords, null, 1, true); } public Shape getOutline(int shapeNum, SWF swf, boolean stroked) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java index 3e40cc9fe..0b1a03e8b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPEWITHSTYLE.java @@ -100,7 +100,7 @@ public class SHAPEWITHSTYLE extends SHAPE implements NeedsCharacters, Serializab @Override public RECT getBounds(int shapeNum) { - return SHAPERECORD.getBounds(shapeRecords, lineStyles, shapeNum); + return SHAPERECORD.getBounds(shapeRecords, lineStyles, shapeNum, false); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/GlyphType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/GlyphType.java index a7f79cf33..366334ff4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/GlyphType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/gfx/GlyphType.java @@ -52,7 +52,7 @@ public class GlyphType implements Serializable { LINESTYLEARRAY lsa = new LINESTYLEARRAY(); lsa.lineStyles = new LINESTYLE[0]; lsa.lineStyles2 = new LINESTYLE2[0]; - RECT bounds = SHAPERECORD.getBounds(records, lsa, 1); + RECT bounds = SHAPERECORD.getBounds(records, lsa, 1, false); boundingBox = new int[4]; boundingBox[0] = bounds.Xmin; boundingBox[1] = bounds.Ymin; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java index f0c096ccf..681054c52 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/shaperecords/SHAPERECORD.java @@ -80,7 +80,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali public abstract void flip(); - public static RECT getBounds(List records, LINESTYLEARRAY lineStyles, int shapeNum) { + public static RECT getBounds(List records, LINESTYLEARRAY lineStyles, int shapeNum, boolean edgeBounds) { int x = 0; int y = 0; int max_x = 0; @@ -92,7 +92,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali int lineWidth = 0; int lineWidthHalf = 0; for (SHAPERECORD r : records) { - if (r instanceof StyleChangeRecord) { + if (!edgeBounds && (r instanceof StyleChangeRecord)) { StyleChangeRecord style = (StyleChangeRecord) r; if (style.stateNewStyles) { lineStyles = style.lineStyles; @@ -121,11 +121,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali if (y2 > max_y) { max_y = y2; } - if (x2 + lineWidthHalf > max_x) { - max_x = x2 + lineWidthHalf; - } - if (y2 + lineWidthHalf > max_y) { - max_y = y2 + lineWidthHalf; + if (!edgeBounds) { + if (x2 + lineWidthHalf > max_x) { + max_x = x2 + lineWidthHalf; + } + if (y2 + lineWidthHalf > max_y) { + max_y = y2 + lineWidthHalf; + } } if (started) { if (y2 < min_y) { @@ -135,12 +137,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali min_x = x2; } - if (y2 - lineWidthHalf < min_y) { - min_y = y2 - lineWidthHalf; - } - - if (x2 - lineWidthHalf < min_x) { - min_x = x2 - lineWidthHalf; + if (!edgeBounds) { + if (y2 - lineWidthHalf < min_y) { + min_y = y2 - lineWidthHalf; + } + if (x2 - lineWidthHalf < min_x) { + min_x = x2 - lineWidthHalf; + } } } } @@ -153,11 +156,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali if (y > max_y) { max_y = y; } - if (x + lineWidthHalf > max_x) { - max_x = x + lineWidthHalf; - } - if (y + lineWidthHalf > max_y) { - max_y = y + lineWidthHalf; + if (!edgeBounds) { + if (x + lineWidthHalf > max_x) { + max_x = x + lineWidthHalf; + } + if (y + lineWidthHalf > max_y) { + max_y = y + lineWidthHalf; + } } if (r.isMove()) { started = true; @@ -170,11 +175,13 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali min_x = x; } - if (y - lineWidthHalf < min_y) { - min_y = y - lineWidthHalf; - } - if (x - lineWidthHalf < min_x) { - min_x = x - lineWidthHalf; + if (!edgeBounds) { + if (y - lineWidthHalf < min_y) { + min_y = y - lineWidthHalf; + } + if (x - lineWidthHalf < min_x) { + min_x = x - lineWidthHalf; + } } } } @@ -206,7 +213,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali lsa.lineStyles = new LINESTYLE[0]; lsa.lineStyles2 = new LINESTYLE2[0]; for (SHAPE s : shapes) { - RECT r = SHAPERECORD.getBounds(s.shapeRecords, lsa, shapeNum); + RECT r = SHAPERECORD.getBounds(s.shapeRecords, lsa, shapeNum, false); if (r.Xmax < r.Xmin || r.Ymax < r.Ymin) { continue; } @@ -262,7 +269,7 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali // shapeNum: 1 SHAPE shape = shapes.get(pos); List records = shape.shapeRecords; - RECT bounds = SHAPERECORD.getBounds(records, lsa, shapeNum); + RECT bounds = SHAPERECORD.getBounds(records, lsa, shapeNum, false); int w1 = bounds.getWidth(); int h1 = bounds.getHeight();