Methods
Load a Icon from an embedded resource and convert it to a bitmap of the specified size. Will look for a icon image that is greater than or equal to the requested size, if all images are less than the requested size the largest image will be used.
public static Bitmap BitmapFromIconResource(string resourceName, Size bitmapSize, Assembly assembly = null)
Load a Icon from an embedded resource and convert it to a bitmap of the specified size. Will look for a icon image that is greater than or equal to the requested size, if all images are less than the requested size the largest image will be used.
Create bitmap of a given size from an svg string
Create bitmap of a given size from an svg string
public static List<Point2f[]> CreateCurvePreviewGeometry(Curve curve, Linetype linetype, int width, int height)
Create a series of closed polyline loops representing a curve and a linetype combination.
public static List<Point2f[]> CreateLinetypePreviewGeometryEx(Curve curve, Linetype linetype, int width, int height, double linetypeScale, int kind)
Preview geometry for a linetype on a curve, by channel, mirroring the viewport renderer. kind 0 returns the dash silhouette polygons with the line cleared under each shape (these are meant to be filled); kind 1 returns curve shape outlines (meant to be stroked); kind 2 returns text and surface shape outlines (meant to be filled with an even-odd rule).
public static Bitmap CreateMeshPreviewImage(IEnumerable<Mesh> meshes, IEnumerable<Color> colors, Size size)
Creates a preview image of one or more meshes.
Parameters:
| meshes (IEnumerable<Mesh>) | The meshes. |
| colors (IEnumerable<Color>) | The draw colors, one for each mesh. |
| size (Size) | The size of the preview image. |
Returns: A bitmap if successful, null otherwise.
Creates a preview image of a mesh.
public static Bitmap CreateMeshPreviewImage(RhinoDoc doc, IEnumerable<Mesh> meshes, IEnumerable<Color> colors, Size size)
Creates a preview image of one or more meshes.
Parameters:
| doc (RhinoDoc) | The active document. |
| meshes (IEnumerable<Mesh>) | The meshes. |
| colors (IEnumerable<Color>) | The draw colors, one for each mesh. |
| size (Size) | The size of the preview image. |
Returns: A bitmap if successful, null otherwise.
Attempt to adjust pixels to an image that works for dark mode
Attempt to adjust pixels to an image that works for dark mode
Parameters:
| rgbaBytes (ref byte[]) |
Load a Icon from an embedded resource.
Load a Icon from an embedded resource.
Parameters:
| resourceName (string) | The case-sensitive name of the icon manifest resource being requested. |
| size (Size) | The desired size of the icon. |
| assembly (Assembly = null) | The assembly containing the manifest resource, will use the calling assembly if null. |
Returns: The Icon resource if found and loaded otherwise null.
Load a Image from an embedded resource.
public static Bitmap LoadBitmapWithScaleDown(string iconName, int sizeDesired, Assembly assembly = null)
Loads an icon from an embedded resource and converts it to a bitmap. If the icon is not a standard size, this function scales down a larger image.
Parameters:
| iconName (string) | The case-sensitive name of the icon manifest resource being requested. |
| sizeDesired (int) | The desired size, in pixels, of the icon. |
| assembly (Assembly = null) | The assembly containing the manifest resource. |
Returns: The icon converted to a bitmap if successful, null otherwise.
Exceptions:
| ArgumentException | Thrown when iconName is not found as an embedded resource in the specified assembly. |
public static Icon LoadIconWithScaleDown(string iconName, int sizeDesired, Assembly assembly = null)
Loads an icon from an embedded resource. If the icon is not a standard size, this function scales down a larger image.
Parameters:
| iconName (string) | The case-sensitive name of the icon manifest resource being requested. |
| sizeDesired (int) | The desired size, in pixels, of the icon. |
| assembly (Assembly = null) | The assembly containing the manifest resource. |
Returns: The icon if successful, null otherwise.
Exceptions:
| ArgumentException | Thrown when iconName is not found as an embedded resource in the specified assembly. |
Stores a color into an integer from 4 bytes.
public static byte[] PixelsFromSvg(string svg, int width, int height, bool premultiplyAlpha, Color backgroundColor, bool adjustForDarkMode)
Get array of bytes that represent RGBA values for an image of a given size created from SVG
Parameters:
| svg (string) | A valid svg string |
| width (int) | Width of the svg in pixels |
| height (int) | Height of the svg in pixels |
| premultiplyAlpha (bool) | Pre-lends the background color with the pixels based on their alpha value |
| backgroundColor (Color) | Background color - pass Color.Empty if you don't know what to pass. |
| adjustForDarkMode (bool) | If true swaps any available attributes for their dark mode counterparts> |
Returns: Null on an exception, an array of Color as bytes otherwise
public static byte[] PixelsFromSvg(string svg, int width, int height, bool premultiplyAlpha, Color backgroundColor)
Get array of bytes that represent RGBA values for an image of a given size created from SVG
Parameters:
| svg (string) | A valid svg string |
| width (int) | Width of the svg in pixels |
| height (int) | Height of the svg in pixels |
| premultiplyAlpha (bool) | Pre-lends the background color with the pixels based on their alpha value |
| backgroundColor (Color) | Background color - pass Color.Empty if you don't know what to pass. |
Returns: Null on an exception, an array of Color as bytes otherwise