实现的代码如下:
1 private void button2_Click(object sender, EventArgs e)
2 {
3 Bitmap curBitmap = new Bitmap(pictureBox1.Image.Width,pictureBox1.Image.Height);
4 Graphics g = Graphics.FromImage(curBitmap);
5 Matrix X = new Matrix();
6 // X.Rotate(30);
7 X.Shear((float)0.16666666667, 0); // 2/12
8 g.Transform = X;
9 // Draw image
10 //Rectangle cloneRect = GetPicValidByValue(128); //Get Valid Pic Rectangle
11 Rectangle cloneRect = new Rectangle(6, 5, 40, 12);
12 Bitmap tmpBmp = ((Bitmap)pictureBox1.Image).Clone(cloneRect, pictureBox1.Image.PixelFormat);
13 g.DrawImage(tmpBmp,
14 new Rectangle(6, 5, 40, 12),
15 0, 0, tmpBmp.Width,
16 tmpBmp.Height,
17 GraphicsUnit.Pixel);
18
19 pictureBox2.Image=curBitmap ;
20 }
21
2 {
3 Bitmap curBitmap = new Bitmap(pictureBox1.Image.Width,pictureBox1.Image.Height);
4 Graphics g = Graphics.FromImage(curBitmap);
5 Matrix X = new Matrix();
6 // X.Rotate(30);
7 X.Shear((float)0.16666666667, 0); // 2/12
8 g.Transform = X;
9 // Draw image
10 //Rectangle cloneRect = GetPicValidByValue(128); //Get Valid Pic Rectangle
11 Rectangle cloneRect = new Rectangle(6, 5, 40, 12);
12 Bitmap tmpBmp = ((Bitmap)pictureBox1.Image).Clone(cloneRect, pictureBox1.Image.PixelFormat);
13 g.DrawImage(tmpBmp,
14 new Rectangle(6, 5, 40, 12),
15 0, 0, tmpBmp.Width,
16 tmpBmp.Height,
17 GraphicsUnit.Pixel);
18
19 pictureBox2.Image=curBitmap ;
20 }
21