Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* The height is required for a special case, see below */
- int height = surface->GetHeight();
- /* Lock the image and get its buffer address */
- BYTE* buffer = surface->LockBuffer();
- /* If for some reason the operation failed, quit */
- if(!buff)
- return 0;
- /* Get the pitch - the size of an image row in bytes */
- int pitch = surface->GetPitch();
- /* Here's the special case: The pitch might be negative (I forgot when)
- in that case we have to do some funky math */
- if(pitch < 0)
- {
- pitch *= -1;
- buff -= pitch*(height-1);
- }
- /* We could now modify the buffer. Note that its upside down - the first row is the last one that is displayed. */
- /* We're done, unlock the image */
- surface->UnlockBuffer(buffer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement