예제 #1
0
        /// <summary>
        /// Create a DDS texture from memory
        /// </summary>
        /// <param name="ddsData">The memory where the DDS data is stored </param>
        /// <param name="mipMapMaxSize">The largest size a mipmap can be (all larger will be discarded)</param>
        /// <param name="loaderFlags">The flags used by the loader</param>
        /// <returns>A descriptor struct of the DDS texture</returns>
        public static DdsTextureDescription CreateDdsTexture(
            Memory <byte> ddsData,
            uint mipMapMaxSize      = default,
            LoaderFlags loaderFlags = LoaderFlags.None)
        {
            if (ddsData.Length < sizeof(DdsHeader) + sizeof(uint))
            {
                ThrowHelper.ThrowArgumentException("Data too small to be a valid DDS file");
            }

            var metadata = FileMetadata.FromMemory(ddsData);

            return(ImplementationFunctions.CreateTextureFromDds12(
                       metadata,
                       mipMapMaxSize,
                       loaderFlags
                       ));
        }