C# Class CSharpImageLibrary.ImageEngineImage

Represents an image. Can use Windows codecs if available.
Inheritance: IDisposable
Mostrar archivo Open project: KFreon/CSharpImageLibrary Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Releases resources used by mipmap MemoryStreams.

GetWPFBitmap ( int maxDimension, bool ShowAlpha = false, int mipIndex ) : System.Windows.Media.Imaging.BitmapSource

Creates a WPF Bitmap from largest mipmap. Does NOT require that image remains alive.

ImageEngineImage ( MemoryStream stream, int maxDimension ) : CSharpImageLibrary.DDS

Creates an image supporting many formats including DDS.

ImageEngineImage ( MipMap mip ) : CSharpImageLibrary.DDS

Creates image from mipmap.

ImageEngineImage ( byte imageData, int maxDimension ) : CSharpImageLibrary.DDS

Creates an image supporting many formats including DDS.

ImageEngineImage ( string path, int maxDimension ) : CSharpImageLibrary.DDS

Creates an image supporting many formats including DDS.

Load ( Stream stream, int maxDimension ) : void
Resize ( double scale ) : void

Scales top mipmap and DESTROYS ALL OTHERS.

Resize ( int DesiredDimension ) : void

Resizes image. If single mip, scales to DesiredDimension. If multiple mips, finds closest mip and scales it (if required). DESTROYS ALL OTHER MIPS.

Save ( string destination, ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : System.Threading.Tasks.Task

Saves image in specified format to file. If file exists, it will be overwritten.

Save ( ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : byte[]

Saves fully formatted image in specified format to byte array.

Save ( Stream destination, ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : void

Saves image in specified format to stream. Stream position not reset before or after.

ToString ( ) : string

Gets string representation of ImageEngineImage.

Private Methods

Method Description
GetWPFBitmap ( MipMap mip, int maxDimension, bool ShowAlpha ) : System.Windows.Media.Imaging.BitmapSource

Method Details

Dispose() public method

Releases resources used by mipmap MemoryStreams.
public Dispose ( ) : void
return void

GetWPFBitmap() public method

Creates a WPF Bitmap from largest mipmap. Does NOT require that image remains alive.
public GetWPFBitmap ( int maxDimension, bool ShowAlpha = false, int mipIndex ) : System.Windows.Media.Imaging.BitmapSource
maxDimension int Resizes image or uses a mipmap if available. Overrides mipIndex if specified.
ShowAlpha bool True = flattens alpha, directly affecting RGB.
mipIndex int Index of mipmap to retrieve. Overridden by maxDimension if it's specified.
return System.Windows.Media.Imaging.BitmapSource

ImageEngineImage() public method

Creates an image supporting many formats including DDS.
public ImageEngineImage ( MemoryStream stream, int maxDimension ) : CSharpImageLibrary.DDS
stream System.IO.MemoryStream Stream containing image.
maxDimension int Max dimension of created image. Useful for mipmapped images, otherwise resized.
return CSharpImageLibrary.DDS

ImageEngineImage() public method

Creates image from mipmap.
public ImageEngineImage ( MipMap mip ) : CSharpImageLibrary.DDS
mip MipMap Mipmap to use as source.
return CSharpImageLibrary.DDS

ImageEngineImage() public method

Creates an image supporting many formats including DDS.
public ImageEngineImage ( byte imageData, int maxDimension ) : CSharpImageLibrary.DDS
imageData byte Fully formatted image data, not just pixels.
maxDimension int Max dimension of created image. Useful for mipmapped images, otherwise resized.
return CSharpImageLibrary.DDS

ImageEngineImage() public method

Creates an image supporting many formats including DDS.
public ImageEngineImage ( string path, int maxDimension ) : CSharpImageLibrary.DDS
path string Path to image.
maxDimension int Max dimension of created image. Useful for mipmapped images, otherwise resized.
return CSharpImageLibrary.DDS

Load() public method

public Load ( Stream stream, int maxDimension ) : void
stream Stream
maxDimension int
return void

Resize() public method

Scales top mipmap and DESTROYS ALL OTHERS.
public Resize ( double scale ) : void
scale double Scaling factor.
return void

Resize() public method

Resizes image. If single mip, scales to DesiredDimension. If multiple mips, finds closest mip and scales it (if required). DESTROYS ALL OTHER MIPS.
public Resize ( int DesiredDimension ) : void
DesiredDimension int Desired size of images largest dimension.
return void

Save() public method

Saves image in specified format to file. If file exists, it will be overwritten.
public Save ( string destination, ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : System.Threading.Tasks.Task
destination string File to save to.
format ImageEngineFormat Desired image format.
GenerateMips MipHandling Determines how mipmaps are handled during saving.
desiredMaxDimension int Maximum size for saved image. Resizes if required, but uses mipmaps if available.
mipToSave int Index of mipmap to save as single image.
removeAlpha bool True = Alpha removed. False = Uses threshold value and alpha values to mask RGB FOR DXT1 ONLY, otherwise removes completely.
customMasks List Custom user defined masks for colours.
return System.Threading.Tasks.Task

Save() public method

Saves fully formatted image in specified format to byte array.
public Save ( ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : byte[]
format ImageEngineFormat Format to save as.
GenerateMips MipHandling Determines how mipmaps are handled during saving.
desiredMaxDimension int Maximum size for saved image. Resizes if required, but uses mipmaps if available.
mipToSave int Index of mipmap to save directly.
removeAlpha bool True = Alpha removed. False = Uses threshold value and alpha values to mask RGB FOR DXT1, otherwise completely removed.
customMasks List Custom user defined masks for colours.
return byte[]

Save() public method

Saves image in specified format to stream. Stream position not reset before or after.
public Save ( Stream destination, ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension, int mipToSave, bool removeAlpha = true, List customMasks = null ) : void
destination Stream Stream to write to at current position.
format ImageEngineFormat Format to save to.
GenerateMips MipHandling Determines how mipmaps are handled during saving.
desiredMaxDimension int Maximum dimension of saved image. Keeps aspect.
mipToSave int Specifies a mipmap to save within the whole.
removeAlpha bool True = removes alpha. False = Uses threshold value and alpha values to mask RGB FOR DXT1 ONLY, otherwise removes completely.
customMasks List Custom user defined masks for DDS colours.
return void

ToString() public method

Gets string representation of ImageEngineImage.
public ToString ( ) : string
return string