Skip to content

LabelStyle: add support for image labels#4517

Merged
swharden merged 5 commits intomainfrom
4503
Nov 15, 2024
Merged

LabelStyle: add support for image labels#4517
swharden merged 5 commits intomainfrom
4503

Conversation

@swharden
Copy link
Member

@swharden swharden commented Nov 15, 2024

This PR adds a nullable Image to LabelStyle so a bitmap image can be displayed anywhere a text label may be placed.

This enables users to use third-party packages to render rich text or emoji as a bitmap image, then display it as an axis label

myPlot.Add.Signal(Generate.Sin(51));
myPlot.Add.Signal(Generate.Cos(51));

// This array holds the bytes of a bitmap. Here it's generated,
// but it could be a byte array read from a bitmap file on disk.
byte[] bytes1 = SampleImages.NoisyText("Horiz", 150, 50).GetImageBytes();
byte[] bytes2 = SampleImages.NoisyText("Vert", 150, 50).GetImageBytes();

// Create a ScottPlot.Image from the bitmap bytes
ScottPlot.Image img1 = new(bytes1);
ScottPlot.Image img2 = new(bytes2);

// Display the image for the bottom axis label
myPlot.Axes.Bottom.Label.Image = img1;
myPlot.Axes.Left.Label.Image = img2;

image

@swharden swharden enabled auto-merge (squash) November 15, 2024 20:22
@swharden swharden merged commit 169f332 into main Nov 15, 2024
@swharden swharden deleted the 4503 branch November 15, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Axis: add support for image labels SP5: Implement rich text panels

1 participant