Gast
#295630
moin moin, wie kann man ein bitmap, was in eine picturebox kommt, skalieren ? mirki
|
Anzeige
|
c# Bitmap Object
Gast
#295630
moin moin, wie kann man ein bitmap, was in eine picturebox kommt, skalieren ? mirki
Gast
#295631
Das Problem ist gelöst.
Bitmap img = new Bitmap(openFileDialog1.FileName);
//skaliert das Bild
double dblHeight = img.Height;
double dblWidth = img.Width;
double dblFactor = 0.0;
if (dblHeight >= dblWidth)
dblFactor = dblHeight / pictureBox1.Height;
else
dblFactor = dblWidth / pictureBox1.Width;
pictureBox1.Width = pictureBox1.Height *2;
dblHeight = dblHeight / dblFactor;
dblWidth = dblWidth / dblFactor;
Bitmap result = new Bitmap((int) dblWidth,(int) dblHeight);
Graphics g = Graphics.FromImage(result);
g.DrawImage(img,new Rectangle(0,0,(int) dblWidth, (int)
dblHeight),
new Rectangle(0,0,img.Height,img.Width),GraphicsUnit.Pixel);
pictureBox1.Image = result;
Antwort schreibenBitte melde dich an, um einen Beitrag zu schreiben. |
Anzeige
|