Skip to content

Commit

Permalink
resize icons keeping aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
g3gg0 committed Oct 2, 2022
1 parent e77fbbc commit aa876b0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions TeddyBench/TeddyMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private void StopAnalyzeThread()

private void AnalyzeMain()
{
ByteQueue ByteBuffer = new ByteQueue();
ByteQueue ByteBuffer = new ByteQueue();
while (!AnalyzeThreadStop)
{
Thread.Sleep(100);
Expand Down Expand Up @@ -965,7 +965,17 @@ private TonieAudio GetTonieAudio(string fileName)

public static Bitmap ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
double srcRatio = (double)image.Width / image.Height;
int dstWidth = width;
int dstHeight = (int)(dstWidth / srcRatio);

if(dstHeight > image.Height)
{
dstHeight = height;
dstWidth = (int)(dstHeight * srcRatio);
}

var destRect = new Rectangle(0, 0, dstWidth, dstHeight);
var destImage = new Bitmap(width, height);

destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
Expand Down

0 comments on commit aa876b0

Please sign in to comment.