Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ComputeFrame() {
- i = 0;
- x = 0;
- uint* ti;
- fixed (uint* f = field) {
- t = (altFrame ? f + l : f);
- a = (altFrame ? f : f + l);
- bmpData = canvas.LockBits(bmpRect, ImageLockMode.ReadWrite, PixelFormat.Format32bppPArgb);
- currPos = (uint*)bmpData.Scan0;
- while (i != l) {
- n = 0;
- ti = t + i;
- if (x != 0) if (*(ti - 1) == 1) n++; //left
- if (x != (w - 1)) if (*(ti + 1) == 1) n++; //right
- if (i > w) if (*(ti - w) == 1) n++; //top
- if (i < (l - w)) if (*(ti + w) == 1) n++; //bottom
- if (x != 0 && i > w) if (*(ti - w - 1) == 1) n++; //left top
- if (x != 0 && i < (l - w)) if (*(ti + w - 1) == 1) n++; //left bottom
- if (x != (w - 1) && i > w) if (*(ti - w + 1) == 1) n++; //right top
- if (x != (w - 1) && i < (l - w)) if (*(ti + w + 1) == 1) n++; //right bottom
- if (*(ti) == 1) {
- *(a + i) = (uint)((n != 2 && n != 3) ? 0 : 1);
- *currPos = col;
- }
- else {
- *(a + i) = (uint)(n == 3 ? 1 : 0);
- //if (fadeColors) {
- // if ((*currPos & 0x00ff0000) > (uint)(colLimit << 16)) *currPos -= (uint)(colDecVal << 16);
- // if ((*currPos & 0x0000ff00) > (uint)(colLimit << 8)) *currPos -= (uint)(colDecVal << 8);
- // if ((*currPos & 0x000000ff) > (uint)(colLimit)) *currPos -= (uint)(colDecVal);
- //}
- //else
- *currPos = 0xff000000;
- }
- ++currPos;
- ++i;
- if (++x == w) x = 0;
- }
- canvas.UnlockBits(bmpData);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement