Пример #1
0
        private void ReplaceImgBtn_Click(object sender, EventArgs e)
        {
            string text = KeyGenerator.OpenOrSaveFile("Select the image file to replace the texture.", "All Supported Formats|*.dds;*.bmp;*.jpg;*.gif;*.png|DDS Texture|*.dds|Bitmap|*.bmp|JPEG|*.jpg|Graphics Interchange Format|*.gif|Portable Network Graphics|*.png", true);

            if (text == "")
            {
                return;
            }
            Image image;

            if (text.EndsWith(".dds", StringComparison.OrdinalIgnoreCase))
            {
                image = new DDSTexture(text).GetImage();
            }
            else
            {
                image = Image.FromFile(text);
            }
            if (!image.Size.Equals(this.size_0) && DialogResult.Yes == MessageBox.Show("The image dimensions don't match. Do you wish scale to the original dimension? (Ratio may change!)", "Replace Texture", MessageBoxButtons.YesNo))
            {
                image = KeyGenerator.ScaleImage(image, this.size_0);
            }
            this._texFile.method_1(this.ImgList.SelectedIndex, image, this._currentTexturePixelFormat);
            this.RebuildBtn.Enabled = true;
        }
Пример #2
0
            public static DDSTexture ReadDDS(this SCMap scMap)
            {
                int length = scMap.ReadInt();

                byte[]     ddsBytes   = scMap.ReadBytes(length);
                DDSTexture ddsTexture = new DDSTexture(ddsBytes);

                return(ddsTexture);
            }
Пример #3
0
        protected override async Task <Texture> GetNewTextureAsync(int id)
        {
            var textures = data.textures;

            var stream = textures.data[id];

            stream.Seek(0, SeekOrigin.Begin);

            var info = new DDSInfo(stream);
            await info.LoadAsync();

            var texture = new DDSTexture(id, info, stream);

            return(texture);
        }
Пример #4
0
        public void Prepare()
        {
            if (File.Exists(GAMEPATH + albedoPath))
            {
                byte[] tmp = File.ReadAllBytes(GAMEPATH + albedoPath);
                albedo = new DDSTexture(tmp);
                albedo.ToTexture2D();
            }
            if (File.Exists(GAMEPATH + normalPath))
            {
                byte[] tmp = File.ReadAllBytes(GAMEPATH + normalPath);
                normal = new DDSTexture(tmp);
                normal.ToTexture2D();
            }
//            Debug.Log("");
        }
Пример #5
0
        private void ImgList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ImgList.SelectedIndex >= 0)
            {
                DDSTexture texture = _texFile[this.ImgList.SelectedIndex];
                _currentTexturePixelFormat = texture.PixelFormat;
                BPPTxt.Text    = string.Concat(texture.BPP);
                FormatTxt.Text = ((texture.PixelFormat == IMGPixelFormat.Dxt1) ? "DXT1" : ((texture.PixelFormat == IMGPixelFormat.Dxt3) ? "DXT3" : ((texture.PixelFormat == IMGPixelFormat.Dxt5) ? "DXT5" : "A8R8G8B8")));
                MipMapTxt.Text = string.Concat(texture.MipMapCount);
                WidthTxt.Text  = string.Concat(texture.Size.Width);
                HeightTxt.Text = string.Concat(texture.Size.Height);

                Image image = texture.GetImage();
                this.size_0 = image.Size;
                if (image.Width > this.ImagePreviewBox.Width || image.Height > this.ImagePreviewBox.Height)
                {
                    image = KeyGenerator.ScaleImageFixedRatio(image, ImagePreviewBox.Size);
                }
                this.ImagePreviewBox.Image = image;
                this.ImageInfoBox.Enabled  = true;
                return;
            }
            this.ImageInfoBox.Enabled = false;
        }