Layer.affineCopy

Function/Meaning

Affine transformation copy

Type
Layerclassmethod of
Syntax
affineCopy(src, sleft, stop, swidth, sheight, affine, A, B, C, D, E, F, type=stNearest, clear=false)
Arguments
src

Specifies the layer object to copy from.
You can also specify an object of the Bitmap class.

sleft

Specifies the left edge position of the rectangle to copy, in pixels (at the image position of the source layer).

stop

Specifies the top position of the rectangle to copy, in pixels (at the image position of the source layer).

swidth

Specifies the width of the rectangle to copy, in pixels (at the image position of the source layer).

sheight

Specifies the height of the rectangle to copy, in pixels (at the image position of the source layer).

affine

Specifies how to handle the following 6 arguments (A to F parameters).
If true is specified, each of the six parameters will be interpreted as follows.

  • A : 2D affine transformation matrix a
  • B : 2D affine transformation matrix b
  • C : 2D affine transformation matrix c
  • D : D of 2D affine transformation matrix
  • E : 2D affine transformation matrix tx
  • F : 2D affine transformation matrix ty

By affine transformation, the copy source image position (x, y) (however, the upper left corner of the copy source rectangle is (0, 0)) is the copy destination image position (x', y') by the following formula. Will be converted to.
x'= a * x + c * y + tx
y'= b * x + d * y + ty
If false is specified, each of the six parameters will be interpreted as follows.
These parameters can also be specified as real numbers.

  • A : X coordinate position (x0) of the point in the upper left corner of the copy source rectangle at the image position at the copy destination
  • B : Y coordinate position (y0) of the point in the upper left corner of the copy source rectangle at the image position at the copy destination
  • C : X coordinate position (x1) of the point in the upper right corner of the copy source rectangle at the image position at the copy destination
  • D : Y coordinate position (y1) of the point in the upper right corner of the copy source rectangle at the image position at the copy destination
  • E : X coordinate position (x2) of the point in the lower left corner of the copy source rectangle at the image position at the copy destination
  • F : Y coordinate position (y2) of the point in the lower left corner of the copy source rectangle at the image position at the copy destination

If false is specified, the copy destination position (x3, y3) corresponding to the lower right corner of the copy source is automatically calculated by the following formula.
x3 = x1-x0 + x2
y3 = y1 --y0 + y2

A

A parameter.
The interpretation depends on the affine argument.

B

B parameter.
The interpretation depends on the affine argument.

C

C parameter.
The interpretation depends on the affine argument.

D

D parameter.
The interpretation depends on the affine argument.

E

E parameter.
The interpretation depends on the affine argument.

F

F parameter.
The interpretation depends on the affine argument.

type

Specifies the type of affine transformation.

  • stNearest : Nearest point method is used
  • stFastLinear : Low precision linear interpolation is used (partially implemented)
  • stLinear : Linear interpolation is used (not implemented)
  • stCubic : 3D interpolation is used (not implemented)

For stFastLinear, stLinear, and stCubic, stRefNoClip can be additionally specified by bitwise OR, in which case it is allowed to refer to the outside of the area of the bitmap to be copied and synthesize the color.
If this is not specified, the out-of-range color will not refer to the closest pixel in the range, even if there is room around the source bitmap. It is considered a color).

clear

Specifies whether to clear the periphery of the affine-transformed image of the transfer destination layer with the color and transparency indicated by the Layer.neutralColor property.
If true is specified, it will be cleared, and if this argument is omitted or false is passed, it will not be cleared.
The area to be cleared can also be limited with the Layer.setClip method.
If you use this clear function, it is a waste of clearing the overwritten area (the part that is overwritten by affine transformation in the cleared place) when overwriting and transferring the image by affine transformation after clearing the transfer destination layer once. Can be omitted.

Return value
None (void)
Explanation

Copies the rectangle of the specified source layer while converting it to the copy destination (layer that executes the method).
The affine argument allows you to choose whether to specify a two-dimensional affine transformation matrix as the transformation parameter or to specify the transformed point directly.
In the current version, linear interpolation is effective when stFastLinear is specified when the Layer.face property of the layer to be overlaid (which executes the method) is dfAlpha (or dfBoth) or dfAddAlpha.
Linear interpolation is also possible when the Layer.face property is dfOpaque and the Layer.holdAlpha property is false.
If the Layer.face property of the layer to which you want to overlay (execute the method) is dfAlpha (or dfBoth) or dfAddAlpha, both the main image and the mask image are copied.
If the Layer.face property of the layer to be overlaid (executes the method) is dfOpaque (or dfMain), only the main image is copied when the Layer.holdAlpha property is true, and the main image and mask are false. Both images are copied.
The transformation by the two-dimensional affine transformation matrix is defined as follows, with the origin (0, 0) at the upper left of the copy source rectangle.
Two-dimensional affine transformations allow you to scale, rotate, shear, translate, flip, or transform any combination of these.
In the method that performs 2D affine transformation, the transformation can be specified by directly specifying each vertex after transformation instead of the 2D affine matrix, but even in this case, transformation that cannot be defined by 2D affine transformation should be performed. You can not.
For affine transformations, pixels are considered to have a size of 1.0 x 1.0.
That is, the pixel at position (0, 0) is considered to be in the range (-0.5, -0.5)-(0.5, 0.5).