问题标签 [bitmapframe]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
309 浏览

c# - 在 async 方法中异步创建 BitmapFrame

任何人都知道如何BitmapFrame在 WPF 中异步创建?

我想批量打印其属性设置在代码后面的 XAMLImage元素。SourceLogoImageUrl是我要异步加载的 Web 图像的 URL。

我可以创建这样的async方法:

...所以我可以在一个try块中使用该方法,然后在finally块中打印它?

0 投票
1 回答
1120 浏览

c# - 例外:BitmapFrameDecode 必须将 IsFrozen 设置为 false 才能修改

我有一个用 C# WPF 编写的程序来自动打印文档。它具有的功能之一是它可以检测图像下载失败,因此具有该空图像的文档不会被打印。

这是检测“发件人徽标”图像下载失败的代码的一部分:

当调用事件处理程序BitmapFrameDownloadFailed_senderLogoFrame.DownloadFailed,会发生此异常:

shippingLabelForm.CreateDocument 异常:“System.Windows.Media.Imaging.BitmapFrameDecode”类型的指定值必须将 IsFrozen 设置为 false 才能修改。堆栈跟踪:在 InvoicePrintingClient.Form.ShippingLabelForm.SetDataToElements() 的 InvoicePrintingClient.Form.ShippingLabelForm.d__18 的 System.Windows.Media.Imaging.BitmapSource.add_DownloadFailed(EventHandler`1 value) 的 System.Windows.Freezable.WritePreamble()。 MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 InvoicePrintingClient 的 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) .Main.PrintClientMainWindow.<>c__DisplayClass101_1.<b__4>d.MoveNext()

IsFrozen设置为false是什么意思?它与BitmapSource.DownloadFailure事件处理程序有什么关系吗?我该怎么做才能解决这个问题?

0 投票
2 回答
374 浏览

c# - C# BitmapFrame.Thumbnail 属性对于某些图像为空

我正在尝试修改此项目以在目录中显示图像。但问题是该代码不适用于像这样的所有图像。所以问题是

在存储库中,某些图像的BitmapFrame.Thumbnail属性为 null。我没有发现这些图像有什么问题。

如何使其适用于所有图像?

工作示例 不工作示例工作示例 不工作的例子

0 投票
1 回答
131 浏览

c# - 如何在 WPF C# 中覆盖(使用)BitmapFrame.Thumbnail 属性?

你好!问题是?我有一个要显示的多页 Tiff 文件,并且我使用 BitmapFrame.Thumbnail 属性来显示我的多页 Tiff 文件的每一帧(页面)的小尺寸缩略图。但是<出于某种原因?该属性返回 null。请给出一步一步的描述,这应该怎么做?

我已经尝试使用此方法创建自己的 BitmapSource 缩略图:

然后我将结果转换为 BitmapSource 并使用以下命令创建 BitmapFrames 列表:

最后我尝试获取属性,但它返回null:

0 投票
0 回答
32 浏览

winforms - 在我的代码中使用 BitmapFrame.Create() 会破坏 Winforms DPI 缩放 - 即使代码没有运行

我有这个功能来检查 PNG 颜色深度:

每当此代码运行时,应用程序的 DPI 缩放将中断并重置为 100%,并且窗口不再最大化。

我已经设法隔离了导致这种情况的代码行,它是 BitmapFrame.Create()。

如果我完全跳过代码,甚至会发生这种情况,如下所示:

“return 32”之后的其他行都不会运行,但是如果我运行该函数,该错误仍然会被触发。只有当我真正注释掉这些行时它才有效。

有任何想法吗?我根本不明白这是怎么可能的,这使得调试变得困难。

0 投票
1 回答
207 浏览

c# - How can I reference WindowsBase in .Net5?

I am writing a .NET 5 class library that contains the following code:

The line with frame.CopyPixels gives the following compilation error:

CS7069 Reference to type 'Freezable' claims it is defined in 'WindowsBase', but it could not be found. Module 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf385ad364e35' should be referenced

I have been trying to add a reference to WindowsBase.dll from this path: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.8\WindowsBase.dll

But I get the following error: The reference is invalid or unsupported

The weird part is that Freezable is listed under .NET 5 in Microsoft's documentation. Maybe the issue is that I am using WindowsBase.dll intended for .NET Framework, but I don't know where the .NET 5 version would be.

Any ideas how I can solve this and get my code to compile?

Thanks!