Questions tagged [gdi+]

The Graphics Device Interface (GDI) is a Microsoft Windows application programming interface and core operating system component responsible for representing graphical objects and transmitting them to output devices such as monitors and printers. -Wikipedia

Questions about the GDI+ drawing library/API, including the Gdiplus namespace in C++ and the System.Drawing namespace in .NET languages.

2771 questions
34
votes
4 answers

What quality level does Image.Save() use for jpeg files?

I just got a real surprise when I loaded a jpg file and turned around and saved it with a quality of 100 and the size was almost 4x the original. To further investigate I open and saved without explicitly setting the quality and the file size was…
scubasteve
  • 2,468
  • 3
  • 32
  • 47
34
votes
9 answers

Can you make an alpha transparent PNG with C#?

I have a multi-browser page that shows vertical text. As an ugly hack to get text to render vertically in all browsers I've created a custom page handler that returns a PNG with the text drawn vertically. Here's my basic code (C#3, but small changes…
Keith
  • 133,927
  • 68
  • 273
  • 391
33
votes
4 answers

Bad text rendering using DrawString on top of transparent pixels

When rendering text into a bitmap, I find that text looks very bad when rendered on top of an area with non-opaque alpha. The problem is progressively worse as the underlying pixels become more transparent. If I had to guess I'd say that when…
mackenir
  • 9,910
  • 14
  • 62
  • 95
33
votes
8 answers

Alternatives to System.Drawing for use with ASP.NET?

After several days of tracking down bizarre GDI+ errors, I've stumbled across this little gem on MSDN: Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from…
Dylan Beattie
  • 50,029
  • 31
  • 120
  • 189
32
votes
4 answers

Is Graphics.DrawImage too slow for bigger images?

I'm currently working on a game and I wish to have a main menu with background image. However, I find the method Graphics.DrawImage() really slow. I have made some measurement. Let's assume that MenuBackground is my resource image with resolution…
Miroslav Mares
  • 2,032
  • 3
  • 20
  • 26
31
votes
2 answers

TextRenderer.MeasureText and Graphics.MeasureString mismatch in size

This is not a rounding problem. Difference ~ 5+ pixels. Test Case String: ""MACD (26,12,9) -0.000016" e.Graphics.MeasureString("MACD (26,12,9) -0.000016", SystemFonts.DefaultFont).Width) TextRenderer.MeasureText("MACD (26,12,9) -0.000016",…
Aseem Gautam
  • 16,505
  • 9
  • 79
  • 107
31
votes
3 answers

Windows Aero: What color to paint to make "glass" appear?

What color must i paint in the client area in order to make glass appear? i've extended the frame of my form into the client area using: DwmExtendFrameIntoClientArea(self.Handle, margins); i cannot find any official documentation from Microsoft on…
Ian Boyd
  • 220,884
  • 228
  • 805
  • 1,125
30
votes
4 answers

InvalidOperationException - object is currently in use elsewhere - red cross

I have a C# desktop application in which one thread that I create continously gets an image from a source(it's a digital camera actually) and puts it on a panel(panel.Image = img) in the GUI(which must be another thread as it is the code-behind of a…
para
29
votes
4 answers

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.
Jared Updike
  • 6,806
  • 7
  • 42
  • 67
28
votes
10 answers

Winforms: SuspendLayout/ResumeLayout is not enough?

I have a library of a few "custom controls". Essentially we have our own buttons, rounder corner panels, and a few groupboxes with some custom paint. Despite the "math" in the OnPaint methods, the controls are pretty standard. Most of the time, all…
Martin Marconcini
  • 23,346
  • 18
  • 98
  • 135
28
votes
1 answer

What System.Drawing classes count as GDI objects?

I have been having difficulties understanding which exact objects from the System.Drawing namespace actually contribute to the system total GDI object count. For instance, do Matrix objects count? GraphicsPath? Pen? In order to test this, I ran the…
glopes
  • 3,198
  • 3
  • 21
  • 25
28
votes
6 answers

A generic error occurred in GDI+ at System.Drawing.Image.Save

Exception: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at…
Razor
  • 1,295
  • 4
  • 17
  • 26
26
votes
6 answers

How do I adjust the brightness of a color?

I would like to darken an existing color for use in a gradient brush. Could somebody tell me how to do this please? C#, .net 2.0, GDI+
Brad
  • 17,634
  • 36
  • 80
  • 101
25
votes
2 answers

Create image with transparent background using GDI+?

I'm trying to create an image with a transparent background to display on a web page. I've tried several techniques but the background is always black. How can I create a transparent image and then draw some lines on it ?
Julien Poulin
  • 11,837
  • 9
  • 49
  • 74
25
votes
3 answers

C# transition between GDI+ and WPF

I'm considering migrating my c# application from using custom GDI+ drawn controls to a WPF application with custom controls etc. I would like to know what's involved and what to expect. Are there any resources people can recommend that might help?…
TK.
  • 42,559
  • 46
  • 114
  • 145