gdi+

GDI handles with icons . l

i have a winforms application. i have a user control with a lot of icons. the user can load this control on a form many times (in a tabbed layout). right now i am loading the icons each time the control is created (could be up to 50 times in teh app). is there any way to cache these icons in the application. if i did this, would tha...

Argument exception - parameter is not valid ( LinkLabel on WinForm )

Hi, I wrote a Win Forms app to test how a LinkLabel class works. It appears to be fine until I click on the changed LinkLabel. The Form1.cs code is below: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.For...

How to Create a Gdiplus::Bitmap from an HBITMAP, retaining the alpha channel information?

When I create a new Gdiplus::Bitmap using the Bitmap::FromHBITMAP function, the resulting Bitmap is opaque - none of the partial transparency from the original HBITMAP is preserved. Is there a way to create a Gdiplus::Bitmap from an HBITMAP which brings across the alpha channel data? ...

Image.Save(..) throws a GDI+ exception because the memory stream is closed.

Hi folks, i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream. this is the code: [TestMetho...

Libraries required for GDI in Mono using xsp...

Here is the situation. I am creating some graphics (using GDI+) on an asp page running under mono xsp. This works great in my development environment as my development environment is running under a GUI, however when I try running it on a GUI-less server, it fails (I am assuming due to the fact that certain libraries which are required...

Strange problem about conversion between GDI+ to GDI: Bitmap and HBitmap

I want to convert gdi+ Bitmap into gdi object HBitmap. I am using the following method: Bitmap* img = new Bitmap(XXX); // lots of codes... HBITMAP temp; Color color; img->GetHBITMAP(color, &temp); the img object is drawing on a dialog. when this part of method is called, strange thing happens! the img displaying in ...

GDI+ Dithering Problem

I have a C++ application that uses the Win32 API for Windows, and I'm having a problem with GDI+ dithering, when I don't know why it should be. I have a custom control (custom window). When I receive the WM_PAINT message, I draw some Polygons using FillPolygon on a Graphics device. This Graphics device was created using the HDC from Beg...

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 to any other version down to 1): Font f = GetSystemConfiguredFont(); //this sets the t...

Highlighted squares on a CustomControl chessboard don't persist beyond the initial MouseDown event

I've been coding a Windows app chess game in C# as an exercise in honing my skills, and also because it's fun. I have included functionality that allows a player to select the option to highlight the squares a piece can legally move to when it gets clicked. A CustomControl handles the rendering of the chessboard and it also highlights th...

how to do Hit testing in GDI+ ?

I have a canvas that contains many shapes and every shape has a location, size and rotation angle (size and location are in inches) and I want to check if mouse position is within which shape (the rotated shape) ?? can anyone help? ...

Is there any way to draw a control on some other control in C#?

I would like to draw a control on some other control in it's overriden paint event. By drawing I mean real drawing, not placing the control inside the other control. Is there any nice way to do that? ...

[C#] How to overlap two controls

Hi! I have a Circle and a Line control. Circle control's OnPaint draws a circle and Line control's one draws a line. These two controls are contained in another control (DrawingControl). I need to put a Line over a Circle, but Circle's background deletes the Line. I tried enabling transparency and overriding Circle's OnPaintBackground me...

Extending the list of supported image formats in GDI+

To quote the documentation for the System.Drawing.Imaging namespace The Encoder class enables users to extend GDI+ to support any image format. Yet I can find no documentation, examples or anything else that explains how I'd go about implementing my own custom file format -- most searches return lots of information on passing Enco...

Convert from tagRECT/CRect to Gdiplus::Rect

What is the easiest way to convert a RECT struct (tagRECT) or a CRect to a Gdiplus::Rect? Gdiplus::Rect tmpRect(rect.top, rect.left, rect.Width(), rect.Height()); works but is a lot of typing. ...

Resizing image crops one pixel form right and bottom

Hi, all! I had discovered that when resizing image by using System.Drawing.Graphics class resulting image missed one pixel from right and bottom borders. This is bug somewhere in my code or .Net issue? Test code: public static void Resize(string imagePath,int width) { InterpolationMode[] interpolationModes = new InterpolationMode[]{In...

How to create a filled arrow CustomLineCap?

The MSDN documentation has several open arrow examples but no examples for filled arrows. I just want to create a bigger arrow than the default LineCapArrowAnchor. I tried several things and can't get it to work. It should be simple, right? ...

GraphicsPath - Why does order of AddLine methods matter

I am drawing a triangle with the following code int x = x coordinate for center; int ax = x coordinate for left; int bx = x coordinate for right; int top = y coordinate for top; int bottom = y coordinate for bottom; // (x, top) //(ax, bottom) (bx, bottom) GraphicsPath path = new GraphicsPath(); // _ path.AddLine(ax, bo...

Intersecting GraphicsPath objects

How can I intersect two (.NET) GraphicsPath objects? ...

How can I extract a specific Image from an Icon file in .NET?

Icon files (*.ico) may contain multiple images at different sizes and of different colour depths. How can I obtain a System.Drawing.Image object from a .ico file? One option is Image.FromFile(...), but for icon files with multiple images there is no way to specify which image size and colour depth to return. Ideally the solution would...

Why am I getting this generic, non-descript error in GDI+ when trying to save a PNG?

I have a function that dynamically adds text to an image in a predesignated spot. Originally I did it with jpegs, and it was working. I switched to PNG so the images would be better quality, as the original jpegs were kind of pixely. Anyway, here is my code. It executes down to the oBitmap.Save(), then dies with "A General Error Has O...