🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / resim döndürme

1-) C# RMOS - resim döndürme

  public Image RotateImage(Image img, float rotationAngle)

        {

            //create an empty Bitmap image

            Bitmap bmp = new Bitmap(img.Width, img.Height);

 

            //turn the Bitmap into a Graphics object

            Graphics gfx = Graphics.FromImage(bmp);

 

            //now we set the rotation point to the center of our image

            gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);

 

            //now rotate the image

            gfx.RotateTransform(rotationAngle);

 

            gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);

 

            //set the InterpolationMode to HighQualityBicubic so to ensure a high

            //quality image once it is transformed to the specified size

            gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;

 

            //now draw our new image onto the graphics object

            gfx.DrawImage(img, new Point(0, 0));

 

            //dispose of our Graphics object

            gfx.Dispose();

 

            //return the image

            return bmp;

        }

 

1-) C# RMOS - kullanımı

 

pictureBox1.Image = RotateImage(pictureBox1.Image,90);

 

3-) en iyisi bu

 Bitmap resim = (Bitmap)pictureBox1.Image;

            resim.RotateFlip(RotateFlipType.RotateNoneFlipX);

            pictureBox1.Image = resim;

 

4-) sola çevirmek için

 

 public void MyOnSolaCevir()

        {

            try

            {

                Bitmap resim = (Bitmap)pictureBoxOn.Image;

                resim.RotateFlip(RotateFlipType.Rotate270FlipNone);

                pictureBoxOn.Image = resim;

            }

            catch (Exception ex)

            {

                RHMesaj.MyMessageError(MyClass, "MySolaCevir", "", ex);

            }

        }

 

5-) sağa çevirmek için

 

public void MyOnSagaCevir()

        {

            try

            {

                Bitmap resim = (Bitmap)pictureBoxOn.Image;

                resim.RotateFlip(RotateFlipType.Rotate90FlipNone);

                pictureBoxOn.Image = resim;

            }

            catch (Exception ex)

            {

                RHMesaj.MyMessageError(MyClass, "MySolaCevir", "", ex);

            }

        }

 2021 Ocak 18 Pazartesi
 401