MLTextureUtils
NameSpace: Native
Class containing utility functions to convert Unity Texture to Magic Leap OS compatible data structures.
Public Methods
byte [] ConvertToByteArray
Convert Unity Texture2D to a byte array. Texture2D should be in one of the following formats: DXT1, RGBA32, RGB24. For DXT1 and RGBA32, resulting byte array is in RGBA format. For RGB24, resulting byte array is in RGB format. The origin of the byte array will be at the top left corner. Returns null on unsupported formats.
public static byte [] ConvertToByteArray(
Texture2D texture,
out int numChannels
)
Parameters
Type | Name | Description |
---|---|---|
Texture2D | texture | Texture to extract byte array from |
out int | numChannels | Out parameter to determine how many bytes per pixel |
Returns: Returns an array of bytes that holds the converted texture
byte [] FlipPixelsVertically
Performs a vertical flip on a byte array of image pixel data. Each pixel is assumed to be 4 bytes.
public static byte [] FlipPixelsVertically(
byte [] originalPixels,
int width,
int height
)
Parameters
Type | Name | Description |
---|---|---|
byte [] | originalPixels | The pixels array of the image to be flipped. The array length is assumed to be 4 * width * height. |
int | width | The number of the pixels wide of the image from the data. |
int | height | The number of the pixels high of the image from the data. |
Returns: A new byte array arranged vertically flipped from the input array of pixels.