package comjunittest;
import javaawtimageBufferedImage;
import javaioFile;
import URL;
import javaximageioImageIO;
import javautil*;
public class Test {
public static void main(String [] args)
{
try {
//本地地址或URL 的图片
//BufferedImage bi = ImageIOread(new URL());
BufferedImage bi = ImageIOread(new File(D:\\jpg));
//截取任意区域的图片
//BufferedImage subimg = bigetSubimage( );
int width = bigetWidth();
int height = bigetHeight();
Systemoutprintln(w:+width);
Systemoutprintln(h:+height);
int [][]datas = new int[width][height];
int [][]datastmp = new int[width][height];
for(int i = ;i< height;i++)
{
for(int j = ;j<width;j++)
{
datas[j][i]= bigetRGB(j i);
datastmp[j][i]= bigetRGB(j i);
Systemoutprint( bigetRGB(j i)+ );
}
Systemoutprintln();
}
int [][] xz = XZ(dataswidthheight);
for(int i = ;i< height;i++)
{
for(int j = ;j<width;j++)
{
bisetRGB(j i xz[j][i]);
}
}
ImageIOwrite(bi JPEG new File(D:\\jpg));
}
/***
* 图片旋转数据处理
* @param datas
* @param width
* @param height
* @param FX 为上下反转 为左右反转
* @return
*/
public static int [][] XZ(int [][] datasint widthint heightint FX)
{
try {
int[][] tmps= new int [width][height];
if(FX==)
{
for(int i = a=height;i< height;i++a)
{
for(int j = b=width;j<width;j++b)
{
tmps[a] = datas[j][i];
}
}
}
else if (FX==)
{
for(int i = ;i< height;i++)
{
for(int j = b=width;j<width;j++b)
{
tmps[i] = datas[j][i];
}
}
}
return tmps;
} catch (Exception e) {
// TODO: handle exception
Systemoutprintln(ex:+egetMessage());
return null;
}
}