Skip to content

Commit

Permalink
Minor & subjective gigascreen colour fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KodeMunkie committed Aug 2, 2020
1 parent 0f1ab7c commit 6aa3b85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6aa3b85

Please sign in to comment.