For Each color in Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Bitmap

Description

For Each color in Bitmap

Demo Code


using System.Drawing.Imaging;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*w  w  w .j  av  a 2 s.co m*/

public class Main{
        static public void ForEach(this Bitmap Bitmap, Action<Color, int, int> Delegate)
      {
         int Width = Bitmap.Width, Height = Bitmap.Height;
         for (int y = 0; y < Height; y++)
         {
            for (int x = 0; x < Width; x++)
            {
               Delegate(Bitmap.GetPixel(x, y), x, y);
            }
         }
      }
}

Related Tutorials