Tag Archives: transformations

Rotate images in C#

This program uses the following RotateBitmap method to rotate an image. // Return a bitmap rotated around its center. private Bitmap RotateBitmap(Bitmap bm, float angle) { // Make a Matrix to represent rotation // by this angle. Matrix rotate_at_origin = … Continue reading

Posted in algorithms, graphics, image processing, transformations | Tagged , , , , , , , , , | 7 Comments

Map drawing coordinates without distortion in C#

The post Easily map drawing coordinates in C# lets you easily map a rectangle in drawing coordinates to a rectangle in device coordinates. Often, however, you’ll want to ensure that the drawing area isn’t distorted. In other words, you don’t … Continue reading

Posted in algorithms, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Easily map drawing coordinates in C#

The example Map points between coordinate systems in C# shows several ways you can map drawing coordinates to screen coordinates. They all work but these sorts of coordinate conversions are really common if you’re doing more advanced graphics so I … Continue reading

Posted in drawing, graphics, transformations | Tagged , , , , , , , , , , , , , , , , , , , | 1 Comment

Draw text on a curve in C#

The example Draw text on a line segment in C# shows how to draw text that follows a line segment. This example uses that code to draw text on a curve. The DrawTextOnPath method shown in the following code uses … Continue reading

Posted in algorithms, fonts, graphics | Tagged , , , , , , , , , , , , , , | 3 Comments

Draw text on a line segment in C#

This example shows how you can draw text on a line segment. The key is the DrawTextOnSegment method shown in the following code. This method can draw text on a line segment or below a line segment. // Draw some … Continue reading

Posted in algorithms, drawing, fonts, graphics, transformations | Tagged , , , , , , , , , , , , , , , | 4 Comments

Rotate a picture in C#

I recently returned from a trip and one particular picture was rotated just a tiny bit from where I wanted it. Normally I wouldn’t care but this picture (a small version is included in the download) has horizontal features at … Continue reading

Posted in algorithms, graphics, image processing | Tagged , , , , , , , , , , , , , , , , | 4 Comments

Print at full scale in C#

This example shows how you can print at full scale so objects drawn on the screen are the same size when printed. Note that your screen and printer are probably not calibrated exactly so the result will not match perfectly. … Continue reading

Posted in drawing, GDI+, graphics, printing | Tagged , , , , , , , , , , , , , , , , | 6 Comments

Draw an animated atom in C#

When the form’s Timer fires, its Tick event handler refreshes the form to force a redraw. The form’s Paint event handler draws the atom. private double Theta = 0; private const double Dtheta = Math.PI / 5; // Draw the … Continue reading

Posted in animation, drawing, graphics, multimedia | Tagged , , , , , , , , , , , | Comments Off on Draw an animated atom in C#

Rotate around a point other than the origin in C#

You can use a Matrix object to rotate, scale, translate, or skew a drawing. Its RotateAt method adds a rotation around a specific point to a Matrix. The following RotateAroundPoint method returns a new Matrix that represents rotation around a … Continue reading

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

Make CAPTCHA images with overlapping characters in C#

The following MakeCaptchaImage2 method creates a Bitmap containing a CAPTCHA image. private Random Rand = new Random(); // Draw the words with letters overlapping each other. private Bitmap MakeCaptchaImage2(string txt, int wid, int hgt, Font the_font, Brush the_brush) { Bitmap … Continue reading

Posted in drawing, graphics, image processing, internet, transformations, web | Tagged , , , , , , , , , , , , | Comments Off on Make CAPTCHA images with overlapping characters in C#