Monthly Archives: August 2016

Scale images and save them in C#

Occasionally when I’m writing a book or article, I need to scale images and then save them. MS Paint does this easily, but it loses any transparency information when it saves images. This program lets you scale images and then … Continue reading

Posted in drawing, graphics, image processing | Tagged , , , , , , , , , , , , | 1 Comment

Make shaped PictureBoxes in C#

This example shows how to use regions to make shaped PictureBoxes. The PNG image format allows you to define transparent pixels. As you might guess, if you draw an image with transparent pixels, those pixels are not drawn and whatever … Continue reading

Posted in algorithms, geometry, graphics, image processing | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Use XML comments in C#

C# let’s you use XML comments to give extra information to IntelliSense and that can be used to automatically generate documentation. These comments start with three / symbols and should be placed before the program item to which they apply. … Continue reading

Posted in debugging, syntax, tips | Tagged , , , , , , , , , , | 2 Comments

Draw trees vertically or horizontally in C#

The example Handle generic TreeNode mouse events in C# shows how to build a generic node class that can draw trees with nodes that contain just about anything. In that example, each each node is centered over its subtree. This … Continue reading

Posted in algorithms, classes, drawing, graphics | Tagged , , , , , , , , , , , , , , , , , , | 3 Comments

Use DrawImage to warp images in C#

The examples Warp images arbitrarily in C#, Part 1 and Warp images arbitrarily in C#, Part 2 show how to use inverse transformations to warp images arbitrarily. The Graphics class’s DrawImage method also lets you warp images. It’s not as … Continue reading

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

Warp images arbitrarily in C#, Part 2

The post Warp images arbitrarily in C#, Part 1 explains how to warp images, but it omits the method that maps an output pixel (x1, y1) back to an input pixel (x0, y0) in the original image. This post describes … Continue reading

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

Warp images arbitrarily in C#, Part 1

This is an extension of the example Use image filters to perform edge detection, smoothing, embossing, and more in C# that adds new features that warp images in arbitrary ways. The idea is to use two functions F(x, y) and … Continue reading

Posted in algorithms, graphics, image processing, mathematics | Tagged , , , , , , , , , , , , , , , , , , , | 3 Comments

Compare fuel efficiency in different units in C#

People in the United States, Canada, the United Kingdom, and several other places measure a car’s fuel efficiency in miles per gallon. As you might expect, countries that use the metric system may measure fuel efficiency in kilometers per liter, … Continue reading

Posted in finance, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Compare car costs including long term mileage in C#

This example calculates the total car costs including gas use. Some cars that seem less expensive than others actually cost more in the long run because they get worse gas mileage. Enter the total number of city and highway miles … Continue reading

Posted in finance, mathematics | Tagged , , , , , , , , , , | Leave a comment

Draw an analog clock in C#

This example demonstrates several useful techniques including: Context menus Restricting a form to a region to give it a shape. Moving a form with no title bar Double buffering Drawing with transformations Drawing an analog clock When you right-click the … Continue reading

Posted in animation, drawing, forms, graphics | Tagged , , , , , , , , , , , , , , , , , | 2 Comments