system.drawing

Compare two Color objects

佐手、 提交于 2019-11-26 16:59:59
问题 This is VS2010 and .NET 4.0. I'm trying to compare two System.Drawing.Color objects. The value of mStartColor.ToArgb() is 16777215 . The value of Color.Transparent.ToArgb() is 16777215 . The value of mStartColor <> Color.Transparent is True . How is equality implemented for Color objects? EDIT Thanks everyone. I got my answer, though it doesn't make much sense to me (see my comments to Tim's and Dave's answers below). I'll mark Tim's post as the answer and he was the first to reply, but Dave

Heatmap style gradients in .NET

给你一囗甜甜゛ 提交于 2019-11-26 16:59:26
问题 I am trying to create a heat map with gradients that look similar to this: This image shows three points and the gradients blend nicely together. Here is what I am currently doing in my drawing function: public void DrawGradient(int x, int y, Graphics g) { using (var ellipsePath = new GraphicsPath()) { var bounds = new Rectangle(x, y, 100, 100); ellipsePath.AddEllipse(bounds); var brush = new PathGradientBrush(ellipsePath); Color[] colors = { Color.FromArgb(64, 0, 0, 255), Color.FromArgb(140,

How to find reason for Generic GDI+ error when saving an image?

旧时模样 提交于 2019-11-26 16:13:22
问题 Having a code that works for ages when loading and storing images, I discovered that I have one single image that breaks this code: const string i1Path = @"c:\my\i1.jpg"; const string i2Path = @"c:\my\i2.jpg"; var i = Image.FromFile(i1Path); i.Save(i2Path, ImageFormat.Jpeg); The exception is: System.Runtime.InteropServices.ExternalException occurred A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at

Double buffering with Panel

烈酒焚心 提交于 2019-11-26 14:25:31
问题 Double buffering the whole form can be done by setting the value of the "AllPaintingInWmPaint", "UserPaint" and "DoubleBuffer" ControlStyles to "true" ( this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true) ). But this can't happen with a System.Windows.Forms.Panel because the class doesn't allow me to do so. I have found one solution: http://bytes.com/topic/c-sharp/answers/267635-double-buffering-panel-control . I have also tried this:

File.Delete failing when Image.FromFile was called prior it, despite making copy of loaded image and destroying original one

不想你离开。 提交于 2019-11-26 12:46:18
问题 UPDATED I used below solutions (loading Image from stream), but get new problem. img object is absolutely correct Image class instance with all field filled with correct values. But calling img.Save(\"path/to/new/image.bmp\"); on it results in new exception for GDI+ (System.Runtime.InteropServices.ExternalException, in GDI+ interface) - I get error message but is in polish, am not sure how to translate it. Original question I have problem with C# .NET Framework 2.0 Basically I\'am trying to

Capture screen on server desktop session

南笙酒味 提交于 2019-11-26 11:06:46
问题 I have developed a GUI test framework that does integrationtesting of our company website on a scheduled basis. When something fails, it\'ll take a screenshot of the desktop, among other things. This runs unattended on a logged in user on a dedicated Windows Server 2008. The problem is that taking a screenshot on a desktop that I have disconnected my remote desktop session from. I get the following exception: System.ComponentModel.Win32Exception (0x80004005): The handle is invalid at System

Manipulating images with .NET Core

微笑、不失礼 提交于 2019-11-26 10:57:18
问题 I have updated my project from .NET 4.5 to .NET Core (with ASP.NET Core). I had some very simple code in my previous version that used the bitmap object from System.Drawing to resize an image. As I understand System.Drawing cannot be used in .NET Core because it is not cross platform, but what can be used instead? I have googled this and cannot find anything. The only thing I can find is this post, which has no code on it what so ever. 回答1: Disclaimer: This is my software. I'm working on a

System.Drawing Out of Memory Exception

坚强是说给别人听的谎言 提交于 2019-11-26 08:33:42
问题 My application graphics engine throws these exceptions. They are all consumed by an empty catch block. In the early days I found one that was not trapped (associated with pen widening as I recall). I surrounded it with try and an empty catch block. It seems that these exceptions have no effect on the drawing produced. I have done some reading on this without really understanding or getting to the bottom of it. So to my questions: Why would these be thrown if they can be consumed safely? and

how to draw a line on a image?

依然范特西╮ 提交于 2019-11-26 08:29:48
问题 i want to draw a line on a bmp image which is pass into a method using drawline method in C# public void DrawLineInt(Bitmap bmp) { Pen blackPen = new Pen(Color.Black, 3); int x1 = 100; int y1 = 100; int x2 = 500; int y2 = 100; // Draw line to screen. e.Graphics.DrawLine(blackPen, x1, y1, x2, y2); } this give a error.So i want to know how to include paint event here (PaintEventArgs e ) and also want to know how to pass parameters when we calling drawmethod? example DrawLineInt(Bitmap bmp);

System.Drawing in Windows or ASP.NET services

£可爱£侵袭症+ 提交于 2019-11-26 08:19:47
问题 According to MSDN, it is not a particularly good idea to use classes within the System.Drawing namespace in a Windows Service or ASP.NET Service. Now I am developing a class library which might need to access this particular namespace (for measuring fonts) but it cannot be guaranteed that the host process is not a service. Now there is a less optimal method I can fall back to if System.Drawing is unavailable, but if it is possible, I would rather use classes in System.Drawing. So what I would