예제 #1
0
        private async void PreviewTexture(PropertiesViewModel propertiesViewModel, FileEntryViewModel selectedItem, IGameFile selectedGameFile)
        {
            propertiesViewModel.IsImagePreviewVisible = true;

            var man = ServiceLocator.Default.ResolveType <ModTools>();

            // extract cr2w to stream
            await using var cr2wstream = new MemoryStream();
            selectedGameFile.Extract(cr2wstream);

            // convert xbm to dds stream
            await using var ddsstream = new MemoryStream();
            var expargs = new XbmExportArgs {
                Flip = false, UncookExtension = EUncookExtension.tga
            };

            man.ConvertXbmToDdsStream(cr2wstream, ddsstream, out _);

            // try loading it in pfim
            try
            {
                var qa = await ImageDecoder.RenderToBitmapSourceDds(ddsstream);

                if (qa != null)
                {
                    StaticReferences.GlobalPropertiesView.LoadImage(qa);
                }
            }
            catch (Exception) { }
        }
예제 #2
0
        private async void PreviewTexture(PropertiesViewModel propertiesViewModel, RedFileViewModel selectedItem, IGameFile selectedGameFile)
        {
            propertiesViewModel.IsImagePreviewVisible = true;
            propertiesViewModel.SelectedIndex         = 3;

            var man = Locator.Current.GetService <IModTools>();

            // extract cr2w to stream
            await using var cr2wstream = new MemoryStream();
            selectedGameFile.Extract(cr2wstream);

            // convert xbm to dds stream
            await using var ddsstream = new MemoryStream();
            var expargs = new XbmExportArgs {
                Flip = false, UncookExtension = EUncookExtension.tga
            };

            if (man != null)
            {
                man.ConvertXbmToDdsStream(cr2wstream, ddsstream, out _);
            }

            // try loading it in pfim
            try
            {
                var qa = await ImageDecoder.RenderToBitmapSourceDds(ddsstream);

                if (qa != null)
                {
                    propertiesViewModel.LoadImage(qa);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }