The GetPixels3D
method retrieves pixel data from a 3D texture within a specified region and mip level. This method is useful for extracting a subset of pixel data from a 3D texture, which can then be processed or analyzed further.
The GetPixels3D
method retrieves pixel data from a 3D texture within a specified region and mip level. This method is useful for extracting a subset of pixel data from a 3D texture, which can then be processed or analyzed further.
To use the GetPixels3D
method, you need to specify the region of the 3D texture you want to extract, the mip level, the destination data span, the desired image format for the destination data, and the size of the destination data.
The srcBox
parameter is a tuple that defines the region of the 3D texture to extract, specified as (x, y, z, width, height, depth).
The mip
parameter specifies the mip level of the texture from which to extract the pixels.
The dstData
parameter is a span where the extracted pixel data will be stored. Ensure that the span is large enough to hold the data for the specified region and format.
The dstFormat
parameter specifies the format of the destination data, which should be compatible with the data type of the span.
The dstSize
parameter is a tuple that specifies the size of the destination data as (width, height, depth).
// Example usage of GetPixels3D var texture = new Texture(); var srcBox = (0, 0, 0, 10, 10, 10); // Define the region to extract int mipLevel = 0; // Mip level to extract from Span<Color32> destinationData = new Color32[1000]; // Ensure this is large enough ImageFormat destinationFormat = ImageFormat.RGBA32; var destinationSize = (10, 10, 10); // Size of the destination data texture.GetPixels3D(srcBox, mipLevel, destinationData, destinationFormat, destinationSize); // Now destinationData contains the extracted pixel data.