Contains extension methods to deal with Image
classes.
PM> Install-Package Zavolokas.GdiExtensions -Version 1.0.0
Clones an original image to a new one with changed size.
using (var bitmap = new Bitmap(pathToImageFile))
using (var scaled = bitmap.CloneWithScaleTo(300, 80))
{
scaled
.SaveTo(resultPath, ImageFormat.Png)
.ShowFile();
}
Input image | Result |
---|---|
Clones an original image to a new one with the opacity set to the specidied.
using (var image = new Bitmap(pathToImageFile))
using (var semiTransparent = image.CloneWithOpacity(0.3f))
{
semiTransparent
.SaveTo(resultPath, ImageFormat.Png)
.ShowFile();
}
Input image | Result |
---|---|
Replaces channel values from a source RGBA image.
Note: The dest and source images should be of the same size.
using (var source = new Bitmap(pathToSrcImage))
using (var dest = new Bitmap(pathToDestImage))
{
const int dstChannelIndex = 2;
const int srcChannelIndex = 3;
dest.CopyChannel(dstChannelIndex, source, srcChannelIndex)
.SaveTo(resultPath, ImageFormat.Png)
.ShowFile();
}
Dest | Src |
---|---|
Replace Red with Alpha | Replace Green with Alpha | Replace Blue with Alpha |
---|---|---|