Skip to main content
Commonmark migration
Source Link

#C#, Winform

C#, Winform

#Code

Code

#C#, Winform

#Code

C#, Winform

Code

Bounty Awarded with 100 reputation awarded by Somnium
added 2026 characters in body
Source Link
edc65
  • 32.3k
  • 3
  • 37
  • 90

Edit Changing the way you fill the coordinates array you can have different patterns - see below

Complex pattern

Scramble

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

Scramble

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(); 
added 2 characters in body
Source Link
edc65
  • 32.3k
  • 3
  • 37
  • 90

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).

Source Link
edc65
  • 32.3k
  • 3
  • 37
  • 90
Loading