Table of Contents

Class ImageParser

Namespace
Map.Loading.Images
Assembly
MapAssembly.dll

Unified image parser that automatically detects and parses BMP or PNG files Provides a common interface for both formats

public static class ImageParser
Inheritance
object
ImageParser

Methods

CollectUniqueColors(ImagePixelData, Allocator)

Scan all pixels and collect unique RGB values

public static NativeHashSet<int> CollectUniqueColors(ImageParser.ImagePixelData pixelData, Allocator allocator)

Parameters

pixelData ImageParser.ImagePixelData
allocator Allocator

Returns

NativeHashSet<int>

DetectFormat(NativeArray<byte>)

Detect image format from file data

public static ImageParser.ImageFormat DetectFormat(NativeArray<byte> fileData)

Parameters

fileData NativeArray<byte>

Returns

ImageParser.ImageFormat

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

pixelData ImageParser.ImagePixelData
targetRGB int
allocator Allocator

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

fileData NativeArray<byte>
header ImageParser.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

fileData NativeArray<byte>
allocator Allocator

Returns

ImageParser.ImagePixelData

ParseHeader(NativeArray<byte>)

Parse image header (auto-detects format)

public static ImageParser.ImageHeader ParseHeader(NativeArray<byte> fileData)

Parameters

fileData NativeArray<byte>

Returns

ImageParser.ImageHeader

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

pixelData ImageParser.ImagePixelData
x int
y int
r byte
g byte
b byte

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

pixelData ImageParser.ImagePixelData
x int
y int
rgb int

Returns

bool