Image in C# Windows Forms

Asked

Viewed 109 times

2

I’m doing a new project using C# windows Forms, and I needed to open an image and rotate it only horizontally. I looked for some examples on the Internet, but I couldn’t find one that was clear. Does anyone have an example that can help me.

  • You’ll need to give a little more information, show a template of how you want it, in which control it will stay and what your code is.

  • I have not written any code yet, I am reading and trying to understand how it works to so begin. What I need is to put this panoramic image in a form and rotate it only horizontally. @Khaosdoctor

  • I believe picturebox has a property for this: - http://msdn.microsoft.com/en-us/library/ms750475(v=vs.110). aspx, http://stackoverflow.com/questions/2163829/how-do-i-rotata-picture-in-c-sharp, http://msdn.microsoft.com/en-us/library/3b575a03(v=vs.110). aspx

1 answer

0

Try to insert a PictureBox within a Panel whose property AutoScroll be it True, and then modify the property Height of the image within the PictureBox to be the same as Panel.

Consider pb your PictureBox, p the Panel that we will use, and img the Panorama Image:

//crie um handler no "p" para o evento "Load"
void p_Load(Object sender, EventArgs args) {
   // isso irá ativar a ScrollBar automática no painel
   p.AutoScroll = true;

   // adiciona o controle "pb" para dentro do painel
   p.Controls.Add(pb);

   // modifica a localização e dimensões da imagem
   pb.Location = new Point(0, 0);
   // define a imagem para o pb
   pb.Image = img;
   // auto ajusta a imagem
   pb.SizeMode = PictureBoxSizeMode.StretchImage;
   // chama a variável "SystemInformation.HorizontalScrollBarWidth"
   // que é o tamanho horizontal da scroll bar
   pb.Size = new Point(img.Width, img.Height -  SystemInformation.HorizontalScrollBarWidth - 1);
   // atualiza a PictureBox
   pb.Refresh();
}

if you want to update the image, just call the method p_Load again.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.