diff --git a/PDGServer_WPF/App.xaml b/PDGServer_WPF/App.xaml index 7124177..f4328e6 100644 --- a/PDGServer_WPF/App.xaml +++ b/PDGServer_WPF/App.xaml @@ -2,5 +2,5 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:RBG_Server" - StartupUri="MainWindow.xaml"> + StartupUri="ConnectionPage.xaml"> diff --git a/PDGServer_WPF/App.xaml.cs b/PDGServer_WPF/App.xaml.cs index 8d26332..3ad354f 100644 --- a/PDGServer_WPF/App.xaml.cs +++ b/PDGServer_WPF/App.xaml.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Navigation; namespace RBG_Server { @@ -31,6 +32,13 @@ namespace RBG_Server public const string MIP_HIGH = "_mip_high"; public const string MIP_RAW = "_mip_raw"; + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + Context = this; + GameCommunicationHandler = new CommunicationHandler(); + } + /// /// Loads the specified files from disk, creating mip maps as appropriate /// @@ -121,7 +129,8 @@ namespace RBG_Server BitmapImage bitmapImage = new(); bitmapImage.BeginInit(); bitmapImage.StreamSource = source; - bitmapImage.CacheOption = BitmapCacheOption.None; + bitmapImage.CreateOptions = BitmapCreateOptions.IgnoreColorProfile | BitmapCreateOptions.PreservePixelFormat; + bitmapImage.CacheOption = BitmapCacheOption.Default; bitmapImage.EndInit(); int height = bitmapImage.PixelHeight; int width = bitmapImage.PixelWidth; @@ -194,15 +203,28 @@ namespace RBG_Server GameCommunicationHandler.ImageCollection.Remove(GameCommunicationHandler.BoardName, out CachedByteArray val); val.Dispose(); } - GameCommunicationHandler.BoardName = path; + GameCommunicationHandler.BoardName = Path.GetFileNameWithoutExtension(path); } - GameCommunicationHandler.ImageList.Add(path); + GameCommunicationHandler.ImageList.Add(Path.GetFileNameWithoutExtension(path)); } } - MemoryStream ScaleImage(BitmapSource source, double scaleRate) + static MemoryStream ScaleImage(BitmapSource source, double scaleRate) { - TransformedBitmap modified = new(source, new ScaleTransform(source.PixelWidth * scaleRate, source.PixelHeight * scaleRate)); + TransformedBitmap modified = new(); + try + { + ScaleTransform transform = new ScaleTransform(scaleRate, scaleRate); + modified.BeginInit(); + modified.Source = source; + modified.Transform = transform; + modified.EndInit(); + //modified = new(source, ); + } + catch (Exception ex) + { + int op = 0; + } PngBitmapEncoder encoder = new(); encoder.Frames.Add(BitmapFrame.Create(modified)); MemoryStream ms = new(); @@ -210,7 +232,7 @@ namespace RBG_Server return ms; } - MemoryStream ScaleAnimatedImage(BitmapFrame[] frames, double scaleRate) + static MemoryStream ScaleAnimatedImage(BitmapFrame[] frames, double scaleRate) { PngBitmapEncoder encoder = new(); foreach (BitmapFrame frame in frames) diff --git a/PDGServer_WPF/ConnectionPage.xaml b/PDGServer_WPF/ConnectionPage.xaml index e25e0ca..8cdcc8b 100644 --- a/PDGServer_WPF/ConnectionPage.xaml +++ b/PDGServer_WPF/ConnectionPage.xaml @@ -1,19 +1,17 @@ - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d" + Title="PDG Server" Height="768" Width="1024" Background="#FF4B4B4B"> - - + +