Tag Archives: graphics

Draw a scrolling family tree in C#

The example Draw a family tree in C# shows how to draw a family tree. Unfortunately if the tree is too big, you can’t make the form big enough to display it all. One solution would be to use smaller … Continue reading

Posted in algorithms, classes, generic, graphics, OOP | Tagged , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Make a cannon game in C#

This simple cannon game randomly positions a target house. Then when you click the Shoot button, it gets angle and speed information for the cannon and enables a timer. To keep the graphics and timing simple, the program uses a … Continue reading

Posted in algorithms, animation, games, graphics | Tagged , , , , , , , , , , , , , | Leave a comment

Convert a bitmap into a cursor in C#

Converting a bitmap into a cursor isn’t easy, but you can do it by using the CreateIconIndirect API function. This example uses the following BitmapToCursor method to create a cursor from a bitmap. // Create a cursor from a bitmap. … Continue reading

Posted in graphics, image processing | Tagged , , , , , , , , , , , , , | Leave a comment

Use a bitmap for an icon in C#

You can’t set a form’s Icon property equal to a bitmap. Fortunately it’s easy enough to create an icon from a bitmap. This example uses the following code to make a form’s icon display the image in a bitmap. // … Continue reading

Posted in forms, graphics, image processing | Tagged , , , , , , , , , , | Leave a comment

Make a tool that creates PNG files with transparent backgrounds in C#

When you use the File menu’s Open command, the following code lets you select a image file. // The image. private Bitmap Bm = null; // Offset for displaying the image. private const int Offset = 10; // Open a … Continue reading

Posted in graphics, image processing | Tagged , , , , , , , , , , , , , | Leave a comment

Give an image a transparent background in C#

The Bitmap class’s MakeTransparent method changes all of the pixels with a given color to the transparent color A = 0, R = 0, G = 0, B = 0. When the program starts, the following code makes the background … Continue reading

Posted in graphics, image processing | Tagged , , , , , , , , , , , , | Leave a comment

Extract text from a metafile in C#

The example Enumerate the records in a metafile in C# shows how to list the records in a metafile. This example lists the records, looks for those that represent DrawString commands, and extracts their text. The following code shows the … Continue reading

Posted in algorithms, graphics | Tagged , , , , , , , , , , , | 2 Comments

Enumerate the records in a metafile in C#

The example Display a Windows metafile (wmf) in C# shows how to draw a metafile. This example shows how to enumerate the records in the metafile that represent its drawing commands and draw only some of them. When you enter … Continue reading

Posted in algorithms, graphics | Tagged , , , , , , , , , | Leave a comment

Draw an interesting pattern of circles in C#

This program simply draws an interesting arrangement of circles. I wrote it because a C# Helper post was mentioned on this Factal [sic] Patterns & Art page. This program uses the following code to draw the circles and connecting lines. … Continue reading

Posted in algorithms, drawings, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , | Leave a comment

Use BeginInvoke and callbacks to perform tasks asynchronously in C#

The example Use BeginInvoke and EndInvoke to perform tasks asynchronously in C# explains one way to call a method asynchronously so it can run on a separate core or CPU. In that example, the program calls BeginInvoke several times to … Continue reading

Posted in algorithms, graphics, image processing, threading | Tagged , , , , , , , , , , , , , , , , | Leave a comment