使用 .NET Core 操作图像 [英] Manipulating images with .NET Core

查看:67
本文介绍了使用 .NET Core 操作图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的项目从 .NET 4.5 更新到 .NET Core(使用 ASP.NET Core).我在之前的版本中有一些非常简单的代码,它们使用 System.Drawing 中的位图对象来调整图像大小.

I have updated my project from .NET 4.5 to .NET Core (with ASP.NET Core). I had some very simple code in my previous version that used the bitmap object from System.Drawing to resize an image.

据我了解 System.Drawing 不能在 .NET Core 中使用,因为它不是跨平台的,但是可以用什么代替?

As I understand System.Drawing cannot be used in .NET Core because it is not cross platform, but what can be used instead?

我用谷歌搜索了这个,找不到任何东西.我唯一能找到的是这篇帖子,上面没有任何代码.

I have googled this and cannot find anything. The only thing I can find is this post, which has no code on it what so ever.

推荐答案

免责声明:这是我的软件.

Disclaimer: This is my software.

我正在开发一个在 .NET Core 上运行的跨平台 2D 图形库,它目前是 Alpha 版,但已经支持全面的功能集.

I'm working on a cross-platform 2D Graphics library that runs on .NET Core It's currently alpha but already supports a comprehensive feature set.

https://github.com/JimBobSquarePants/ImageSharp

示例用法.

using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg"))
{
    Image image = new Image(stream);
    image.Resize(image.Width / 2, image.Height / 2)
         .Greyscale()
         .Save(output);
}

这篇关于使用 .NET Core 操作图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆