Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SiliconStudio.Paradox.Graphics.Image Class Reference

Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to load/save an image from the disk. More...

Inheritance diagram for SiliconStudio.Paradox.Graphics.Image:

Public Member Functions

delegate Image ImageLoadDelegate (IntPtr dataPointer, int dataSize, bool makeACopy, GCHandle?handle)
 
delegate void ImageSaveDelegate (PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
 
void Dispose ()
 
MipMapDescription GetMipMapDescription (int mipmap)
 Gets the mipmap description of this instance for the specified mipmap level. More...
 
PixelBuffer GetPixelBuffer (int arrayOrZSliceIndex, int mipmap)
 Gets the pixel buffer for the specified array/z slice and mipmap level. More...
 
PixelBuffer GetPixelBuffer (int arrayIndex, int zIndex, int mipmap)
 Gets the pixel buffer for the specified array/z slice and mipmap level. More...
 
DataBox[] ToDataBox ()
 Gets the databox from this image. More...
 
void Save (Stream imageStream, ImageFileType fileType)
 Saves this instance to a stream. More...
 

Static Public Member Functions

static void Register (ImageFileType type, ImageLoadDelegate loader, ImageSaveDelegate saver)
 Registers a loader/saver for a specified image file type. More...
 
static Image New (ImageDescription description)
 Creates a new instance of Image from an image description. More...
 
static Image New1D (int width, MipMapCount mipMapCount, PixelFormat format, int arraySize=1)
 Creates a new instance of a 1D Image. More...
 
static Image New2D (int width, int height, MipMapCount mipMapCount, PixelFormat format, int arraySize=1, int rowStride=0)
 Creates a new instance of a 2D Image. More...
 
static Image NewCube (int width, MipMapCount mipMapCount, PixelFormat format)
 Creates a new instance of a Cube Image. More...
 
static Image New3D (int width, int height, int depth, MipMapCount mipMapCount, PixelFormat format)
 Creates a new instance of a 3D Image. More...
 
static Image New (ImageDescription description, IntPtr dataPointer)
 Creates a new instance of Image from an image description. More...
 
static Image New (ImageDescription description, IntPtr dataPointer, int offset, GCHandle?handle, bool bufferIsDisposable)
 Initializes a new instance of the Image class. More...
 
static Image New1D (int width, MipMapCount mipMapCount, PixelFormat format, int arraySize, IntPtr dataPointer)
 Creates a new instance of a 1D Image. More...
 
static Image New2D (int width, int height, MipMapCount mipMapCount, PixelFormat format, int arraySize, IntPtr dataPointer, int rowStride=0)
 Creates a new instance of a 2D Image. More...
 
static Image NewCube (int width, MipMapCount mipMapCount, PixelFormat format, IntPtr dataPointer)
 Creates a new instance of a Cube Image. More...
 
static Image New3D (int width, int height, int depth, MipMapCount mipMapCount, PixelFormat format, IntPtr dataPointer)
 Creates a new instance of a 3D Image. More...
 
static Image Load (DataPointer dataBuffer, bool makeACopy=false)
 Loads an image from an unmanaged memory pointer. More...
 
static Image Load (IntPtr dataPointer, int dataSize, bool makeACopy=false)
 Loads an image from an unmanaged memory pointer. More...
 
static unsafe Image Load (byte[] buffer)
 Loads an image from a managed buffer. More...
 
static Image Load (Stream imageStream)
 Loads the specified image from a stream. More...
 
static int CalculateMipLevels (int width, MipMapCount mipLevels)
 Calculates the number of miplevels for a Texture 1D. More...
 
static int CalculateMipLevels (int width, int height, MipMapCount mipLevels)
 Calculates the number of miplevels for a Texture 2D. More...
 
static int CalculateMipLevels (int width, int height, int depth, MipMapCount mipLevels)
 Calculates the number of miplevels for a Texture 2D. More...
 
static int CalculateMipSize (int width, int mipLevel)
 
static int CountMips (int width)
 
static int CountMips (int width, int height)
 
static int CountMips (int width, int height, int depth)
 

Public Attributes

ImageDescription Description
 Description of this image. More...
 

Properties

IntPtr DataPointer [get]
 Gets a pointer to the image buffer in memory. More...
 
PixelBufferArray PixelBuffer [get]
 Provides access to all pixel buffers. More...
 
int TotalSizeInBytes [get]
 Gets the total number of bytes occupied by this image in memory. More...
 

Detailed Description

Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to load/save an image from the disk.

Definition at line 88 of file Image.cs.

Member Function Documentation

static int SiliconStudio.Paradox.Graphics.Image.CalculateMipLevels ( int  width,
MipMapCount  mipLevels 
)
static

Calculates the number of miplevels for a Texture 1D.

Parameters
widthThe width of the texture.
mipLevelsA MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.
Returns
The number of miplevels.

Definition at line 552 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CalculateMipLevels ( int  width,
int  height,
MipMapCount  mipLevels 
)
static

Calculates the number of miplevels for a Texture 2D.

Parameters
widthThe width of the texture.
heightThe height of the texture.
mipLevelsA MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.
Returns
The number of miplevels.

Definition at line 578 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CalculateMipLevels ( int  width,
int  height,
int  depth,
MipMapCount  mipLevels 
)
static

Calculates the number of miplevels for a Texture 2D.

Parameters
widthThe width of the texture.
heightThe height of the texture.
depthThe depth of the texture.
mipLevelsA MipMapCount, set to true to calculates all mipmaps, to false to calculate only 1 miplevel, or > 1 to calculate a specific amount of levels.
Returns
The number of miplevels.

Definition at line 605 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CalculateMipSize ( int  width,
int  mipLevel 
)
static

Definition at line 630 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CountMips ( int  width)
static

Definition at line 1069 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CountMips ( int  width,
int  height 
)
static

Definition at line 1084 of file Image.cs.

static int SiliconStudio.Paradox.Graphics.Image.CountMips ( int  width,
int  height,
int  depth 
)
static

Definition at line 1102 of file Image.cs.

void SiliconStudio.Paradox.Graphics.Image.Dispose ( )

Definition at line 157 of file Image.cs.

MipMapDescription SiliconStudio.Paradox.Graphics.Image.GetMipMapDescription ( int  mipmap)

Gets the mipmap description of this instance for the specified mipmap level.

Parameters
mipmapThe mipmap.
Returns
A description of a particular mipmap for this texture.

Definition at line 175 of file Image.cs.

PixelBuffer SiliconStudio.Paradox.Graphics.Image.GetPixelBuffer ( int  arrayOrZSliceIndex,
int  mipmap 
)

Gets the pixel buffer for the specified array/z slice and mipmap level.

Parameters
arrayOrZSliceIndexFor 3D image, the parameter is the Z slice, otherwise it is an index into the texture array.
mipmapThe mipmap.
Returns
A pixelBufferArray.
Exceptions
System.ArgumentExceptionIf arrayOrZSliceIndex or mipmap are out of range.

Definition at line 187 of file Image.cs.

PixelBuffer SiliconStudio.Paradox.Graphics.Image.GetPixelBuffer ( int  arrayIndex,
int  zIndex,
int  mipmap 
)

Gets the pixel buffer for the specified array/z slice and mipmap level.

Parameters
arrayIndexIndex into the texture array. Must be set to 0 for 3D images.
zIndexZ index for 3D image. Must be set to 0 for all 1D/2D images.
mipmapThe mipmap.
Returns
A pixelBufferArray.
Exceptions
System.ArgumentExceptionIf arrayIndex, zIndex or mipmap are out of range.

Definition at line 219 of file Image.cs.

delegate Image SiliconStudio.Paradox.Graphics.Image.ImageLoadDelegate ( IntPtr  dataPointer,
int  dataSize,
bool  makeACopy,
GCHandle?  handle 
)
delegate void SiliconStudio.Paradox.Graphics.Image.ImageSaveDelegate ( PixelBuffer[]  pixelBuffers,
int  count,
ImageDescription  description,
Stream  imageStream 
)
static Image SiliconStudio.Paradox.Graphics.Image.Load ( DataPointer  dataBuffer,
bool  makeACopy = false 
)
static

Loads an image from an unmanaged memory pointer.

Parameters
dataBufferPointer to an unmanaged memory. If makeACopy is false, this buffer must be allocated with Utilities.AllocateMemory.
makeACopyTrue to copy the content of the buffer to a new allocated buffer, false otherwhise.
Returns
An new image.

If makeACopy is set to false, the returned image is now the holder of the unmanaged pointer and will release it on Dispose.

Definition at line 477 of file Image.cs.

References SiliconStudio.Paradox.Graphics.DataPointer.Pointer, and SiliconStudio.Paradox.Graphics.DataPointer.Size.

static Image SiliconStudio.Paradox.Graphics.Image.Load ( IntPtr  dataPointer,
int  dataSize,
bool  makeACopy = false 
)
static

Loads an image from an unmanaged memory pointer.

Parameters
dataPointerPointer to an unmanaged memory. If makeACopy is false, this buffer must be allocated with Utilities.AllocateMemory.
dataSizeSize of the unmanaged buffer.
makeACopyTrue to copy the content of the buffer to a new allocated buffer, false otherwise.
Returns
An new image.

If makeACopy is set to false, the returned image is now the holder of the unmanaged pointer and will release it on Dispose.

Definition at line 490 of file Image.cs.

static unsafe Image SiliconStudio.Paradox.Graphics.Image.Load ( byte[]  buffer)
static

Loads an image from a managed buffer.

Parameters
bufferReference to a managed buffer.
Returns
An new image.

This method support the following format: dds, bmp, jpg, png, gif, tiff, wmp, tga.

Definition at line 501 of file Image.cs.

References DirectX.size.

static Image SiliconStudio.Paradox.Graphics.Image.Load ( Stream  imageStream)
static

Loads the specified image from a stream.

Parameters
imageStreamThe image stream.
Returns
An new image.

This method support the following format: dds, bmp, jpg, png, gif, tiff, wmp, tga.

Definition at line 527 of file Image.cs.

References SiliconStudio.Core.Utilities.ReadStream().

static Image SiliconStudio.Paradox.Graphics.Image.New ( ImageDescription  description)
static

Creates a new instance of Image from an image description.

Parameters
descriptionThe image description.
Returns
A new image.

Definition at line 329 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New ( ImageDescription  description,
IntPtr  dataPointer 
)
static

Creates a new instance of Image from an image description.

Parameters
descriptionThe image description.
dataPointerPointer to an existing buffer.
Returns
A new image.

Definition at line 393 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New ( ImageDescription  description,
IntPtr  dataPointer,
int  offset,
GCHandle?  handle,
bool  bufferIsDisposable 
)
static

Initializes a new instance of the Image class.

Parameters
descriptionThe image description.
dataPointerThe pointer to the data buffer.
offsetThe offset from the beginning of the data buffer.
handleThe handle (optionnal).
bufferIsDisposableif set to true [buffer is disposable].
Exceptions
System.InvalidOperationExceptionIf the format is invalid, or width/height/depth/arraysize is invalid with respect to the dimension.

Definition at line 407 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New1D ( int  width,
MipMapCount  mipMapCount,
PixelFormat  format,
int  arraySize = 1 
)
static

Creates a new instance of a 1D Image.

Parameters
widthThe width.
mipMapCountThe mip map count.
formatThe format.
arraySizeSize of the array.
Returns
A new image.

Definition at line 342 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New1D ( int  width,
MipMapCount  mipMapCount,
PixelFormat  format,
int  arraySize,
IntPtr  dataPointer 
)
static

Creates a new instance of a 1D Image.

Parameters
widthThe width.
mipMapCountThe mip map count.
formatThe format.
arraySizeSize of the array.
dataPointerPointer to an existing buffer.
Returns
A new image.

Definition at line 421 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New2D ( int  width,
int  height,
MipMapCount  mipMapCount,
PixelFormat  format,
int  arraySize = 1,
int  rowStride = 0 
)
static

Creates a new instance of a 2D Image.

Parameters
widthThe width.
heightThe height.
mipMapCountThe mip map count.
formatThe format.
arraySizeSize of the array.
Returns
A new image.

Definition at line 356 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New2D ( int  width,
int  height,
MipMapCount  mipMapCount,
PixelFormat  format,
int  arraySize,
IntPtr  dataPointer,
int  rowStride = 0 
)
static

Creates a new instance of a 2D Image.

Parameters
widthThe width.
heightThe height.
mipMapCountThe mip map count.
formatThe format.
arraySizeSize of the array.
dataPointerPointer to an existing buffer.
rowStrideSpecify a specific rowStride, only valid when mipMapCount == 1 and pixel format is not compressed.
Returns
A new image.

Definition at line 437 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New3D ( int  width,
int  height,
int  depth,
MipMapCount  mipMapCount,
PixelFormat  format 
)
static

Creates a new instance of a 3D Image.

Parameters
widthThe width.
heightThe height.
depthThe depth.
mipMapCountThe mip map count.
formatThe format.
Returns
A new image.

Definition at line 382 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.New3D ( int  width,
int  height,
int  depth,
MipMapCount  mipMapCount,
PixelFormat  format,
IntPtr  dataPointer 
)
static

Creates a new instance of a 3D Image.

Parameters
widthThe width.
heightThe height.
depthThe depth.
mipMapCountThe mip map count.
formatThe format.
dataPointerPointer to an existing buffer.
Returns
A new image.

Definition at line 465 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.NewCube ( int  width,
MipMapCount  mipMapCount,
PixelFormat  format 
)
static

Creates a new instance of a Cube Image.

Parameters
widthThe width.
mipMapCountThe mip map count.
formatThe format.
Returns
A new image.

Definition at line 368 of file Image.cs.

static Image SiliconStudio.Paradox.Graphics.Image.NewCube ( int  width,
MipMapCount  mipMapCount,
PixelFormat  format,
IntPtr  dataPointer 
)
static

Creates a new instance of a Cube Image.

Parameters
widthThe width.
mipMapCountThe mip map count.
formatThe format.
dataPointerPointer to an existing buffer.
Returns
A new image.

Definition at line 450 of file Image.cs.

static void SiliconStudio.Paradox.Graphics.Image.Register ( ImageFileType  type,
ImageLoadDelegate  loader,
ImageSaveDelegate  saver 
)
static

Registers a loader/saver for a specified image file type.

Parameters
typeThe file type (use integer and explicit casting to ImageFileType to register other fileformat.
loaderThe loader delegate (can be null).
saverThe saver delegate (can be null).
Exceptions
System.ArgumentException

Definition at line 242 of file Image.cs.

void SiliconStudio.Paradox.Graphics.Image.Save ( Stream  imageStream,
ImageFileType  fileType 
)

Saves this instance to a stream.

Parameters
imageStreamThe destination stream.
fileTypeSpecify the output format.

This method support the following format: dds, bmp, jpg, png, gif, tiff, wmp, tga.

Definition at line 540 of file Image.cs.

DataBox [] SiliconStudio.Paradox.Graphics.Image.ToDataBox ( )

Member Data Documentation

Property Documentation

IntPtr SiliconStudio.Paradox.Graphics.Image.DataPointer
get

Gets a pointer to the image buffer in memory.

A pointer to the image buffer in memory.

Definition at line 267 of file Image.cs.

PixelBufferArray SiliconStudio.Paradox.Graphics.Image.PixelBuffer
get

Provides access to all pixel buffers.

For Texture3D, each z slice of the Texture3D has a pixelBufferArray * by the number of mipmaps. For other textures, there is Description.MipLevels * Description.ArraySize pixel buffers.

Definition at line 279 of file Image.cs.

Referenced by SiliconStudio.Paradox.Graphics.Regression.TestResultImage.Write().

int SiliconStudio.Paradox.Graphics.Image.TotalSizeInBytes
get

Gets the total number of bytes occupied by this image in memory.

Definition at line 287 of file Image.cs.


The documentation for this class was generated from the following file: