package com.fdkankan.dxf.generate.util;/*
package com.fdkankan.dxf.generate.util;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Stack;

public class PicAnalysis {
	private static final int abs = 30;
	public static final Color black = new Color(0, 0, 0);
	public static final Color white = new Color(255, 255, 255);

	public static int[][][] analysisPicture(BufferedImage img) {
		int[][][] data = new int[0][][];
		if (img != null) {
			int width = img.getWidth();
			int height = img.getHeight();
			data = new int[width][height][3]; // [0]:0、1:黑;2:白;[1]next;[2]实际
			// 分析图片获取数据
			for (int x = 1; x < width - 1; x++) {
				for (int y = 1; y < height - 1; y++) {
					int rgb = img.getRGB(x, y);
					Color colors = new Color(rgb);
					data[x][y][2] = rgb;

					double red = (new Color(data[x - 1][y][2]).getRed() + new Color(data[x + 1][y][2]).getRed() - new Color(data[x][y - 1][2]).getRed() - new Color(data[x][y + 1][2]).getRed()
							+ 0.5 * (new Color(data[x - 1][y - 1][2]).getRed() - new Color(data[x + 1][y + 1][2]).getRed())
							+ 0.5 * (new Color(data[x + 1][y - 1][2]).getRed() - new Color(data[x - 1][y + 1][2]).getRed()));
					double green = (new Color(data[x - 1][y][2]).getGreen() + new Color(data[x + 1][y][2]).getGreen() - new Color(data[x][y - 1][2]).getGreen()
							- new Color(data[x][y + 1][2]).getGreen() + 0.5 * (new Color(data[x - 1][y - 1][2]).getGreen() - new Color(data[x + 1][y + 1][2]).getGreen())
							+ 0.5 * (new Color(data[x + 1][y - 1][2]).getGreen() - new Color(data[x - 1][y + 1][2]).getGreen()));
					double blue = (new Color(data[x - 1][y][2]).getBlue() + new Color(data[x + 1][y][2]).getBlue() - new Color(data[x][y - 1][2]).getBlue() - new Color(data[x][y + 1][2]).getBlue()
							+ 0.5 * (new Color(data[x - 1][y - 1][2]).getBlue() - new Color(data[x + 1][y + 1][2]).getBlue())
							+ 0.5 * (new Color(data[x + 1][y - 1][2]).getBlue() - new Color(data[x - 1][y + 1][2]).getBlue()));

					if (Math.abs(red) + Math.abs(green) + Math.abs(blue) < abs) {
						data[x][y][0] = 1;
					}

					if ((colors.getRed() + colors.getBlue() + colors.getGreen()) > 255 * 2.95) {
						data[x][y][0] = 2;
					}
				}
			}
			// 获取黑色数据
			for (int y = 1; y < height - 1; y++) {
				for (int x = 1; x < width - 1; x++) {
					if (data[x][y][1] <= 0) {
						Stack<Integer> q = new Stack<>();
						q.add(x * 10000 + y);
						pro(data, q, width, height);
					}
				}
			}
		}
		return data;
	}

	private static void pro(int[][][] data, Stack<Integer> queue, int width, int height) {
		while (queue.size() > 0) {
			int a = queue.pop();
			int x = a / 10000;
			int y = a % 10000;

			if (data[x][y][0] == 0 && data[x][y][1] <= 0) {
				data[x][y][1] = 1;

				if (queue.size() < 1000) {
					if (x < width - 1 && data[x + 1][y][1] <= 0) {
						int ad = (x + 1) * 10000 + y;
						queue.add(ad);
					}
					if (y < height - 1 && data[x][y + 1][1] <= 0) {
						int ad = (x) * 10000 + y + 1;
						queue.add(ad);
					}
					if (x > 0 && data[x - 1][y][1] <= 0) {
						int ad = (x - 1) * 10000 + y;
						queue.add(ad);
					}
					if (y > 0 && data[x][y - 1][1] <= 0) {
						int ad = (x) * 10000 + y - 1;
						queue.add(ad);
					}
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedImage img = ImageIO.read(new File("E:\\test\\企业微信截图_20240118165835.png"));
		int[][][] data = analysisPicture(img);
		int width = data.length;
		int height = data[0].length;
//		for (int x = 1; x < width - 1; x++) {
//			for (int y = 1; y < height - 1; y++) {
//				String txt = "x:%s;y:%s;value=%s";
//				System.out.println(String.format(txt, x, y, data[x - 1][y - 1][0]));
//			}
//		}
		try {
			BufferedImage testImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
			for (int x = 1; x < width - 1; x++) {
				for (int y = 1; y < height - 1; y++) {
					testImage.setRGB(x, y, data[x - 1][y - 1][0] == 2 ? black.getRGB() : white.getRGB());
				}
			}
			data = analysisPicture(img);
			width = data.length;
			height = data[0].length;
			testImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
			for (int x = 1; x < width - 1; x++) {
				for (int y = 1; y < height - 1; y++) {
					testImage.setRGB(x, y, data[x - 1][y - 1][0] == 2 ? black.getRGB() : white.getRGB());
				}
			}
			ImageIO.write(testImage, "JPEG", new FileOutputStream("D:\\test1.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
*/
