// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/Color.java
// public enum Color {
// 	BLACK, DARK_GRAY, LIGHT_GRAY, WHITE;
// }
// 
// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/DrawingColors.java
// public class DrawingColors {
// 	private final Color foreground;
// 
// 	private final Color background;
// 
// 	public DrawingColors(Color foreground, Color background) {
// 		this.foreground = foreground;
// 		this.background = background;
// 	}
// 
// 	public Color getForeground() {
// 		return foreground;
// 	}
// 
// 	public Color getBackground() {
// 		return background;
// 	}
// }
// 
// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/EPaperValidationException.java
// public class EPaperValidationException extends EPaperException {
// 	private static final long serialVersionUID = 1L;
// 
// 	public EPaperValidationException(String message) {
// 		super(message);
// 	}
// }


import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import fr.romainmoreau.epaper.client.api.Color;
import fr.romainmoreau.epaper.client.api.DrawingColors;
import fr.romainmoreau.epaper.client.api.EPaperValidationException;
package fr.romainmoreau.epaper.client.common;




public class Colors {
	public static Color fromRgb(int rgb) {
		java.awt.Color color = new java.awt.Color(rgb);
		return Color.values()[(int) Math
				.floor((0.21 * color.getRed() + 0.72 * color.getGreen() + 0.07 * color.getBlue()) / 64d)];
	}

	public static Map<Color, List<Point>> getColorPointsMap(InputStream inputStream) throws IOException {
		BufferedImage image = ImageIO.read(inputStream);
		Map<Color, List<Point>> points = new HashMap<>();
		for (Color color : Color.values()) {
			points.put(color, new ArrayList<>());
		}
		for (int y = 0; y < image.getHeight(); y++) {
			for (int x = 0; x < image.getWidth(); x++) {
				points.get(Colors.fromRgb(image.getRGB(x, y))).add(new Point(x, y));
			}
		}
		return points;
	}

// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/Color.java
// public enum Color {
// 	BLACK, DARK_GRAY, LIGHT_GRAY, WHITE;
// }
// 
// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/DrawingColors.java
// public class DrawingColors {
// 	private final Color foreground;
// 
// 	private final Color background;
// 
// 	public DrawingColors(Color foreground, Color background) {
// 		this.foreground = foreground;
// 		this.background = background;
// 	}
// 
// 	public Color getForeground() {
// 		return foreground;
// 	}
// 
// 	public Color getBackground() {
// 		return background;
// 	}
// }
// 
// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/EPaperValidationException.java
// public class EPaperValidationException extends EPaperException {
// 	private static final long serialVersionUID = 1L;
// 
// 	public EPaperValidationException(String message) {
// 		super(message);
// 	}
// }


// Path: e-paper-client-common/src/main/java/fr/romainmoreau/epaper/client/common/Colors.java
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.imageio.ImageIO;
import fr.romainmoreau.epaper.client.api.Color;
import fr.romainmoreau.epaper.client.api.DrawingColors;
import fr.romainmoreau.epaper.client.api.EPaperValidationException;

package fr.romainmoreau.epaper.client.common;




public class Colors {
	public static Color fromRgb(int rgb) {
		java.awt.Color color = new java.awt.Color(rgb);
		return Color.values()[(int) Math
				.floor((0.21 * color.getRed() + 0.72 * color.getGreen() + 0.07 * color.getBlue()) / 64d)];
	}

	public static Map<Color, List<Point>> getColorPointsMap(InputStream inputStream) throws IOException {
		BufferedImage image = ImageIO.read(inputStream);
		Map<Color, List<Point>> points = new HashMap<>();
		for (Color color : Color.values()) {
			points.put(color, new ArrayList<>());
		}
		for (int y = 0; y < image.getHeight(); y++) {
			for (int x = 0; x < image.getWidth(); x++) {
				points.get(Colors.fromRgb(image.getRGB(x, y))).add(new Point(x, y));
			}
		}
		return points;
	}

	public static void validateDrawingColors(DrawingColors drawingColors) throws EPaperValidationException {