Class ImageParser
Unified image parser that automatically detects and parses BMP or PNG files Provides a common interface for both formats
public static class ImageParser
- Inheritance
-
objectImageParser
Methods
CollectUniqueColors(ImagePixelData, Allocator)
Scan all pixels and collect unique RGB values
public static NativeHashSet<int> CollectUniqueColors(ImageParser.ImagePixelData pixelData, Allocator allocator)
Parameters
pixelDataImageParser.ImagePixelDataallocatorAllocator
Returns
- NativeHashSet<int>
DetectFormat(NativeArray<byte>)
Detect image format from file data
public static ImageParser.ImageFormat DetectFormat(NativeArray<byte> fileData)
Parameters
fileDataNativeArray<byte>
Returns
FindPixelsWithColor(ImagePixelData, int, Allocator)
Find all pixels with a specific RGB color
public static NativeList<PixelCoord> FindPixelsWithColor(ImageParser.ImagePixelData pixelData, int targetRGB, Allocator allocator)
Parameters
pixelDataImageParser.ImagePixelDatatargetRGBintallocatorAllocator
Returns
- NativeList<PixelCoord>
GetPalette(NativeArray<byte>, ImageHeader)
Get the palette from an indexed image (8-bit BMP or indexed PNG) Returns null if image doesn't have a palette
public static Color32[] GetPalette(NativeArray<byte> fileData, ImageParser.ImageHeader header)
Parameters
fileDataNativeArray<byte>headerImageParser.ImageHeader
Returns
- Color32[]
Parse(NativeArray<byte>, Allocator)
Parse entire image file (auto-detects format)
public static ImageParser.ImagePixelData Parse(NativeArray<byte> fileData, Allocator allocator)
Parameters
fileDataNativeArray<byte>allocatorAllocator
Returns
ParseHeader(NativeArray<byte>)
Parse image header (auto-detects format)
public static ImageParser.ImageHeader ParseHeader(NativeArray<byte> fileData)
Parameters
fileDataNativeArray<byte>
Returns
TryGetPixelRGB(ImagePixelData, int, int, out byte, out byte, out byte)
Get RGB color at specific pixel coordinates (works for both BMP and PNG)
public static bool TryGetPixelRGB(ImageParser.ImagePixelData pixelData, int x, int y, out byte r, out byte g, out byte b)
Parameters
pixelDataImageParser.ImagePixelDataxintyintrbytegbytebbyte
Returns
- bool
TryGetPixelRGBPacked(ImagePixelData, int, int, out int)
Get packed RGB color (0xRRGGBB) at specific coordinates
public static bool TryGetPixelRGBPacked(ImageParser.ImagePixelData pixelData, int x, int y, out int rgb)
Parameters
pixelDataImageParser.ImagePixelDataxintyintrgbint
Returns
- bool