none
Скроллинг в PictureBox RRS feed

  • Общие обсуждения

  • Я не понимаю, но у меня прямоугольник увеличенный в picturebox1 (там где увеличенное изображение), а я хочу сделать увеличенным всё фото, а не тольео этот фрагмент. (чтобы перемещаться скроллингом по фото)
    using System;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.IO;
    using System.Windows.Forms;
    
    
    
    namespace ZOS_LAB1_UNIVER
    {
        public partial class Form1 : Form
        {
            public double koef = 1;
            public int w1, h1, w_temp, h_temp;
            public Form1()
            {
                InitializeComponent();
            }
    
            
    
            private void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                Image img = new Bitmap(openFileDialog1.FileName);
                int width = img.Width;
                int height = img.Height;
    
    
                e.Graphics.InterpolationMode = InterpolationMode.Bilinear;
                e.Graphics.DrawImage(img, new Rectangle(0, 0, w1, h1), 0, 0, width, height, GraphicsUnit.Pixel);
    
    
    
    
    
    
            }
                   
    
    
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                pictureBox2.Hide();
                pictureBox1.Show();
    
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                pictureBox1.Show();
                pictureBox2.Hide();
    
    
            }
           #region koef
            
    
    
           
            
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                openFileDialog1.Filter = "BMP Picture |*.bmp";
                openFileDialog1.ShowDialog();
                pictureBox1.Hide();
                pictureBox2.Hide();
    
    
                pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);
                pictureBox1.Refresh();
                Image img2 = new Bitmap(openFileDialog1.FileName);
                pictureBox2.Image = img2;
    
                w_temp = img2.Width;
                h_temp = img2.Height;
    
            }
    
            private void button3_Click_1(object sender, EventArgs e)
            {
                pictureBox1.Show();
                pictureBox2.Hide();
               
    
            }
    
            private void pictureBox1_Click(object sender, EventArgs e)
            {
                /*openFileDialog1.Filter = "BMP Picture |*.bmp";
                openFileDialog1.ShowDialog();
                pictureBox1.Hide();
                pictureBox2.Hide();
    
    
                pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);
                pictureBox1.Refresh();
                Image img2 = new Bitmap(openFileDialog1.FileName);
                pictureBox2.Image = img2;
    
                w_temp = img2.Width;
                h_temp = img2.Height;*/
            }
    
            private void button2_Click_1(object sender, EventArgs e)
            {
                pictureBox2.Show();
                pictureBox1.Hide();  
               
    
            }
    
            private void pictureBox2_Click(object sender, EventArgs e)
            {
    
            }
    
            private void button4_Click_1(object sender, EventArgs e)
            {
                koef = 1.2;
                w1 = w_temp * Convert.ToInt16(koef);
                h1 = h_temp * Convert.ToInt16(koef);
    
    
            }
    
            private void button5_Click_1(object sender, EventArgs e)
            {
                koef = 3;
                w1 = w_temp * Convert.ToInt16(koef);
                h1 = h_temp * Convert.ToInt16(koef);
    
            }
    
            private void button6_Click_1(object sender, EventArgs e)
            {
                koef = 7;
                w1 = w_temp * Convert.ToInt16(koef);
                h1 = h_temp * Convert.ToInt16(koef);
    
            }
    
            private void button7_Click_1(object sender, EventArgs e)
            {
                koef = 21;
                w1 = w_temp * Convert.ToInt16(koef);
                h1 = h_temp * Convert.ToInt16(koef);
    
            }
    
            private void pictureBox2_Click_1(object sender, EventArgs e)
            {
    
            }
    
            private void button9_Click_1(object sender, EventArgs e)
            {
                koef = 3;
                w1 = w_temp / Convert.ToInt16(koef);
                h1 = h_temp / Convert.ToInt16(koef);
    
            }
    
            private void button8_Click_1(object sender, EventArgs e)
            {
                koef = 1.2;
                w1 = w_temp / Convert.ToInt16(koef);
                h1 = h_temp / Convert.ToInt16(koef);
    
            }
    
            private void button10_Click_1(object sender, EventArgs e)
            {
                koef = 7;
                w1 = w_temp / Convert.ToInt16(koef);
                h1 = h_temp / Convert.ToInt16(koef);
    
            }
    
            private void button11_Click_1(object sender, EventArgs e)
            {
                koef = 21;
                w1 = w_temp / Convert.ToInt16(koef);
                h1 = h_temp / Convert.ToInt16(koef);
    
            }
           #endregion
    
            private void fontDialog1_Apply(object sender, EventArgs e)
            {
                        }
    
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
    
            }
    
            private void rectangleShape1_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label2_Click(object sender, EventArgs e)
            {
    
            }
    
            private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
    
            }
    
            private void pictureBox1_Click_1(object sender, EventArgs e)
            {
    
            }
    
            private void panel1_Paint(object sender, PaintEventArgs e)
            {
    
            }
    
            private void pictureBox1_Click_2(object sender, EventArgs e)
            {
    
            }
    
            private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
            {
    
            }
    
            private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
            {
    
            }
         
    
            
        }
    }

    4 апреля 2019 г. 8:57