Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Main(string[] args)
- {
- Stopwatch s = new Stopwatch();
- s.Start();
- while(true) {
- long start = s.ElapsedMilliseconds;
- Bitmap b = new Bitmap(1280, 720);
- BitmapData bData = b.LockBits(
- new Rectangle(Point.Empty, b.Size),
- ImageLockMode.ReadWrite,
- PixelFormat.Format24bppRgb);
- int numBytes = Math.Abs(bData.Stride) * b.Height;
- byte[] rgbValues = new byte[numBytes];
- for(int i = 2; i < numBytes - 2; i += 3) {
- if(0.3 * rgbValues[i] + 0.3 * rgbValues[i + 1] + 0.4 * rgbValues[i + 2] < 0.4) {
- rgbValues[i] = 255;
- rgbValues[i + 1] = 0;
- rgbValues[i + 2] = 0;
- }
- }
- System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, bData.Scan0, numBytes);
- b.UnlockBits(bData);
- b.Save("huy.png");
- Console.WriteLine("{0:F3}", (s.ElapsedMilliseconds - start) / 1000.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement