예제 #1
0
        /// <summary>
        /// Create image from stream. Pfim will try to detect the format based on several leading bytes
        /// </summary>
        public static IImage FromStream(Stream stream, PfimConfig config)
        {
            byte[] magic = new byte[4];
            if (stream.Read(magic, 0, 4) != 4)
            {
                throw new ArgumentException("stream must contain magic header", nameof(stream));
            }

            if (magic[0] == 0x44 && magic[1] == 0x44 && magic[2] == 0x53 && magic[3] == 0x20)
            {
                return(Dds.CreateSkipMagic(stream, config));
            }

            return(Targa.CreateWithPartialHeader(stream, config, magic));
        }
예제 #2
0
파일: Pfim.cs 프로젝트: poeAddict/LibGGPK2
        /// <summary>
        /// Create image from stream. Pfim will try to detect the format based on several leading bytes
        /// </summary>
        public static IImage FromStream(Stream stream, PfimConfig config)
        {
            byte[] magic = new byte[4];
            if (stream.Read(magic, 0, 4) != 4)
            {
                throw new ArgumentException("stream must contain magic header", nameof(stream));
            }

            if (magic[0] == 0x44 && magic[1] == 0x44 && magic[2] == 0x53 && magic[3] == 0x20)
            {
                return(Dds.CreateSkipMagic(stream, config));
            }

            throw new Exception("This is not a DDS image file");
        }