I'm trying to read a png file and I'm having some trouble with the chunk-size. Each chunk of a png file begins with a 4 byte (unsigned) integer. When I read this 4 byte integer (uint) I get an absolutely incorrect length. My code currently looks like:
void main(string args) { File f = new File("test.png", FileMode.In); // png signature ubyte[8] buffer; f.read(buffer); // first chunk (IHDR) uint size; f.read(size); f.close(); } When I run my code, I get 218103808 instead of 13 (decimal) or 0x0D (hex). When I try to read the 4 byte integer as a ubyte[4]-array, I get [0, 0, 0, 13] where 13 seems to be the correct ones because my hex-editor says [0x00 0x00 0x00 0x0D] for these 4 bytes. I hope anyone know where my mistake is. Thanks!