update 20250202

This commit is contained in:
Stefan Hutter
2025-02-02 18:07:10 +01:00
parent f1f74f8cc5
commit 293b615547
133 changed files with 333088 additions and 333 deletions

View File

@@ -45,6 +45,7 @@ namespace API_NetFramework.Controllers
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
private System.Drawing.Image ResizeImage(System.Drawing.Image imgToResize, Size size)
{
return imgToResize;
// Get the image current width
int sourceWidth = imgToResize.Width;
// Get the image current height
@@ -67,10 +68,71 @@ namespace API_NetFramework.Controllers
g.Dispose();
return (System.Drawing.Image)b;
}
private System.Drawing.Image ScaleImage(System.Drawing.Image image, int height)
{
double ratio = height / (double)image.Height;
var newWidth = System.Convert.ToInt32(image.Width * ratio);
var newHeight = System.Convert.ToInt32(image.Height * ratio);
Bitmap newImage = new Bitmap(newWidth, newHeight);
using (Graphics g = Graphics.FromImage(newImage))
{
g.DrawImage(image, 0, 0, newWidth, newHeight);
}
image.Dispose();
return newImage;
}
private System.Drawing.Image resizeImage(System.Drawing.Image imgToResize, Size size)
{
return (System.Drawing.Image)(new Bitmap(imgToResize, size));
}
public System.Drawing.Image AutoSizeImage(System.Drawing.Image oBitmap, int maxWidth, int maxHeight, bool bStretch = false)
{
// Größenverhältnis der max. Dimension
float maxRatio = (float)maxWidth / (float)maxHeight;
// Bildgröße und aktuelles Größenverhältnis
var imgWidth = oBitmap.Width;
var imgHeight = oBitmap.Height;
float imgRatio = (float)imgWidth / (float)imgHeight;
// Bild anpassen?
if (imgWidth > maxWidth | imgHeight > maxHeight | bStretch)
{
if (imgRatio <= maxRatio)
{
// Größenverhältnis des Bildes ist kleiner als die
// maximale Größe, in der das Bild angezeigt werden kann.
// In diesem Fall muss die Bildbreite angepasst werden.
imgWidth = System.Convert.ToInt32(Math.Round(imgWidth / (double)(imgHeight / (double)maxHeight)));
imgHeight = maxHeight;
}
else
{
// Größenverhältnis des Bildes ist größer als die
// maximale Größe, in der das Bild angezeigt werden kann.
// In diesem Fall muss die Bildhöhe angepasst werden.
imgHeight = System.Convert.ToInt32(Math.Round(imgHeight / (double)(imgWidth / (double)maxWidth)));
imgWidth = maxWidth;
}
// Bitmap-Objekt in der neuen Größe erstellen
var oImage = new Bitmap(imgWidth, imgHeight);
// Bild interpolieren, damit die Qualität erhalten bleibt
using (Graphics g = Graphics.FromImage(oImage))
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(oBitmap, new System.Drawing.Rectangle(0, 0, imgWidth, imgHeight));
}
// neues Bitmap zurückgeben
return oImage;
}
else
// unverändertes Originalbild zurückgeben
return oBitmap;
}
/// <summary>
///
@@ -119,17 +181,23 @@ namespace API_NetFramework.Controllers
case 0:
ImageWidth = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageWidth"]);
ImageHeight = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DefaultImageHeight"]);
Bitmap b = new Bitmap(iimg);
imgnew = ResizeImage(b, new Size(ImageHeight, ImageWidth));
b = null;
imgnew= iimg;
//Bitmap b = new Bitmap(iimg);
//imgnew = AutoSizeImage(b, ImageWidth, ImageHeight, false);
//imgnew = ScaleImage(b, ImageHeight);
//imgnew = ResizeImage(b, new Size(ImageWidth,ImageHeight));
//b = null;
break;
case -1:
imgnew = iimg;
break;
default:
Bitmap b1 = new Bitmap(iimg);
imgnew = ResizeImage(b1, new Size(ImageHeight, ImageWidth));
b1 = null;
//Bitmap b1 = new Bitmap(iimg);
imgnew = iimg;
//imgnew = AutoSizeImage(b1, ImageWidth, ImageHeight, false);
//imgnew = ScaleImage(b1, ImageHeight);
//imgnew = ResizeImage(b1, new Size(ImageWidth, ImageHeight));
//b1 = null;
break;
}
@@ -162,6 +230,7 @@ namespace API_NetFramework.Controllers
}
}
/// <summary>
///
/// </summary>