using System.Drawing; // Load image to Bitmap object Bitmap sampleImage = new Bitmap("sampleImage.jpg"); // Get the RGB value of pixel at location (100, 100) Color pixelColor = sampleImage.GetPixel(100, 100); // Print the RGB value Console.WriteLine("Pixel color (R,G,B) = ({0},{1},{2})", pixelColor.R, pixelColor.G, pixelColor.B);
using System.Drawing; // Create a Bitmap object with width of 200 and height of 100 Bitmap newImage = new Bitmap(200, 100); // Set every pixel color to black for (int i = 0; i < newImage.Width; i++) { for (int j = 0; j < newImage.Height; j++) { newImage.SetPixel(i, j, Color.Black); } }Both examples use the System.Drawing package/library to manipulate Bitmap objects, retrieve pixel colors, and set pixel colors.