diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/math/BezierEdge.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/math/BezierEdge.java index f306188b6..d8332d896 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/math/BezierEdge.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/math/BezierEdge.java @@ -578,7 +578,7 @@ public class BezierEdge implements Serializable { )); } calcParams(); - } + } public static final double ROUND_VALUE = 2; @@ -591,6 +591,16 @@ public class BezierEdge implements Serializable { } calcParams(); } + + public void roundN(double n) { + for (int i = 0; i < this.points.size(); i++) { + this.points.set(i, new Point2D.Double( + Math.round(this.points.get(i).getX() * n) / n, + Math.round(this.points.get(i).getY() * n) / n + )); + } + calcParams(); + } @Override public int hashCode() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 619350d76..b72f787dc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -252,7 +252,7 @@ public class XFLConverter { */ private final boolean DEBUG_EXPORT_LAYER_DEPTHS = false; - private static final DecimalFormat EDGE_DECIMAL_FORMAT = new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); + private static final DecimalFormat EDGE_DECIMAL_FORMAT = new DecimalFormat("0.##", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); private static final double SMALL_DIVISOR = 20; @@ -308,12 +308,12 @@ public class XFLConverter { } private static String formatEdgeDouble(double value) { - if (value % 1 == 0) { + /*if (value % 1 == 0) { return "" + (int) value; - } + }*/ //value = Math.round(value * 2.0) / 2.0; - return EDGE_DECIMAL_FORMAT.format(value); - //return numEdgeToString(value); + //return EDGE_DECIMAL_FORMAT.format(value); + return numEdgeToString(value); } private static String convertShapeEdge(MATRIX mat, ShapeRecordAdvanced record, double x, double y) { @@ -715,7 +715,7 @@ public class XFLConverter { shapeTransformer.transformStyles(scale, fillStyles, lineStyles, shapeNum); } - shapeRecordsAdvanced = fixer.fix(shapeRecords, shapeNum, fillStyles, lineStyles); + shapeRecordsAdvanced = fixer.fix(shapeRecords, shapeNum, fillStyles, lineStyles, small); List edges = new ArrayList<>(); int lineStyleCount = 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/ShapeFixer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/ShapeFixer.java index 11a8d4e3a..d327fc11d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/ShapeFixer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/shapefixer/ShapeFixer.java @@ -253,7 +253,7 @@ public class ShapeFixer { } } - private void handleBewList(List bewList, List> shapes) { + private void handleBewList(List bewList, List> shapes, boolean wasSmall) { Map> bewMap = bewList.stream() .collect(Collectors.groupingBy(b -> b.layer)); @@ -368,7 +368,11 @@ public class ShapeFixer { shapes.get(bew.shapeIndex).remove(bew.edgeIndex); int pos = 0; for (BezierEdge bes : splitted) { - bes.roundX(); + if (wasSmall) { + bes.roundN(2); //this value works best for #1011, why? Also for #2532 it is okay. + } else { + bes.roundN(100); //this value works best for #2165, it's not multiplied by 20 like not small :-( + } if (bes.isEmpty()) { continue; } @@ -384,7 +388,8 @@ public class ShapeFixer { List fillStyles0, List fillStyles1, List lineStyles, - List layers + List layers, + boolean wasSmall ) { /*if (true) { @@ -412,8 +417,8 @@ public class ShapeFixer { } } - handleBewList(strokesBewList, shapes); - handleBewList(fillsBewList, shapes); + handleBewList(strokesBewList, shapes, wasSmall); + handleBewList(fillsBewList, shapes, wasSmall); for (int i1 = 0; i1 < shapes.size(); i1++) { for (int j1 = 0; j1 < shapes.get(i1).size(); j1++) { @@ -848,7 +853,8 @@ public class ShapeFixer { List records, int shapeNum, FILLSTYLEARRAY baseFillStyles, - LINESTYLEARRAY baseLineStyles + LINESTYLEARRAY baseLineStyles, + boolean wasSmall ) { List> shapes = new ArrayList<>(); List fillStyles0 = new ArrayList<>(); @@ -865,7 +871,7 @@ public class ShapeFixer { if (Configuration.flaExportFixShapes.get()) { SwitchedFillSidesFixer switchedFillSidesFixer = new SwitchedFillSidesFixer(); switchedFillSidesFixer.fixSwitchedFills(shapeNum, records, baseFillStyles, baseLineStyles, shapes, fillStyles0, fillStyles1, layers); - detectOverlappingEdges(shapes, fillStyles0, fillStyles1, lineStyles, layers); + detectOverlappingEdges(shapes, fillStyles0, fillStyles1, lineStyles, layers, wasSmall); } return combineLayers(shapes, fillStyles0, fillStyles1, lineStyles, layers, fillStyleLayers, lineStyleLayers); @@ -919,6 +925,6 @@ public class ShapeFixer { beList.add(new BezierEdge(10000.0, 4980.0, 10040.0, 5060.0)); beList.add(new BezierEdge(10040.0, 5040.0, 9900.0, 4900.0, 9900.0, 4860.0)); shapes.add(beList); - f.detectOverlappingEdges(shapes, Arrays.asList(1), Arrays.asList(2), Arrays.asList(0), Arrays.asList(0)); + f.detectOverlappingEdges(shapes, Arrays.asList(1), Arrays.asList(2), Arrays.asList(0), Arrays.asList(0), false); } }