mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-15 03:16:05 +12:00
Resize to exact width or height
Resize to exact width or height instead of using a ratio for both width and height.
This commit is contained in:
parent
d0be0cff95
commit
34bb70b277
|
@ -183,13 +183,21 @@ public static Image ResizeImageLimit(Image img, int width, int height)
|
||||||
|
|
||||||
double ratioX = (double)width / img.Width;
|
double ratioX = (double)width / img.Width;
|
||||||
double ratioY = (double)height / img.Height;
|
double ratioY = (double)height / img.Height;
|
||||||
double ratio = ratioX < ratioY ? ratioX : ratioY;
|
int newWidth = width;
|
||||||
int newWidth = (int)(img.Width * ratio);
|
int newHeight = height;
|
||||||
int newHeight = (int)(img.Height * ratio);
|
if (ratioX < ratioY)
|
||||||
|
newHeight = (int)(img.Height * ratioX);
|
||||||
|
else
|
||||||
|
newWidth = (int)(img.Width * ratioY);
|
||||||
|
|
||||||
return ResizeImage(img, newWidth, newHeight);
|
return ResizeImage(img, newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Image ResizeImageLimit(Image img, int maxPixels)
|
||||||
|
{
|
||||||
|
return ResizeImageLimit(img, maxPixels, maxPixels);
|
||||||
|
}
|
||||||
|
|
||||||
public static Image CropImage(Image img, Rectangle rect)
|
public static Image CropImage(Image img, Rectangle rect)
|
||||||
{
|
{
|
||||||
if (img != null && rect.X >= 0 && rect.Y >= 0 && rect.Width > 0 && rect.Height > 0 &&
|
if (img != null && rect.X >= 0 && rect.Y >= 0 && rect.Width > 0 && rect.Height > 0 &&
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Gma.QrCodeNet.Encoding, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Gma.QrCodeNet.Encoding, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
|
Loading…
Reference in a new issue