2016-03-01 65 views
2

使用SkiaSharp我研究为未来的项目使用SkiaSharp,目前提供的文档在GitHub上以下内容:在Visual Studio

https://developer.xamarin.com/guides/cross-platform/drawing/introduction/

我在Windows 7上的Visual Studio 2013开发。我尝试使用Xamarin Android App项目类型,但它需要SkiaSharp软件包中的DllImportAttribute的营业执照。

我想知道是否有可能选择一个C#Visual Studio项目,将一些如何能够显示SkiaSharp画布,如果是的话,我将如何做到这一点?

+1

怎么来的downvote,请解释一下,所以我可以改变我的问题 –

+0

我是继上手指南其中并未包含Windows整合。感谢您指出样品:-) –

回答

6

该评论的链接目前已被打破。由于“样本”文件夹可能会再次改变路径,所以需要的人可以从https://github.com/mono/SkiaSharp页面开始探索。

关于使用SkiaSharp可以在API documentation online与本文有关与skia sharp

对于谁需要了解如何在这里使用它的一些例子实用的快速启动绘图中可以找到更多信息:

获得的SKCanvas

using (var surface = SKSurface.Create (width: 640, height: 480, SKColorType.N_32, SKAlphaType.Premul)) { 
SKCanvas myCanvas = surface.Canvas; 

// Your drawing code goes here. 
} 

绘制文本

// clear the canvas/fill with white 
canvas.DrawColor (SKColors.White); 

// set up drawing tools 
using (var paint = new SKPaint()) { 
    paint.TextSize = 64.0f; 
    paint.IsAntialias = true; 
    paint.Color = new SKColor (0x42, 0x81, 0xA4); 
    paint.IsStroke = false; 

    // draw the text 
    canvas.DrawText ("Skia", 0.0f, 64.0f, paint); 
} 

绘制位图

Stream fileStream = File.OpenRead ("MyImage.png"); 

// clear the canvas/fill with white 
canvas.DrawColor (SKColors.White); 

// decode the bitmap from the stream 
using (var stream = new SKManagedStream(fileStream)) 
using (var bitmap = SKBitmap.Decode(stream)) 
using (var paint = new SKPaint()) { 
    canvas.DrawBitmap(bitmap, SKRect.Create(Width, Height), paint); 
} 

用图像过滤器绘制

Stream fileStream = File.OpenRead ("MyImage.png"); // open a stream to an image file 

// clear the canvas/fill with white 
canvas.DrawColor (SKColors.White); 

// decode the bitmap from the stream 
using (var stream = new SKManagedStream(fileStream)) 
using (var bitmap = SKBitmap.Decode(stream)) 
using (var paint = new SKPaint()) { 
    // create the image filter 
    using (var filter = SKImageFilter.CreateBlur(5, 5)) { 
    paint.ImageFilter = filter; 

    // draw the bitmap through the filter 
    canvas.DrawBitmap(bitmap, SKRect.Create(width, height), paint); 
    } 
}