From 6aa3b85b845d55d160e0c6ccd0304ebb9d13243a Mon Sep 17 00:00:00 2001 From: KodeMunkie Date: Sun, 2 Aug 2020 18:02:17 +0100 Subject: [PATCH] Minor & subjective gigascreen colour fixes --- .../uk/co/silentsoftware/config/SpectrumDefaults.java | 9 ++++++--- .../converters/image/processors/GigaScreenAttribute.java | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/co/silentsoftware/config/SpectrumDefaults.java b/src/main/java/uk/co/silentsoftware/config/SpectrumDefaults.java index 1fe0d0b..58f5312 100644 --- a/src/main/java/uk/co/silentsoftware/config/SpectrumDefaults.java +++ b/src/main/java/uk/co/silentsoftware/config/SpectrumDefaults.java @@ -27,7 +27,7 @@ */ public class SpectrumDefaults { - private static final int UNIQUE_COLOURS_THRESHOLD = 4; + private static final int UNIQUE_COLOURS_THRESHOLD = 3; /** * The size of Spectrum the colour "blocks" (8x8 pixels default) @@ -329,9 +329,12 @@ public static GigaScreenAttribute[] generateGigascreenAttributes(int[] palette1, for (int paperScreen2 : palette2) { GigaScreenAttribute gc = new GigaScreenAttribute(inkScreen1, paperScreen1, inkScreen2, paperScreen2); - // Only use those attributes that have 4 colours otherwise we don't get + // Only use those attributes that have 3+ colours otherwise we don't get // maximum benefit from this screenmode - if (gc.getUniqueColourCount() == UNIQUE_COLOURS_THRESHOLD) { + // Nb. used to be 4 colour threshold however colour quantisation/distance/attribute calcuations + // seem to benefit where very same colours appear multiple times within 8x8 pixels (this is + // subjective however I think it's important enough to adjust). + if (gc.getUniqueColourCount() >= UNIQUE_COLOURS_THRESHOLD) { combos.add(gc); } } diff --git a/src/main/java/uk/co/silentsoftware/core/converters/image/processors/GigaScreenAttribute.java b/src/main/java/uk/co/silentsoftware/core/converters/image/processors/GigaScreenAttribute.java index 367d895..ed90d7c 100644 --- a/src/main/java/uk/co/silentsoftware/core/converters/image/processors/GigaScreenAttribute.java +++ b/src/main/java/uk/co/silentsoftware/core/converters/image/processors/GigaScreenAttribute.java @@ -16,6 +16,7 @@ */ package uk.co.silentsoftware.core.converters.image.processors; +import org.apache.commons.lang3.StringUtils; import uk.co.silentsoftware.core.helpers.ColourHelper; import java.util.Set; @@ -57,7 +58,7 @@ public class GigaScreenAttribute { // colour for each screen, separate RGB values) private GigaScreenColour[] gigaScreenColours = new GigaScreenColour[4]; private int uniqueColourCount; - private String uniqueHash; + private String uniqueHash = StringUtils.EMPTY; /** * Constructor for a GigaScreenAttribute @@ -136,7 +137,10 @@ public class GigaScreenColour { int[] rgbS1 = ColourHelper.intToRgbComponents(screen1Colour); int[] rgbS2 = ColourHelper.intToRgbComponents(screen2Colour); - gigascreenColour = ColourHelper.componentsToAlphaRgb((rgbS1[0] + rgbS2[0]) / 2, (rgbS1[1] + rgbS2[1]) / 2, (rgbS1[2] + rgbS2[2]) / 2); + gigascreenColour = ColourHelper.componentsToAlphaRgb( + (int)(((long)rgbS1[0] + (long)rgbS2[0]) / 2l), + (int)(((long)rgbS1[1] + (long)rgbS2[1]) / 2l), + (int)(((long)rgbS1[2] + (long)rgbS2[2]) / 2l)); gigascreenColourRGB = ColourHelper.intToRgbComponents(gigascreenColour); }