Table Of Contens 1. Class Example |
1. Example
class ProcessingSVG
{
public List SVGlist = new List();
// SVG를 처리하는 Class
public class SvgClass
{
private SkiaSharp.Extended.Svg.SKSvg svg;
// Get file .svg to folder Images
// Form Embeded Resoure
Stream GetImageStream(string svgName, Type PageType)
{
TypeInfo PageInfo = PageType.GetTypeInfo();
Assembly assembly = PageInfo.Assembly;
var abc = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.Images.{svgName}");
return abc;
}
// return picture of the SVG
public SKPicture GetPicture()
{
return svg.Picture;
}
public void LoadSvg(string svgName, Type PageType)
{
// create a new SVG object
svg = new SkiaSharp.Extended.Svg.SKSvg();
// load the SVG document from a stream
using (var stream = GetImageStream(svgName, PageType))
svg.Load(stream);
}
}
}
// Save SVG File
ProcessingSVG XX_SVG = new ProcessingSVG();
const int NumberOfSVG = 10;
void LoadSVGimage()
{
// Data Exist
if (XX_SVG.SVGlist != null) XX_SVG.SVGlist.Clear();
for(int i=0; i< NumberOfSVG; i++)
{
var oneSVG = new ProcessingSVG.SvgClass();
oneSVG.LoadSvg("test"+i.ToString()+".svg", typeof(MainPage));
XX_SVG.SVGlist.Add(oneSVG);
}
}
// Draw SVG Picture
canvasXX.Save();
canvasXX.Scale(0.1f);
canvasXX.DrawPicture(XX_SVG.SVGlist[7].GetPicture(), 0,0);
canvasXX.Restore();
2. Reference
https://stackoverflow.com/questions/58259473/how-to-load-file-svg-with-skiasharp-on-xamarin-forms
'컴퓨터 이야기 > xamarin' 카테고리의 다른 글
[xamarin]Android icon folder (0) | 2020.06.03 |
---|---|
[xamarin]embedded resource로 mp3 등록 하여 소리내기 (0) | 2020.06.02 |
[xamarin] Screen Tap Event Handler (0) | 2020.05.14 |
[svg] SVG 파일을 만들어 주는 곳 (0) | 2020.05.14 |
[xamarin] SKShader Class (0) | 2020.05.09 |