Windows Aero: What color to paint to make “glass” appear?

Color fillColor = Color.FromArgb(0, 0, 0, 0); //(a, r, g, b) e.Graphics.FillRectangle(new SolidBrush(fillColor), e.ClipRectangle); This is actually rather amusing. It means that you are drawing something completely transparent – so this changes absolutely nothing! 🙂 Guess: if black (0,0,0) should mean “glass”, how about drawing (1,1,1) to get (almost) black?

How do I make a PictureBox use Nearest Neighbor resampling?

I needed this functionality also. I made a class that inherits PictureBox, overrides OnPaint and adds a property to allow the interpolation mode to be set: using System.Drawing.Drawing2D; using System.Windows.Forms; /// <summary> /// Inherits from PictureBox; adds Interpolation Mode Setting /// </summary> public class PictureBoxWithInterpolationMode : PictureBox { public InterpolationMode InterpolationMode { get; set; } … Read more

What System.Drawing classes count as GDI objects?

The following objects cause a GDI handle to be created: Bitmap Brush DC Enhanced Metafile Enhanced Metafile DC Font Memory DC Metafile Metafile DC Palette Pen Extended Pen Region This list was drawn up by using the information from here: https://learn.microsoft.com/en-gb/windows/desktop/SysInfo/gdi-objects

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

When you are loading an imagefrom a Stream, You have to keep the stream open for the lifetime of the image, see this MSDN Image.FromStream. I think the exception is caused because the memory stream gets closed even before the image gets disposed. You can change your code like this: byte[] bitmapData = new byte[imageText.Length]; … Read more

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

There is an excellent blog post including C# code about using the ImageMagick graphics library through Interop over at TopTen Software Blog. This post deals specifically with running ASP.net on linux under mono; however, the C# code should be perfectly copy-paste-able, the only thing you’ll need to change is the Interop attributes if you are … Read more