Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal example for CSharpMath.SkiaSharp #226

Open
harveytriana opened this issue Sep 4, 2023 · 2 comments
Open

Fatal example for CSharpMath.SkiaSharp #226

harveytriana opened this issue Sep 4, 2023 · 2 comments

Comments

@harveytriana
Copy link

The Example2. CSharpMath.SkiaSharp, apart from having syntax errors, doesn't say anything. Suggest to replace it with the following.

using CSharpMath.SkiaSharp;
using SkiaSharp;
//...
void DrawSample()
{
    var p = pictureBox; // exists a PictureBox with name pictureBox

    // create canvas
    var imageInfo = new SKImageInfo(p.Width, p.Height);
    using var surface = SKSurface.Create(imageInfo);
    using var canvas = surface.Canvas;

    var painter = new MathPainter {
        LaTeX = @"\frac\sqrt23"
    };
    painter.Draw(canvas);

    using var snapshot = surface.Snapshot();
    using var image = snapshot.Encode(SKEncodedImageFormat.Png, 100);
    using var stream = new MemoryStream(image.ToArray());
    p.Image = new Bitmap(stream, false);
}
@Happypig375
Copy link
Collaborator

Happypig375 commented Sep 4, 2023

Where does the PictureBox come from?

@harveytriana
Copy link
Author

It is a WinForm Control, in this case a project net7.0-windows. I publish that: https://github.com/harveytriana/LaTeXForms

Of course, the canvas can be from SKCanvasView for other platforms. i.g. Blazor or MAUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants