积极答复者
关于 DrawToBitmap获取到空白图片问题

问题
-
我的一个winfrom程序有一个UserControl,运行期间需要定时获取该界面上的图片并进行保存,我使用DrawToBitmap发现保存的图片中偶尔会出现空白图片?这个是为什么?图片像素尺寸是正常的,但是图片里面只有一个小白条
下面是我的代码
int mapWidth = rtChartPage.Width <= 100 ? 1300 : rtChartPage.Width;
int mapHeight = rtChartPage.Height <= 100 ? 670 : rtChartPage.Height;
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
Bitmap map = new Bitmap(mapWidth, mapHeight);
rtChartPage.DrawToBitmap(map, new Rectangle(0, 0, mapWidth, mapHeight));
map.Save(filePath+fileName);
全部回复
-
Hi Z_H,
我使用定时器连续截取了多张图片,并没有出现你所描述的问题。你能提供一个能够重现该问题的简单项目案例吗?
Regards,
Kyle
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.