static void Main(string[] args) { //Quickly load a PixelMap through a Bitmap PixelMap map = new PixelMap("Lenna.png"); for (int x = 0; x < map.Width; x++) { for (int y = 0; y < map.Height; y++) { //Sample a pixel Pixel pixel = map[x, y]; //Create a hue value double value = ((double)x / map.Width) * 360d; //Set the hue value to our sample pixel.Hue = value; //Return our sample to the PixelMap map[x, y] = pixel; } } //Save the PixelMap through a Bitmap map.GetBitmap().Save("output.png"); }
static int errorBitmap(PixelMap a, PixelMap b) { int error = 0; PixelMap output = new PixelMap(a.Width, a.Height); for (int x = 0; x < a.Width; x++) { for (int y = 0; y < a.Height; y++) { Pixel cA = a[x, y]; Pixel cB = b[x, y]; Pixel diff = cA - cB; error += (diff.R + diff.G + diff.B); output[x, y] = diff; } } output.GetBitmap().Save("tests\\error.png"); return error; }