c# Bitmap Object

Gast #295631
Lesenswert?

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 schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren