StbImageResizeSharp is C# port of the stb_image_resize.h, which is C library to resize images.
There are two ways of referencing StbImageResizeSharp in the project:
Through nuget: https://www.nuget.org/packages/StbImageResizeSharp/
As submodule:
a.
git submodule add https://github.com/rds1983/StbImageResizeSharp.gitb. Now there are two options:
Add src/StbImageResizeSharp.csproj to the solution
Include *.cs from folder "src" directly in the project. In this case, it might make sense to add STBSHARP_INTERNAL build compilation symbol to the project, so StbImageResizeSharp classes would become internal.
StbImageResizeSharp exposes API similar to stb_image_resize.h. Also it adds some wrapper methods.
Sample code to load and resize an image
// Load an image using StbImageSharp(https://github.com/StbSharp/StbImageSharp)ImageResultimage;using(varstream=File.OpenRead("image.png")){image=ImageResult.FromStream(stream);}// Retrieve amount of channels in the image(from 1 to 4)intchannels=(int)image.Comp;// Resize to 400x400intnewWidth=400;intnewHeight=400;byte[]newImageData=newbyte[newWidth*newHeight*channels];StbImageResize.stbir_resize_uint8(imageData,width,height,image.Width*channels,newImageData,newWidth,newHeight,newWidth*channels,channels);Public Domain