KlassenDLL im Main integriert
This commit is contained in:
36
SanSystem/BerichtGen/BerichtWorker.cs
Normal file
36
SanSystem/BerichtGen/BerichtWorker.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BerichtGen
|
||||
{
|
||||
public class BerichtWorker
|
||||
{
|
||||
public static Image resizeImage(Image imgToResize, Size size)
|
||||
{
|
||||
int width = imgToResize.Width;
|
||||
int height = imgToResize.Height;
|
||||
float scale = 0f;
|
||||
float newWidth = 0f;
|
||||
float newHeight = 0f;
|
||||
|
||||
newWidth = (float)size.Width / (float)width;
|
||||
newHeight = (float)size.Height / (float)height;
|
||||
|
||||
scale = ((!(newHeight < newWidth)) ? newWidth : newHeight);
|
||||
int width2 = (int)((float)width * scale);
|
||||
int height2 = (int)((float)height * scale);
|
||||
|
||||
Bitmap bitmap = new Bitmap(width2, height2);
|
||||
Graphics graphics = Graphics.FromImage(bitmap);
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphics.DrawImage(imgToResize, 0, 0, width2, height2);
|
||||
graphics.Dispose();
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user