Skip to content

Colormap: Add GetImage() to compliment GetSKBitmap() #4371

@swharden

Description

@swharden

This is present

/// <summary>
/// Create a 1 by 256 bitmap displaying all values of a heatmap
/// </summary>
public static SKBitmap GetSKBitmap(this IColormap colormap, bool vertical)
{
uint[] argbs = Enumerable.Range(0, 256)
.Select(i => colormap.GetColor((vertical ? 255 - i : i) / 255f).ARGB)
.ToArray();
int bmpWidth = vertical ? 1 : 256;
int bmpHeight = !vertical ? 1 : 256;
SKBitmap bmp = Drawing.BitmapFromArgbs(argbs, bmpWidth, bmpHeight);
return bmp;
}

However it would be nice to have a similar method that returned a ScottPlot.Image

This may be as simple as a one-liner, because I think an Image can be constructed form a GetSKBitmap

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions