GPU - imageData
ImageData, modifiable pixel data, not drawable, convert to an image to draw.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.8.0
Methods:
imageData:encode
Encodes the imagedata into lk12 image string.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
data = imageData:encode()
Returns:
- data (string): The imagedata into lk12 image string.
imageData:enlarge
This function will multiply the image dimensions with the given scale, and automatically scales the image data, then returns the result imagedata.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
enimgdata = imageData:enlarge(scale)
Arguments:
- <scale> (number): The scale to multiply the image dimensions with, must be bigger than zero and integer.
Returns:
- enimgdata (GPU/imageData): The resulting imagedata.
imageData:export
Exports the imagedata to png, all transparent pixel in palt() will be transparent in the result png.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
png = imageData:export()
Returns:
- png (string): The binary png data.
imageData:exportOpaque
Exports the imagedata to png, all the colors will be opaque.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
png = imageData:exportOpaque()
Returns:
- png (string): The binary png data.
imageData:getPixel
Get a pixel color in the imagedata.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
color = imageData:getPixel(x, y)
Arguments:
- <x> (number): The pixel x position.
- <y> (number): The pixel y position.
Returns:
- color (number): The pixel color (0-15).
imageData:height
Returns the imagedata height.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
height = imageData:height()
Returns:
- height (number): The imagedata height in pixels.
imageData:image
Converts the imagedata to an image, which can be drawn to the screen.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
This function is slow if called repeatly, unlike image:data(). image:refresh() will reload it's content from it's source imagedata.
img = imageData:image()
Returns:
- img (GPU/image): The created image object.
imageData:map
Transform an image by applying a function to every pixel.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
The function that's passed as an argument will be called for every pixel in the image, starting with the top-left one, and going in horizental lines.
imageData:map(f)
Arguments:
- <f> (function): The callback function. The x, y coord and color are passed. And the function can return the new pixel color, otherwise the pixel color will stay the same.
imageData:paste
Paste into ImageData from another source ImageData.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
The function returns the imagedata object itself, so it can be used for chain calls.
imgdata = imageData:paste(source, dx, dy, sx, sy, sw, sh)
Arguments:
- <source> (GPU/imageData): The source imagedata (To copy from).
- [dx] (number) (Default:
0
): Destination top-left x position. - [dy] (number) (Default:
0
): Destination top-left y position. - [sx] (number) (Default:
0
): Source top-left x position. - [sy] (number) (Default:
0
): Source top-left y position. - <sw> (number): Source width.
- <sh> (number): Source height.
Returns:
- imgdata (GPU/imageData): The imagedata itself.
imageData:quad
Creates a new quad passing the imagedata dimensions automatically.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
q = imageData:quad(x, y, width, height)
Arguments:
- <x> (number): The x coord of the quad's top-left corner.
- <y> (number): The y coord of the quad's top-left corner.
- <width> (number): The width of the quad.
- <height> (number): The height of the quad.
Returns:
- q (GPU/quad): The created quad.
imageData:setPixel
Set a pixel color in the imagedata.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
The function returns the imagedata object itself, so it can be used for chain calls.
imgdata = imageData:setPixel(x, y, color)
Arguments:
- <x> (number): The pixel x position.
- <y> (number): The pixel y position.
- <color> (number): The new pixel color (0-15).
Returns:
- imgdata (GPU/imageData): The imagedata itself.
imageData:size
Returns the imagedata dimensions.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
width, height = imageData:size()
Returns:
- width (number): The imagedata width in pixels.
- height (number): The imagedata height in pixels.
imageData:type
Gets the type of the object as a string.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
type = imageData:type()
Returns:
- type (string): The object type, (GPU.imageData).
imageData:typeOf
Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
For GPUImg, it returns true for the folowing types: 'GPU', 'imageData', 'GPU.imageData', 'LK12'
bool = imageData:typeOf(type)
Arguments:
- <type> (string): The name of the type to check for.
Returns:
- bool (boolean): True if the object is of the specified type, false otherwise.
imageData:width
Returns the imagedata width.
- Available since: imageData: v1.0.0, LIKO-12: v0.6.0
- Last updated in: imageData: v1.0.0, LIKO-12: v0.6.0
width = imageData:width()
Returns:
- width (number): The imagedata width in pixels.