runnig

Image access

Feb 25th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. struct Img
  2. {
  3.     byte * data;
  4.     int w, h;
  5.    
  6.     byte & pixel(int x, int y)
  7.     {
  8.         x = max(x,0);
  9.         x = min(x, w-1);
  10.        
  11.         y = max(y,0);
  12.         y = min(y,h-1);
  13.        
  14.         return data[y * w + x];
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment