package graph;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Img {
public BufferedImage getImg(String fnm) {
BufferedImage bi = null;
try {
bi = ImageIO.read(new File(fnm));
} catch (Exception e) {
e.printStackTrace();
}
return bi;
}
public void mkImgFile(String fnm, BufferedImage img) {
try {
ImageIO.write(img, "jpg", new File(fnm));
} catch (Exception e) {
e.printStackTrace();
}
}
public static int[] getSplitRGB(BufferedImage image, int x, int y) {
int[] rgb = null;
if (image != null && x
rgb = new int[3];
int pixel = image.getRGB(x, y);
rgb = getSplitRGB(pixel);
}
return rgb;
}
public static int[] getSplitRGB(int pixel) {
int[] rgbs = new int[3];
rgbs[ 0] = (pixel & 0xff0000) >> 16;
rgbs[ 1] = (pixel & 0xff00) >> 8;
rgbs[ 2] = (pixel & 0xff);
return rgbs;
}
public static int[] getPixes(BufferedImage bimg) {
int w = bimg.getWidth();
int h = bimg.getHeight();
int[] rgbs = new int[h * w];
bimg.getRGB(0, 0, w, h, rg