예제 #1
0
        public void GetPreview()
        {
            DdsFile dds;

            CSharpImageLibrary.ImageEngineImage image = null;
            try
            {
                this.Preview = null;
                dds          = new DdsFile(Texture, false);
                dds.Write(File.Open(System.AppDomain.CurrentDomain.BaseDirectory + "\\temp.dds", FileMode.Create, FileAccess.ReadWrite, FileShare.Read), -1);
                int maxDimension = (int)Math.Max(dds.header.width, dds.header.height);

                image        = new CSharpImageLibrary.ImageEngineImage(System.AppDomain.CurrentDomain.BaseDirectory + "\\temp.dds", maxDimension);
                Preview      = null;
                this.Preview = image.GetWPFBitmap(maxDimension, true);

                this.PreviewErrorVisibility = Visibility.Collapsed;
                OnPropertyChanged(nameof(Width));
                OnPropertyChanged(nameof(Height));
                OnPropertyChanged(nameof(TextureInfo));
            }
            catch (Exception ex)
            {
                Preview                     = null;
                this.PreviewError           = "Could not create preview! Export/Import may still work in certain circumstances." + Environment.NewLine + Environment.NewLine + ex.Message;
                this.PreviewErrorVisibility = Visibility.Visible;
            }
            finally
            {
                dds = null;
                image?.Dispose();
                image = null;
            }
        }
예제 #2
0
        public void GetPreview()
        {
            DdsFile dds;

            CSharpImageLibrary.ImageEngineImage image = null;
            try
            {
                this.Preview = null;
                dds          = ExportDDS(System.AppDomain.CurrentDomain.BaseDirectory + "\\temp.dds", true, false);
                int maxDimension = (int)Math.Max(dds.header.width, dds.header.height);
                Width  = (int)dds.header.width;
                Height = (int)dds.header.height;

                image        = new CSharpImageLibrary.ImageEngineImage(System.AppDomain.CurrentDomain.BaseDirectory + "\\temp.dds", maxDimension);
                Preview      = null;
                this.Preview = image.GetWPFBitmap(maxDimension, true);

                this.PreviewErrorVisibility = Visibility.Collapsed;
            }
            catch (Exception ex) when(!Debugger.IsAttached)
            {
                Preview                     = null;
                this.PreviewError           = "Could not create preview! Export/Import may still work in certain circumstances." + Environment.NewLine + Environment.NewLine + ex.Message;
                this.PreviewErrorVisibility = Visibility.Visible;
            }
            finally
            {
                dds = null;
                image?.Dispose();
                image = null;
            }
        }