E
eriwik
Hi,
I'm working on a small application which processes PNG-images and need
to read parts of them into structures and/or variables and I was
wondering what assumptions one can make about how the compiler places
things in memory.
Or more specific, I want to read the color-palette into a array of
structs with the following format:
typedef struct {
uint8_t red;
uint8_t green;
uint8_t blue;
} palette8e;
and the array:
typedef palette8e palette8[256];
Can I assume that a pointer to a palette8 will be a block of 3*256
consecutive bytes in memory so that I can just read in from the file
(which stores the palette as 256 tripplets of bytes)?
If not, is there some other easy way to do this, except for reading the
file byte for byte?
I'm working on a small application which processes PNG-images and need
to read parts of them into structures and/or variables and I was
wondering what assumptions one can make about how the compiler places
things in memory.
Or more specific, I want to read the color-palette into a array of
structs with the following format:
typedef struct {
uint8_t red;
uint8_t green;
uint8_t blue;
} palette8e;
and the array:
typedef palette8e palette8[256];
Can I assume that a pointer to a palette8 will be a block of 3*256
consecutive bytes in memory so that I can just read in from the file
(which stores the palette as 256 tripplets of bytes)?
If not, is there some other easy way to do this, except for reading the
file byte for byte?