C# Class CSharpImageLibrary.ImageFormats

Provides format functionality
Datei anzeigen Open project: KFreon/CSharpImageLibrary Class Usage Examples

Public Properties

Property Type Description
SaveUnsupported List

Public Methods

Method Description
DetermineImageType ( Stream imgData ) : SupportedExtensions

Determines image type via headers. Keeps stream position.

FindFormatInString ( string stringWithFormatInIt ) : ImageEngineFormat

Searches for a format within a string. Good for automatic file naming.

GetBlockSize ( ImageEngineFormat format ) : int

Gets block size of DDS format. Number of channels if not compressed. 1 if not a DDS format.

GetCompressedSize ( int numMipmaps, ImageEngineFormat format, int width, int height ) : int

Calculates the compressed size of an image with given parameters.

GetExtensionOfFormat ( ImageEngineFormat format ) : string

Gets file extension of supported surface formats. Doesn't include preceding dot.

GetSupportedExtensions ( bool addDot = false ) : List

Get list of supported extensions in lower case.

GetSupportedExtensionsDescriptions ( ) : List

Get descriptions of supported images. Generally the description as would be seen in a SaveFileDialog.

GetSupportedExtensionsForDialogBox ( ) : List

Get list of filter strings for dialog boxes of the Supported Images.

GetSupportedExtensionsForDialogBoxAsString ( ) : string

Gets list of filter strings for dialog boxes already formatted as string.

GetUncompressedSize ( int topWidth, int topHeight, int numChannels, bool inclMips ) : int

Gets uncompressed size of image with mipmaps given dimensions and number of channels. Assume 8 bits per channel.

IsAlphaPresent ( System.Windows.Media.PixelFormat format ) : bool

Determines if alpha channel COULD be present in given format.

IsBlockCompressed ( ImageEngineFormat format ) : bool

Determines if format is a block compressed format.

IsExtensionSupported ( string filePath, List supported = null ) : bool

Determines if file has a supported extension.

IsFormatMippable ( ImageEngineFormat format ) : bool

Determines if given format supports mipmapping.

MaxNumberOfChannels ( ImageEngineFormat format ) : int

Gets maximum number of channels a format can contain. NOTE: This likely isn't actually the max number. i.e. None exceed four, but some are only one or two channels.

ParseExtension ( string extension ) : SupportedExtensions

Gets file extension from string of extension.

Method Details

DetermineImageType() public static method

Determines image type via headers. Keeps stream position.
public static DetermineImageType ( Stream imgData ) : SupportedExtensions
imgData Stream Image data, incl header.
return SupportedExtensions

FindFormatInString() public static method

Searches for a format within a string. Good for automatic file naming.
public static FindFormatInString ( string stringWithFormatInIt ) : ImageEngineFormat
stringWithFormatInIt string String containing format somewhere in it.
return ImageEngineFormat

GetBlockSize() public static method

Gets block size of DDS format. Number of channels if not compressed. 1 if not a DDS format.
public static GetBlockSize ( ImageEngineFormat format ) : int
format ImageEngineFormat DDS format to test.
return int

GetCompressedSize() public static method

Calculates the compressed size of an image with given parameters.
public static GetCompressedSize ( int numMipmaps, ImageEngineFormat format, int width, int height ) : int
numMipmaps int Number of mipmaps in image. JPG etc only have 1.
format ImageEngineFormat Format of image.
width int Width of image (top mip if mip-able)
height int Height of image (top mip if mip-able)
return int

GetExtensionOfFormat() public static method

Gets file extension of supported surface formats. Doesn't include preceding dot.
public static GetExtensionOfFormat ( ImageEngineFormat format ) : string
format ImageEngineFormat Format to get file extension for.
return string

GetSupportedExtensions() public static method

Get list of supported extensions in lower case.
public static GetSupportedExtensions ( bool addDot = false ) : List
addDot bool Adds preceeding dot to be same as Path.GetExtension.
return List

GetSupportedExtensionsDescriptions() public static method

Get descriptions of supported images. Generally the description as would be seen in a SaveFileDialog.
public static GetSupportedExtensionsDescriptions ( ) : List
return List

GetSupportedExtensionsForDialogBox() public static method

Get list of filter strings for dialog boxes of the Supported Images.
public static GetSupportedExtensionsForDialogBox ( ) : List
return List

GetSupportedExtensionsForDialogBoxAsString() public static method

Gets list of filter strings for dialog boxes already formatted as string.
public static GetSupportedExtensionsForDialogBoxAsString ( ) : string
return string

GetUncompressedSize() public static method

Gets uncompressed size of image with mipmaps given dimensions and number of channels. Assume 8 bits per channel.
public static GetUncompressedSize ( int topWidth, int topHeight, int numChannels, bool inclMips ) : int
topWidth int Width of top mipmap.
topHeight int Height of top mipmap.
numChannels int Number of channels in image.
inclMips bool Include size of mipmaps.
return int

IsAlphaPresent() public static method

Determines if alpha channel COULD be present in given format.
public static IsAlphaPresent ( System.Windows.Media.PixelFormat format ) : bool
format System.Windows.Media.PixelFormat Format to check alpha in.
return bool

IsBlockCompressed() public static method

Determines if format is a block compressed format.
public static IsBlockCompressed ( ImageEngineFormat format ) : bool
format ImageEngineFormat DDS Surface Format.
return bool

IsExtensionSupported() public static method

Determines if file has a supported extension.
public static IsExtensionSupported ( string filePath, List supported = null ) : bool
filePath string Path of file to to check.
supported List Optionally list of supported extensions. Good if looping and can initialise supported and pass into this every loop.
return bool

IsFormatMippable() public static method

Determines if given format supports mipmapping.
public static IsFormatMippable ( ImageEngineFormat format ) : bool
format ImageEngineFormat Image format to check.
return bool

MaxNumberOfChannels() public static method

Gets maximum number of channels a format can contain. NOTE: This likely isn't actually the max number. i.e. None exceed four, but some are only one or two channels.
public static MaxNumberOfChannels ( ImageEngineFormat format ) : int
format ImageEngineFormat Format to channel count.
return int

ParseExtension() public static method

Gets file extension from string of extension.
public static ParseExtension ( string extension ) : SupportedExtensions
extension string String containing file extension.
return SupportedExtensions

Property Details

SaveUnsupported public_oe static_oe property

Contains formats not yet capable of saving.
public static List SaveUnsupported
return List