Exemple #1
0
        internal unsafe SafeHeifDecodingOptions CreateDecodingOptions()
        {
            var decodingOptions = LibHeifNative.heif_decoding_options_alloc();

            if (decodingOptions.IsInvalid)
            {
                ExceptionUtil.ThrowHeifException(Properties.Resources.HeifDecodingOptionsCreationFailed);
            }

            byte version = Marshal.ReadByte(decodingOptions.DangerousGetHandle());

            if (version >= 2)
            {
                var options = (DecodeOptionsVersion2 *)decodingOptions.DangerousGetHandle();

                options->ignore_transformations = (byte)(this.IgnoreTransformations ? 1 : 0);
                options->convert_hdr_to_8bit    = (byte)(this.ConvertHdrToEightBit ? 1 : 0);
            }
            else
            {
                var options = (DecodeOptionsVersion1 *)decodingOptions.DangerousGetHandle();

                options->ignore_transformations = (byte)(this.IgnoreTransformations ? 1 : 0);
            }

            return(decodingOptions);
        }