Apply Matrix, Global, Local, World Coordinate Transformation in C#


Coordinate systems are important while working with graphics and shapes. The coordinate axis can be rotated for obtaining new axes through the same origin. Let us explore the following transformations including Matrix, Global, Local, and World transformation using C# language. Moreover, let us learn the following transformations through this article:

Matrix, Global, Local and World Transformation – C# API Installation

Aspose.Drawing for .NET API supports processing different drawing objects. You can easily create, edit, transform, or render graphics in your .NET-based applications. Simply download the DLL file from the New Releases section. On the other hand, you can configure it from NuGet with the following installation command:

PM> Install-Package Aspose.Drawing

Apply Matrix Transformation Programmatically using C#

The Matrix class has a 3 by 3 affine matrix which represents the transformation. You can use it to Rotate, Translate, or Scale a shape as per your requirements. The following steps explain how to apply matrix transformation:

  1. Instantiate Bitmap class object
  2. Create a shape
  3. Apply Matrix transformation

The code below shows how to apply matrix transformation programmatically using C# language:

Apply Global Coordinate Transformation Programmatically with C#

Global transformation is used to transform all graphical objects in a drawing. You can follow the steps below for applying global coordinate transformation:

  1. Initialize an instance of Bitmap class
  2. Declare Graphics class object
  3. Set rotation
  4. Draw a shape with Global Transformation

The following code elaborates global coordinate transformation programmatically using C#:

Set Local Transformation Programmatically in C#

Local transformation is related to specific shapes or graphics in a drawing. It can be explained with transformation of a graphics path where only the items of that path are transformed. You can set local transformation with the following steps:

  1. Initialize an object of Bitmap class
  2. Declare Graphics and GraphicsPath class object
  3. Create a shape and define Matrix
  4. Call Transform method

The code snippet below explains how to set local transformation programmatically using C#:

Apply World Transformation Programmatically using C#

The conversion of World coordinates to Page coordinates is known as World Transformation. Such page coordinates are then used for rendering graphics on different devices. So you can apply world transformation using C# with the steps below:

  1. Initialize an object of the Bitmap class
  2. Call TranslateTransform method
  3. Draw a shape

The following code shows how to apply world transformation programmatically using C# language:


In a nutshell, you have learned about different transformations related to computer graphics and shapes. You must be able to understand the details of Global, Local, and World transformation using the C# language. Furthermore, you may read the API Documentation for more details or get in touch with us via the Free Support Forums. We would love to help you!

See Also

Add, Insert, or Draw Text on PNG, JPEG, TIFF, Icon, GIF Image using C#