本文整理汇总了C#中Axiom.Media.PixelBox类的典型用法代码示例。如果您正苦于以下问题:C# PixelBox类的具体用法?C# PixelBox怎么用?C# PixelBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PixelBox类属于Axiom.Media命名空间,在下文中一共展示了PixelBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyContentsToMemory
public override void CopyContentsToMemory( PixelBox dst, RenderTarget.FrameBuffer buffer )
{
if ( buffer == FrameBuffer.Auto )
buffer = FrameBuffer.Front;
if ( buffer != FrameBuffer.Front )
{
throw new Exception( "Invalid buffer." );
}
pixelBuffer.BlitToMemory( dst );
}
示例2: Scale
/// <summary>
/// </summary>
public static void Scale( PixelBox src, PixelBox dst, int elementSize )
{
// assert(src.format == dst.format);
// srcdata stays at beginning, pdst is a moving pointer
//byte* srcdata = (byte*)src.Data;
//byte* pdst = (byte*)dst.Data;
var dstOffset = 0;
// sx_48,sy_48,sz_48 represent current position in source
// using 16/48-bit fixed precision, incremented by steps
var stepx = ( (ulong)src.Width << 48 )/(ulong)dst.Width;
var stepy = ( (ulong)src.Height << 48 )/(ulong)dst.Height;
var stepz = ( (ulong)src.Depth << 48 )/(ulong)dst.Depth;
// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
// for the center of the destination pixel, not the top-left corner
var sz_48 = ( stepz >> 1 ) - 1;
for ( var z = (uint)dst.Front; z < dst.Back; z++, sz_48 += stepz )
{
var srczoff = (uint)( sz_48 >> 48 )*(uint)src.SlicePitch;
var sy_48 = ( stepy >> 1 ) - 1;
for ( var y = (uint)dst.Top; y < dst.Bottom; y++, sy_48 += stepy )
{
var srcyoff = (uint)( sy_48 >> 48 )*(uint)src.RowPitch;
var sx_48 = ( stepx >> 1 ) - 1;
for ( var x = (uint)dst.Left; x < dst.Right; x++, sx_48 += stepx )
{
Memory.Copy( src.Data, dst.Data, (int)( elementSize*( (uint)( sx_48 >> 48 ) + srcyoff + srczoff ) ), dstOffset,
elementSize );
dstOffset += elementSize;
}
dstOffset += elementSize*dst.RowSkip;
}
dstOffset += elementSize*dst.SliceSkip;
}
}
示例3: EncodeToFile
public override void EncodeToFile( Stream input, string outFileName, Codec.CodecData codecData )
{
int imageID;
// create and bind a new image
Il.ilGenImages( 1, out imageID );
Il.ilBindImage( imageID );
var buffer = new byte[input.Length];
input.Read( buffer, 0, buffer.Length );
var imgData = (ImageData)codecData;
PixelBox src;
using ( var bufHandle = BufferBase.Wrap( buffer ) )
{
src = new PixelBox( imgData.width, imgData.height, imgData.depth, imgData.format, bufHandle );
}
try
{
// Convert image from Axiom to current IL image
ILUtil.ConvertToIL( src );
}
catch ( Exception ex )
{
LogManager.Instance.Write( "IL Failed image conversion :", ex.Message );
}
// flip the image
Ilu.iluFlipImage();
// save the image to file
Il.ilSaveImage( outFileName );
var error = Il.ilGetError();
if ( error != Il.IL_NO_ERROR )
{
LogManager.Instance.Write( "IL Error, could not save file: {0} : {1}", outFileName, Ilu.iluErrorString( error ) );
}
Il.ilDeleteImages( 1, ref imageID );
}
示例4: BlitToMemory
protected void BlitToMemory( BasicBox srcBox, PixelBox dst, BufferResources srcBufferResources, D3D9.Device d3d9Device )
{
// Decide on pixel format of temp surface
PixelFormat tmpFormat = Format;
if ( D3D9Helper.ConvertEnum( dst.Format ) != D3D9.Format.Unknown )
{
tmpFormat = dst.Format;
}
if ( srcBufferResources.Surface != null )
{
Debug.Assert( srcBox.Depth == 1 && dst.Depth == 1 );
var srcDesc = srcBufferResources.Surface.Description;
var temppool = D3D9.Pool.Scratch;
// if we're going to try to use GetRenderTargetData, need to use system mem pool
var tryGetRenderTargetData = false;
if ( ( ( srcDesc.Usage & D3D9.Usage.RenderTarget ) != 0 ) && ( srcBox.Width == dst.Width ) &&
( srcBox.Height == dst.Height ) && ( srcBox.Width == Width ) && ( srcBox.Height == Height ) &&
( Format == tmpFormat ) )
{
tryGetRenderTargetData = true;
temppool = D3D9.Pool.SystemMemory;
}
// Create temp texture
var tmp = new D3D9.Texture( d3d9Device, dst.Width, dst.Height, 1, // 1 mip level ie topmost, generate no mipmaps
0, D3D9Helper.ConvertEnum( tmpFormat ), temppool );
var surface = tmp.GetSurfaceLevel( 0 );
// Copy texture to this temp surface
var srcRect = ToD3DRectangle( srcBox );
var destRect = ToD3DRectangle( dst );
// Get the real temp surface format
var dstDesc = surface.Description;
tmpFormat = D3D9Helper.ConvertEnum( dstDesc.Format );
// Use fast GetRenderTargetData if we are in its usage conditions
var fastLoadSuccess = false;
if ( tryGetRenderTargetData )
{
var result = d3d9Device.GetRenderTargetData( srcBufferResources.Surface, surface );
fastLoadSuccess = result.Success;
}
if ( !fastLoadSuccess )
{
var res = D3D9.Surface.FromSurface( surface, srcBufferResources.Surface, D3D9.Filter.Default, 0, srcRect, destRect );
if ( res.Failure )
{
surface.SafeDispose();
tmp.SafeDispose();
throw new AxiomException( "D3D9.Surface.FromSurface failed in D3D9HardwarePixelBuffer.BlitToMemory" );
}
}
// Lock temp surface and copy it to memory
var lrect = surface.LockRectangle( D3D9.LockFlags.ReadOnly );
// Copy it
var locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
FromD3DLock( locked, lrect );
PixelConverter.BulkPixelConversion( locked, dst );
surface.UnlockRectangle();
// Release temporary surface and texture
surface.SafeDispose();
tmp.SafeDispose();
}
else if ( srcBufferResources.Volume != null )
{
// Create temp texture
var tmp = new D3D9.VolumeTexture( d3d9Device, dst.Width, dst.Height, dst.Depth, 0, 0,
D3D9Helper.ConvertEnum( tmpFormat ), D3D9.Pool.Scratch );
var surface = tmp.GetVolumeLevel( 0 );
// Volume
var ddestBox = ToD3DBoxExtent( dst );
var dsrcBox = ToD3DBox( srcBox );
var res = D3D9.Volume.FromVolume( surface, srcBufferResources.Volume, D3D9.Filter.Default, 0, dsrcBox, ddestBox );
if ( res.Failure )
{
surface.SafeDispose();
tmp.SafeDispose();
throw new AxiomException( "D3D9.Surface.FromVolume failed in D3D9HardwarePixelBuffer.BlitToMemory" );
}
// Lock temp surface and copy it to memory
var lbox = surface.LockBox( D3D9.LockFlags.ReadOnly ); // Filled in by D3D
// Copy it
var locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
FromD3DLock( locked, lbox );
PixelConverter.BulkPixelConversion( locked, dst );
surface.UnlockBox();
// Release temporary surface and texture
surface.SafeDispose();
tmp.SafeDispose();
//.........这里部分代码省略.........
示例5: BlitFromMemory
protected void BlitFromMemory( PixelBox src, BasicBox dstBox, BufferResources dstBufferResources )
{
// for scoped deletion of conversion buffer
var converted = src;
var bufSize = 0;
// convert to pixelbuffer's native format if necessary
if ( D3D9Helper.ConvertEnum( src.Format ) == D3D9.Format.Unknown )
{
bufSize = PixelUtil.GetMemorySize( src.Width, src.Height, src.Depth, Format );
var newBuffer = new byte[bufSize];
using ( var data = BufferBase.Wrap( newBuffer ) )
{
converted = new PixelBox( src.Width, src.Height, src.Depth, Format, data );
}
PixelConverter.BulkPixelConversion( src, converted );
}
int rowWidth = 0;
if ( PixelUtil.IsCompressed( converted.Format ) )
{
rowWidth = converted.RowPitch/4;
// D3D wants the width of one row of cells in bytes
if ( converted.Format == PixelFormat.DXT1 )
{
// 64 bits (8 bytes) per 4x4 block
rowWidth *= 8;
}
else
{
// 128 bits (16 bytes) per 4x4 block
rowWidth *= 16;
}
}
else
{
rowWidth = converted.RowPitch*PixelUtil.GetNumElemBytes( converted.Format );
}
if ( dstBufferResources.Surface != null )
{
var srcRect = ToD3DRectangle( converted );
var destRect = ToD3DRectangle( dstBox );
bufSize = PixelUtil.GetMemorySize( converted.Width, converted.Height, converted.Depth, converted.Format );
var data = new byte[bufSize];
using ( var dest = BufferBase.Wrap( data ) )
{
Memory.Copy( converted.Data, dest, bufSize );
}
try
{
D3D9.Surface.FromMemory( dstBufferResources.Surface, data, D3D9.Filter.Default, 0,
D3D9Helper.ConvertEnum( converted.Format ), rowWidth, srcRect, destRect );
}
catch ( Exception e )
{
throw new AxiomException( "D3D9.Surface.FromMemory failed in D3D9HardwarePixelBuffer.BlitFromMemory", e );
}
}
else if ( dstBufferResources.Volume != null )
{
var srcBox = ToD3DBox( converted );
var destBox = ToD3DBox( dstBox );
var sliceWidth = 0;
if ( PixelUtil.IsCompressed( converted.Format ) )
{
sliceWidth = converted.SlicePitch/16;
// D3D wants the width of one slice of cells in bytes
if ( converted.Format == PixelFormat.DXT1 )
{
// 64 bits (8 bytes) per 4x4 block
sliceWidth *= 8;
}
else
{
// 128 bits (16 bytes) per 4x4 block
sliceWidth *= 16;
}
}
else
{
sliceWidth = converted.SlicePitch*PixelUtil.GetNumElemBytes( converted.Format );
}
bufSize = PixelUtil.GetMemorySize( converted.Width, converted.Height, converted.Depth, converted.Format );
var data = new byte[ bufSize ];
using ( var dest = BufferBase.Wrap( data ) )
{
Memory.Copy( converted.Data, dest, bufSize );
}
try
{
using ( var srcData = BufferBase.Wrap( data ) )
{
var srcMemoryPtr = new IntPtr( srcData.Ptr );
dstBufferResources.Volume.LoadFromMemory( null, destBox, srcMemoryPtr, D3D9Helper.ConvertEnum( converted.Format ),
rowWidth, slicePitch, null, srcBox, D3D9.Filter.Default, 0 );
//.........这里部分代码省略.........
示例6: LockBuffer
protected PixelBox LockBuffer( BufferResources bufferResources, BasicBox lockBox, D3D9.LockFlags flags )
{
// Set extents and format
// Note that we do not carry over the left/top/front here, since the returned
// PixelBox will be re-based from the locking point onwards
var rval = new PixelBox( lockBox.Width, lockBox.Height, lockBox.Depth, Format );
if ( bufferResources.Surface != null )
{
//Surface
DX.DataRectangle lrect; // Filled in by D3D
if ( lockBox.Left == 0 && lockBox.Top == 0 && lockBox.Right == Width && lockBox.Bottom == Height )
{
// Lock whole surface
lrect = bufferResources.Surface.LockRectangle( flags );
}
else
{
var prect = ToD3DRectangle( lockBox );
lrect = bufferResources.Surface.LockRectangle( prect, flags );
}
FromD3DLock( rval, lrect );
}
else if ( bufferResources.Volume != null )
{
// Volume
var pbox = ToD3DBox( lockBox ); // specify range to lock
var lbox = bufferResources.Volume.LockBox( pbox, flags );
FromD3DLock( rval, lbox );
}
return rval;
}
示例7: ToD3DRectangleExtent
protected static System.Drawing.Rectangle ToD3DRectangleExtent( PixelBox lockBox )
{
Debug.Assert( lockBox.Depth == 1 );
var r = new System.Drawing.Rectangle();
r.X = 0;
r.Width = lockBox.Width;
r.X = 0;
r.Height = lockBox.Height;
return r;
}
示例8: Bind
public void Bind( D3D9.Device dev, D3D9.Volume volume, D3D9.BaseTexture mipTex )
{
//Entering critical section
LockDeviceAccess();
var bufferResources = GetBufferResources( dev );
var isNewBuffer = false;
if ( bufferResources == null )
{
bufferResources = new BufferResources();
this.mapDeviceToBufferResources.Add( dev, bufferResources );
isNewBuffer = true;
}
bufferResources.MipTex = mipTex;
bufferResources.Volume = volume;
var desc = volume.Description;
width = desc.Width;
height = desc.Height;
depth = desc.Depth;
format = D3D9Helper.ConvertEnum( desc.Format );
// Default
rowPitch = Width;
slicePitch = Height*Width;
sizeInBytes = PixelUtil.GetMemorySize( Width, Height, Depth, Format );
if ( isNewBuffer && this.ownerTexture.IsManuallyLoaded )
{
foreach ( var it in this.mapDeviceToBufferResources )
{
if ( it.Value != bufferResources && it.Value.Volume != null && it.Key.TestCooperativeLevel().Success &&
dev.TestCooperativeLevel().Success )
{
var fullBufferBox = new BasicBox( 0, 0, 0, Width, Height, Depth );
var dstBox = new PixelBox( fullBufferBox, Format );
var data = new byte[sizeInBytes];
using ( var d = BufferBase.Wrap( data ) )
{
dstBox.Data = d;
BlitToMemory( fullBufferBox, dstBox, it.Value, it.Key );
BlitFromMemory( dstBox, fullBufferBox, bufferResources );
Array.Clear( data, 0, sizeInBytes );
}
break;
}
}
}
//Leaving critical section
UnlockDeviceAccess();
}
示例9: WriteContentsToFile
public void WriteContentsToFile(string fileName)
{
var pf = SuggestPixelFormat();
var data = new byte[Width * Height * PixelUtil.GetNumElemBytes(pf)];
var bufGcHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
var pb = new PixelBox(Width, Height, 1, pf, bufGcHandle.AddrOfPinnedObject());
CopyContentsToMemory(pb);
(new Image()).FromDynamicImage(data, Width, Height, 1, pf, false, 1, 0).Save(fileName);
if (bufGcHandle.IsAllocated)
bufGcHandle.Free();
}
示例10: CopyContentsToMemory
/// <summary>
/// </summary>
/// <param name="pb"> </param>
/// <param name="buffer"> </param>
public override void CopyContentsToMemory( PixelBox pb, RenderTarget.FrameBuffer buffer )
{
throw new NotImplementedException();
}
示例11: Scale
/// <summary>
///
/// </summary>
/// <param name="src"></param>
/// <param name="dst"></param>
public void Scale( PixelBox src, PixelBox dst )
{
int srcelemsize = PixelUtil.GetNumElemBytes( src.Format );
int dstelemsize = PixelUtil.GetNumElemBytes( dst.Format );
int dstOffset = 0;
// sx_48,sy_48,sz_48 represent current position in source
// using 16/48-bit fixed precision, incremented by steps
UInt64 stepx = ( (UInt64)src.Width << 48 ) / (UInt64)dst.Width;
UInt64 stepy = ( (UInt64)src.Height << 48 ) / (UInt64)dst.Height;
UInt64 stepz = ( (UInt64)src.Depth << 48 ) / (UInt64)dst.Depth;
// temp is 16/16 bit fixed precision, used to adjust a source
// coordinate (x, y, or z) backwards by half a pixel so that the
// integer bits represent the first sample (eg, sx1) and the
// fractional bits are the blend weight of the second sample
uint temp;
// note: ((stepz>>1) - 1) is an extra half-step increment to adjust
// for the center of the destination pixel, not the top-left corner
UInt64 sz_48 = ( stepz >> 1 ) - 1;
for ( int z = dst.Front; z < dst.Back; z++, sz_48 += stepz )
{
temp = (uint)( sz_48 >> 32 );
temp = ( temp > 0x8000 ) ? temp - 0x8000 : 0;
int sz1 = (int)( temp >> 16 );
int sz2 = System.Math.Min( sz1 + 1, src.Depth - 1 );
float szf = ( temp & 0xFFFF ) / 65536f;
UInt64 sy_48 = ( stepy >> 1 ) - 1;
for ( int y = dst.Top; y < dst.Bottom; y++, sy_48 += stepy )
{
temp = (uint)( sy_48 >> 32 );
temp = ( temp > 0x8000 ) ? temp - 0x8000 : 0;
int sy1 = (int)( temp >> 16 ); // src x #1
int sy2 = System.Math.Min( sy1 + 1, src.Height - 1 ); // src x #2
float syf = ( temp & 0xFFFF ) / 65536f; // weight of #2
UInt64 sx_48 = ( stepx >> 1 ) - 1;
for ( int x = dst.Left; x < dst.Right; x++, sx_48 += stepx )
{
temp = (uint)( sy_48 >> 32 );
temp = ( temp > 0x8000 ) ? temp - 0x8000 : 0;
int sx1 = (int)( temp >> 16 ); // src x #1
int sx2 = System.Math.Min( sx1 + 1, src.Width - 1 ); // src x #2
float sxf = ( temp & 0xFFFF ) / 65536f; // weight of #2
ColorEx x1y1z1 = ColorEx.White, x2y1z1 = ColorEx.White, x1y2z1 = ColorEx.White, x2y2z1 = ColorEx.White;
ColorEx x1y1z2 = ColorEx.White, x2y1z2 = ColorEx.White, x1y2z2 = ColorEx.White, x2y2z2 = ColorEx.White;
Unpack( ref x1y1z1, sx1, sy1, sz1, src.Format, src.Data, src, srcelemsize );
Unpack( ref x2y1z1, sx2, sy1, sz1, src.Format, src.Data, src, srcelemsize );
Unpack( ref x1y2z1, sx1, sy2, sz1, src.Format, src.Data, src, srcelemsize );
Unpack( ref x2y2z1, sx2, sy2, sz1, src.Format, src.Data, src, srcelemsize );
Unpack( ref x1y1z2, sx1, sy1, sz2, src.Format, src.Data, src, srcelemsize );
Unpack( ref x2y1z2, sx2, sy1, sz2, src.Format, src.Data, src, srcelemsize );
Unpack( ref x1y2z2, sx1, sy2, sz2, src.Format, src.Data, src, srcelemsize );
Unpack( ref x2y2z2, sx2, sy2, sz2, src.Format, src.Data, src, srcelemsize );
ColorEx accum =
x1y1z1 * ( ( 1.0f - sxf ) * ( 1.0f - syf ) * ( 1.0f - szf ) ) +
x2y1z1 * ( sxf * ( 1.0f - syf ) * ( 1.0f - szf ) ) +
x1y2z1 * ( ( 1.0f - sxf ) * syf * ( 1.0f - szf ) ) +
x2y2z1 * ( sxf * syf * ( 1.0f - szf ) ) +
x1y1z2 * ( ( 1.0f - sxf ) * ( 1.0f - syf ) * szf ) +
x2y1z2 * ( sxf * ( 1.0f - syf ) * szf ) +
x1y2z2 * ( ( 1.0f - sxf ) * syf * szf ) +
x2y2z2 * ( sxf * syf * szf );
PixelConverter.PackColor( accum, dst.Format, new IntPtr( dst.Data.ToInt32() + dstOffset ) );
dstOffset += dstelemsize;
}
dstOffset += dstelemsize * dst.RowSkip;
}
dstOffset += dstelemsize * dst.SliceSkip;
}
}
示例12: Unpack
void Unpack( ref ColorEx dst, int x, int y, int z, PixelFormat format, IntPtr src, PixelBox srcbox, int elemsize )
{
unsafe
{
byte* pSrc = (byte*)src;
IntPtr data = (IntPtr)( pSrc + elemsize * ( ( x ) + ( y ) * srcbox.RowPitch + ( z ) * srcbox.SlicePitch ) );
dst = PixelConverter.UnpackColor( format, data );
}
}
示例13: WriteContentsToFile
public void WriteContentsToFile( string fileName )
{
var pf = SuggestPixelFormat();
var data = new byte[Width*Height*PixelUtil.GetNumElemBytes( pf )];
var buf = BufferBase.Wrap( data );
var pb = new PixelBox( Width, Height, 1, pf, buf );
CopyContentsToMemory( pb );
( new Image() ).FromDynamicImage( data, Width, Height, 1, pf, false, 1, 0 ).Save( fileName );
buf.Dispose();
}
示例14: ConvertToIL
static public void ConvertToIL( PixelBox src )
{
// ilTexImage http://openil.sourceforge.net/docs/il/f00059.htm
ILFormat ifmt = Convert( src.Format );
if ( src.IsConsecutive && ifmt.IsValid )
{
// The easy case, the buffer is laid out in memory just like
// we want it to be and is in a format DevIL can understand directly
// We could even save the copy if DevIL would let us
Il.ilTexImage( src.Width, src.Height, src.Depth, (byte)ifmt.Channels, ifmt.Format, ifmt.Type, src.Data );
}
else if ( ifmt.IsValid )
{
// The format can be understood directly by DevIL. The only
// problem is that ilTexImage expects our image data consecutively
// so we cannot use that directly.
// Let DevIL allocate the memory for us, and copy the data consecutively
// to its memory
Il.ilTexImage( src.Width, src.Height, src.Depth, (byte)ifmt.Channels, ifmt.Format, ifmt.Type, IntPtr.Zero );
PixelBox dst = new PixelBox( src.Width, src.Height, src.Depth, src.Format, Il.ilGetData() );
PixelConverter.BulkPixelConversion( src, dst );
}
else
{
// Here it gets ugly. We're stuck with a pixel format that DevIL
// can't do anything with. We will do a bulk pixel conversion and
// then feed it to DevIL anyway. The problem is finding the best
// format to convert to.
// most general format supported by Axiom and DevIL
PixelFormat fmt = PixelUtil.HasAlpha( src.Format ) ? PixelFormat.FLOAT32_RGBA : PixelFormat.FLOAT32_RGB;
// Make up a pixel format
// We don't have to consider luminance formats as they have
// straight conversions to DevIL, just weird permutations of RGBA an LA
int[] depths = PixelUtil.GetBitDepths( src.Format );
// Native endian format with all bit depths<8 can safely and quickly be
// converted to 24/32 bit
if ( PixelUtil.IsNativeEndian( src.Format ) &&
depths[ 0 ] <= 8 && depths[ 1 ] <= 8 && depths[ 2 ] <= 8 && depths[ 3 ] <= 8 )
{
if ( PixelUtil.HasAlpha( src.Format ) )
{
fmt = PixelFormat.A8R8G8B8;
}
else
{
fmt = PixelFormat.R8G8B8;
}
}
// Let DevIL allocate the memory for us, then do the conversion ourselves
ifmt = Convert( fmt );
Il.ilTexImage( src.Width, src.Height, src.Depth, (byte)ifmt.Channels, ifmt.Format, ifmt.Type, IntPtr.Zero ); // TAO 2.0
//Il.ilTexImage( src.Width, src.Height, src.Depth, (byte)ifmt.Channels, ifmt.Format, ifmt.Type, null );
IntPtr data = Il.ilGetData();
PixelBox dst = new PixelBox( src.Width, src.Height, src.Depth, fmt, data );
PixelConverter.BulkPixelConversion( src, dst );
}
}
示例15: ConvertFromIL
static public void ConvertFromIL( PixelBox dst )
{
if ( !dst.IsConsecutive )
throw new Exception( "Destination must currently be consecutive" );
if ( dst.Width != Il.ilGetInteger( Il.IL_IMAGE_WIDTH ) ||
dst.Height != Il.ilGetInteger( Il.IL_IMAGE_HEIGHT ) ||
dst.Depth != Il.ilGetInteger( Il.IL_IMAGE_DEPTH ) )
throw new Exception( "Destination dimensions must equal IL dimension" );
int ilfmt = Il.ilGetInteger( Il.IL_IMAGE_FORMAT );
int iltp = Il.ilGetInteger( Il.IL_IMAGE_TYPE );
// Check if in-memory format just matches
// If yes, we can just copy it and save conversion
ILFormat ifmt = Convert( dst.Format );
if ( ifmt.Format == ilfmt && ILabs( ifmt.Type ) == ILabs( iltp ) )
{
Memory.Copy( Il.ilGetData(), dst.Data, Il.ilGetInteger( Il.IL_IMAGE_SIZE_OF_DATA ) );
return;
}
// Try if buffer is in a known Axiom format so we can use its conversion routines
PixelFormat bufFmt = Convert( (int)ilfmt, (int)iltp );
ifmt = Convert( bufFmt );
if ( ifmt.Format == ilfmt && ILabs( ifmt.Type ) == ILabs( iltp ) )
{
// IL format matches another Axiom format
PixelBox src = new PixelBox( dst.Width, dst.Height, dst.Depth, bufFmt, Il.ilGetData() );
PixelConverter.BulkPixelConversion( src, dst );
return;
}
// Thee extremely slow method
if ( iltp == Il.IL_UNSIGNED_BYTE || iltp == Il.IL_BYTE )
{
throw new NotImplementedException( "Cannot convert this DevIL type." );
//ilToOgreInternal( static_cast<uint8*>( dst.data ), dst.format, (uint8)0x00, (uint8)0x00, (uint8)0x00, (uint8)0xFF );
}
else if ( iltp == Il.IL_FLOAT )
{
throw new NotImplementedException( "Cannot convert this DevIL type." );
//ilToOgreInternal( static_cast<uint8*>( dst.data ), dst.format, 0.0f, 0.0f, 0.0f, 1.0f );
}
else if ( iltp == Il.IL_SHORT || iltp == Il.IL_UNSIGNED_SHORT )
{
throw new NotImplementedException( "Cannot convert this DevIL type." );
//ilToOgreInternal( static_cast<uint8*>( dst.data ), dst.format, (uint16)0x0000, (uint16)0x0000, (uint16)0x0000, (uint16)0xFFFF );
}
else
{
throw new Exception( "Cannot convert this DevIL type." );
}
}