Anonymous user
Image noise: Difference between revisions
more improvements! 140 FPS to 185 FPS!
m (→{{header|J}}) |
(more improvements! 140 FPS to 185 FPS!) |
||
Line 7:
=={{header|C sharp|C#}}==
Max
<lang csharp>using System;
Line 20:
class Program
{
static byte[] colors = { 0, 255 };▼
static Size size = new Size(320, 240);
static Rectangle rectsize = new Rectangle(new Point(0, 0), size);
Line 32 ⟶ 31:
static double frames = 0;
static Random rand = new Random();
static byte tmp;
static byte black = 0;
static int halfmax = int.MaxValue / 2; // more voodoo! calling Next() is faster than Next(2)!
static IEnumerable<byte> YieldVodoo()
{
// Yield 3 times same number (i.e 255 255 255) for numpixels times.
for (int i = 0; i < numpixels; i++)
{
}
}
Line 51 ⟶ 55:
{
// Low-level bitmaps
var bitmap = new Bitmap(size.Width, size.Height);
var data = bitmap.LockBits(rectsize, ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
Marshal.Copy(
YieldVodoo().ToArray<byte>(),// source
Line 64 ⟶ 68:
}
[STAThread]
static void Main()
{
var form = new Form();
form.AutoSize = true;
form.Size = new Size(0, 0);
Line 81 ⟶ 86:
worker.DoWork += delegate
{
System.Threading.Thread.Sleep(500); // remove try/catch, just wait a bit before looping
while (true)
{
}
}
Line 115:
pb.Size = size;
flp.AutoSize = true;
flp.Controls.Add(pb);
|