java 图片拼接 高分奉上
package screen;
import java.io.File;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class Picture
{ public Picture(String filePath,double leftcoordinate_x,int time){
try
{ for(int i=0;i<time;i++){
//读取第一张图片
File fileOne = new File(filePath+leftcoordinate_x+"("+i+")"+".Png");
BufferedImage ImageOne = ImageIO.read(fileOne);
int width = ImageOne.getWidth();//图片宽度
int height = ImageOne.getHeight();//图片高度
//从图片中读取RGB
int[] ImageArrayOne = new int[width*height];
ImageArrayOne = ImageOne.getRGB(0,0,width,height,ImageArrayOne,0,width);
//对第二张图片做相同的处理
int two=i+1;
File fileTwo = new File(filePath+leftcoordinate_x+"("+two+")"+".Png");
BufferedImage ImageTwo = ImageIO.read(fileTwo);
int[] ImageArrayTwo = new int[width*height];
ImageArrayTwo = ImageTwo.getRGB(0,0,width,height,ImageArrayTwo,0,width);
//对第三张图片做相同的处理
int three=i+2;
File fileThree = new File(filePath+leftcoordinate_x+"("+three+")"+".Png");
BufferedImage ImageThree = ImageIO.read(fileThree);
int[] ImageArrayThree = new int[width*height];
ImageArrayThree = ImageThree.getRGB(0,0,width,height,ImageArrayThree,0,width);
//生成新图片
int widthtwo=width+1240;
BufferedImage ImageNew = new BufferedImage(widthtwo,height,BufferedImage.TYPE_INT_RGB);
ImageNew.setRGB(0,0,width,height,ImageArrayOne,0,width);//设置左半部分的RGB
ImageNew.setRGB(623,0,width,height,ImageArrayTwo,0,width);//设置右半部分的RGB
ImageNew.setRGB(1240,0,width,height,ImageArrayThree,0,width);
File outFile = new File(filePath+leftcoordinate_x+"("+i+i+")"+".Png");
ImageIO.write(ImageNew, "png", outFile);//写图片
i=i+2;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
这是我用来图片拼接的,因为我把握不住那个起始X坐标所以拼接的横不理想,有没有高手能告诉下,有没有其它的方法,基于象素数组的算法,想做到无缝拼接!
或者油水能告诉我在GOOGLEEARTH上面按着方向键一秒钟,能在地图上走多少,我指的是相对于桌面的,也就是走了多少象素,有谁能相告一下,高分奉上,谢谢!