gdi+

Image.Save() throws ExternalException on Image loaded from Stream (Image.FromStream())

I'm tracking down a pesky problem and I've narrowed down the problem down and realized it only happens when I'm dealing with an Image instance returned by Image.FromStream(). I have a utility method that returns an Image instance from a file using a Stream so I don't have the file handle left open. Here is that utility method (nothing ...

How do I implement high performance 3D graphics w/ WPF?

Hi, I have to develop a CAD application and I am planing to use WPF with C#. Earlier I had used GDI+ with C# to write similar application. How can I perform the graphics operation in WPF similar to GDI+? I want to set the pixel color with pencil (similar to MS Paint), draw some basic shapes such as circles, lines, rectangles etc etc. ...

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 exactly the same. I figured this was because nothing changed so it's just writing the exac...

Getting a bitmap from the cache

Whenever I try to get a bitmap I have cached from the context I am getting an argument exception. The bitmap is cast from the cached object but it's contents are corrupted. The exception is thrown on the line ImageFormat imageFormat = bitmap.RawFormat; bitmap.RawFormat' threw an exception of type 'System.ArgumentException' Which ju...

Finding the shape created by two other intersecting shapes

I have two overlapping shapes in my C# app, defined by Point arrays. I need to find the points that define the shape where these two overlap. In this image, I know the red and green points, but I need the yellow points. Here is some dummy code that might help: Point[] GetIntersection(Point[] red, Point[] green) { Point[] yellow =...

[Windows Imaging] Prevent GDI+ PNG Encoder from adding Gamma information to a 1-bit PNG

I wonder if its possible to instruct the Imaging PNG Encoder not to add any gamma and chroma informations to a 1-bit PNG. I am creating a 2 color palette for the image ColorPalette* pal = (ColorPalette*)CoTaskMemAlloc(sizeof(ColorPalette) + 2 * sizeof(ARGB)); pal->Count = 2; pal->Flags = 0; pal->Entries[0] = MAKEARGB(0,0,0...

Creating a transparent window in C++ Win32

I'm creating what should be a very simple Win32 C++ app who's sole purpose it to ONLY display a semi-transparent PNG. The window shouldn't have any chrome, and all the opacity should be controlled in the PNG itself. My problem is that the window doesn't repaint when the content under the window changes, so the transparent areas of the P...

Pixelation when loading a greyscale image

I've got a tiff image that is greyscale, and when I load it using Image.FromFile, the quality of that image is very pixelated. However, if I save the tiff as indexed in Gimp beforehand, then loading that image with Image.FromFile is no longer pixelated. Is there anyway I can load a greyscale image at the original quality? [edit] Note t...

Add accent marks with custom colors in .Net's RichTextBox

Using the Text property of a WinForms' RichTextBox, you can show a letter with an accent above it, in a way that the letter is one character, and the accent is another one. I.e., also visually it looks like one character, it actually consists of two. In Unicode terms, the letter is called a 'base character', while the accent is called 'c...

Drawing polygon with more than one hole?

I'm trying to draw a polygon with more than one holes. I tried the following code and it does not work correctly. Please advise. PointF[] mypoly = new PointF[6 + 5 + 5]; mypoly[0] = new PointF(0, 0); mypoly[1] = new PointF(100, 0); mypoly[2] = new PointF(100, 100); mypoly[3] = new PointF(0, 100); mypoly[4] = new...

Black WinForms button.

What is the most straightforward way to add a black button with white text in a WinForms Application? Simply setting the BackColor to black and the ForeColor to white the button border remains as before. Do I need to subclass the System.Windows.Forms.Button class and take control of the OnPaint() drawing? Thanks. ...

Gdiplusshutdown results in exit code 1.

Hi, when my app is exited i see the following in the debugger console. The thread '_threadstartex' (0xd48) has exited with code 0 (0x0). The thread '_threadstartex' (0xf80) has exited with code 0 (0x0). The thread '_threadstartex' (0x190) has exited with code 0 (0x0). The thread '_threadstartex' (0xaa0) has exited with code 0 (0x0). T...

C# Image Edge Feathering

Hi Everyone, DISCLAIMER: This code is terrible and should not be used in production. It's testing a proof of concept. I want to create an image like below using C# the key points are the feathered edges and the transparency of the whole image. Here is my result so far As you can see the edges are feathered. My question is, does a...