Ejemplo n.º 1
0
 public static Bitmap Paste(this Bitmap bac, Bitmap bmp, Point p, ImagePasteMode imagepastemode, Rectangle region = default(Rectangle))
 {
     int w1 = Math.Max(-p.X, 0), w2 = Math.Min(bmp.Width, bac.Width - p.X);
     int h1 = Math.Max(-p.Y, 0), h2 = Math.Min(bmp.Height, bac.Height - p.Y);
     if (w1 >= w2 || h1 >= h2) return bac;
     Point sp = new Point(w1 + p.X, h1 + p.Y);
     BitmapData data_bac = bac.GetBitmapData(new Rectangle(sp, new Size(w2 - w1, h2 - h1)));
     BitmapData data_bmp = bmp.GetBitmapData(new Rectangle(new Point(w1, h1), new Size(w2 - w1, h2 - h1)));
     if (region != default(Rectangle)) region = region.Add_Location(-sp.X, -sp.Y);
     data_bac.Paste(data_bmp, new Point(0, 0), imagepastemode, region);
     bac.UnlockBits(data_bac);
     bmp.UnlockBits(data_bmp);
     return bac;
 }