简体   繁体   English

使用C#中的通用Windows应用程序进行图像编辑

[英]Image editing with universal windows app in C#

I am trying to build a Universal Windows App in C# that involves opening an image, re-sizing it, editing some of the pixels' RGB values and saving it again. 我正在尝试使用C#构建通用Windows应用程序,该应用程序涉及打开图像,调整其大小,编辑一些像素的RGB值并再次保存。 After looking around the net for a while I found that most people seemed to be using the namespace "System.Drawing.Imaging" to do similar things, however when I tried to include "System.Drawing.Imaging", Visual Studio told me that the namespace didn't exist. 在网上浏览了一会儿之后,我发现大多数人似乎正在使用名称空间“ System.Drawing.Imaging”来做类似的事情,但是当我尝试包含“ System.Drawing.Imaging”时,Visual Studio告诉我名称空间不存在。

I believed this may just be that some namespaces that are available for .NET programs are not available for Universal Windows Apps, so I tried looking around some more and found a similar namespace that could be used, "Windows.UI.Xaml.Media.Imaging", however this one is much more limited than "System.Drawing.Imaging" and cannot read or edit pixels as far as I could tell. 我认为这可能只是.NET程序可用的某些名称空间不适用于Universal Windows Apps,所以我尝试了一些其他内容,并找到了可以使用的类似名称空间“ Windows.UI.Xaml.Media。图像”,但是比“ System.Drawing.Imaging”要受限制得多,据我所知,它无法读取或编辑像素。

Is there another namespace I could use, or a way to get "System.Drawing.Imaging" to in a Universal Windows App? 我可以使用另一个名称空间,还是在通用Windows应用程序中获取“ System.Drawing.Imaging”的方法? If there isn't anyway of doing something like this with a Universal Windows App in C#, is there a way to do it in another language? 如果仍然无法使用C#中的通用Windows应用程序执行类似的操作,是否可以使用另一种语言来执行此操作? Any tips or pointers would help. 任何提示或指示将有所帮助。

For straight pixel manipulations you can use Windows.UI.Xaml.Media.Imaging WriteableBitmap and stream out of and back into its PixelBuffer property. 对于直接像素操作,您可以使用Windows.UI.Xaml.Media.Imaging WriteableBitmap并从其PixelBuffer属性中流传回。 There is a third party library WriteableBitmapEx which provides extension methods to perform higher level manipulations on the buffer. 有一个第三方库WriteableBitmapEx ,它提供扩展方法以对缓冲区执行更高级别的操作。

Another alternate is the Win2D library which exposes the low level Direct2D and DirectWrite libraries to UWP apps. 另一个替代方法是Win2D库,它向UWP应用程序公开了低级Direct2D和DirectWrite库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM