public static Bitmap CreateGrayscaleImage(int width, int height) { // create new image Bitmap image = new Bitmap(width, height, PixelFormat.Format8bppIndexed); // set palette to grayscale SetGrayscalePalette(image); // return new image return image; }