当前位置: 首页 > news >正文

ImageSharp报错

错误信息

System.MissingMethodException: Method not found: 'System.Span`1<SixLabors.ImageSharp.PixelFormats.Rgba32> SixLabors.ImageSharp.Memory.Buffer2D`1.GetRowSpan(Int32)'.

需要升级项目

原来仅升级了SixLabors.ImageSharp没有升级drawing,都升级到最新版本
在这里插入图片描述
原来代码

//构建字体//装载字体(ttf)(而且字体一定要支持简体中文的)
var fonts = new FontCollection();
SixLabors.Fonts.FontFamily fontFamily = fonts.Install("/fonts/SourceHanSansK-Normal.ttf");
//设置为多行文本输出
SixLabors.Fonts.Font titleFont = new SixLabors.Fonts.Font(fontFamily, 60, SixLabors.Fonts.FontStyle.Regular);
//多行文本输出
var textOptions = new TextOptions()
{ApplyKerning = true,VerticalAlignment = VerticalAlignment.Top,HorizontalAlignment = HorizontalAlignment.Left,WrapTextWidth = 700
};
var graphicsOptions = new GraphicsOptions()
{Antialias = true
};
//沿着行尾的绕行路径绘制文本  
var options = new SixLabors.ImageSharp.Drawing.Processing.DrawingOptions
{GraphicsOptions = graphicsOptions,TextOptions = textOptions
};
//开始绘制文字
imageTemple.Mutate(ctx => ctx.DrawText(options, goodModel.name, titleFont, SixLabors.ImageSharp.Color.Red, new SixLabors.ImageSharp.PointF(30, 1350)));

修改后代码

//构建字体//装载字体(ttf)(而且字体一定要支持简体中文的)
var fonts = new FontCollection();
SixLabors.Fonts.FontFamily fontFamily = fonts.Add("/fonts/SourceHanSansK-Normal.ttf");
//设置为多行文本输出
SixLabors.Fonts.Font titleFont = new SixLabors.Fonts.Font(fontFamily, 60, SixLabors.Fonts.FontStyle.Regular);
//多行文本输出
var graphicsOptions = new GraphicsOptions()
{Antialias = true
};
//沿着行尾的绕行路径绘制文本  
var options = new SixLabors.ImageSharp.Drawing.Processing.DrawingOptions
{GraphicsOptions = graphicsOptions,
};
//开始绘制文字
imageTemple.Mutate(ctx => ctx.DrawText(options, goodModel.name, titleFont, SixLabors.ImageSharp.Color.Red, new SixLabors.ImageSharp.PointF(30, 1350)));

参考

https://stackoverflow.com/questions/76023548/imagesharp-watermark-net6
https://github.com/SixLabors/ImageSharp/issues/1237

http://www.lryc.cn/news/471558.html

相关文章:

  • Android中常用adb命令
  • PostgreSQL的奥秘:全面解读JSONB——非结构化数据支持的深入探索
  • tornado,flaskd这两个框架主要是干什么的
  • Sigrity Power SI Noise coupling analysis模式如何进行压降仿真分析操作指导
  • 国产游戏技术能否引领全球?
  • 【前端】在 Next.js 开发服务器中应该如何配置 HTTPS?
  • 基于深度学习算法的动物检测系统(含PyQt+代码+训练数据集)
  • 微信小程序美团点餐
  • 音频剪辑还花钱?2024年这4款免费工具让你告别烦恼
  • 【YOLO模型】(4)--YOLO V3超超超超详解!!!
  • 管理类联考 信息整理和经验分享
  • JetBrains IDE中GPU进程(JCEF)重启问题(Too many restarts of GPU-process)解决方案
  • 《泛基因组:高质量参考基因组的新标准》
  • 模型其他压缩方法
  • Python学习的自我理解和想法(22)
  • 基于neo4j的糖尿病知识图谱数据
  • 分布式搜索引擎elasticsearch操作文档操作介绍
  • C++ 中的可调用对象
  • [HBase]二 HBase原生Shell命令大全
  • Kafka之消费者客户端
  • 使用Python进行数据分析入门
  • ubuntu20 从源码编译升级到版本5.15.263
  • php 程序开发分层与验证思想
  • 关于InternVL2的单卡、多卡推理
  • Go语言设计Web框架
  • 2024年10月28日练习(双指针算法)
  • Objective-C 音频爬虫:实时接收数据的 didReceiveData_ 方法
  • 提升网站流量和自然排名的SEO基本知识与策略分析
  • 雷池社区版compose文件配置讲解--fvm
  • 基于51单片机的智能断路器proteus仿真