Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool CImgProc::isRepeatable(BYTE ** picture, CPoint p)
  2. {
  3.     int maxElem = 0;
  4.     for (int y = -1; y <= 1; ++y)
  5.     {
  6.         maxElem = max(maxElem, picture[p.y + y][p.x + 1]);
  7.     }
  8.  
  9.     if (maxElem > 0)
  10.     {
  11.         maxElem = 0;
  12.         for (int y = -1; y <= 1; ++y)
  13.         {
  14.             maxElem = max(maxElem, picture[p.y + y][p.x - 1]);
  15.         }
  16.         maxElem = maxElem > 0 && picture[p.y - 1][p.x] == 0 && picture[p.y + 1][p.x] == 0 ? 1 : 0;
  17.     }
  18.  
  19.     if (maxElem > 0)
  20.         return true;
  21.     else
  22.         maxElem = 0;
  23.  
  24.     for (int x = -1; x <= 1; ++x)
  25.     {
  26.         maxElem = max(maxElem, picture[p.y + 1][p.x + x]);
  27.     }
  28.  
  29.     if (maxElem > 0)
  30.     {
  31.         maxElem = 0;
  32.         for (int x = -1; x <= 1; ++x)
  33.         {
  34.             maxElem = max(maxElem, picture[p.y - 1][p.x + x]);
  35.         }
  36.         maxElem = maxElem > 0 && picture[p.y][p.x + 1] == 0 && picture[p.y][p.x - 1] == 0 ? 1 : 0;
  37.     }
  38.  
  39.     if (maxElem > 0)
  40.         return true;
  41.     else
  42.         maxElem = 0;
  43.  
  44.  
  45.     if (picture[p.y + 1][p.x + 1] > 0 && picture[p.y + 1][p.x] == 0 && picture[p.y][p.x + 1] == 0)
  46.     {
  47.         for (int y = -1; y <= 1; ++y)
  48.         {
  49.             maxElem = max(maxElem, picture[p.y + y][p.x - 1]);
  50.         }
  51.  
  52.         for (int x = -1; x <= 1; ++x)
  53.         {
  54.             maxElem = max(maxElem, picture[p.y - 1][p.x + x]);
  55.  
  56.         }
  57.     }
  58.  
  59.     if (maxElem > 0)
  60.         return true;
  61.     else
  62.         maxElem = 0;
  63.  
  64.     if (picture[p.y - 1][p.x + 1] > 0 && picture[p.y - 1][p.x] == 0 && picture[p.y][p.x + 1] == 0)
  65.     {
  66.         for (int y = -1; y <= 1; ++y)
  67.         {
  68.             maxElem = max(maxElem, picture[p.y + y][p.x - 1]);
  69.         }
  70.  
  71.         for (int x = -1; x <= 1; ++x)
  72.         {
  73.             maxElem = max(maxElem, picture[p.y + 1][p.x + x]);
  74.  
  75.         }
  76.     }
  77.  
  78.     if (maxElem > 0)
  79.         return true;
  80.     else
  81.         maxElem = 0;
  82.  
  83.     if (picture[p.y - 1][p.x - 1] > 0 && picture[p.y - 1][p.x] == 0 && picture[p.y][p.x - 1] == 0)
  84.     {
  85.         for (int y = -1; y <= 1; ++y)
  86.         {
  87.             maxElem = max(maxElem, picture[p.y + y][p.x + 1]);
  88.         }
  89.  
  90.         for (int x = -1; x <= 1; ++x)
  91.         {
  92.             maxElem = max(maxElem, picture[p.y + 1][p.x + x]);
  93.  
  94.         }
  95.     }
  96.  
  97.     if (maxElem > 0)
  98.         return true;
  99.     else
  100.         maxElem = 0;
  101.  
  102.     if (picture[p.y + 1][p.x - 1] > 0 && picture[p.y + 1][p.x] == 0 && picture[p.y][p.x - 1] == 0)
  103.     {
  104.         for (int y = -1; y <= 1; ++y)
  105.         {
  106.             maxElem = max(maxElem, picture[p.y + y][p.x + 1]);
  107.         }
  108.  
  109.         for (int x = -1; x <= 1; ++x)
  110.         {
  111.             maxElem = max(maxElem, picture[p.y - 1][p.x + x]);
  112.  
  113.         }
  114.     }
  115.     return maxElem > 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement