Colors from Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Bitmap

Description

Colors from Bitmap

Demo Code


using System.Drawing.Imaging;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from  ww w .ja v  a2s  .co m

public class Main{
        static public IEnumerable<Color> Colors(this Bitmap Bitmap)
      {
         int Width = Bitmap.Width, Height = Bitmap.Height;
         for (int y = 0; y < Height; y++)
         {
            for (int x = 0; x < Width; x++)
            {
               yield return Bitmap.GetPixel(x, y);
            }
         }
      }
}

Related Tutorials