Axiom.RenderSystems.DirectX9.D3DHardwarePixelBuffer.BlitToMemory C# (CSharp) Метод

BlitToMemory() публичный Метод

Copies a region of this pixelbuffer to normal memory.
The source and destination regions don't have to match, in which case scaling is done. Only call this function when the buffer is unlocked.
public BlitToMemory ( BasicBox srcBox, PixelBox dst ) : void
srcBox Axiom.Media.BasicBox BasicBox describing the source region of this buffer
dst Axiom.Media.PixelBox PixelBox describing the destination pixels and format in memory
Результат void
		public override void BlitToMemory( BasicBox srcBox, PixelBox dst )
		{
			// Decide on pixel format of temp surface
			PixelFormat tmpFormat = Format;
			if ( D3DHelper.ConvertEnum( dst.Format ) == D3D.Format.Unknown )
				tmpFormat = dst.Format;
			if ( surface != null )
			{
				Debug.Assert( srcBox.Depth == 1 && dst.Depth == 1 );
				// Create temp texture
				D3D.Texture tmp =
					new D3D.Texture( device, dst.Width, dst.Height,
									1, // 1 mip level ie topmost, generate no mipmaps
									0, D3DHelper.ConvertEnum( tmpFormat ),
									D3D.Pool.Scratch );
				D3D.Surface subSurface = tmp.GetSurfaceLevel( 0 );
				// Copy texture to this temp surface
				System.Drawing.Rectangle destRect, srcRect;
				srcRect = ToD3DRectangle( srcBox );
				destRect = ToD3DRectangleExtent( dst );

				D3D.Surface.FromSurface( subSurface, surface, D3D.Filter.None, 0, srcRect, destRect );

				// Lock temp surface and copy it to memory
				int pitch; // Filled in by D3D
				DX.DataRectangle data = subSurface.LockRectangle( D3D.LockFlags.ReadOnly );
				// Copy it
				PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
				FromD3DLock( locked, data );
				PixelConverter.BulkPixelConversion( locked, dst );
				subSurface.UnlockRectangle();
				// Release temporary surface and texture
				subSurface.Dispose();
				tmp.Dispose();
			}
			else
			{
				// Create temp texture
				D3D.VolumeTexture tmp =
					new D3D.VolumeTexture( device, dst.Width, dst.Height, dst.Depth,
										   0, D3D.Usage.None,
										   D3DHelper.ConvertEnum( tmpFormat ),
										   D3D.Pool.Scratch );
				D3D.Volume subVolume = tmp.GetVolumeLevel( 0 );
				// Volume
				D3D.Box ddestBox = ToD3DBoxExtent( dst );
				D3D.Box dsrcBox = ToD3DBox( srcBox );

				D3D.Volume.FromVolume( subVolume, volume, D3D.Filter.None, 0, dsrcBox, ddestBox );
				// Lock temp surface and copy it to memory
				//D3D.LockedBox lbox; // Filled in by D3D
				DX.DataBox data = subVolume.LockBox( D3D.LockFlags.ReadOnly );

				// Copy it
				PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat );
				FromD3DLock( locked, data );
				PixelConverter.BulkPixelConversion( locked, dst );
				subVolume.UnlockBox();
				// Release temporary surface and texture
				subVolume.Dispose();
				tmp.Dispose();
			}
		}