LEADTOOLS For .NET Class Library Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.28
Accounting for View Perspective

Many LEADTOOLS methods reference Image coordinates, which are often different from the display coordinates of an image. For example, in Windows, the first pixel of a displayed image is always in the top-left corner, but in the RasterImage object of the same image, the first pixel in memory is often the bottom-left corner of the image. The arrangement of pixels in the Image is called the view perspective.

For information on changing Image coordinates, based on view perspective, refer to "Translating to or from Image Coordinates" below.

LEADTOOLS keeps track of the view perspective in the ViewPerspective property.

The following are possible values.

All toolkits:

TopLeft

[0] Top-left of image is first in memory.

BottomLeft

[2] Bottom-left of image is first in memory.



Document/Medical:

TopRight

[1] Top-right of image is first in memory.

BottomRight

[3] Bottom-right of image is first in memory.

RightTop

[4] First row is the right side, first column is top side.

TopLeft90

[4] Same as RightTop, which is TopLeft rotated clockwise by 90 degrees.

LeftBottom

[8] First row is the left side, first column is the bottom side.

TopLeft270

[8] Same as LeftBottom, which is TopLeft rotated clockwise by 270 degrees.

BottomLeft180

[1] Same as TopRight, which is BottomLeft rotated clockwise by 180 degrees.

TopLeft180

[3] Same as BottomRight, which is TopLeft rotated clockwise by 180 degrees.

LeftTop

[5] First row is the left side, first column is the top side

BottomLeft90

[5] Same as LeftTop, which is BottomLeft rotated clockwise by 90 degrees

RightBottom

[7] First row is the right side, first column is the bottom side

BottomLeft270

[7] Same as RightBottom, which is BottomLeft rotated clockwise by 270 degrees



The methods that display images account for the view perspective, so that the displayed image has the proper orientation. Nevertheless, when getting the Image width and height, you must consider the possibilty that the Image may have a rotated view perspective. Also, in some cases, you must translate to or from Image coordinates.

Interpreting the Image Width and Height (Document/Medical only)

In the LEADTOOLS Document/Medical toolkit, an image can have a rotated view perspective if you set RasterCodecs.Options.Load.Rotated to true before you load the image, or if you use the ChangeViewPerspective method for fast rotation.

In such cases, the Width and Height properties may not match the displayed orientation of the image. This is an important consideration in any calculations of the image's aspect ratio. LEADTOOLS provides the following properties to help you with the interpretation:

Translating to and from Image Coordinates

In some situations you must translate to or from Image coordinates. For example, suppose you are using the GetPixelColor method to get the color at the current mouse position. Because Leadtools.RasterImage.GetPixelColor(System.Int32,System.Int32) uses Image coordinates, you must translate the mouse coordinates.

Similarly, if you are working with two Images that have different view perspectives, you may need to translate the Image coordinates from one to the other. LEADTOOLS provides the following methods to simplify the translation:

PointFromImage

PointToImage

RectangleFromImage

RectangleToImage

If necessary, you can also use the following methods to rotate and flip the Image data as necessary to achieve a different view perspective:

ChangeViewPerspective