Anonymous user
Image noise: Difference between revisions
perfomance improvement too! from 111 fps to 130 fps.
m (→{{header|J}}) |
(perfomance improvement too! from 111 fps to 130 fps.) |
||
Line 7:
=={{header|C sharp|C#}}==
<lang csharp>using System;
using System.
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.
using System.
class Program
{
static
static Size size = new Size(320, 240);
static Rectangle rectsize = new Rectangle(new Point(0, 0), size);
static int
static int numbytes = numpixels * 3;
static PictureBox pb;
Line 29 ⟶ 30:
static Random rand = new Random();
static IEnumerable<byte> YieldVodoo(
{
// Yield 3 times same number (i.e 255 255 255) for numpixels
for (int i = 0; i < numpixels
{
var tmp = colors[rand.Next(
for (int j = 0; j < 3; j++)
{
yield return
}
}
Line 47:
static Image Randimg()
{
// Low-level bitmaps
var bitmap = new Bitmap(size.Width, size.Height); ▼
▲ var bitmap = new Bitmap(size.Width, size.Height);
var data = bitmap.LockBits(rectsize, ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
Marshal.Copy(
0, // start
data.Scan0, // scan0 is a pointer to low-level bitmap data
numbytes); /
bitmap.UnlockBits(data);
Line 65 ⟶ 63:
static void Main()
{
var form = new Form();
form.AutoSize = true;
form.Size = new Size(0, 0);
form.Text = "Test";
form.FormClosed += delegate
{
Line 76 ⟶ 75:
worker = new BackgroundWorker();
worker.DoWork += delegate
{
Line 98:
}
catch
{
// Just pass.
}
}
};
worker.RunWorkerAsync();
FlowLayoutPanel flp = new FlowLayoutPanel();
form.Controls.Add(flp);
pb = new PictureBox();
pb.Size = size;
form.Show();
Application.Run();
}
|