I have created a BYTE array containing a image pixel data. Image is grayscale and each pixel intensity is a 32bit integer. Now I want to read the each pixel intensity( 32 bit int) and then do some operations on each pixel intensity and store back the modified pixel intensity (again in 32bit int). So my question is how can I read a 32 bit (or also 16 bit) integer from a BYTE array. (working in VC++/MFC).
Thank you.
Use
memcpyto get the data from your array ofBYTEto an array ofint32_t(oruint32_t).If you don’t need portability, your architecture probably allows casting the address of the first
BYTEto aint32_t*and using it in-place.If all your data always comes from a file, and nothing needs to work on the individual bytes, you could just read it directly into an array of
int32_t.