【发布时间】:2022-09-23 02:56:16
【问题描述】:
我需要在我的 MAUI.NET 应用程序中存储一个位图对象。
要清楚 - 在我的定义中:位图是由至少具有 R、G 和 B 值的二维像素数组表示的图像。
在 .NET 4.7 中,它还不是这样的对象,但是有一个 NuGet System.Drawings.Common 允许我使用这样的对象。
如何在 MAUI.NET 中处理这种情况?
编辑: 抱歉,如果我不清楚。这是我的场景:
我不是在 UI 中绘图和图像。
我想让用户指定文件的路径,然后我需要这个图片/图像的位图,因为我需要将它传递给不同的图层/项目 - >将它传递给具有处理它的逻辑的算法。
所以这将是我将在 .NET Framework 4 中执行的代码......:
string filepath = someFileSystemDialog.Result;
Bitmap bitmap = new Bitmap(filepath); // here is the problem, in previous .NET there was Bitmap object wchich was perfect, here is lack
Bitmap processedBitmap = MyOtherProjectWithLogicAlgorithms.ProcessAnImage(bitmap);
processedBitmap.Save(finalOutputPath, ImageFormat.Png);
但是在 Maui.NET 中,我从文件对话框中得到了如下信息:
var fileResult = await FilePicker.Default.PickAsync(...);
if(fileResult != null)
{
ImageSource is = ImageSource.FromFile(fileResult.FullPath);
Bitmap bm = ??(is); // how to get Bitmap from an ImageSource ?
MyOtherProjectWithLogicAlgorithms 是另一个 .NET 项目(为了兼容性也将具有 .NET 6.0) - 我想这是将 MAUI.NET 作为依赖项项目使用所必需的。
-
你能分享一些代码吗?
-
使用 SkiaSharp 进行跨平台图形
标签: c# bitmap maui c#-6.0 .net-maui