It is very simple to get RGB Color at specific point in an image. For this purpose we need to include System.Drawing Namespace in our code.
using System.Drawing;
Steps as below:- Define a point at which, you want to find the color.
- Get the image loaded.
- Use method GetPixel from Image class instance to get color at a point.
Bitmap img = Image.FromFile(@"<This is simple method getting color at a point.Image_file_path>" ) as Bitmap; Color colorAtPoint = img.GetPixel(10, 10);
Bitmap img = Image.FromFile("<>");
ReplyDeleteit can't ....
Error 1 Cannot implicitly convert type 'System.Drawing.Image' to 'System.Drawing.Bitmap'. An explicit conversion exists (are you missing a cast?) C:\Users\Filbert\Documents\Visual Studio 2005\Projects\WindowsApplication7\WindowsApplication7\Form1.cs 25 28 WindowsApplication7
Bitmap img = Image.FromFile("<>");
ReplyDeleteit can't ....
Error 1 Cannot implicitly convert type 'System.Drawing.Image' to 'System.Drawing.Bitmap'. An explicit conversion exists (are you missing a cast?) C:\Users\Filbert\Documents\Visual Studio 2005\Projects\WindowsApplication7\WindowsApplication7\Form1.cs 25 28 WindowsApplication7
Whenever you see this kind of error of implicit conversion, try to convert it explicitly. I have updated the code snippet for this error. I wonder how come I did not encountered it.
Delete