SetImage() public method

public SetImage ( Image NewImage, string Format ) : void
NewImage Image
Format string
return void
Esempio n. 1
0
        public EQArchiveFile AsFormat(string NewFormat, bool ChangeExtension)
        {
            if ((NewFormat == null) || (NewFormat == "") || (this.GetImage() == null))
            {
                return this;
            }

            NewFormat = NewFormat.ToLower();

            if (NewFormat == "auto")
            {
                switch (GetAlphaBits())
                {
                    case 0:
                    case 1:
                        NewFormat = "16-bit";
                        break;

                    case 8:
                        NewFormat = "32-bit";
                        break;

                    default: // ?
                        NewFormat = "32-bit";
                        break;
                }
            }

            EQArchiveFile _newFile = null;

            if (NewFormat != this.ImageFormat)
            {
                _newFile = new EQArchiveFile();
                _newFile.Filename = this.Filename;
                _newFile.SetImage(this.GetImage(), NewFormat);
            }

            if (ChangeExtension && !System.IO.Path.GetExtension(this.Filename).Equals((NewFormat[0] == '.' ? NewFormat : ".dds"), StringComparison.CurrentCultureIgnoreCase))
            {
                // Gotta change the extension

                if (_newFile == null)
                {
                    _newFile = new EQArchiveFile();
                    _newFile.SetContents(this.GetContents());
                }

                _newFile.Filename = System.IO.Path.GetFileNameWithoutExtension(this.Filename) + (NewFormat[0] == '.' ? NewFormat : ".dds");
            }
            else
            {
                if (_newFile == null)
                {
                    _newFile = this; // Unchanged from our current contents
                }
                else
                {
                    _newFile.Filename = this.Filename;
                }
            }

            return _newFile;
        }
Esempio n. 2
0
        public EQArchiveFile AsFormat(string NewFormat, bool ChangeExtension)
        {
            if ((NewFormat == null) || (NewFormat == "") || (this.GetImage() == null))
            {
                return(this);
            }

            NewFormat = NewFormat.ToLower();

            if (NewFormat == "auto")
            {
                switch (GetAlphaBits())
                {
                case 0:
                case 1:
                    NewFormat = "16-bit";
                    break;

                case 8:
                    NewFormat = "32-bit";
                    break;

                default:     // ?
                    NewFormat = "32-bit";
                    break;
                }
            }

            EQArchiveFile _newFile = null;

            if (NewFormat != this.ImageFormat)
            {
                _newFile          = new EQArchiveFile();
                _newFile.Filename = this.Filename;
                _newFile.SetImage(this.GetImage(), NewFormat);
            }

            if (ChangeExtension && !System.IO.Path.GetExtension(this.Filename).Equals((NewFormat[0] == '.' ? NewFormat : ".dds"), StringComparison.CurrentCultureIgnoreCase))
            {
                // Gotta change the extension

                if (_newFile == null)
                {
                    _newFile = new EQArchiveFile();
                    _newFile.SetContents(this.GetContents());
                }

                _newFile.Filename = System.IO.Path.GetFileNameWithoutExtension(this.Filename) + (NewFormat[0] == '.' ? NewFormat : ".dds");
            }
            else
            {
                if (_newFile == null)
                {
                    _newFile = this; // Unchanged from our current contents
                }
                else
                {
                    _newFile.Filename = this.Filename;
                }
            }

            return(_newFile);
        }