Color Scaling - AzuxirenLeadGuy/GdiPlusExtension GitHub Wiki

Color-Scaling

Color scaling allows to change the color scheme of an image by doing a linear interpolation (also called Lerp operation) for every pixel according to its intensity

This static method is defined in the static class GdiPlusExtensions.ColorScaling

It defines the static extension method


	public static Bitmap CustomScale(this Bitmap bitmap, Color x, Color y) {...}

This Wiki will showcase dithering for the following input image in public domain:

Sample Image

The method CustomScale() will scale/interpolate all pixel between the color x and color y provided as the arguments.

The following script transforms the image in black and white (i.e grayscale as)

Bitmap bitmap = ...//Open Image
bitmap.CustomScale(Color.Black, Color.White);

Alternativly the Grayscale method is also availale to do the same:

Bitmap bitmap = ...//Open Image
bitmap.Grayscale();

To produce the output

Grayscaled-image

Any other color schemes can be taken as well. For example, using Black and Red can be done with

Bitmap bitmap = ...//Open Image
bitmap.CustomScale(Color.Black, Color.Red);

To produce the output

Red-Black-Scaled-image

Similarly, using DarkGreen and GreenYellow would be done with

Bitmap bitmap = ...//Open Image
bitmap.CustomScale(Color.DarkGreen, Color.GreenYellow);

To produce the output

Greenscaled-image