如何绘制旋转文本SkiaSharp
.
目前我正在旋转SKCanvas
,绘制文本然后将其旋转回来.但我想可能有更有效的方法来做到这一点.
canvas.RotateDegrees(45, 20, 20);
canvas.DrawText("Text", 20, 20, paint);
canvas.RotateDegrees(-45, 20, 20);
Run Code Online (Sandbox Code Playgroud) I think this error started happening after I change the provisioning profile.
My app is on visual 2017 Xamarin.Forms project and building through on Windows PC connected to a MAC book. The Android and UWP projects works fine.
I have tried:
Here is the error:
/Users/myusername/Library/Caches/Xamarin/mtbs/buildsenter code here/MyAppName.iOS/ec3fa8c87274cfb85c8423bb8f475608/bin/iPhone/Debug/MyAppName.iOS.app/Frameworks/libSkiaSharp.framework/libSkiaSharp: replacing existing signature …
假设我有svg文件,如下所示:
"<svg height='300' width='300'><rect class='rect us' id='12212' x='34' y='54' width='20' height='20'/><rect class='rect us' id='12213' x='64' y='54' width='20' height='20'/></svg>
Run Code Online (Sandbox Code Playgroud)
是否可以按给定的点命中SVGElement测试并获得该元素的ID?如果可以,我该如何完成这项任务?我做了一些谷歌搜索,却找不到任何东西。
我正在评估 SkiaSharp 库(来自 nuget,版本 1.59.3)。一切都渲染得很好。但 Skia 似乎并没有使用 GPU 来加速渲染。Windows 10 任务管理器未检测到我的测试应用程序对 GPU 的任何使用。我正在使用下一个命令来创建 SKCanvas:
using (SKBitmap bitmap = new SKBitmap(gWidth, gHeight, SKColorType.Bgra8888, alphaType))
using (SKCanvas canvas = new SKCanvas(bitmap))
{ ... }
Run Code Online (Sandbox Code Playgroud)
GPU加速是否需要某种特殊的方式来初始化SkiaSharp?
我尝试过下一个命令:
GRContext context = GRContext.Create(GRBackend.OpenGL);
Run Code Online (Sandbox Code Playgroud)
但它返回 null。
当我从 GPS 传感器读取数据时,有轻微的延迟。你不会得到像 0,1 0,2 0,3 0,4 0,5 等这样的值,但它们会像 1 一样突然变成 5 或 9 或 12。在这种情况下,针会来回跳动。有人知道如何使针顺利移动吗?我想需要某种延迟?
类似的东西,取自另一个控件:
async void animateProgress(int progress)
{
sweepAngle = 1;
// Looping at data interval of 5
for (int i = 0; i < progress; i=i+5)
{
sweepAngle = i;
await Task.Delay(3);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我有点困惑如何实现它。
以下是在画布上绘制针的代码:
private void OnDrawNeedle()
{
using (var needlePath = new SKPath())
{
//first set up needle pointing towards 0 degrees (or 6 o'clock)
var widthOffset = ScaleToSize(NeedleWidth / 2.0f);
var …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Xamarin.forms 制作应用程序。我正在使用 SkiaSharp 绘制 2d 视图。
我可以在 iOS pcl 端使用 SetNeedDisplay 来制作动画。
但我想从 Forms pcl 调用它。有没有这样的方法?
我承认我是 Xamarin 和跨平台开发的新手,所以如果这看起来是一个微不足道的问题,我深表歉意,但我已经花了几个晚上试图弄清楚它的真相。
我有一个基本的 Xamarin Forms 应用程序,它在 Windows 8.1、Windows UWP 和 Android 中运行。它使用 SkiaSharp 来处理一些基本图形(基于 Skia 示例)。
它在所有三个平台上运行,但我必须删除 Xamarin 包并将其重新添加到项目中,并且我无法让 SkiaSharp 在 Windows 或 Android 中正常运行。我收到 BadImageFormatException:
Additional information: Could not load file or assembly 'SkiaSharp, Version=1.56.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
我在 Windows 8.1 版本的 x86、x64 和任何 CPU 配置以及 Android 版本中遇到此异常。
如果我运行 UWP 项目,它会完美运行。
相关项目结构: …
如何使用Skia Sharp添加rect或任何形状,并在iOS中将填充颜色和笔触颜色应用于该对象
我正在尝试SkiaSharp
使用以下代码将照片旋转到90度:
public SKBitmap Rotate()
{
var bitmap = SKBitmap.Decode("test.jpg");
using (var surface = new SKCanvas(bitmap))
{
surface.RotateDegrees(90, bitmap.Width / 2, bitmap.Height / 2);
surface.DrawBitmap(bitmap.Copy(), 0, 0);
}
return bitmap;
}
Run Code Online (Sandbox Code Playgroud)
但是当我将位图保存到JPEG
文件时,它在图像的顶部和底部都有边距.
原图:http://imgur.com/pGAuko8.旋转图像:http://imgur.com/bYxpmI7.
我究竟做错了什么?
结构中有一组预定义的颜色SkiaSharp.SKColors
.它们作为静态字段公开公开SKColor
.
我想提取这些字段并创建一个列表SKColor
.我的尝试如下,但我不知道在代码中指出的地方该做什么.
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Example
{
class Program
{
static void Main()
{
Type type = typeof(SKColors);
FieldInfo[] fis = type.GetFields(BindingFlags.Static | BindingFlags.Public);
List<SKColor> colors = new List<SKColor>();
foreach(FieldInfo fi in fis)
{
//colors.Add(fi.WhatIsThis); // The point in question
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是摘录SKColors
:
//
// Just contains various utility colors
//
// Author:
// Miguel de Icaza
//
// Copyright 2016 Xamarin Inc
// …
Run Code Online (Sandbox Code Playgroud)