Package net.paulhertz.pixelaudio
Class BitmapTransform
java.lang.Object
net.paulhertz.pixelaudio.BitmapTransform
Provides static methods for rotating and reflecting 2D integer arrays using
index remapping. For methods that accept an int[] array and width and height parameters,
the arrays may be bitmap pixel arrays, but not necessarily--they could represent
index values over a large bitmap or integer data of any sort, such as the LUTs generated
by PixelMapGen subclasses. Methods that take a PImage as an argument will use the
PImage.pixels
array, and resize the image when necessary. Map methods
that accept width and height parameters return arrays of transformed pixel indices.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
coordTransform
(int x, int y, int width, int height, AffineTransformType type) Performs a geometric transform (rotation, reflection) of a single pixel location.static int[]
flipX
(int[] pixels, int width, int height) Reflects an array of integers on vertical axis, as determined by width and height arguments, flipping x-coordinates.static PImage
Reflects a PImage on the vertical axis, flipping the x-coordinates.static int[]
flipX90
(int[] pixels, int width, int height) Reflects an array of integers on the secondary diagonal, as determined by width and height arguments.static PImage
Reflects a PImage on the secondary diagonal, running from lower left to upper right.static int[]
flipX90CCW
(int[] pixels, int width, int height) Reflects an array of integers on the primary diagonal, as determined by width and height arguments.static PImage
flipX90CCW
(PImage img) Reflects a PImage on the primary diagonal, running from upper left to lower right.static int[]
flipX90CCWCoord
(int x, int y, int w, int h) Reflect x and y on primary diagonal.static int[]
flipX90CCWMap
(int width, int height) Generates a map to reflect pixels on primary diagonal.static int[]
flipX90Coord
(int x, int y, int w, int h) Reflect x and y on secondary diagonal.static int[]
flipX90Map
(int width, int height) Generates a map to reflect pixels on secondary diagonal.static int[]
flipXCoord
(int x, int y, int w, int h) static int[]
flipXMap
(int width, int height) Generates a map to reflect pixels on the vertical axis, flipping x-coordinates.static int[]
flipY
(int[] pixels, int width, int height) Reflects an array of integers on the horizontal axis, as determined by width and height arguments, flipping y-coordinates.static PImage
Reflects a PImage on the horizontal axis, flipping the y-coordinates.static int[]
flipYCoord
(int x, int y, int w, int h) static int[]
flipYMap
(int width, int height) Generates a map to reflect pixels on the horizontal axis, flipping y-coordinates.static int[]
getIndexMap
(int w, int h, AffineTransformType type) static PImage
imageTransform
(PImage img, AffineTransformType type) static int[]
nadaCoord
(int x, int y, int w, int h) Don't do nothing, no, no, no, just return an array with x and y.static int[]
nadaMap
(int width, int height) Generates a map to leave a pixel array unchanged: the don't do nothing map, oh no, nada, nothing map.static int[]
pixelsTransform
(int[] pixels, int width, int height, AffineTransformType type) Performs a geometric transform (rotation, reflection) of an array of pixels.static int[]
rotate180
(int[] pixels, int width, int height) Rotates an array of integers 180 degrees, as determined by width and height arguments.static PImage
Rotates a PImage 180 degrees.static int[]
rotate180Coord
(int x, int y, int w, int h) static int[]
rotate180Map
(int width, int height) Generates a map to rotate pixels 180 degrees.static int[]
rotate90
(int[] pixels, int width, int height) Rotates an array of integers 90 degrees clockwise, as determined by width and height arguments.static PImage
Rotates a PImage 90 degrees clockwise.static int[]
rotate90CCW
(int[] pixels, int width, int height) Rotates an array of integers 90 degrees counter-clockwise, as determined by width and height arguments.static PImage
rotate90CCW
(PImage img) Rotates a PImage 90 degrees counter-clockwise.static int[]
rotate90CCWCoord
(int x, int y, int w, int h) static int[]
rotate90CCWMap
(int width, int height) Generates a map to rotate pixels 90 degrees CCW.static int[]
rotate90Coord
(int x, int y, int w, int h) static int[]
rotate90Map
(int width, int height) Generates a map to rotate pixels 90 degrees CW.
-
Constructor Details
-
BitmapTransform
public BitmapTransform()
-
-
Method Details
-
imageTransform
- Parameters:
img
- a PImage to transformtype
- a geometric transform (rotation, reflection) to perform on img- Returns:
- transformed image
-
pixelsTransform
Performs a geometric transform (rotation, reflection) of an array of pixels.- Parameters:
pixels
- an array of integers, possibly RGB or ARGB colors or array indiceswidth
- width of bitmap for pixelheight
- height of bitmap for pixeltype
- type of geometric transform for the bitmap- Returns:
- transformed coordinate pair, as determined by width, height, and transform type
-
coordTransform
Performs a geometric transform (rotation, reflection) of a single pixel location.- Parameters:
x
- x-coordinate of a pixely
- y-coordinate of a pixelwidth
- width of bitmap for pixelheight
- height of bitmap for pixeltype
- type of geometric transform for the bitmap- Returns:
- transformed coordinate pair, as determined by width, height, and transform type
-
getIndexMap
- Parameters:
w
- bitmap widthh
- bitmap heighttype
- type of affine transform- Returns:
- array of bitmap indices reordered in accordance with the desired transform
-
rotate90
public static int[] rotate90(int[] pixels, int width, int height) Rotates an array of integers 90 degrees clockwise, as determined by width and height arguments.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
rotate90CCW
public static int[] rotate90CCW(int[] pixels, int width, int height) Rotates an array of integers 90 degrees counter-clockwise, as determined by width and height arguments.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
rotate180
public static int[] rotate180(int[] pixels, int width, int height) Rotates an array of integers 180 degrees, as determined by width and height arguments.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
flipX
public static int[] flipX(int[] pixels, int width, int height) Reflects an array of integers on vertical axis, as determined by width and height arguments, flipping x-coordinates.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
flipY
public static int[] flipY(int[] pixels, int width, int height) Reflects an array of integers on the horizontal axis, as determined by width and height arguments, flipping y-coordinates.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
flipX90CCW
public static int[] flipX90CCW(int[] pixels, int width, int height) Reflects an array of integers on the primary diagonal, as determined by width and height arguments.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
flipX90
public static int[] flipX90(int[] pixels, int width, int height) Reflects an array of integers on the secondary diagonal, as determined by width and height arguments.- Parameters:
pixels
- an array of integer values, possibly RGB or ARGB colors or array indiceswidth
- width of the bitmap for the pixels arrayheight
- height of the bitmap for the pixels array- Returns:
- a transformed copy of the pixels array
-
rotate90
Rotates a PImage 90 degrees clockwise.- Parameters:
img
- a PImage- Returns:
- transformed image
-
rotate90CCW
Rotates a PImage 90 degrees counter-clockwise.- Parameters:
img
- a PImage- Returns:
- transformed image
-
rotate180
Rotates a PImage 180 degrees.- Parameters:
img
- a PImage- Returns:
- transformed image
-
flipX
Reflects a PImage on the vertical axis, flipping the x-coordinates.- Parameters:
img
- a PImage- Returns:
- transformed image
-
flipY
Reflects a PImage on the horizontal axis, flipping the y-coordinates.- Parameters:
img
- a PImage- Returns:
- transformed image
-
flipX90CCW
Reflects a PImage on the primary diagonal, running from upper left to lower right.- Parameters:
img
- a PImage- Returns:
- transformed image
-
flipX90
Reflects a PImage on the secondary diagonal, running from lower left to upper right.- Parameters:
img
- a PImage- Returns:
- transformed image
-
rotate90Coord
public static int[] rotate90Coord(int x, int y, int w, int h) - Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
rotate90CCWCoord
public static int[] rotate90CCWCoord(int x, int y, int w, int h) - Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
rotate180Coord
public static int[] rotate180Coord(int x, int y, int w, int h) - Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
flipXCoord
public static int[] flipXCoord(int x, int y, int w, int h) - Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
flipYCoord
public static int[] flipYCoord(int x, int y, int w, int h) - Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
flipX90CCWCoord
public static int[] flipX90CCWCoord(int x, int y, int w, int h) Reflect x and y on primary diagonal.- Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
flipX90Coord
public static int[] flipX90Coord(int x, int y, int w, int h) Reflect x and y on secondary diagonal.- Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- transformed coordinates {x, y}
-
nadaCoord
public static int[] nadaCoord(int x, int y, int w, int h) Don't do nothing, no, no, no, just return an array with x and y.- Parameters:
x
- x-coordinate of pixely
- y-coordinate of pixelw
- width of bitmaph
- height of bitmap- Returns:
- untransformed coordinates {x, y}
-
rotate90Map
public static int[] rotate90Map(int width, int height) Generates a map to rotate pixels 90 degrees CW.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform of 90 degrees CW
-
rotate90CCWMap
public static int[] rotate90CCWMap(int width, int height) Generates a map to rotate pixels 90 degrees CCW.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform of 90 degrees CCW
-
rotate180Map
public static int[] rotate180Map(int width, int height) Generates a map to rotate pixels 180 degrees.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform rotates 180 degrees
-
flipXMap
public static int[] flipXMap(int width, int height) Generates a map to reflect pixels on the vertical axis, flipping x-coordinates.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform that reflects on Y-axis
-
flipYMap
public static int[] flipYMap(int width, int height) Generates a map to reflect pixels on the horizontal axis, flipping y-coordinates.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform that reflects on X-axis
-
flipX90CCWMap
public static int[] flipX90CCWMap(int width, int height) Generates a map to reflect pixels on primary diagonal.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform that reflects on primary diagonal
-
flipX90Map
public static int[] flipX90Map(int width, int height) Generates a map to reflect pixels on secondary diagonal.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform that reflects on secondary diagonal
-
nadaMap
public static int[] nadaMap(int width, int height) Generates a map to leave a pixel array unchanged: the don't do nothing map, oh no, nada, nothing map.- Parameters:
width
- width of transformation mapheight
- height of transformation map- Returns:
- look up table for a geometric transform that does nothing
-