2016-03-01 66 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); 
    } 
}