'PixelTranspose' |
Previous Next |
IntroductionPixelTranspose 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 Tablevoid 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 Informationvoid 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 Transpositionvoid 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 Tablevoid ReleasePixelTransposeTable()
Using this function releases the created transpose table. That means, that the reserved memory is made available again.
ExamplesThe 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.
Clockwise RotationAs a Global Macro, this macro rotates the output by 90° clockwise. @scriptname="Output Rotation";
Counter-Clockwise RotationAs a Global Macro, this macro rotates the output by 90° counter-clockwise. @scriptname="Output Rotation"; Mirror DiagonallyAs a Global Macro, this macro mirrors the output at the diagonal axis. @scriptname="Output Rotation"; |
MADRIX Version: 5.6 | Script Version: 3.18 |
[Ctrl & +/-] = Zoom In/Out | [Ctrl & 0] = 100% |
Previous
Next
|
Enable automatic translation | Activer la traduction automatique | |