Zavolokas.GdiExtensions 1.0.0

GDI+ extension methods.

Install-Package Zavolokas.GdiExtensions -Version 1.0.0
dotnet add package Zavolokas.GdiExtensions --version 1.0.0
<PackageReference Include="Zavolokas.GdiExtensions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zavolokas.GdiExtensions --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

GDI+ Extensions

license

Contains extension methods to deal with Image classes.

Contents

  1. Scaling
  2. Opacity
  3. Channels copy

Scaling

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 |
| ----------- | ------ |
| ![input1] | ![scalingOutput1]|

Opacity

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 |
| ----------- | ------ |
| ![input1] | ![opacityOutput]|

Channels copy

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|
| - |-|
| ![input1] |![input2]|

| Replace Red with Alpha |Replace Green with Alpha | Replace Blue with Alpha |
| - |-| - |
| ![channelsOutputAR] |![channelsOutputAG]| ![channelsOutputAB]|

[input1]: Images/t023.jpg "Input image"
[input2]: Images/m023.png "Input image"
[scalingOutput1]: Images/scaling_out.png "Scaled image"
[opacityOutput]: Images/opacity_out.png "Transparent image"
[channelsOutputAR]: Images/channels_ar_out.png "Mixed channel image"
[channelsOutputAG]: Images/channels_ag_out.png "Mixed channel image"
[channelsOutputAB]: Images/channels_out.png "Mixed channel image"

GDI+ Extensions

license

Contains extension methods to deal with Image classes.

Contents

  1. Scaling
  2. Opacity
  3. Channels copy

Scaling

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 |
| ----------- | ------ |
| ![input1] | ![scalingOutput1]|

Opacity

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 |
| ----------- | ------ |
| ![input1] | ![opacityOutput]|

Channels copy

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|
| - |-|
| ![input1] |![input2]|

| Replace Red with Alpha |Replace Green with Alpha | Replace Blue with Alpha |
| - |-| - |
| ![channelsOutputAR] |![channelsOutputAG]| ![channelsOutputAB]|

[input1]: Images/t023.jpg "Input image"
[input2]: Images/m023.png "Input image"
[scalingOutput1]: Images/scaling_out.png "Scaled image"
[opacityOutput]: Images/opacity_out.png "Transparent image"
[channelsOutputAR]: Images/channels_ar_out.png "Mixed channel image"
[channelsOutputAG]: Images/channels_ag_out.png "Mixed channel image"
[channelsOutputAB]: Images/channels_out.png "Mixed channel image"

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.0.0 647 12/12/2017