【发布时间】:2010-02-19 18:32:03
【问题描述】:
我正在摆弄一个桌面小工具(时钟)。它下面有一个反射效果,需要透明,我使用 CopyFromScreen 来获取背景,然后将表单背景设置为此。
像这样(“停靠/取消停靠”按钮的一部分):
Rectangle bounds = this.Bounds;
using (Bitmap ss = new Bitmap(bounds.Width, bounds.Height))
using (Graphics g = Graphics.FromImage(ss))
{
this.Opacity = 0;
g.CopyFromScreen(this.Location, Point.Empty, bounds.Size);
ss.Save(@"C:\clock1s\bg", ImageFormat.Png);
this.Opacity = 100;
this.BackgroundImage = new Bitmap(@"C:\clock1s\bg");
g.Dispose();
}
现在,每当我想再次使用它(例如移动时钟)时,我都无法删除该文件或重新保存它,因为它当前正在使用中。我已经尝试将表单 BG 设置为其他内容,但这不起作用。
我该怎么做?
编辑:已排序,谢谢 (Lance McNearney)。
现在,如果我不得不将它保存到文件中呢?
另外,额外的问题:
the goddamn batwatch http://upload.snelhest.org/images/100219batwatch.jpg
选择和图标最终位于表单下方是一个小麻烦,如果可能的话,我希望它们最终位于顶部或下方(保持平滑的抗锯齿)。不过,我假设这是我无法解决的问题。
【问题讨论】:
标签: c# winforms image file desktop