Skip to content

Commit

Permalink
Merge pull request #948 from VladiStep/textureItemImportExportFix
Browse files Browse the repository at this point in the history
Fix of QOI textures display on different system scale setting.
  • Loading branch information
Grossley authored Jun 3, 2022
2 parents a5dfa21 + a263f92 commit 82f2382
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions UndertaleModLib/Util/QoiConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public unsafe static Bitmap GetImageFromSpan(ReadOnlySpan<byte> bytes, out int l
ReadOnlySpan<byte> pixelData = bytes.Slice(12, length);

Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
bmp.SetResolution(96.0f, 96.0f);

BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
if (data.Stride != width * 4)
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModTool/Converters/MaskImageConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace UndertaleModTool
{
public class MaskImageConverer : IMultiValueConverter
public class MaskImageConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Expand Down
3 changes: 2 additions & 1 deletion UndertaleModTool/Editors/UndertaleEmbeddedTextureEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Viewbox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Stretch="Uniform" StretchDirection="DownOnly">
<Viewbox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Stretch="Uniform" StretchDirection="DownOnly"
SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Border>
<Border.Background>
<DrawingBrush Stretch="None" TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
Expand Down
5 changes: 3 additions & 2 deletions UndertaleModTool/Editors/UndertaleSpriteEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@
<StackPanel Name="MaskEditor">
<Viewbox Stretch="None">
<Border BorderThickness="2" BorderBrush="Gray" Name="MaskBorder">
<Image Stretch="None" Name="MaskImage">
<Image Stretch="None" Name="MaskImage"
SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Image.Source>
<MultiBinding>
<MultiBinding.Converter>
<local:MaskImageConverer/>
<local:MaskImageConverter/>
</MultiBinding.Converter>
<Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.Width" Mode="OneWay"/>
<Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.Height" Mode="OneWay"/>
Expand Down
3 changes: 2 additions & 1 deletion UndertaleModTool/Editors/UndertaleTexturePageItemEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
<Button Grid.Column="3" Content="Export" Click="Export_Click"/>
</Grid>

<Viewbox Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Stretch="Uniform" StretchDirection="DownOnly">
<Viewbox Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Stretch="Uniform" StretchDirection="DownOnly"
SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down

0 comments on commit 82f2382

Please sign in to comment.