0

Formu Resme Dönüştürme

Formun belli bir bölümünü resim olarak kaydetme..

            int x = 50; // Where inside the form do you want to take a snapshot
            int y = 20; // Where inside the form do you want to take a snapshot
            int width = 500; // width of snapshot
            int height = 300; // height of snapshot

            int formLocX = this.Location.X; // Where is the form on the desktop?
            int formLocY = this.Location.Y; // Where is the form on the desktop?
            int offsetX = this.Size.Width - this.DisplayRectangle.Width; // this is the offset, i.e. the border
            int offsetY = this.Size.Height - this.DisplayRectangle.Height; // this is the offset, i.e. the border
            x = x + formLocX + offsetX; // Add where you want the screenshot taken with its location and the offset
            y = y + formLocY + offsetY; // Add where you want the screenshot taken with its location and the offset

            Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(bmp);
            g.CopyFromScreen(x, y, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);

            pictureBox1.Image = bmp;

admin

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir