diff --git a/build.gradle b/build.gradle
index 2578df7..822dd02 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ plugins {
}
group 'pl.asie.zima'
-version '0.6.0'
+version '0.7.0'
repositories {
mavenCentral()
diff --git a/docs/changelog/0.7.0.txt b/docs/changelog/0.7.0.txt
new file mode 100644
index 0000000..8f69027
--- /dev/null
+++ b/docs/changelog/0.7.0.txt
@@ -0,0 +1,8 @@
+Improvements:
+
+* Added experimental "GMse" converter algorithm.
+* Added "Toggle all" button to the Elements tab.
+
+Bugs fixed:
+
+* Fixed performance regression from zima 0.6.0.
\ No newline at end of file
diff --git a/docs/changelog/versions.txt b/docs/changelog/versions.txt
index 850a028..c7d968f 100644
--- a/docs/changelog/versions.txt
+++ b/docs/changelog/versions.txt
@@ -6,4 +6,5 @@
0.4.2
0.5.0
0.5.1
-0.6.0
\ No newline at end of file
+0.6.0
+0.7.0
\ No newline at end of file
diff --git a/src/main/java/pl/asie/zima/image/GmseImageMseCalculator.java b/src/main/java/pl/asie/zima/image/GmseImageMseCalculator.java
index 39cf7ae..4ac086c 100644
--- a/src/main/java/pl/asie/zima/image/GmseImageMseCalculator.java
+++ b/src/main/java/pl/asie/zima/image/GmseImageMseCalculator.java
@@ -20,7 +20,6 @@
import pl.asie.libzzt.TextVisualData;
import pl.asie.zima.util.ColorUtils;
-import pl.asie.zima.util.DebugUtils;
import pl.asie.zima.util.Gaussian2DKernel;
import java.awt.image.BufferedImage;
@@ -108,8 +107,6 @@ public GaussianCharCache(TextVisualData visual, int radius, float sigma) {
float[] data = this.cache.get(entries.getKey());
Arrays.fill(data, entries.getValue());
}
-
- DebugUtils.print1DArray(this.cache.get(178), visual.getCharWidth());
}
public float[] getGaussian(int chr) {
@@ -123,12 +120,14 @@ public float[] getGaussian(int chr) {
private final float contrastReduction;
private final boolean blinkingDisabled;
- public GmseImageMseCalculator(TextVisualData visual, boolean blinkingDisabled, float contrastReduction) {
+ public GmseImageMseCalculator(TextVisualData visual, boolean blinkingDisabled, float contrastReduction, float accurateApproximate) {
this.visual = visual;
- this.gaussCache = new GaussianCharCache(visual, 3, 1.5f);
- this.mixCache = new ColorMixCache(visual, 256);
this.contrastReduction = contrastReduction;
this.blinkingDisabled = blinkingDisabled;
+
+ float size = 0.05f + (accurateApproximate * 1.45f);
+ this.gaussCache = new GaussianCharCache(visual, 3, size);
+ this.mixCache = new ColorMixCache(visual, 256);
}
@Override
diff --git a/src/main/java/pl/asie/zima/image/ImageConverterType.java b/src/main/java/pl/asie/zima/image/ImageConverterType.java
new file mode 100644
index 0000000..ab50ee0
--- /dev/null
+++ b/src/main/java/pl/asie/zima/image/ImageConverterType.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2020, 2021 Adrian Siekierka
+ *
+ * This file is part of zima.
+ *
+ * zima is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * zima is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with zima. If not, see .
+ */
+package pl.asie.zima.image;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor
+public enum ImageConverterType {
+ TRIX("Trix"),
+ GMSE("GMse (Experimental)");
+
+ private final String name;
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/src/main/java/pl/asie/zima/image/gui/ZimaConversionProfile.java b/src/main/java/pl/asie/zima/image/gui/ZimaConversionProfile.java
index 6830ba4..3eecaff 100644
--- a/src/main/java/pl/asie/zima/image/gui/ZimaConversionProfile.java
+++ b/src/main/java/pl/asie/zima/image/gui/ZimaConversionProfile.java
@@ -48,6 +48,8 @@ public class ZimaConversionProfile {
public static final Property STAT_CYCLE = Property.create("output.statCycle", 0);
public static final Property MAX_STAT_COUNT = Property.create("converter.maxStatCount", 150);
public static final Property MAX_BOARD_SIZE = Property.create("converter.maxBoardSize", 20002);
+
+ public static final Property IMAGE_CONVERTER_TYPE = Property.create("converter.type", ImageConverterType.TRIX, MSE_CALCULATOR);
public static final Property TRIX_CONTRAST_REDUCTION = Property.create("converter.trix.contrastReduction", 0.0035f, MSE_CALCULATOR);
public static final Property TRIX_ACCURATE_APPROXIMATE = Property.create("converter.trix.accurateApproximate", 0.45f, MSE_CALCULATOR);
@@ -188,8 +190,14 @@ public Pair convert(BufferedImage input, P
this.renderer = new TextVisualRenderer(properties.get(VISUAL_DATA), properties.get(PLATFORM));
}
if (localHolder.isAffected(MSE_CALCULATOR) || this.mseCalculator == null) {
- this.mseCalculator = new TrixImageMseCalculator(properties.get(VISUAL_DATA), properties.get(BLINKING_DISABLED), properties.get(TRIX_CONTRAST_REDUCTION), properties.get(TRIX_ACCURATE_APPROXIMATE));
- //this.mseCalculator = new GmseImageMseCalculator(properties.get(VISUAL_DATA), properties.get(BLINKING_DISABLED), properties.get(TRIX_CONTRAST_REDUCTION));
+ switch (properties.get(IMAGE_CONVERTER_TYPE)) {
+ case TRIX:
+ this.mseCalculator = new TrixImageMseCalculator(properties.get(VISUAL_DATA), properties.get(BLINKING_DISABLED), properties.get(TRIX_CONTRAST_REDUCTION), properties.get(TRIX_ACCURATE_APPROXIMATE));
+ break;
+ case GMSE:
+ this.mseCalculator = new GmseImageMseCalculator(properties.get(VISUAL_DATA), properties.get(BLINKING_DISABLED), properties.get(TRIX_CONTRAST_REDUCTION), properties.get(TRIX_ACCURATE_APPROXIMATE));
+ break;
+ }
localHolder.affect(IMAGE_CONVERTER);
}
if (localHolder.isAffected(IMAGE_CONVERTER) || this.converter == null) {
diff --git a/src/main/java/pl/asie/zima/image/gui/ZimaFrontendSwing.java b/src/main/java/pl/asie/zima/image/gui/ZimaFrontendSwing.java
index ccf2244..4cc2422 100644
--- a/src/main/java/pl/asie/zima/image/gui/ZimaFrontendSwing.java
+++ b/src/main/java/pl/asie/zima/image/gui/ZimaFrontendSwing.java
@@ -129,6 +129,7 @@ Platform.MEGAZEUX, new ImageConverterRuleset(List.of())
);
private Map rulesetBoxEdit = new HashMap<>();
private ImageConverterRuleset customRuleset;
+ private JComboBox converterTypeEdit;
private JSlider contrastReductionEdit;
private JButton contrastReductionReset;
private JSlider accurateApproximateEdit;
@@ -297,6 +298,9 @@ public ZimaFrontendSwing(byte[] defaultCharset, int[] defaultPalette, String zim
bindPropertyInt(this.profile.getProperties(), ZimaConversionProfile.MAX_BOARD_SIZE, this.maxBoardSizeEdit);
this.profile.getProperties().addChangeListener(ZimaConversionProfile.PLATFORM, (k, v) -> this.maxBoardSizeEdit.setModel(boardSizeModel(((Number) this.maxBoardSizeEdit.getValue()).intValue())));
+ appendTabRow(this.optionsBoardPanel, gbc, "Conversion algorithm", this.converterTypeEdit = createEnumComboBox(ImageConverterType.class));
+ bindPropertyEnum(this.profile.getProperties(), ZimaConversionProfile.IMAGE_CONVERTER_TYPE, this.converterTypeEdit);
+
appendTabRow(this.optionsBoardPanel, gbc, "Accurate/Approximate",
this.accurateApproximateEdit = new JSlider(JSlider.HORIZONTAL, 0, 1000, 0),
this.accurateApproximateReset = new JButton("Reset"));