-
|
In my Apps I already have some functions to load my SVG as Now I wonder if it is possible to draw a SVG when I have the Byte-Array? it's not possible for me to simply give a Plus:
So maybe there is a documentation about how I could Rewrite my own SvgImage-Controls to use the Canvas provided by the DrawnUI 🤔 currently the Controls have their own canvas so I know: the Canvas is the Size of what I like to paint on - so I know have the Space from 0,0 to width, height available. (the Controls is a Border-Based control so in the XAML the heightRequest and such are set or MAUI is setting the size based on the parent Grid-Cell etc.) I don't know how it would work if I don't create my own Border+Canvas but instead setting a Canvas from DrawnUI … how would my control know where to draw and in what size? Basically my SvgImage Controls are like this: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Hi! Did you had the opportunity to check demo apps like Sandbox or the engine demo? I almost never load svg from source, i just use SvgString property that accepts raw svg string. For example i get stuff from app resources like I imagine you could create a string from the byte array? If this doesn't help please tell me and we would dig further! :) |
Beta Was this translation helpful? Give feedback.
-
|
From what i see in the skiasvg source you could also subclass SkiaSvg, like: |
Beta Was this translation helpful? Give feedback.
-
|
I think i should modify SkiaSvg like this: public virtual bool LoadSvgFromBytes(byte[] byteArray)
{
using (Stream stream = new MemoryStream(byteArray))
{
var svg = new SKSvg();
try
{
svg.Load(stream);
Svg = svg;
if (Svg == null)
{
throw new Exception("[SkiaSvg] Failed to load string");
}
Update();
return true;
}
catch (Exception e)
{
Super.Log($"Failed to load {e}");
}
return false;
}
}
public virtual bool CreateSvg(string loadedString)
{
byte[] byteArray = Encoding.ASCII.GetBytes(loadedString);
return LoadSvgFromBytes(byteArray);
}This way you could directly call LoadSvgFromBytes? |
Beta Was this translation helpful? Give feedback.
Hi!
Did you had the opportunity to check demo apps like Sandbox or the engine demo? I almost never load svg from source, i just use SvgString property that accepts raw svg string.
For example i get stuff from app resources like
svg.SvgString = App.Current.Resources.Get<string>("SvgDefinedInResourcesName");or
SvgString = {x:StaticResource SvgDefinedInResourcesName}or you can set
svg.SvgString = "<svg>...blablabla</svg>".I imagine you could create a string from the byte array?
If this doesn't help please tell me and we would dig further! :)