TextureCache
Since v9.0Rhino identifies a texture by a name. Normally that name is the path of an image file, but it does not have to be: a name registered here shadows the file system, so any texture that refers to the name - a Texture, a DisplayMaterial, a Material - draws the pixels registered here instead of reading a file.
Calling Set(string, Bitmap) again with the same name replaces the pixels in place.
var bitmap = new System.Drawing.Bitmap(512, 512);
// ...paint into bitmap...
Rhino.Display.TextureCache.Set("MyPaintTool:canvas", bitmap);
material.SetBitmapTexture("MyPaintTool:canvas");
doc.Views.Redraw();Methods
| name (string) | The name to look for. |
| name (string) | The name to look for. |
Anything still pointing at the name falls back to looking for an image file called that, so remove a name only once nothing is drawing it.
| name (string) | The name to remove. |
The bitmap's pixels are copied, so the caller stays free to keep painting into the same bitmap and call this again. Replacing the pixels of a name that is already in use invalidates the copy the display holds on the GPU, so the new pixels appear on the next redraw of any viewport that draws the texture.
| name (string) | The name to register the pixels under. Any string will do as long as it is used consistently; prefixing it with something specific to your tool avoids colliding with another plug-in, or with a real image file path. Comparison is case-insensitive and treats forward and back slashes as equivalent, the same as texture file paths. |
| bitmap (Bitmap) | The pixels to use. |