Skip to content

Commit

Permalink
Fix displayed zoom factor by setting bitmap DPI=96
Browse files Browse the repository at this point in the history
  • Loading branch information
siyu6974 committed Apr 5, 2021
1 parent 1d46811 commit 863dba5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions StandaloneViewer/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Window x:Class="StandaloneViewer.MainWindow"
<Window x:Class="StandaloneViewer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
xmlns:local="clr-namespace:StandaloneViewer"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="MainWindow" Height="720" Width="1280">
<Grid>
<!--<Grid.RowDefinitions>
<RowDefinition Height="*"/>
Expand Down
8 changes: 4 additions & 4 deletions StandaloneViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
QuickFits - FITS file preview plugin for QL-win
Copyright (C) 2021 Siyu Zhang
Expand Down Expand Up @@ -157,19 +157,19 @@ public MainWindow()
int rawStride = bufferSize.nx * bufferSize.nc;
if (bufferSize.nc == 3)
{
bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 300, 300, PixelFormats.Rgb24, null, img, rawStride);
bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 96, 96, PixelFormats.Rgb24, null, img, rawStride);
}
else
{
bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 300, 300, PixelFormats.Gray8, null, img, rawStride);
bitmapSource = BitmapSource.Create(bufferSize.nx, bufferSize.ny, 96, 96, PixelFormats.Gray8, null, img, rawStride);
}

var co = new ContextObject();
_ip = new ImagePanel(co, header);
_ip.Source = bitmapSource;

var size = new Size(bufferSize.nx, bufferSize.ny);
co.SetPreferredSizeFit(size, 0.8);
_ip.Source = bitmapSource;

_tabUserPage = new TabItem { Content = _ip };
MainTab.Items.Add(_tabUserPage);
Expand Down

0 comments on commit 863dba5

Please sign in to comment.