- 29
- 0
- 约6.91万字
- 约 9页
- 2017-01-03 发布于贵州
- 举报
1、通过拷贝像素 实现图片的切割和拼接来自:百度空间/%B2%E8%B6%E0%B7%D3%BB%BC%D5%DF/blog/item/051081c7df4c5c069c163da6.html这种方法我不想试了,效率太低了try{int count = myarray.Count;//动态数据,保存所有图片的Top和Left,以及最大点的坐标 int width = (((int)myarray[count - 2])/256+1)*256;//使动态生成的图片长和宽式256的整数倍int height = (((int)myarray[count - 1])/256+1)*256;Bitmap newBitmap = new Bitmap(width,height);Color pixel;int width1 = 0, height1 = 0;for (int j = 0; j (count-2)/2; j++){Bitmap oldBitmap=(Bitmap)((PictureBox)this.Controls.Find(newpicturebox+j, true)[0]).Image;width1 = ((PictureBox)this.Controls.Find(newpicturebox+j, true)[0]).Image.Width;height1 = ((PictureBox)this.Controls.Find(newpicturebox+j, true)[0]).Image.Height;int px =Convert.ToInt16(myarray[j*2]);// ((PictureBox)this.Controls.Find(newpicturebox + j, true)[0]).Location.X;int py=Convert.ToInt16(myarray[j*2+1]);//((PictureBox)this.Controls.Find(newpicturebox+j, true)[0]).Location.Y;for(int p=0;pwidth1;p++)for (int q=0; qheight1; q++){pixel = oldBitmap.GetPixel(p,q);newBitmap.SetPixel(px+p,py+q, pixel);}}Clear();this.pictureBox1.Size = new Size(width,height);this.pictureBox1.Image = newBitmap;newBitmap.Save(DirectoryInfoPath+00.jpg, System.Drawing.Imaging.ImageFormat.Jpeg);}catch (Exception ex){MessageBox.Show(ex.Message, 信息提示);} 图片切割: int width2 = this.pictureBox1.Width;int height2 = this.pictureBox1.Height;Bitmap newBitmap = new Bitmap(256, 256);Bitmap oldBitmap = (Bitmap)this.pictureBox1.Image;Color pixel;for (int i = 0; i width2 / 256; i++)for (int j = 0; j height2 / 256; j++){for (int p =i * 256; p i * 256 + 256; p++)for (int q = i * 256; q j * 256 + 256; q++){pixel = oldBitmap.GetPixel(p, q);newBitmap.SetPixel(p%256,q%256, pixel);}newBitmap.Save(DirectoryInfoPath +新+i+j+ .jpg, System.Drawing.Imaging.ImageFormat.Jpeg);} 2、使用Graphics类中的DrawImage方法,实现图片的拼接Graphics draw;来自:博客园/youwang/archive/2011/12/22/2298594.htmlprivate Image JoinImage(List imageList, JoinMode jm){ //图片列表 if (imageList.Count = 0) return null; if (jm == JoinMode.Horizontal) { //横向拼接 int width = 0
原创力文档

文档评论(0)