Good evening,
Hopefully a quick and easy question. In reviewing the HMH videos, I've noticed some basic pointer size casting (hopefully the correct terminology) that has always thrown me off a bit in my hobby coding endeavors.
One example from day 36 is the following (where ReadResult.Contents is a void*):
| uint32* Pixels = (uint32*)((uint8*)ReadResult.Contents + Header->BitmapOffset);
|
So I believe I understand correctly that the overall cast (uint32*) is done to keep everything in 4-byte chunks for pointer arithmetic that would advance a 4-byte stored pixel (AA RR GG BB).
Where I get lost now is the need for the initial (uint8*) cast. Especially since Header->BitmapOffset is already a (uint32) value. I've attempted to change it to the following, but doesn't work:
| uint32* Pixels = ((uint32*)ReadResult.Contents + Header->BitmapOffset);
|
Any help understanding this would be greatly appreciated.
-Mebourne