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

Cannot render properly #51

Closed
claunia opened this issue Sep 9, 2018 · 2 comments
Closed

Cannot render properly #51

claunia opened this issue Sep 9, 2018 · 2 comments

Comments

@claunia
Copy link

claunia commented Sep 9, 2018

Tried with several SVGs:

Sample svg
image

Gets rendered as:
image

And
Sample svg
image

Is completely invisible.

Code:

            SKSvg                svg      = new SKSvg();
            SKEncodedImageFormat skFormat = SKEncodedImageFormat.Png;
            svg.Load(svgStream);
            //SKRect   svgSize   = svg.Picture.CullRect;
            float canvasMin = Math.Min(svg.Picture.CullRect.Width, svg.Picture.CullRect.Height);
            float svgMax = Math.Max(svg.Picture.CullRect.Width, svg.Picture.CullRect.Height);
            float scale = canvasMin / svgMax;
            var matrix = SKMatrix.MakeScale(scale, scale);
            SKBitmap bitmap    = new SKBitmap((int)svg.Picture.CullRect.Width, (int)svg.Picture.CullRect.Height);
            SKCanvas canvas    = new SKCanvas(bitmap);
            canvas.DrawPicture(svg.Picture, ref matrix);
            canvas.Flush();
            SKImage      image = SKImage.FromBitmap(bitmap);
            SKData       data  = image.Encode(skFormat, 100);
            MemoryStream outMs = new MemoryStream();
            data.SaveTo(outMs);
            cachedRender = outMs.ToArray();
            base.Image   = new Bitmap(cachedRender);
            FileStream foo = new FileStream("/mnt/datos/foo.png", FileMode.Create);
            foo.Write(cachedRender, 0, cachedRender.Length);
            foo.Close();
@AxelUser
Copy link
Contributor

Hi, Natalia.
Seems like this is the same bug, as in #42

@mattleibow
Copy link
Contributor

Closing this as it is a duplicate of #42 fixed in #44

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

3 participants