Axiom.Graphics.RenderTarget.WriteContentsToFile C# (CSharp) Method

WriteContentsToFile() private method

private WriteContentsToFile ( string fileName ) : void
fileName string
return void
        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();
        }