Skip to content

Commit

Permalink
fix adjustment selection, implement kepp aspect-ratio and resize to p…
Browse files Browse the repository at this point in the history
…ercentage [#12]
  • Loading branch information
t0815 committed Sep 1, 2024
1 parent 88ea142 commit 9737ccf
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 71 deletions.
2 changes: 1 addition & 1 deletion MyCBZ/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<applicationSettings>
<Win_CBZ.Win_CBZSettings>
<setting name="Version" serializeAs="String">
<value>0.20.154b</value>
<value>0.20.155b</value>
</setting>
<setting name="RenamerPlaceholders" serializeAs="Xml">
<value>
Expand Down
19 changes: 11 additions & 8 deletions MyCBZ/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

197 changes: 148 additions & 49 deletions MyCBZ/Forms/MainForm.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions MyCBZ/Forms/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAbgoAAAJNU0Z0AUkBTAIBAQMB
AAGgAR8BoAEfARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMAAUADAAEQAwABAQEAAQgG
AAG4AR8BuAEfARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMAAUADAAEQAwABAQEAAQgG
AAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEAAfABygGmAQABMwUAATMB
AAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQ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QAB1gLnAQABkAGpAa0CAAH/ATMDAAFmAwABmQMAAcwCAAEzAwAC
Expand Down
4 changes: 4 additions & 0 deletions MyCBZ/Models/ImageAdjustments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public ImageAdjustments(ImageAdjustments copyFrom = null)
ConvertFormat = copyFrom.ConvertFormat;
Interpolation = copyFrom.Interpolation;
MaxDimensions = copyFrom.MaxDimensions;
KeepAspectRatio = copyFrom.KeepAspectRatio;
ResizeToPercentage = copyFrom.ResizeToPercentage;
DontStretch = copyFrom.DontStretch;
Grayscale = copyFrom.Grayscale;
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions MyCBZ/Models/ImageTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,26 @@ public ImageTask Apply()

if (ImageAdjustments.KeepAspectRatio)
{
float ratio = 1.0f;

//Math.Min(targetFormat.W / SourceFormat.W, targetFormat.H / SourceFormat.H);

if (targetFormat.H == 0)
{
targetFormat.H = (int)(targetFormat.W * (ImageAdjustments.ResizeTo.Y / ImageAdjustments.ResizeTo.X));
ratio = (float)targetFormat.W / SourceFormat.W;
}
else if (targetFormat.W == 0)
{
targetFormat.W = (int)(targetFormat.H * (ImageAdjustments.ResizeTo.X / ImageAdjustments.ResizeTo.Y));
ratio = (float)targetFormat.H / SourceFormat.H;
}
else if (targetFormat.W > 0 && targetFormat.H > 0)
{
//targetFormat.W = (int)(targetFormat.H * (ImageAdjustments.ResizeTo.X / ImageAdjustments.ResizeTo.Y));
//targetFormat.H = (int)(targetFormat.W * (ImageAdjustments.ResizeTo.Y / ImageAdjustments.ResizeTo.X));
}

targetFormat.W = (int)(SourceFormat.W * ratio);
targetFormat.H = (int)(SourceFormat.H * ratio);
}

if (ImageAdjustments.ResizeMode == 3) // Resize percentage
Expand Down
2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">%APPDATA%\WIN_CBZ\Temp\</Value>
</Setting>
<Setting Name="Version" Type="System.String" Scope="Application">
<Value Profile="(Default)">0.20.154b</Value>
<Value Profile="(Default)">0.20.155b</Value>
</Setting>
<Setting Name="RenamerPlaceholders" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Microsoft Visual Studio [Community] 2022 (64-Bit)

## Latest Release

v0.20.154b released!
v0.20.155b released!


>[!IMPORTANT]
Expand Down
8 changes: 4 additions & 4 deletions Win_CBZ-Setup/Win_CBZ-Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Win_CBZ"
"ProductCode" = "8:{9EB3C6FD-7921-47BA-93F6-88893864F722}"
"PackageCode" = "8:{0F1ECEAC-2FE7-4C63-AE33-938BCF0127B8}"
"ProductCode" = "8:{49599E47-00F9-42C1-B559-55E9C136EAF1}"
"PackageCode" = "8:{E0C557C1-47D7-45E4-BE1A-3DC11715FE62}"
"UpgradeCode" = "8:{66FAEF81-1CAE-4971-9E0F-796310EFEA5E}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.20.154"
"ProductVersion" = "8:0.20.155"
"Manufacturer" = "8:Trash_s0Ft"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down Expand Up @@ -808,7 +808,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_1DAB07B3E40248E0B54293E16EE30178"
{
"SourcePath" = "8:..\\MyCBZ\\obj\\x64\\Release\\net8.0-windows7.0\\apphost.exe"
"SourcePath" = "8:..\\MyCBZ\\obj\\x64\\Debug\\net8.0-windows7.0\\apphost.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_381C2AC7AD384E1488C6014F95032920"
Expand Down

0 comments on commit 9737ccf

Please sign in to comment.