From 863dba5787fa791bc8a26ed8fca6ea86ec9cae49 Mon Sep 17 00:00:00 2001 From: Siyu Zhang Date: Mon, 5 Apr 2021 19:13:20 +0800 Subject: [PATCH] Fix displayed zoom factor by setting bitmap DPI=96 --- Plugin.cs | 6 ++++-- StandaloneViewer/MainWindow.xaml | 4 ++-- StandaloneViewer/MainWindow.xaml.cs | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Plugin.cs b/Plugin.cs index 413dd5b..64c96e5 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -154,6 +154,7 @@ public bool CanHandle(string path) path.ToLower().EndsWith(".fit") || path.ToLower().EndsWith(".fts")); } + public void Prepare(string path, ContextObject context) { _fitsImagePtr = NativeMethods.FitsImageCreate(path); @@ -163,6 +164,7 @@ public void Prepare(string path, ContextObject context) context.SetPreferredSizeFit(size, 0.8); } + public void View(string path, ContextObject context) { var header = NativeMethods.FitsImageGetHeader(_fitsImagePtr); @@ -176,11 +178,11 @@ public void View(string path, ContextObject context) int rawStride = outputDim.nx * outputDim.nc; if (outputDim.nc == 3) { - bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 300, 300, PixelFormats.Rgb24, null, img, rawStride); + bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 96, 96, PixelFormats.Rgb24, null, img, rawStride); } else { - bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 300, 300, PixelFormats.Gray8, null, img, rawStride); + bitmapSource = BitmapSource.Create(outputDim.nx, outputDim.ny, 96, 96, PixelFormats.Gray8, null, img, rawStride); } _ip = new ImagePanel(context, header); diff --git a/StandaloneViewer/MainWindow.xaml b/StandaloneViewer/MainWindow.xaml index fac7f80..e263e6d 100644 --- a/StandaloneViewer/MainWindow.xaml +++ b/StandaloneViewer/MainWindow.xaml @@ -1,11 +1,11 @@ - + Title="MainWindow" Height="720" Width="1280">