Advertisement
Guest User

Untitled

a guest
Jan 12th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /* The height is required for a special case, see below */
  2. int height = surface->GetHeight(); 
  3.  
  4. /* Lock the image and get its buffer address */
  5. BYTE* buffer = surface->LockBuffer();
  6.  
  7. /* If for some reason the operation failed, quit */
  8. if(!buff)
  9.     return 0;
  10.  
  11. /* Get the pitch - the size of an image row in bytes */
  12. int pitch = surface->GetPitch();
  13.  
  14. /* Here's the special case: The pitch might be negative (I forgot when)
  15.    in that case we have to do some funky math */
  16. if(pitch < 0)
  17. {
  18.     pitch *= -1;
  19.     buff -= pitch*(height-1);
  20. }
  21.  
  22. /* We could now modify the buffer. Note that its upside down - the first row is the last one that is displayed. */
  23.  
  24. /* We're done, unlock the image */
  25. surface->UnlockBuffer(buffer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement