mirror of
https://github.com/4sval/FModel.git
synced 2026-09-14 12:36:45 -05:00
ResizeWithRatio
This commit is contained in:
Submodule CUE4Parse updated: 1ac4640cdb...73c1273292
@@ -38,7 +38,9 @@ namespace FModel.Creator.Bases.FN
|
||||
!_apiEndpointView.FortniteApi.TryGetBytes(playlist.Data.Images.Showcase, out var image))
|
||||
return;
|
||||
|
||||
Preview = Utils.GetBitmap(image).Resize(1024, 512); // Force size to 1024x512 to prevent huge previews.
|
||||
Preview = Utils.GetBitmap(image).ResizeWithRatio(1024, 512);
|
||||
Width = Preview.Width;
|
||||
Height = Preview.Height;
|
||||
}
|
||||
|
||||
public override SKImage Draw()
|
||||
|
||||
@@ -108,7 +108,6 @@ namespace FModel.Creator
|
||||
public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data);
|
||||
|
||||
public static SKBitmap Resize(this SKBitmap me, int size) => me.Resize(size, size);
|
||||
|
||||
public static SKBitmap Resize(this SKBitmap me, int width, int height)
|
||||
{
|
||||
var bmp = new SKBitmap(new SKImageInfo(width, height), SKBitmapAllocFlags.ZeroPixels);
|
||||
@@ -116,6 +115,13 @@ namespace FModel.Creator
|
||||
me.ScalePixels(pixmap, SKFilterQuality.Medium);
|
||||
return bmp;
|
||||
}
|
||||
public static SKBitmap ResizeWithRatio(this SKBitmap me, double width, double height)
|
||||
{
|
||||
var ratioX = width / me.Width;
|
||||
var ratioY = height / me.Height;
|
||||
var ratio = ratioX < ratioY ? ratioX : ratioY;
|
||||
return me.Resize(Convert.ToInt32(me.Width * ratio), Convert.ToInt32(me.Height * ratio));
|
||||
}
|
||||
|
||||
public static bool TryGetPackageIndexExport<T>(FPackageIndex packageIndex, out T export) where T : UObject
|
||||
{
|
||||
|
||||
@@ -535,4 +535,4 @@ namespace FModel.Settings
|
||||
set => SetProperty(ref _textureExportFormat, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,4 +183,4 @@ namespace FModel.ViewModels
|
||||
}
|
||||
#pragma warning restore 649
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user