Пример #1
0
        /// <summary>
        /// Converts a dds stream to another texture file type and writes it to file
        /// </summary>
        /// <param name="ms">The input dds stream</param>
        /// <param name="outfilename">The output filename. Extension will be overwritten with the correct filetype</param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static unsafe bool ConvertFromDdsAndSave(Stream ms, string outfilename, ExportArgs args)
        {
            // check if stream is dds
            if (!DDSUtils.IsDdsFile(ms))
            {
                throw new ArgumentException("Input stream not a dds file", nameof(ms));
            }

            // get arguments
            var uext  = EUncookExtension.dds;
            var vflip = false;

            if (args is not XbmExportArgs and not MlmaskExportArgs)
            {
                return(false);
            }
            if (args is XbmExportArgs xbm)
            {
                uext  = xbm.UncookExtension;
                vflip = xbm.Flip;
            }
            if (args is MlmaskExportArgs ml)
            {
                uext = ml.UncookExtension;
            }
            if (uext == EUncookExtension.dds)
            {
                return(false);
            }

            return(ConvertFromDdsAndSave(ms, outfilename, (DirectXTexSharp.ESaveFileTypes)uext, vflip));
        }
Пример #2
0
        /// <summary>
        /// Converts a dds stream to another texture file type and writes it to file
        /// </summary>
        /// <param name="ms">The input dds stream</param>
        /// <param name="outfilename">The output filename. Extension will be overwritten with the correct filetype</param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static bool ConvertFromDdsAndSave(Stream ms, string outfilename, ExportArgs args)
        {
            // check if stream is dds
            if (!DDSUtils.IsDdsFile(ms))
            {
                throw new ArgumentException("Input stream not a dds file", nameof(ms));
            }

            // get arguments
            var uext  = EUncookExtension.dds;
            var vflip = false;

            if (args is not XbmExportArgs and not MlmaskExportArgs)
            {
                return(false);
            }
            switch (args)
            {
            case XbmExportArgs xbm:
                uext  = xbm.UncookExtension;
                vflip = xbm.Flip;
                break;

            case MlmaskExportArgs ml:
                uext = ml.UncookExtension.FromMlMaskExtension();
                break;
            }

            return(uext != EUncookExtension.dds && ConvertFromDdsAndSave(ms, outfilename, ToSaveFormat(uext), vflip));
        }