feat: allow turning off the minimum stroke width of 1 pixel

This commit is contained in:
Jindra Petřík
2026-04-05 18:20:33 +02:00
parent ab0a616612
commit 5413feb307
9 changed files with 43 additions and 17 deletions

View File

@@ -1233,6 +1233,10 @@ public final class Configuration {
@ConfigurationCategory("export")
public static ConfigurationItem<Integer> msaaGridForExport = null;
@ConfigurationDefaultBoolean(true)
@ConfigurationCategory("display")
public static ConfigurationItem<Boolean> useMinimumStrokeWidth1Px = null;
private static Map<String, String> configurationDescriptions = new LinkedHashMap<>();
private static Map<String, String> configurationTitles = new LinkedHashMap<>();

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.exporters.shape;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.ImageTagBufferedImage;
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
@@ -422,10 +423,12 @@ public class BitmapExporter extends ShapeExporterBase {
}
}
//always display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * unzoom / aaScale < 1 * SWF.unitDivisor) {
thickness = 1 * SWF.unitDivisor / (unzoom / aaScale);
}
if (Configuration.useMinimumStrokeWidth1Px.get()) {
//display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * unzoom / aaScale < 1 * SWF.unitDivisor) {
thickness = 1 * SWF.unitDivisor / (unzoom / aaScale);
}
}
if (joinStyle == BasicStroke.JOIN_MITER) {
lineStroke = new ExtendedBasicStroke((float) thickness, capStyle, ExtendedBasicStroke.JOIN_MITER_CLIP, miterLimit);

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.exporters.shape;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
@@ -238,11 +239,13 @@ public class SVGShapeExporter extends DefaultSVGShapeExporter {
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
finalizePath();
//always display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * displayZoom * thicknessScale < 1 * SWF.unitDivisor) {
path.setAttribute("ffdec:has-small-stroke", "true");
path.setAttribute("ffdec:original-stroke-width", Double.toString(thickness * displayZoom / SWF.unitDivisor));
thickness = 1 * SWF.unitDivisor / displayZoom / thicknessScale;
if (Configuration.useMinimumStrokeWidth1Px.get()) {
//display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * displayZoom * thicknessScale < 1 * SWF.unitDivisor) {
path.setAttribute("ffdec:has-small-stroke", "true");
path.setAttribute("ffdec:original-stroke-width", Double.toString(thickness * displayZoom / SWF.unitDivisor));
thickness = 1 * SWF.unitDivisor / displayZoom / thicknessScale;
}
}
thickness *= zoom / SWF.unitDivisor;

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.exporters.shape;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
@@ -306,11 +307,11 @@ public class XamlShapeExporter extends ShapeExporterBase {
public void lineStyle(double thickness, RGB color, boolean pixelHinting, String scaleMode, int startCaps, int endCaps, int joints, float miterLimit, boolean noClose) {
finalizePath();
//always display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * displayZoom * thicknessScale < 1 * SWF.unitDivisor) {
//path.setAttribute("ffdec:has-small-stroke", "true");
//path.setAttribute("ffdec:original-stroke-width", Double.toString(thickness * displayZoom / SWF.unitDivisor));
thickness = 1 * SWF.unitDivisor / displayZoom / thicknessScale;
if (Configuration.useMinimumStrokeWidth1Px.get()) {
//display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness * displayZoom * thicknessScale < 1 * SWF.unitDivisor) {
thickness = 1 * SWF.unitDivisor / displayZoom / thicknessScale;
}
}
thickness *= zoom / SWF.unitDivisor;

View File

@@ -1,6 +1,7 @@
package com.jpexs.decompiler.flash.exporters.shape.aa;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
@@ -412,9 +413,11 @@ public class AntialiasedBitmapExporter extends BitmapExporter {
thickness *= unzoom / SWF.unitDivisor;
//always display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness < 1) {
thickness = 1;
if (Configuration.useMinimumStrokeWidth1Px.get()) {
//display minimum stroke of 1 pixel, no matter how zoomed it is
if (thickness < 1) {
thickness = 1;
}
}
if (joinStyle == BasicStroke.JOIN_MITER) {