Axiom.Media.Image.FromDynamicImage C# (CSharp) Method

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
		public Image FromDynamicImage( byte[] buffer, int width, int height, int depth, PixelFormat format, bool autoDelete, int numFaces, int numMipMaps )
		{

			this.width = width;
			this.height = height;
			this.depth = depth;
			this.format = format;

			this.numMipMaps = numMipMaps;

			this.flags = 0;
			if ( PixelUtil.IsCompressed( format ) )
				this.flags |= ImageFlags.Compressed;
			if ( depth != 1 )
				this.flags |= ImageFlags.Volume;
			if ( numFaces == 6 )
				this.flags |= ImageFlags.CubeMap;
			if ( numFaces != 6 && numFaces != 1 )
				throw new Exception( "Number of faces currently must be 6 or 1." );

			this.size = CalculateSize( numMipMaps, numFaces, width, height, depth, format );

			SetBuffer( buffer );

			return this;
		}

Same methods

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

Usage Example

Beispiel #1
0
        private void SaveToDisk( Texture tp, string filename )
        {
          // Declare buffer
            int buffSize = tp.Width * tp.Height * tp.Depth * 4;
            byte[] data = new byte[buffSize];
          

          // Setup Image with correct settings
          Image i = new Image();
          i.FromDynamicImage(data, tp.Width, tp.Height, tp.Depth,tp.Format);
          
          // Copy Texture buffer contents to image buffer
          HardwarePixelBuffer buf = tp.GetBuffer();      
          PixelBox destBox = i.GetPixelBox(0,0);
          buf.BlitToMemory(destBox);
          
          // Save to disk!
          i.Save( @"C:\" + filename );
        }
All Usage Examples Of Axiom.Media.Image::FromDynamicImage