Class PNGParser
High-performance PNG file parser for map files Supports 8-bit indexed, 24-bit RGB, and 32-bit RGBA formats Uses managed decompression but NativeArray for pixel storage
public static class PNGParser
- Inheritance
-
objectPNGParser
Methods
CollectUniqueColors(PNGPixelData, Allocator)
Scan all pixels and collect unique RGB values
public static NativeHashSet<int> CollectUniqueColors(PNGParser.PNGPixelData pixelData, Allocator allocator)
Parameters
pixelDataPNGParser.PNGPixelDataallocatorAllocator
Returns
- NativeHashSet<int>
FindPixelsWithColor(PNGPixelData, int, Allocator)
Find all pixels with a specific RGB color
public static NativeList<PixelCoord> FindPixelsWithColor(PNGParser.PNGPixelData pixelData, int targetRGB, Allocator allocator)
Parameters
pixelDataPNGParser.PNGPixelDatatargetRGBintallocatorAllocator
Returns
- NativeList<PixelCoord>
IsPNG(NativeArray<byte>)
Check if file data is a valid PNG
public static bool IsPNG(NativeArray<byte> fileData)
Parameters
fileDataNativeArray<byte>
Returns
- bool
Parse(NativeArray<byte>, Allocator)
Parse and decode entire PNG file
public static PNGParser.PNGPixelData Parse(NativeArray<byte> fileData, Allocator allocator)
Parameters
fileDataNativeArray<byte>allocatorAllocator
Returns
ParseHeader(NativeArray<byte>)
Parse PNG header from file data
public static PNGParser.PNGHeader ParseHeader(NativeArray<byte> fileData)
Parameters
fileDataNativeArray<byte>
Returns
TryGetPixelRGB(PNGPixelData, int, int, out byte, out byte, out byte)
Get RGB color at specific pixel coordinates
public static bool TryGetPixelRGB(PNGParser.PNGPixelData pixelData, int x, int y, out byte r, out byte g, out byte b)
Parameters
pixelDataPNGParser.PNGPixelDataxintyintrbytegbytebbyte
Returns
- bool
TryGetPixelRGBPacked(PNGPixelData, int, int, out int)
Get packed RGB color (0xRRGGBB) at specific coordinates
public static bool TryGetPixelRGBPacked(PNGParser.PNGPixelData pixelData, int x, int y, out int rgb)
Parameters
pixelDataPNGParser.PNGPixelDataxintyintrgbint
Returns
- bool