0

Rhino (アーキテクチャ) プラグインである Grasshopper 3D のコンポーネントを開発しています。

メソッドを使用して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. ピクセルを通過する際の例外 BMP C#

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

ただし、上記の例は主に多次元配列に適用されますが、私は 1 次元配列を持っています。

他の誰かが以前にこの問題を抱えていたのではないかと思っていました。

ありがとう。

4

1 に答える 1