TH-Soft wrote:
Extragorey wrote:
I've found the issue! The images I was trying to render (both BMP and PNG formats) had a pixel format of PixelFormat.Format1bppIndexed, which MigraDoc apparently doesn't like.
1 BPP works in BMP format, but not in PNG format.
1 BPP works for PNG when using the GDI or WPF builds. And "since I only need the code to run on Windows" you can use one of those builds.
You might get smaller PDF files when converting to 1 BPP BMP instead of 32 BPP PNG. And 8 BPP PNG is also supported and may also lead to smaller PDF files.
You're right, the BMP's pixel format was Format24bppRgb, not 1 BPP. Annoying how the QRCoder library's output is so inconsistent. I've now changed it to use Format8bppIndexed, which seems to work.
My initial approach was to use the GDI build as you suggest, which greatly simplifies font and image handling, but it forces projects to target net6.0-windows which has massive caveats for a web application, even when only running it on Windows. Namely, it doesn't even use the same .NET 6 runtime, but the "Desktop Runtime" instead. This also seems to prevent on-the-fly updates/deployments as the application's DLL files are locked by the system. All fine and dandy for a WinForms application, perhaps, but not for a web API hosted in IIS.
I found all this out through a long, frustrating process of trial and error, as you would think there's no harm in targeting net6.0-windows in an application that's only going to run on Windows. Big mistake.