Skip to content

Conversation

@Try
Copy link
Contributor

@Try Try commented Nov 18, 2019

The problem

stb consistently under reads last 4 bytes of *png file.

Why this happends

in function stbi__parse_png_file we have a code:

static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { ... for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch(c.type) { ... case STBI__PNG_TYPE('I','E','N','D'): { ... return 1; // <--- CRC-read, will be skipped because of this 'return' } } ... stbi__get32be(s); // for normal chunk stb reading CRC here } }

Why this is a problem

In my video-game I have a screen-shoot inside save-file binary:

[ header ][ png-priview ][ data ] 

And to make it work I need a byte-exact png-reader/writer.

@nothings
Copy link
Owner

Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants