Advertisement
timeshifter

Untitled

Apr 29th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1.         void ComputeFrame() {
  2.             i = 0;
  3.             x = 0;
  4.             uint* ti;
  5.             fixed (uint* f = field) {
  6.                 t = (altFrame ? f + l : f);
  7.                 a = (altFrame ? f : f + l);
  8.                 bmpData = canvas.LockBits(bmpRect, ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
  9.                 currPos = (uint*)bmpData.Scan0;
  10.                 while (i != l) {
  11.                     n = 0;
  12.                     ti = t + i;
  13.                     if (x != 0) if (*(ti - 1) == 1) n++; //left
  14.                     if (x != (w - 1)) if (*(ti + 1) == 1) n++; //right
  15.                     if (i > w) if (*(ti - w) == 1) n++; //top
  16.                     if (i < (l - w)) if (*(ti + w) == 1) n++; //bottom
  17.                     if (x != 0 && i > w) if (*(ti - w - 1) == 1) n++; //left top
  18.                     if (x != 0 && i < (l - w)) if (*(ti + w - 1) == 1) n++; //left bottom
  19.                     if (x != (w - 1) && i > w) if (*(ti - w + 1) == 1) n++; //right top
  20.                     if (x != (w - 1) && i < (l - w)) if (*(ti + w + 1) == 1) n++; //right bottom
  21.  
  22.                     if (*(ti) == 1) {
  23.                         *(a + i) = (uint)((n != 2 && n != 3) ? 0 : 1);
  24.                         *currPos = col;
  25.                     }
  26.                     else {
  27.                         *(a + i) = (uint)(n == 3 ? 1 : 0);
  28.                         //if (fadeColors) {
  29.                         //    if ((*currPos & 0x00ff0000) > (uint)(colLimit << 16)) *currPos -= (uint)(colDecVal << 16);
  30.                         //    if ((*currPos & 0x0000ff00) > (uint)(colLimit << 8)) *currPos -= (uint)(colDecVal << 8);
  31.                         //    if ((*currPos & 0x000000ff) > (uint)(colLimit)) *currPos -= (uint)(colDecVal);
  32.                         //}
  33.                         //else
  34.                             *currPos = 0xff000000;
  35.                     }
  36.                     ++currPos;
  37.                     ++i;
  38.                     if (++x == w) x = 0;
  39.                 }
  40.                 canvas.UnlockBits(bmpData);
  41.             }
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement