C# Get Bitmap Pixel Color
Získá barvu pixelu na bitmapě
java
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Vyberte bitmapu z počítače...");
Console.ReadKey();
Console.WriteLine();
Color color = GetBitmapPixelColor(1, 1);
Console.WriteLine(String.Format("Pixel (1, 1) at Bitmap is {0},{1},{2}", color.R, color.G, color.B));
Console.ReadKey();
}
public static Color GetBitmapPixelColor(int x, int y)
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Bitmap b = new Bitmap(ofd.FileName);
return Color.FromArgb(b.GetPixel(x, y).A, b.GetPixel(x, y).R, b.GetPixel(x, y).G, b.GetPixel(x, y).B);
}
else
throw new NotImplementedException("File MUST be selected");
}
Neformátovaný
Přidáno: 6.11.2013
Expirace: Neuvedeno