开发者

C# print screen scrollable control

开发者 https://www.devze.com 2023-02-20 00:07 出处:网络
i have a control that is the plotter which is scrollable. After the plotter has finished plotting, it is able to scroll just like this:

i have a control that is the plotter which is scrollable. After the plotter has finished plotting, it is able to scroll just like this:

C# print screen scrollable control

My plotter is a real-time plotter i.e. meaning it plots as time goes by and it's not a static plotter(one which u put in the values manually). After I've stopped the plotter, I'm able to scroll around the plotter to see the results. However, I want to save the plotte开发者_JAVA技巧r into an image, which I'm trying to do using print screen method. But what I was able to capture is only the visible part of the plotter, but not the non-visible part of the plotter(which is because it needs scrolling). I hope it's clearer now. The code for the print screen is:

// Set the bitmap object to the size of the screen
        bmpScreenshot = new Bitmap(panel2.Bounds.Width, panel2.Bounds.Height, PixelFormat.Format32bppArgb);
        // Create a graphics object from the bitmap
        gfxScreenshot = Graphics.FromImage(bmpScreenshot);

        Point p = this.PointToScreen(new Point(panel2.Bounds.X, panel2.Bounds.Y));
        gfxScreenshot.CopyFromScreen(p.X, p.Y, 0, 0,
                         panel2.Bounds.Size, CopyPixelOperation.SourceCopy);


        SaveFileDialog saveImageDialog = new SaveFileDialog();
        saveImageDialog.Title = "Select output file:";
        saveImageDialog.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
        if (saveImageDialog.ShowDialog() == DialogResult.OK)
        {
            bmpScreenshot.Save(saveImageDialog.FileName, ImageFormat.Jpeg);
        }

Thanks a lot.


Have a look here: http://www.eggheadcafe.com/community/aspnet/2/10201852/how-to-print-window-form-usig-cnet.aspx you should call the Win32 API PrintWindow.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号