byteOrdering :: little-endian; format struct TGAFile { local arraysize :: int = (header.width * header.height) * header.bits.bytes; header :: TGAHeader; #All the names from TGAHeader are now in the TGAFile scope palettedata :: byte[header.colourmaplength]; pixeldata :: byte[arraysize]; } struct TGAHeader{ identsize :: byte; colormaptype :: ColorMapType; imagetype :: ImageType; colourmapstart :: short; colourmaplength :: short; colourmapbits :: ColorMapBits; xstart :: short; ystart :: short; width :: short; height :: short; bits :: BitsPerPixel; descriptor :: Descriptor; } #Defined types of data: enum ColorMapType :: byte{ 0: None; 1: Palette; } enum ImageType :: byte{ local useRLE :: bool; 0: None; 1: Indexed; 2: Rgb; 3: Grey; 8: [error("Empty images can't have RLE encoding")]; 9: Indexed [useRLE=true]; 10: Rgb [useRLE=true]; 11: Grey [useRLE=true]; else: [error("Invalid Imagetype") ]; } enum ColorMapBits :: byte{ 15; 16; 24; 32; else: [error("Invalid number of bits per palette entry")]; } enum BitsPerPixel :: byte{ local bytes :: int; 8: [bytes=1]; 16: [bytes=2]; 24: [bytes=3]; 32: [bytes=4]; else: [error("Invalid bits per pixel")]; } bitfield Descriptor :: byte { local FlipHorizontal, FlipVertical :: bool; 2: [FlipVertical=true]; 3: [FlipHorizontal=true]; }