|
@@ -29,14 +29,27 @@ public class MarkerUtils {
|
29
|
29
|
|
30
|
30
|
// Color[] map = getColorMapping(color);
|
31
|
31
|
int outerRGB = outer.getRGB() & 0x00ffffff;
|
32
|
|
- int innerRGB = inner.getRGB() & 0x00ffffff;
|
33
|
32
|
for (int i = 0; i < image.getHeight(); ++i) {
|
34
|
33
|
for (int j = 0; j < image.getWidth(); ++j) {
|
35
|
|
- if (i >= MIN_Y_CENTER && i < MAX_Y_CENTER && j >= MIN_X_CENTER
|
36
|
|
- && j < MAX_X_CENTER) {
|
37
|
|
- image.setRGB(j, i, innerRGB
|
38
|
|
- | ((mode == AlphaMode.OPAQUE ? MAXIMUM_MAX_VALUE : mask[i][j]) << 24));
|
|
34
|
+
|
|
35
|
+ // If we are in the "inner" part of the marker...
|
|
36
|
+ if (i >= MIN_Y_CENTER && i < MAX_Y_CENTER && j >= MIN_X_CENTER && j < MAX_X_CENTER
|
|
37
|
+ && mask[i][j] != MAXIMUM_INNER_MASK_VALUE) {
|
|
38
|
+ // Don't ask... https://stackoverflow.com/a/29321264/2666289
|
|
39
|
+ // Basically, this compute a "middle" color between outer and inner depending on
|
|
40
|
+ // the current mask value.
|
|
41
|
+ double t = 1 - (mask[i][j] - MINIMUM_INNER_MASK_VALUE)
|
|
42
|
+ / (double) (MAXIMUM_INNER_MASK_VALUE - MINIMUM_INNER_MASK_VALUE);
|
|
43
|
+ int r = (int) Math.sqrt((1 - t) * outer.getRed() * outer.getRed()
|
|
44
|
+ + t * inner.getRed() * inner.getRed());
|
|
45
|
+ int g = (int) Math.sqrt((1 - t) * outer.getGreen() * outer.getGreen()
|
|
46
|
+ + t * inner.getGreen() * inner.getGreen());
|
|
47
|
+ int b = (int) Math.sqrt((1 - t) * outer.getBlue() * outer.getBlue()
|
|
48
|
+ + t * inner.getBlue() * inner.getBlue());
|
|
49
|
+ int a = mode == AlphaMode.OPAQUE ? MAXIMUM_INNER_MASK_VALUE : mask[i][j];
|
|
50
|
+ image.setRGB(j, i, (a << 24) | (r << 16) | (g << 8) | b);
|
39
|
51
|
}
|
|
52
|
+ // Otherwize, just fill with the outer color and set the alpha value properly.
|
40
|
53
|
else {
|
41
|
54
|
image.setRGB(j, i, outerRGB | (mask[i][j] << 24));
|
42
|
55
|
}
|
|
@@ -53,7 +66,7 @@ public class MarkerUtils {
|
53
|
66
|
// with a different color.
|
54
|
67
|
private static final int MIN_X_CENTER = 40, MAX_X_CENTER = 101, MIN_Y_CENTER = 40,
|
55
|
68
|
MAX_Y_CENTER = 100;
|
56
|
|
- private static final int MAXIMUM_MAX_VALUE = 249;
|
|
69
|
+ private static final int MINIMUM_INNER_MASK_VALUE = 116, MAXIMUM_INNER_MASK_VALUE = 249;
|
57
|
70
|
|
58
|
71
|
/**
|
59
|
72
|
* @return Retrieve the mask from the mask file or from the cache.
|