#C#, Winform
C#, Winform
#Code
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internal#C#, Winform
#Code
#C#, Winform
#Code
Edit Changing the way you fill the coordinates array you can have different patterns - see below
Complex pattern

Change the first part of work function, up to Application.DoEvents:
int w = srcb.Width, h = srcb.Height; string Msg = "Scramble"; Graphics gr = Graphics.FromImage(outb); Font f = new Font("Arial", 100, FontStyle.Bold); var size = gr.MeasureString(Msg, f); f = new Font("Arial", w / size.Width * 110, FontStyle.Bold); size = gr.MeasureString(Msg, f); gr.DrawString(Msg, f, new SolidBrush(Color.White), (w - size.Width) / 2, (h - size.Height) / 2); gr.Dispose(); Coord[] coord = new Coord[w * h]; FastBitmap fsb = new FastBitmap(srcb); FastBitmap fob = new FastBitmap(outb); fsb.LockImage(); fob.LockImage(); ulong seed = 1; int numpix = h * w; int c1 = 0, c2 = numpix; int y2 = h / 2; int p2 = numpix/2; for (int p = 0; p < p2; p++) { for (int s = 1; s > -2; s -= 2) { int y = (p2+s*p) / w; int x = (p2+s*p) % w; uint d = fob.GetPixel(x, y); if (d != 0) { c2--; coord[c2].x = x; coord[c2].y = y; } else { coord[c1].x = x; coord[c1].y = y; c1++; } fob.SetPixel(x, y, fsb.GetPixel(x, y)); } } fsb.UnlockImage(); fob.UnlockImage(); pbOutput.Refresh(); Application.DoEvents(); Edit Changing the way you fill the coordinates array you can have different patterns - see below
Complex pattern

Change the first part of work function, up to Application.DoEvents:
int w = srcb.Width, h = srcb.Height; string Msg = "Scramble"; Graphics gr = Graphics.FromImage(outb); Font f = new Font("Arial", 100, FontStyle.Bold); var size = gr.MeasureString(Msg, f); f = new Font("Arial", w / size.Width * 110, FontStyle.Bold); size = gr.MeasureString(Msg, f); gr.DrawString(Msg, f, new SolidBrush(Color.White), (w - size.Width) / 2, (h - size.Height) / 2); gr.Dispose(); Coord[] coord = new Coord[w * h]; FastBitmap fsb = new FastBitmap(srcb); FastBitmap fob = new FastBitmap(outb); fsb.LockImage(); fob.LockImage(); ulong seed = 1; int numpix = h * w; int c1 = 0, c2 = numpix; int y2 = h / 2; int p2 = numpix/2; for (int p = 0; p < p2; p++) { for (int s = 1; s > -2; s -= 2) { int y = (p2+s*p) / w; int x = (p2+s*p) % w; uint d = fob.GetPixel(x, y); if (d != 0) { c2--; coord[c2].x = x; coord[c2].y = y; } else { coord[c1].x = x; coord[c1].y = y; c1++; } fob.SetPixel(x, y, fsb.GetPixel(x, y)); } } fsb.UnlockImage(); fob.UnlockImage(); pbOutput.Refresh(); Application.DoEvents(); Random swap exactly one time all pixelpixels in upper half with all pixelpixels in lower half. Repeat the same procedure for unscrambling (bonus).
Random swap exactly one time all pixel in upper half with all pixel in lower half. Repeat the same procedure for unscrambling (bonus).
Random swap exactly one time all pixels in upper half with all pixels in lower half. Repeat the same procedure for unscrambling (bonus).