Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- namespace Get_Color_Count_From_Image
- {
- class Program
- {
- static void Main(string[] args)
- {
- var img = Image.FromFile("image.png");
- List<Color> colors = new List<Color>();
- using (Bitmap bmp = new Bitmap(img))
- {
- for (int i = 0; i < bmp.Width; i++)
- {
- for (int j = 0; j < bmp.Height; j++)
- {
- Color clr = bmp.GetPixel(i, j);
- if (colors.IndexOf(clr) == -1)
- {
- colors.Add(clr);
- }
- }
- }
- }
- Console.WriteLine(colors.Count);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement