gdi+

How to mimic Picasa's rendering of reduced quality image to speed up drawing

I have an owner-drawn control where performance is an issue during quick repaints such as object drags, resizing and painting the selector square. i have noticed that several other apps, including Picasa, will temporarily draw a reduced-quality image during fast repaint scenarios and then update the image with a higher-quality version wh...

GDI+ functionality in .NET CF generic WinCE

There is no gdiplus.dll in my WinCE device, Is there any way I can get gdi+ functionality in .NET CF? I'm particularly interested in anti aliased drawing of polygons. (that's all I want). ...

Double Buffering when not drawing in OnPaint(): why doesn't it work?

I'm working on a simple vector drawing app in C#/.Net. The drawing is done in a panel, but I'm not using the OnPaint() event for all of it - in fact the OnPaint() even just calls another method which actually draws everything in the document. I tried to add double buffering, but when I set DoubleBuffered to true, the flicker issue is ev...

looking for the most efficient way to take repetitive desktop screenshots in C#

Hello, I am looking for the most efficient way to take repetitive desktop screenshots in C#. I am currently using copyfromscreen but it is a little bit too taxing on the CPU. I would like to know if there is other alternatives. Thank you ...

Region.IsVisible() not working as documented (?) [GDI+]

I see that Region.IsVisible(rectangle) is not working as I expect. So, is me who expect that should not, or is the method that is doing not that it should ??! I have the following situation: And the following code: private void Form1_Paint(object sender, PaintEventArgs e) { Point[] points1 = new Point[] { new Point(50, ...

Drawing polygonal line with gradient in GDI+

I have a List<Point> of multiple points. How can I draw these points into a bitmap, to get the same as this: Points are known, I just need to achieve this gradient effect somehow. Please note that the gradient isn't radial, if you untwist the polygonal line to a straight one, you would get simple linear gradient from one end to anoth...

GDI+ Moving Line Memory Leak

I have tried to do this both with GDI+/Invalidate and by using a Line Shape Control. In both cases the memory spirals out of control. To demonstrate, create a windows form application with a timer object which is set to 100ms and enabled and use the following code: Public Class Form1 Private Y As Integer Private intDirection As ...

Changing co-ordinate system

I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind: float rotation = // +90 below is because AB is the new vertical... Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f; Matrix m; m.T...

Pixel behaviour of FillRectangle and DrawRectangle

Hi, nearly every time I use Graphics.DrawRectangle or Graphics.FillRectangle (the int versions) I seem to miss the pixels on the right and bottom border of the rectangle I want to draw. What is the exact definition of which pixels get filled by Graphics.FillRectangle(brush,x,y,width,height) and Graphics.DrawRectangle(pen,x,y,width,...

Remove corners when drawing thick lines

Result: Question: Can I round or do something with this line "appendix"? Code: private void Form1_Paint(object sender, PaintEventArgs e) { Point[] points1 = new Point[] { new Point(50, 90), new Point(60, 20), new Point(70, 120) }; GraphicsPath path1 = new Graphics...

Library of Objects - Access Index Value or Object Itself? (e.g., deep vs. shallow copy perhaps?)

I've always been confused/unsure about how .Net copies references. Let's say I have a Bitmap object for GDI+. dim foo as new bitmap("c:\foo.bmp") 'Foo' holds the bitmap object. Now let's say I do this. dim bar as bitmap = foo Is this a shallow copy or a deep copy? If I set foo equal to nothing, does bar suddenly reference 'nothing...

Deleting GDI+ objects

I am building a C# application that uses GDI+ to draw images and shapes to the form but I have no idea how to delete them. Let's say I have a optional grid drawn using GDI+ and when users turns it off, I want to, well, turn it off, delete it somehow and without affecting other objects on the working canvas. What is the best approach? Tha...

Is there a definite way to determine the overflow of a pen object when drawing a rotated object? .Net GDI+

As an example imagine you have a rectangular clock. The hand is made of a filled triangle with a border. The border is drawn with a gdi+ pen and the thickness can vary from 1 upwards. The problem is, the hand should always be within the bounds of the clock face. Using pen Alignment.Inset solves this problem but, because it renders terrib...

why is my Win32 gdi+ game unusably slow on Windows 7?

[important new information available below at bottom of this entry] I have what I believe is a very standard game loop using GDI+. It works reasonably well (about 25 fps for a complex game, 40 fps for a simple game) on Vista and XP. When I run it on Windows 7 (with a significantly faster CPU, and more memory), it slows down so much the ...

Avoiding disposing system-defined Pen and Brush instances

I understand it is best practise to call Dispose() on instances of Pen and Brush, except if they've been set to the system-predefined values (eg. System.Drawing.Brushes, System.Drawing.Pens or System.Drawing.SystemBrushes) Trying to dispose a system-defined resource results in an exception being thrown. It doesn't appear to be obvious...

Draw shape to alpha channel only

I want to draw a shape to the alpha channel only of my image. I can use a colour matrix when drawing an image with Graphics.DrawImage(..), as it has a parameter to pass in the ImageAttributes. Is it possible to do this with the FillEllipse method? Or would I have to draw it to a separate image, then use DrawImage to apply it to my mai...

How to create a simple glass effect

I am currently painting a light blue, partly transparent overlay over owner-drawn objects to indicate certain state. It's OK but I thought that it would be even nicer if I could at some sort of glass effect to further establish the idea that the particular object has "something" overlaid over the top of it. I thought that some glass str...

What package should I be using for 2d animation?

I am working with a client on a 2d map. The map is centered on the user's position and marks various headings and points of interest. As the user moves, the headings change and the points of interest move. My client is insistent on using OpenGL for this, but this seems like overkill. He has mentioned he thinks GDI+ and SDL are too slow...

How to Create Subset Fonts in .NET?

I have a Silverlight application that I need to embed some less-than-common fonts in. It's simple enough for me to just copy over the TTF/OTF and compile that with my app. However, in many cases, only like 5-10 of the characters are actually used. In other cases, some font files are incredibly large (Arial Unicode MS Regular is 22.1 MB, ...

Convert a .fntdata file into a .ttf

Is anyone familar with the .fntdata structure of an embedded font? This is used in PowerPoint 2007/2010 when embedding a font into a presentation (it is unlike .odttf that is used in Word 2007/Word 2010). Basically, I just want to convert this to a .ttf or .odttf file so it can be read by WPF/Silverlight applcations. One page of the sta...