public override void BlitFromMemory( PixelBox src, BasicBox dstBox )
{
PixelBox converted = src;
GCHandle bufGCHandle = new GCHandle();
int bufSize = 0;
// Get src.Data as byte[]
bufSize = PixelUtil.GetMemorySize( src.Width, src.Height, src.Depth, Format );
byte[] newBuffer = new byte[ bufSize ];
bufGCHandle = GCHandle.Alloc( newBuffer, GCHandleType.Pinned );
//XnaHelper.Convert(XFG.SurfaceFormat) would never have returned SurfaceFormat.Unknown anyway...
//if ( XnaHelper.Convert( src.Format ) == XFG.SurfaceFormat.Unknown )
//{
// converted = new PixelBox( src.Width, src.Height, src.Depth, Format, bufGCHandle.AddrOfPinnedObject() );
// PixelConverter.BulkPixelConversion( src, converted );
//}
//else
{
Memory.Copy( converted.Data, bufGCHandle.AddrOfPinnedObject(), bufSize );
}
if ( surface != null )
{
surface.SetData<byte>( mipLevel, XnaHelper.ToRectangle( dstBox ), newBuffer, 0, bufSize );
}
else
{
throw new NotSupportedException( "BlitFromMemory on Volume Textures not supported." );
}
// If we allocated a buffer for the temporary conversion, free it here
if ( bufGCHandle.IsAllocated )
bufGCHandle.Free();
if ( doMipmapGen )
GenMipmaps();
}