Class NetImageUtils
Provides .NET FX specific image processing utils - mostly used for legacy apps
Inheritance
Inherited Members
Namespace: Azos.Platform.Abstraction.NetFramework.Graphics
Assembly: Azos.Platform.NetFramework.dll
Syntax
public static class NetImageUtils
Methods
ExtractMainColors(Bitmap, Int32, Int32, Single)
Extracts three main colors and background color from source image by the following algorithm:
- source image color quality reduced down to 256/
dwnFactor1
color per each of RGB channel (222=8 base colors used as default) - four areas (three main and one background) with the biggest color frequencies are taken
- color frequency analisys is performed in each area which gives area main color
(image color quality reduced down to 256/
dwnFactor2
color per each of RGB channel)
Background area search is limited to [1-interiorPct
, interiorPct
] portion of image interior
Declaration
public static Color[] ExtractMainColors(Bitmap srcBmp, int dwnFactor1 = 128, int dwnFactor2 = 24, float interiorPct = 0.9F)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Bitmap | srcBmp | Source image |
System.Int32 | dwnFactor1 | Main downgrade factor
(source image color quality reduced down to 256/ |
System.Int32 | dwnFactor2 | Secondary downgrade factor for inner-area main color selection |
System.Single | interiorPct | Value within (0,1) range that indicates portion of image interior, i.e. 0.9 means that 10% part of the image will be used for boundary detection |
Returns
Type | Description |
---|---|
System.Drawing.Color[] | Three main colors and background volor |
ExtractMainColors2Iter(Bitmap, Int32, Int32, Single, Single)
Extracts three main colors and background color from source image. Does the same as ExtractMainColors(Bitmap, Int32, Int32, Single) method but performs the second extraction attempt if the first attempt returns almost the same colors
Declaration
public static Color[] ExtractMainColors2Iter(Bitmap srcBmp, int dwnFactor1 = 128, int dwnFactor2 = 24, float interiorPct = 0.9F, float imgDistEps = 0.2F)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Bitmap | srcBmp | Source image |
System.Int32 | dwnFactor1 | Main downgrade factor
(source image color quality reduced down to 256/ |
System.Int32 | dwnFactor2 | Secondary downgrade factor for inner-area main color selection |
System.Single | interiorPct | Value within (0,1) range that indicates portion of image interior, i.e. 0.9 means that 10% part of the image will be used for boundary detection |
System.Single | imgDistEps | Color similarity factor. If less that specified value, then the second extraction attempt will be performed |
Returns
Type | Description |
---|---|
System.Drawing.Color[] | Three main colors and background color |
FitCenteredImage(Image, Int32, Int32, Int32, Int32, Nullable<Color>)
Scales source image so it uniformly (without cropping) fits in the desired image size preserving aspect ratio. This function is usable for profile picture size/aspect normalization
Declaration
public static Image FitCenteredImage(this Image srcImage, int targetWidth = 128, int targetHeight = 128, int xDpi = 96, int yDpi = 96, Color? bColor = default(Color? ))
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | srcImage | |
System.Int32 | targetWidth | |
System.Int32 | targetHeight | |
System.Int32 | xDpi | |
System.Int32 | yDpi | |
System.Nullable<System.Drawing.Color> | bColor |
Returns
Type | Description |
---|---|
System.Drawing.Image |
ModifyBitsPerBixel(Image, PixelFormat)
Declaration
public static Bitmap ModifyBitsPerBixel(Image img, PixelFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | img | |
System.Drawing.Imaging.PixelFormat | format |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap |
NormalizeCenteredImage(Image, Int32, Int32, Int32, Int32)
Scales source image so it fits in the desired image size preserving aspect ratio. This function is usable for profile picture size/aspect normalization
Declaration
public static Image NormalizeCenteredImage(this Image srcImage, int targetWidth = 128, int targetHeight = 128, int xDpi = 96, int yDpi = 96)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | srcImage | |
System.Int32 | targetWidth | |
System.Int32 | targetHeight | |
System.Int32 | xDpi | |
System.Int32 | yDpi |
Returns
Type | Description |
---|---|
System.Drawing.Image |