首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Visual中使用SkiaSharp

在Visual中使用SkiaSharp
EN

Stack Overflow用户
提问于 2016-03-01 09:37:11
回答 1查看 10.2K关注 0票数 2

我正在研究如何在未来的项目中使用SkiaSharp,下面是GitHub上现有的文档:

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

我正在Windows 7上开发Visual 2013,我尝试使用Xamarin项目类型,但它需要DllImportAttribute在SkiaSharp包中的商业许可证。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-11 10:37:17

该评论上的链接目前已中断。由于文件夹“示例”将来可能会再次更改路径,所以无论谁需要,都可以从https://github.com/mono/SkiaSharp页面开始探索。

有关使用SkiaSharp的更多信息,请参见API文档联机和本文中有关使用尖尖的绘图的信息。

对于谁需要一个实用的、快速的、如何在这里使用它的例子:

获得一个SKCanvas

代码语言:javascript
复制
using (var surface = SKSurface.Create (width: 640, height: 480, SKColorType.N_32, SKAlphaType.Premul)) {
SKCanvas myCanvas = surface.Canvas;

// Your drawing code goes here.
}

绘图文本

代码语言:javascript
复制
// 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);
}

绘制位图

代码语言:javascript
复制
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);
}

基于图像滤波器的绘图

代码语言:javascript
复制
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);
  }
}
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35719258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档