C# Class Axiom.Media.Image

Class representing an image file.
The Image class usually holds uncompressed image data and is the only object that can be loaded in a texture. Image objects handle image data decoding themselves by the means of locating the correct ICodec implementation for each data type.
Inheritance: DisposableObject
Datei anzeigen Open project: mono-soc-2011/axiom Class Usage Examples

Protected Properties

Property Type Description
bufPtr System.IntPtr
buffer byte[]
bufferPinnedHandle System.Runtime.InteropServices.GCHandle
depth int
flags ImageFlags
format PixelFormat
height int
numMipMaps int
size int
width int

Public Methods

Method Description
ApplyGamma ( IntPtr bufPtr, float gamma, int size, int bpp ) : void

Variant of ApplyGamma that operates on an unmanaged chunk of memory

ApplyGamma ( byte buffer, float gamma, int size, int bpp ) : void

Performs gamma adjustment on this image.

Basic algo taken from Titan Engine, copyright (c) 2000 Ignacio Castano Iguado.

CalculateSize ( int mipmaps, int faces, int width, int height, int depth, PixelFormat format ) : int
CropImage ( Image source, uint offsetX, uint offsetY, int width, int height ) : Image

Little utility function that crops an image (Doesn't alter the source image, returns a cropped representation)

FlipAroundX ( ) : void

Flips this image around the X axis. This will invalidate any

FromDynamicImage ( byte buffer, int width, int height, PixelFormat format ) : Image

Loads raw image data from a byte array.

FromDynamicImage ( byte buffer, int width, int height, int depth, PixelFormat format ) : Image

Loads raw image data from a byte array.

FromDynamicImage ( byte buffer, int width, int height, int depth, PixelFormat format, bool autoDelete, int numFaces, int numMipMaps ) : Image
FromFile ( string fileName ) : Image

Loads an image file from the file system.

FromRawStream ( Stream stream, int width, int height, PixelFormat format ) : Image

Loads raw image data from memory.

FromRawStream ( Stream stream, int width, int height, int depth, PixelFormat format ) : Image

Loads raw image data from memory.

FromStream ( Stream stream, string type ) : Image

Loads an image from a stream.

This method allows loading an image from a stream, which is helpful for when images are being decompressed from an archive into a stream, which needs to be loaded as is.

GetColorAt ( int x, int y, int z ) : ColorEx
GetPixelBox ( int face, int mipmap ) : PixelBox

Get a PixelBox encapsulating the image data of a mipmap

HasFlag ( ImageFlags flag ) : bool

Checks if the specified flag is set on this image.

Image ( ) : System
Resize ( int width, int height ) : void

Resize a 2D image, applying the appropriate filter.

Resize ( int width, int height, ImageFilter filter ) : void

Resize a 2D image, applying the appropriate filter.

Save ( String filename ) : void

Saves the Image as a file

The codec used to save the file is determined by the extension of the filename passed in Invalid or unrecognized extensions will throw an exception.

Scale ( PixelBox src, PixelBox dst ) : void

Scale a 1D, 2D or 3D image volume.

This function can do pixel format conversion in the process. dst and src can point to the same PixelBox object without any problem

Scale ( PixelBox src, PixelBox scaled, ImageFilter filter ) : void

Scale a 1D, 2D or 3D image volume.

This function can do pixel format conversion in the process. dst and src can point to the same PixelBox object without any problem

Protected Methods

Method Description
SetBuffer ( byte newBuffer ) : void
dispose ( bool disposeManagedResources ) : void

Class level dispose method

When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } isDisposed = true; // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }

Method Details

ApplyGamma() public static method

Variant of ApplyGamma that operates on an unmanaged chunk of memory
public static ApplyGamma ( IntPtr bufPtr, float gamma, int size, int bpp ) : void
bufPtr System.IntPtr
gamma float
size int
bpp int
return void

ApplyGamma() public static method

Performs gamma adjustment on this image.
Basic algo taken from Titan Engine, copyright (c) 2000 Ignacio Castano Iguado.
public static ApplyGamma ( byte buffer, float gamma, int size, int bpp ) : void
buffer byte
gamma float
size int
bpp int
return void

CalculateSize() public static method

public static CalculateSize ( int mipmaps, int faces, int width, int height, int depth, PixelFormat format ) : int
mipmaps int
faces int
width int
height int
depth int
format PixelFormat
return int

CropImage() public method

Little utility function that crops an image (Doesn't alter the source image, returns a cropped representation)
public CropImage ( Image source, uint offsetX, uint offsetY, int width, int height ) : Image
source Image The source image
offsetX uint The X offset from the origin
offsetY uint The Y offset from the origin
width int The width to crop to
height int The height to crop to
return Image

FlipAroundX() public method

Flips this image around the X axis. This will invalidate any
public FlipAroundX ( ) : void
return void

FromDynamicImage() public method

Loads raw image data from a byte array.
public FromDynamicImage ( byte buffer, int width, int height, PixelFormat format ) : Image
buffer byte Raw image buffer.
width int Width of this image data (in pixels).
height int Height of this image data (in pixels).
format PixelFormat Pixel format used in this texture.
return Image

FromDynamicImage() public method

Loads raw image data from a byte array.
public FromDynamicImage ( byte buffer, int width, int height, int depth, PixelFormat format ) : Image
buffer byte Raw image buffer.
width int Width of this image data (in pixels).
height int Height of this image data (in pixels).
depth int
format PixelFormat Pixel format used in this texture.
return Image

FromDynamicImage() public method

public FromDynamicImage ( byte buffer, int width, int height, int depth, PixelFormat format, bool autoDelete, int numFaces, int numMipMaps ) : Image
buffer byte
width int
height int
depth int
format PixelFormat
autoDelete bool
numFaces int
numMipMaps int
return Image

FromFile() public static method

Loads an image file from the file system.
public static FromFile ( string fileName ) : Image
fileName string Full path to the image file on disk.
return Image

FromRawStream() public static method

Loads raw image data from memory.
public static FromRawStream ( Stream stream, int width, int height, PixelFormat format ) : Image
stream Stream Stream containing the raw image data.
width int Width of this image data (in pixels).
height int Height of this image data (in pixels).
format PixelFormat Pixel format used in this texture.
return Image

FromRawStream() public static method

Loads raw image data from memory.
public static FromRawStream ( Stream stream, int width, int height, int depth, PixelFormat format ) : Image
stream Stream Stream containing the raw image data.
width int Width of this image data (in pixels).
height int Height of this image data (in pixels).
depth int
format PixelFormat Pixel format used in this texture.
return Image

FromStream() public static method

Loads an image from a stream.
This method allows loading an image from a stream, which is helpful for when images are being decompressed from an archive into a stream, which needs to be loaded as is.
public static FromStream ( Stream stream, string type ) : Image
stream Stream Stream serving as the data source.
type string /// Type (i.e. file format) of image. Used to decide which image decompression codec to use. ///
return Image

GetColorAt() public method

public GetColorAt ( int x, int y, int z ) : ColorEx
x int
y int
z int
return Axiom.Core.ColorEx

GetPixelBox() public method

Get a PixelBox encapsulating the image data of a mipmap
public GetPixelBox ( int face, int mipmap ) : PixelBox
face int
mipmap int
return PixelBox

HasFlag() public method

Checks if the specified flag is set on this image.
public HasFlag ( ImageFlags flag ) : bool
flag ImageFlags The flag to check for.
return bool

Image() public method

public Image ( ) : System
return System

Resize() public method

Resize a 2D image, applying the appropriate filter.
public Resize ( int width, int height ) : void
width int
height int
return void

Resize() public method

Resize a 2D image, applying the appropriate filter.
public Resize ( int width, int height, ImageFilter filter ) : void
width int
height int
filter ImageFilter
return void

Save() public method

Saves the Image as a file
The codec used to save the file is determined by the extension of the filename passed in Invalid or unrecognized extensions will throw an exception.
public Save ( String filename ) : void
filename String Filename to save as
return void

Scale() public static method

Scale a 1D, 2D or 3D image volume.
This function can do pixel format conversion in the process. dst and src can point to the same PixelBox object without any problem
public static Scale ( PixelBox src, PixelBox dst ) : void
src PixelBox PixelBox containing the source pointer, dimensions and format
dst PixelBox PixelBox containing the destination pointer, dimensions and format
return void

Scale() public static method

Scale a 1D, 2D or 3D image volume.
This function can do pixel format conversion in the process. dst and src can point to the same PixelBox object without any problem
public static Scale ( PixelBox src, PixelBox scaled, ImageFilter filter ) : void
src PixelBox PixelBox containing the source pointer, dimensions and format
scaled PixelBox PixelBox containing the destination pointer, dimensions and format
filter ImageFilter Which filter to use
return void

SetBuffer() protected method

protected SetBuffer ( byte newBuffer ) : void
newBuffer byte
return void

dispose() protected method

Class level dispose method
When implementing this method in an inherited class the following template should be used; protected override void dispose( bool disposeManagedResources ) { if ( !isDisposed ) { if ( disposeManagedResources ) { // Dispose managed resources. } // There are no unmanaged resources to release, but // if we add them, they need to be released here. } isDisposed = true; // If it is available, make the call to the // base class's Dispose(Boolean) method base.dispose( disposeManagedResources ); }
protected dispose ( bool disposeManagedResources ) : void
disposeManagedResources bool True if Unmanaged resources should be released.
return void

Property Details

bufPtr protected_oe property

This is the pointer to the contents of buffer.
protected IntPtr,System bufPtr
return System.IntPtr

buffer protected_oe property

Byte array containing the image data.
protected byte[] buffer
return byte[]

bufferPinnedHandle protected_oe property

This allows me to pin the buffer, so that I can return PixelBox objects representing subsets of this image. Since the PixelBox does not own the data, and has an IntPtr, I need to pin the internal buffer here.
protected GCHandle,System.Runtime.InteropServices bufferPinnedHandle
return System.Runtime.InteropServices.GCHandle

depth protected_oe property

Depth of the image
protected int depth
return int

flags protected_oe property

Additional features on this image.
protected ImageFlags flags
return ImageFlags

format protected_oe property

Image format.
protected PixelFormat format
return PixelFormat

height protected_oe property

Width of the image (in pixels).
protected int height
return int

numMipMaps protected_oe property

Number of mip maps in this image.
protected int numMipMaps
return int

size protected_oe property

Size of the image buffer.
protected int size
return int

width protected_oe property

Width of the image (in pixels).
protected int width
return int