2012-09-06 6 views
0

다른 해상도 사이에서 크기가 다른 PictureBox과 관련된 문제가 있습니다.PictureBox에서 그림 영역 가져 오기

나는 그 이미지가 PictureBox인데, 크기를 스스로 조정해야하기 때문에 드로잉 크기를 알아야합니다. (그렇지 않으면 시스템이 너무 느리고,하기로 결정했습니다. 수동으로 크기 조정, 해상도가 필요한지 잘 작동합니다).

나는 PictureBox.Height/WidthPictureBox.ClientRectangle.Height/Width을 시도했지만 그 값은 모든 해상도에서 동일합니다. 실제 드로잉 크기를 얻으려면 어떻게해야합니까?

초기화 코드 :이 앵커가 설정되고 함께 할 수있다, 그러나 이것은 PictureBox를 잘 서로 다른 해상도로 볼되고 있습니다 이해

  // 
      // PicboxRed 
      // 
      this.PicboxRed.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
         | System.Windows.Forms.AnchorStyles.Left) 
         | System.Windows.Forms.AnchorStyles.Right))); 

      this.PicboxRed.BackColor = System.Drawing.Color.DimGray; 
      this.PicboxRed.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; 
      this.PicboxRed.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 
      this.PicboxRed.Location = new System.Drawing.Point(19, 92); 
      this.PicboxRed.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); 
      this.PicboxRed.Name = "PicboxRed"; 
      this.PicboxRed.Size = new System.Drawing.Size(852, 840); 
      this.PicboxRed.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Normal; 
      this.PicboxRed.TabIndex = 9; 
      this.PicboxRed.TabStop = false; 
      this.PicboxRed.Click += new System.EventHandler(this.PicboxRed_Click); 
      this.PicboxRed.Paint += new System.Windows.Forms.PaintEventHandler(this.Picbox_Paint); 

. 어떻게 그 그리기 영역을 잡을 수 있습니까?

답변

1

ClientSize 속성이 얼마나 큰 알려줍니다. ClientSizeChanged 이벤트는 폼의 AutoScaleMode 속성으로 인한 자동 확장을 포함하여 어떤 이유로 든 변경된 경우 알려줍니다.

+0

감사합니다. 실제로 표시 될 때만 초기화되고 초기화 후에는 크기가 조정되지 않습니다. 그 다음에 기대 값이 나타났다. – SinisterMJ

0

I tried PictureBox.Height/Width, and PictureBox.ClientRectangle.Height/Width, but that values are the same for all resolutions.

난 당신이 DPI 설정을 찾고 있습니다 생각 :

int currentDPI = 0; 

using (Graphics g = this.CreateGraphics()) 
{ 
    currentDPI = (int)g.DpiX;  
} 

이 값은 다른 해상도와 dpi의 설정을 컴퓨터에서 변경해야합니다.

아니면 현재 화면 해상도를 얻는 데 흥미가 있습니다. 그들은 도움이 될 수 있습니다 :

Rectangle resolution = Screen.PrimaryScreen.Bounds;

관련 문제