Skip to content

Commit

Permalink
[HaRepacker] Fix blurry image rendered on the image preview window
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Dec 6, 2020
1 parent 1493f67 commit 88d1141
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
32 changes: 32 additions & 0 deletions HaRepacker/Converter/ImageZoomSliderConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaRepacker.Converter
{
/// <summary>
/// Rounds a double to 2 decimal place, and an even number
/// </summary>
public class ImageZoomSliderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double zoom = (double)value;
zoom = Math.Round(zoom, 2); // to 2 decimal place
//System.Diagnostics.Debug.WriteLine(((zoom * 100)));
if ((zoom * 100) % 2 != 0) // odd number
zoom += 0.01;

//System.Diagnostics.Debug.WriteLine("Zoom: " + zoom + " " + ((zoom * 100)));
return zoom;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (double)value;
}
}
}
10 changes: 7 additions & 3 deletions HaRepacker/GUI/Panels/SubPanels/ImageRenderViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<converter:PointFOriginToStringConverter x:Key="pointFOriginToStringConverter"/>
<converter:PointFToVisiblityConverter x:Key="pointFToVisiblityConverter"/>
<converter:CheckboxToBorderTransparencyConverter x:Key="checkboxToBorderTransparencyConverter"/>
<converter:ImageZoomSliderConverter x:Key="imageZoomSliderConverter"/>

<ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}">
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
Expand Down Expand Up @@ -525,15 +526,18 @@
BorderThickness="0.5" VerticalAlignment="Center" HorizontalAlignment="Center">
<Border.RenderTransform>
<ScaleTransform
ScaleX="{Binding ElementName=ZoomSlider, Path='Value'}"
ScaleY="{Binding ElementName=ZoomSlider, Path='Value'}"/>
ScaleX="{Binding ElementName=ZoomSlider, Path='Value', Converter={StaticResource imageZoomSliderConverter}}"
ScaleY="{Binding ElementName=ZoomSlider, Path='Value', Converter={StaticResource imageZoomSliderConverter}}"/>
</Border.RenderTransform>

<Grid>
<!-- Source="pack://siteoforigin:,,,/Resources/ladyboss_test_attack2_0.png" -->
<!-- Source="{Binding Image}" -->
<Image x:Name="canvasPropBox"
Source="{Binding Image}"
Source="{Binding Image}"
SnapsToDevicePixels="True" UseLayoutRounding="True"
RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased"

Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Center"/>

<!-- Click draggable borders-->
Expand Down
1 change: 1 addition & 0 deletions HaRepacker/Harepacker-resurrected.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<Compile Include="Comparer\SemiNumericComparer.cs" />
<Compile Include="Comparer\TreeViewNodeSorter.cs" />
<Compile Include="Converter\CheckboxToBorderTransparencyConverter.cs" />
<Compile Include="Converter\ImageZoomSliderConverter.cs" />
<Compile Include="GUI\ContextMenuManager.cs" />
<Compile Include="Converter\CheckboxToVisibilityConverter.cs" />
<Compile Include="Converter\ImageSizeDoubleToIntegerConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion MapleLib/WzLib/WzListFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static List<string> ParseListFile(string filePath, WzMapleVersion version
/// Parses a wz list file on the disk
/// </summary>
/// <param name="filePath">Path to the wz file</param>
public static List<string> ParseListFile(string filePath, byte[] WzIv)
private static List<string> ParseListFile(string filePath, byte[] WzIv)
{
List<string> listEntries = new List<string>();
byte[] wzFileBytes = File.ReadAllBytes(filePath);
Expand Down

0 comments on commit 88d1141

Please sign in to comment.