Skip to content

Commit 6a63651

Browse files
committed
Fix color extraction
1 parent 480deee commit 6a63651

1 file changed

Lines changed: 1 addition & 20 deletions

File tree

src/main/java/space/essem/image2map/renderer/MapRenderer.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@
2828
import space.essem.image2map.ImageData;
2929

3030
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-
4331
public static CanvasImage render(BufferedImage image, DitherMode mode, int width, int height) {
4432
Image resizedImage = image.getScaledInstance(width, height, Image.SCALE_DEFAULT);
4533
BufferedImage resized = convertToBufferedImage(resizedImage);
@@ -142,16 +130,9 @@ public static List<ItemStack> toVanillaItems(CanvasImage image, ServerLevel worl
142130
return stack;
143131
}*/
144132

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-
152133
private static CanvasColor floydDither(int[][] pixels, int x, int y, int imageColor) {
153134
var closestColor = CanvasUtils.findClosestColorARGB(imageColor);
154-
var palletedColor = mapColorToRGBColor(closestColor);
135+
var palletedColor = closestColor.getRgbColor();
155136

156137
var errorR = ARGB.red(imageColor) - ARGB.red(palletedColor);
157138
var errorG = ARGB.green(imageColor) - ARGB.green(palletedColor);

0 commit comments

Comments
 (0)