Example #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));
        }
Example #2
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));
            }

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