2013-12-19 11 views
0

Rhino (아키텍처) 플러그인 인 Grasshopper 3D 용 구성 요소를 개발 중입니다."매개 변수는 양수 여야하며 <높이 매개 변수 이름 : y"오류입니다.

Render() 메서드를 사용하면 히트 맵 이미지가 캔버스에 그려집니다. 내 다른 메서드 및 생성자를 격리,이 메서드는 내 문제를 일으키는 것으로 매우 믿습니다.

protected override void Render(Grasshopper.GUI.Canvas.GH_Canvas canvas, Graphics graphics, Grasshopper.GUI.Canvas.GH_CanvasChannel channel) { 
    // Render the default component. 
    base.Render(canvas, graphics, channel); 

    // Now render our bitmap if it exists. 
    if (channel == Grasshopper.GUI.Canvas.GH_CanvasChannel.Wires) { 
     KT_HeatmapComponent comp = Owner as KT_HeatmapComponent; 
     if (comp == null) 
      return; 

     List<HeatMap> maps = comp.CachedHeatmaps; 
     if (maps == null) 
      return; 

     if (maps.Count == 0) 
      return; 

     int x = Convert.ToInt32(Bounds.X + Bounds.Width/2); 
     int y = Convert.ToInt32(Bounds.Bottom + 10); 

     for (int i = 0; i < maps.Count; i++) { 
      Bitmap image = maps[i].Image; 
      if (image == null) 
       continue; 

      Rectangle mapBounds = new Rectangle(x, y, maps[i].Width * 10, maps[i].Height * 10); 
      mapBounds.X -= mapBounds.Width/2; 

      Rectangle edgeBounds = mapBounds; 
      edgeBounds.Inflate(4, 4); 

      GH_Capsule capsule = GH_Capsule.CreateCapsule(edgeBounds, GH_Palette.Normal); 
      capsule.Render(graphics, Selected, false, false); 
      capsule.Dispose(); 

      // Unnecessary graphics.xxxxxx methods and parameters 

      y = edgeBounds.Bottom + 10; 
     } 
    } 
} 

내 캔버스에 물건을 렌더링하려고 할 때 나타나는 오류는 다음과 같습니다 내 연구에서

1. Solution exception:Parameter must be positive and < Height. 
Parameter name: y 

, 일이 나타나는 가장 당신이 배열 오버 플로우가 발생합니다.

내 연구 링크 :

  1. http://www.codeproject.com/Questions/158055/Help-in-subtraction-of-two-images

  2. Exception on traveling through pixels BMP C#

  3. http://www.c-sharpcorner.com/Forums/Thread/64792/

그러나, 위의 예는 다차원 배열에 주로 WHI 적용 르 1 차원입니다.

다른 사람이이 문제를 전에 가지고 있었는지 궁금 해서요, 그리고 몇 가지 지침과 지침을 줄 수 있습니까?

감사합니다.

+0

@theGreenCabbage - 정확히 어떤 줄이 오류입니까? 디버거 내의 변수 값을 검사하여 범위를 벗어난 변수를 파악 했습니까? – McAden

+0

@McAden 경고 또는 오류없이 코드가 컴파일되므로 실제로 확신 할 수 없습니다. 어떻게 디버깅을 시작해야한다고 생각하니? – theGreenCabbage

+0

오류가 Render 메서드에 있다고 생각합니다. 거기에 중단 점을 넣고 잘못된 값을 찾으십시오. 특히 범위를 벗어난 값을 찾는 조건부 중단 점을 시도 할 수 있습니다. – McAden

답변

1
int x = Convert.ToInt32(Bounds.X + Bounds.Width/2); 
int y = Convert.ToInt32(Bounds.Bottom + 10); 

귀하의 오류가 y가 높이보다 작아야 함을 말하고있다,하지만 당신은 Bounds.Bottom에 추가되기 때문에 당신은 더 높이 10로 설정되어 있습니다.

maps[i].Height * 10 

는 또한 Height 당신이 생각하고 y가에 대한 유효 함을 비교하는 것입니다 계산 있는지 확인해야합니다.

+0

문제는 Render() 메소드에 없었지만 감사합니다. 내 의견을 상기시켜주기 위해서. – theGreenCabbage