gdi+

.Net drawing clipping bug

gdi+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code two line paths appear that should be identical, because both of them are inside the clipping region, but when the clipping region is set one of the line segment is not drawn. protected override void OnPaint(PaintEv...

Is GDI+ actually still a "usable" technology?

I just wonder a bit whether or not GDI+ is still a technology worth using, especially in a .net sense. Granted, GDI+ is still THE technology to handle Images in Windows, but it is also unmanaged code (obviously). Now, after discovering that GDI+ is actually not supported on ASP.net¹, I just wonder: Is it actually feasible to have Image ...

How do I make a PictureBox use Nearest Neighbor resampling?

I am using StretchImage because the box is resizable with splitters. It looks like the default is some kind of smooth bilinear filtering, causing my image to be blurry and have moire patterns. ...

Compact Framework - Lightweight GUI Framework?

Winform on CF is a bit heavy, initialising a lot of windows handles takes serious time and memory. Another issue is the lack of inbuilt double buffering and lack of control you have over the UI rendering means that during processor intensive operations the UI might leave the user staring at a half rendered screen. Nice! To alleviate thi...

Apply an ICC Color Profile to an image in C# (Dotnet)

How does one convert an image from one color profile to another (screen to printer, or scanner to screen). In Visual C++ you would use the function in ICM.h, is there a managed way to do this with GDI+? I need to use GDI+, not WPF. I'd prefer to have a managed solution, but if it is not available, I guess PInkvoke will have to suffice...

Is there any way to draw an image to use 4 points rather than 3 (perspective warp).

Drawing a parallelgram is nicely supported with Graphics.DrawImage: Bitmap destImage = new Bitmap(srcImage.Width, srcImage.Height); using (Graphics gr = new Graphics.FromImage(destImage)) { Point[] destPts = new Point[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x4, y4)}; gr.DrawImage(srcImage, destPts); How...

Polygon fill modes in GDI and GDI+

The system default polygon fill mode in current device context is ALTERNATE (as I've learned from the Petzold book on Windows programming) and this one is used in Polygon Win32 function unless you change the mode with SetPolyFillMode. My question is: Does the GDI+ Graphics::FillPolygon (without the FillMode parameter in its signature) m...

BufferedGraphicsContext Error

I am getting the below error and call stack at the same time everyday after several hours of application use. Can anyone shed some light on what is happening? System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress. at System.Drawing.BufferedGraphicsContext.Dis...

Rendering Graphics in C#

Are there any other way to render graphics in C# beyond GDI+ and XNA? (For the development of a tile map editor) ...

GDI+ DrawImage() with transparent bitmap to a printer

Does anybody have any pointers on how to successfully draw a bitmap that has an alpha channel using Graphics::DrawImage() when the Graphics context is created based on a printer HDC? The printer drivers don't generally support alpha blending - so is there an alternative to rendering everything to an offscreen bitmap and just sending that...

polyline with gradient

Is there a way to draw a line along a curved path with a gradient that varies in a direction perpendicular to the direction of the line? I am using the GDI+ framework for my graphics. ...

How to eliminate flicker in Windows.Forms custom control when scrolling?

I want to create a custom control in C#. But every time I have to fully redraw my control, it flickers, even if I use double buffering (drawing to an Image first, and blitting that). How do I eliminate flicker when I have to fully redraw? ...

Font rendering libraries for C# / dot-NET?

Are there any free, third-party libraries for rendering arbitrarily scaled and rotated text in dot-NET applications? Although native GDI+ allows for text scaling and rotation, its methods for determining the rendered text's dimensions are not sufficiently precise and the differences in kerning as text is added to a rendered string make i...

How to wrap an existing memory buffer as a DC for GDI

I have a memory buffer corresponding to my screen resolution (1280x800 at 24-bits-per-pixel) that contains my screen contents at 24bpp. I want to convert this to 8-bpp (ie. Halftone color palette in Windows). I currently do this: 1. Use CreateDIBSection to allocate a new 1280x800 24-bpp buffer and access it as a DC, as well as a plain me...

What's a good f/oss GDI+ (System.Drawing) based graphing and charting component for .NET?

I want to create basic line, bar, pie and area charts for .NET 3.5 WinForms and I'm interested in finding a free, mature, open-source .NET (preferably C# based) project to help me accomplish that. I would consider a WPF based project, however I'm more comfortable in GDI+ so I'd rather it used System.Drawing and/or GDI interop as its bas...

LinearGradientBrush Artifact Workaround?

The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See here or here - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black line and then with the proper White to Black gradient) I ...

GDI+: MeasureString() pads the text on the left and the right

I'm using GDI+ in C++. (This issue might exist in C# too). I notice that whenever I call Graphics::MeasureString() or Graphics::DrawString(), the string is padded with blank space on the left and right. For example, if I am using a Courier font, (not italic!) and I measure "P" I get 90, but "PP" gives me 150. I would expect a monosp...

GDI+ / C#: How to save an image as EMF?

If you use Image.Save Method to save an image to a EMF/WMF, you got an exceptoin (http://msdn.microsoft.com/en-us/library/ktx83wah.aspx) Is there another way to save the image to an EMF/WMF? Are there any encoders available? Thanks Eric ...

How do I determine the intersection point of two lines in GDI+?

I'm using .NET to make an application with a drawing surface, similar to Visio. The UI connects two objects on the screen with Graphics.DrawLine. This simple implementation works fine, but as the surface gets more complex, I need a more robust way to represent the objects. One of these robust requirements is determining the intersection ...

How to draw ARGB bitmap using GDI+?

I have valid HBITMAP handle of ARGB type. How to draw it using GDI+? I've tried method: graphics.DrawImage(Bitmap::FromHBITMAP(m_hBitmap, NULL), 0, 0); But it doesn't use alpha channel. ...