PixelTranspose is a technique to transpose (move) pixels from their origin/source (srcX and srcY coordinate) to a new destination. Three (or four) steps are necessary to perform a pixel transposition.
1. Creating the pixel transpose table which holds the information for each pixel that should be moved.
2. Setting or adding the information (source and destination coordinates) for each of those pixels to the table.
3. Executing the pixel transposition.
4. Releasing the pixel transpose table.
1. Creating The Pixel Transpose Table
void CreatePixelTransposeTable(int size, int growsize)
The parameter size describes the amount of pixels in the table. The second parameter growsize describes the size that will be used to grow the table by using AddPixelTransposeEntry if the predefined size of PixelTransposeTable is reached. It is not necessarily required to use the second parameter because the growsize is set to 128 by default.
2. Setting Or Adding Information
void SetPixelTransposeEntry(int idx, int srcX, int srcY, int destX, int destY)
Using SetPixelTransposeEntry requires 5 parameters. The first parameter idx defines the index in the predefined table. This index count starts with 0 and has to be lower than the size value of CreatePixelTransposeTable(int size, int growsize). The second and third parameter, srcX and srcY, describe the source coordinates and the fourth and fifth parameter, destX and destY, set the destination coordinates.
void AddPixelTransposeEntry(int srcX, int srcY, int destX, int destY)
Using AddPixelTransposeEntry requires only 4 parameters, i.e. the source and destination coordinates. The function validates if an entry already exists. If this is not the case, the function adds the entry to the end of the pixel transpose table. If the predefined size in CreatePixelTransposeTable(int size, int growsize) is then exceeded, the table automatically grows by the size defined with growsize.
The execution of SetPixelTransposeEntry is performed much faster than that of AddPixelTransposeEntry.
3. Executing The Pixel Transposition
void ExecutePixelTranspose(int clear)
Using this function executes all pixel transpositions that are defined in the pixel transpose table. The clear parameter defines how the part of the matrix is handled which is not defined as destination. If the clear parameter is set to CLEAR, the part will be erased using black. Otherwise, if this parameter is set to NOCLEAR, the color values will be left like they were before.
4. Releasing The Pixel Transpose Table
Using this function releases the created transpose table. That means, that the reserved memory is made available again.
The following three examples will rotate the Main Output using the pixel transpose technique. Please note that this only works on quadratic matrices. Just use the SCE Color Gradient effect and insert the following source code into the Global Macro. The differences will be easily visible.
As a Global Macro, this macro rotates the output by 90° clockwise.
As a Global Macro, this macro rotates the output by 90° counter-clockwise.
As a Global Macro, this macro mirrors the output at the diagonal axis.
|MADRIX Version: 5.5 | Script Version: 3.14|
|[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100%|
Enable automatic translation | Activer la traduction automatique |