Click or drag to resize

DisplayPipelineDrawBitmap Method

Draws a bitmap in screen coordinates

Namespace:  Rhino.Display
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.10
Syntax
public void DrawBitmap(
	DisplayBitmap bitmap,
	int left,
	int top
)

Parameters

bitmap
Type: Rhino.DisplayDisplayBitmap
bitmap to draw
left
Type: SystemInt32
where top/left corner of bitmap should appear in screen coordinates
top
Type: SystemInt32
where top/left corner of bitmap should appear in screen coordinates
Examples
using System.Drawing;
using Rhino;
using Rhino.Commands;
using Rhino.Display;

namespace examples_cs
{
  public class DrawBitmapConduit : Rhino.Display.DisplayConduit
  {
    private readonly DisplayBitmap m_display_bitmap;

    public DrawBitmapConduit()
    {
      var flag = new System.Drawing.Bitmap(100, 100);
      for( int x = 0; x <  flag.Height; ++x )
          for( int y = 0; y < flag.Width; ++y )
              flag.SetPixel(x, y, Color.White);

      var g = Graphics.FromImage(flag);
      g.FillEllipse(Brushes.Blue, 25, 25, 50, 50);
      m_display_bitmap = new DisplayBitmap(flag);
    }

    protected override void DrawForeground(Rhino.Display.DrawEventArgs e)
    {
      e.Display.DrawBitmap(m_display_bitmap, 50, 50);
    }
  }

  public class DrawBitmapCommand : Command
  {
    public override string EnglishName { get { return "csDrawBitmap"; } }

    readonly DrawBitmapConduit m_conduit = new DrawBitmapConduit();

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      // toggle conduit on/off
      m_conduit.Enabled = !m_conduit.Enabled;

      RhinoApp.WriteLine("Custom conduit enabled = {0}", m_conduit.Enabled);
      doc.Views.Redraw();
      return Result.Success;
    }
  }
}
Python
import Rhino
from Rhino.Geometry import *
import System.Drawing
import Rhino.Display
import scriptcontext
import rhinoscriptsyntax as rs

class CustomConduit(Rhino.Display.DisplayConduit):
    def __init__(self):
      flag = System.Drawing.Bitmap(100,100)
      for x in range(0,100):
        for y in range(0,100):
          flag.SetPixel(x, y, System.Drawing.Color.Red)
      g = System.Drawing.Graphics.FromImage(flag)
      g.FillEllipse(System.Drawing.Brushes.Blue, 25, 25, 50, 50)
      self.display_bitmap = Rhino.Display.DisplayBitmap(flag)

    def DrawForeground(self, e):
      e.Display.DrawBitmap(self.display_bitmap, 50, 50)

if __name__== "__main__":
    conduit = CustomConduit()
    conduit.Enabled = True
    scriptcontext.doc.Views.Redraw()
    rs.GetString("Pausing for user input")
    conduit.Enabled = False
    scriptcontext.doc.Views.Redraw()
See Also