|
28 | 28 | import space.essem.image2map.ImageData; |
29 | 29 |
|
30 | 30 | public class MapRenderer { |
31 | | - private static final double shadeCoeffs[] = { 0.71, 0.86, 1.0, 0.53 }; |
32 | | - |
33 | | - private static double distance(double[] vectorA, double[] vectorB) { |
34 | | - return Math.sqrt(Math.pow(vectorA[0] - vectorB[0], 2) + Math.pow(vectorA[1] - vectorB[1], 2) |
35 | | - + Math.pow(vectorA[2] - vectorB[2], 2)); |
36 | | - } |
37 | | - |
38 | | - private static double[] applyShade(double[] color, int ind) { |
39 | | - double coeff = shadeCoeffs[ind]; |
40 | | - return new double[] { color[0] * coeff, color[1] * coeff, color[2] * coeff }; |
41 | | - } |
42 | | - |
43 | 31 | public static CanvasImage render(BufferedImage image, DitherMode mode, int width, int height) { |
44 | 32 | Image resizedImage = image.getScaledInstance(width, height, Image.SCALE_DEFAULT); |
45 | 33 | BufferedImage resized = convertToBufferedImage(resizedImage); |
@@ -142,16 +130,9 @@ public static List<ItemStack> toVanillaItems(CanvasImage image, ServerLevel worl |
142 | 130 | return stack; |
143 | 131 | }*/ |
144 | 132 |
|
145 | | - private static int mapColorToRGBColor(CanvasColor color) { |
146 | | - var mcColor = color.getRgbColor(); |
147 | | - double[] mcColorVec = { (double) ARGB.red(mcColor), (double) ARGB.green(mcColor), (double) ARGB.blue(mcColor) }; |
148 | | - double coeff = shadeCoeffs[color.getColor().id & 3]; |
149 | | - return ARGB.color(0, (int) (mcColorVec[0] * coeff), (int) (mcColorVec[1] * coeff), (int) (mcColorVec[2] * coeff)); |
150 | | - } |
151 | | - |
152 | 133 | private static CanvasColor floydDither(int[][] pixels, int x, int y, int imageColor) { |
153 | 134 | var closestColor = CanvasUtils.findClosestColorARGB(imageColor); |
154 | | - var palletedColor = mapColorToRGBColor(closestColor); |
| 135 | + var palletedColor = closestColor.getRgbColor(); |
155 | 136 |
|
156 | 137 | var errorR = ARGB.red(imageColor) - ARGB.red(palletedColor); |
157 | 138 | var errorG = ARGB.green(imageColor) - ARGB.green(palletedColor); |
|
0 commit comments