110,545
社区成员
发帖
与我相关
我的任务
分享
Bitmap newBitmap = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(newBitmap, panel1.ClientRectangle);
Bitmap halfBitmap = new Bitmap(newBitmap.Width, newBitmap.Height >> 1);
Graphics g = Graphics.FromImage(halfBitmap);
g.DrawImage(newBitmap, 0, -halfBitmap.Height);
g.Dispose();
halfBitmap.Save("d:\\2222.png", System.Drawing.Imaging.ImageFormat.Png);
halfBitmap.Dispose();
Bitmap newBitmap = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(newBitmap,panel1.ClientRectangle);
Bitmap halfBitmap = newBitmap.Clone(new Rectangle(0,newBitmap.Height>>1,newBitmap.Width,newBitmap.Height>>1),newBitmap.PixelFormat);
newBitmap.Dispose();
halfBitmap.Save("d:\\2222.png", System.Drawing.Imaging.ImageFormat.Png);
halfBitmap.Dispose();
memoryImageSamSung = new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(memoryImageSamSung, new Rectangle(0, 0, this.Width, this.Height));
Bitmap newBitmap = new Bitmap(panel1.Width, panel1.Height);
Graphics mygraphics = Graphics.FromImage(newBitmap);
Rectangle rectangle = new Rectangle(0, this.panel1.Height / 2, panel1.Width, panel1.Height / 2);
Rectangle newRectangle = new Rectangle(0, 0, panel1.Width, panel1.Height);
mygraphics.DrawImage(memoryImageSamSung, newRectangle, rectangle, GraphicsUnit.Pixel);
newBitmap.Save(@"f:\aaa.jpg");
private void button1_Click(object sender, EventArgs e)
{
Bitmap newBitmap = new Bitmap(panel1.Width, panel1.Height / 2);
Graphics g = Graphics.FromImage(newBitmap);
Point src = PointToScreen(new Point(panel1.Location.X, panel1.Location.Y + panel1.Height / 2));
Point dest = new Point(0, 0);
g.CopyFromScreen(src, dest, new Size(newBitmap.Width, newBitmap.Height), CopyPixelOperation.SourceCopy);
g.Dispose();
newBitmap.Save("d:\\2222.png", System.Drawing.Imaging.ImageFormat.Png);
newBitmap.Dispose();
}