Tag: system.drawing

为什么DarkGray比Gray更轻?

简单的好奇心在这里,带着一些实际的担忧,因为偶尔会被抓住。 Color.DarkGray是如何比Color.Gray轻?

System.Drawing在Windows或ASP.NET服务

根据MSDN的说法,在Windows服务或ASP.NET服务的System.Drawing命名空间中使用类并不是一个特别好的主意。 现在我正在开发一个类库,它可能需要访问这个特定的命名空间(用于测量字体),但不能保证主机进程不是服务。 现在,如果System.Drawing不可用,还有一个不太理想的方法,但是如果可能的话,我宁愿在System.Drawing中使用类。 所以我想要做的是在runtume中确定System.Drawing是否安全,如果是,则使用它,否则返回到次优选项。 我的问题是: 我怎么可能检测到System.Drawing是否安全使用? 我想我也应该 检测当前进程是Windows服务还是ASP.NET服务 检测GDI是否可用 或者也许有一种方法来问System.Drawing.dll本身,如果它是安全的使用 不幸的是,我不能想出一个方法来实现这些方法。 有没有人有任何想法?

Bitmap.Save方法中的GDI +中发生了一般性错误

我正在上传并将缩略图副本保存在缩略图文件夹中。 我正在使用以下链接: http://weblogs.asp.net/markmcdonnell/archive/2008/03/09/resize-image-before-uploading-to-server.aspx 但 newBMP.Save(directory + "tn_" + filename); 导致exception“GDI +中发生一般性错误”。 我试图给予文件夹权限,也试图保存时使用新的单独的bmp对象。 编辑: protected void ResizeAndSave(PropBannerImage objPropBannerImage) { // Create a bitmap of the content of the fileUpload control in memory Bitmap originalBMP = new Bitmap(fuImage.FileContent); // Calculate the new image dimensions int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; int sngRatio = origWidth / […]

如何截取WPF控件的截图?

我使用Bing地图WPF控件创build了一个WPF应用程序。 我想只能截图Bing地图控件。 使用这个代码来制作屏幕截图: // Store the size of the map control int Width = (int)MyMap.RenderSize.Width; int Height = (int)MyMap.RenderSize.Height; System.Windows.Point relativePoint = MyMap.TransformToAncestor(Application.Current.MainWindow).Transform(new System.Windows.Point(0, 0)); int X = (int)relativePoint.X; int Y = (int)relativePoint.Y; Bitmap Screenshot = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(Screenshot); // snip wanted area G.CopyFromScreen(X, Y, 0, 0, new System.Drawing.Size(Width, Height), CopyPixelOperation.SourceCopy); […]