AdvancedLauncher.Tools.Imaging.TargaImage.TargaImage C# (CSharp) Метод

TargaImage() приватный Метод

private TargaImage ( string strFileName ) : System
strFileName string
Результат System
        public TargaImage(string strFileName)
            : this()
        {
            // make sure we have a .tga file
            if (System.IO.Path.GetExtension(strFileName).ToLower() == ".tga") {
                // make sure the file exists
                if (System.IO.File.Exists(strFileName) == true) {
                    this.strFileName = strFileName;
                    MemoryStream filestream = null;
                    BinaryReader binReader = null;
                    byte[] filebytes = null;

                    // load the file as an array of bytes
                    filebytes = System.IO.File.ReadAllBytes(this.strFileName);
                    if (filebytes != null && filebytes.Length > 0) {
                        // create a seekable memory stream of the file bytes
                        using (filestream = new MemoryStream(filebytes)) {
                            if (filestream != null && filestream.Length > 0 && filestream.CanSeek == true) {
                                // create a BinaryReader used to read the Targa file
                                using (binReader = new BinaryReader(filestream)) {
                                    this.LoadTGAFooterInfo(binReader);
                                    this.LoadTGAHeaderInfo(binReader);
                                    this.LoadTGAExtensionArea(binReader);
                                    this.LoadTGAImage(binReader);
                                }
                            } else
                                throw new Exception(@"Error loading file, could not read file from disk.");
                        }
                    } else
                        throw new Exception(@"Error loading file, could not read file from disk.");
                } else
                    throw new Exception(@"Error loading file, could not find file '" + strFileName + "' on disk.");
            } else
                throw new Exception(@"Error loading file, file '" + strFileName + "' must have an extension of '.tga'.");
        }

Same methods

TargaImage::TargaImage ( ) : System
TargaImage::TargaImage ( byte filebytes ) : System