RGNXFORM

typedef struct _RGNXFORM
{
   L_UINT uViewPerspective;
   L_INT nXScalarNum;
   L_INT nXScalarDen;
   L_INT nYScalarNum;
   L_INT nYScalarDen;
   L_INT nXOffset;
   L_INT nYOffset;
} RGNXFORM, *pRGNXFORM;

The RGNXFORM structure provides data for translating between region coordinates and external representations of those coordinates.

[Document/Medical]

Member

Description

uViewPerspective

The view perspective of the external representation. Valid values are TOP_LEFT, BOTTOM_LEFT, TOP_RIGHT, BOTTOM_RIGHT, TOP_LEFT90, TOP_LEFT270, BOTTOM_LEFT180, TOP_LEFT180, LEFT_TOP, BOTTOM_LEFT90, RIGHT_BOTTOM, and BOTTOM_LEFT270. For descriptions, refer to Accounting for View Perspective.

nXScalarNum

The numerator for the X scaling factor.

nXScalarDen

The denominator for the X scaling factor.

nYScalarNum

The numerator for the Y scaling factor.

nYScalarDen

The denominator for the Y scaling factor.

nXOffset

The X offset of the external representation.

nYOffset

The Y offset of the external representation.

Comments

pRGNXFORM is a pointer to an RGNXFORM structure. Generally, where a function parameter type is pRGNXFORM, you can declare an RGNXFORM variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pRGNXFORM variable is necessary only if your program requires a pointer.

All region functions accept a NULL pointer for this structure. In that case, no transformation occurs. The scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the bitmap's view perspective.

Several of the LEADTOOLS functions for creating and working with a bitmap region use coordinates from an external representation of the region, such as a shape drawn in a device context.

To compensate for possible differences in view perspective, scaling, and display offsets, these LEADTOOLS functions require that you provide translation information in an RGNXFORM structure.

This topic provides a general description of how fields in the structure work. For a description of common usage, refer to Translating Coordinates for a Bitmap Region.

When assigning an external representation to a bitmap (pointed to by pBitmap), every point (Xa, Ya) in the an external representation is transformed (by structure XForm) to point (Xc, Yc) in the bitmap's region as follows:

1.

Add offsets:

Xb = Xa + XForm.nXOffset
Yb = Ya + XForm.nYOffset

2.

Multiply by scalars:

Xc = (Xb * XForm.nXScalarNum) / XForm.nXScalarDen
Yc = (Yb * XForm.nYScalarNum) / XForm.nYScalarDen

3.

Compensate for view perspective (updating Xc and Yc in place):

LBitmapBase::PointToBitmap(pBitmap, XForm.uViewPerspective, Xc, Yc)

When retrieving an external representation from a bitmap (pointed to by pBitmap), every point (Xa, Ya) in the bitmap's region is transformed (by structure Xform) to point (Xc, Yc) in the external region as follows:

1.

Compensate for view perspective (updating Xa and Ya in place):

LBitmapBase::PointFromBitmap(pBitmap, XForm.uViewPerspective, Xa, Ya)

2.

Mulitply by scalars:

Xb = (Xa * XForm.nXScalarNum) / XForm.nXScalarDen
Yb = (Ya * XForm.nYScalarNum) / XForm.nYScalarDen

3.

Add offsets:

Xc = Xb + XForm.nXOffset
Yc = Yb + XForm.nYOffset