Class ImageExtensions
- Namespace
- AetherUtils.Core.Extensions
- Assembly
- AetherUtils.Core.dll
Provides extension methods for manipulating Image objects.
[UsedImplicitly]
public static class ImageExtensions
- Inheritance
-
ImageExtensions
- Inherited Members
Methods
IsValidImage(string)
Get a value indicating if the image specified by the
filePath is a valid image file.[UsedImplicitly]
public static bool IsValidImage(this string filePath)
Parameters
filePathstring- The file path to an image file.
Returns
- bool
trueif the image was valid;falseotherwise.
Exceptions
- FormatException
- If the image specified by
filePathwas not in the correct format. - FileNotFoundException
- If the file specified by
filePathwas not found.
ResizeImage(Image, int, int)
Resize the Image to the specified width and height.
[UsedImplicitly]
public static Image ResizeImage(this Image image, int newWidth, int newHeight)
Parameters
imageImage- The Image to resize.
newWidthint- The width to resize to.
newHeightint- The height to resize to.
Returns
Exceptions
- ArgumentNullException
- If
imagewasnull. - InvalidOperationException
- If the
newWidthornewHeightwas less than 0.
ResizeImageScaled(Image, float, float)
Resize the image to be the desired width and height while attempting to maintain the aspect ratio.
[UsedImplicitly]
public static Image ResizeImageScaled(this Image image, float desiredWidth, float desiredHeight)
Parameters
imageImage- The Image to resize.
desiredWidthfloat- The desired width of the new image.
desiredHeightfloat- The desired height of the new image.
Returns
Exceptions
- ArgumentNullException
- If
imagewasnull. - InvalidOperationException
- If the
desiredWidthordesiredHeightwas less than 0.
ToByteArray(Image)
[UsedImplicitly]
public static byte[] ToByteArray(this Image image)
Parameters
imageImage- The image to convert.
Returns
Exceptions
- ArgumentNullException
- If the
imagewasnull.