public void WriteTga(void *data, int width, int height, ColorComponents components, Stream dest)
 {
     try
     {
         _stream = dest;
         StbImageWrite.stbi_write_tga_to_func(WriteCallback, null, width, height, (int)components, data);
     }
     finally
     {
         _stream = null;
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="components"></param>
        /// <param name="dest"></param>
        /// <param name="quality">Should be from 1 to 100</param>
        public void WriteJpg(void *data, int width, int height, ColorComponents components, Stream dest, int quality)
        {
            try
            {
                _stream = dest;

                StbImageWrite.stbi_write_jpg_to_func(WriteCallback, null, width, height, (int)components, data, quality);
            }
            finally
            {
                _stream = null;
            }
        }
        public void WriteHdr(byte[] data, int width, int height, ColorComponents components, Stream dest)
        {
            CheckParams(data, width, height, components);

            try
            {
                _stream = dest;
                var f = new float[data.Length];
                for (var i = 0; i < data.Length; ++i)
                {
                    f[i] = data[i] / 255.0f;
                }

                fixed(float *fptr = f)
                {
                    StbImageWrite.stbi_write_hdr_to_func(WriteCallback, null, width, height, (int)components, fptr);
                }
            }
            finally
            {
                _stream = null;
            }
        }