计算单色 BMP 的 BITMAPINFOHEADER 双压缩值
希望有人能给出答案,而且答案并不太复杂。 我正在开发 C++ dll(没有 C# 或 .Net,完全静态 DLL)。
无论如何,它适用于内置单色位图。 除了决议之外,我已经完成了所有工作。 我获取设备上下文,获取兼容的设备上下文,构建位图,绘制我需要的内容(黑/白),并且可以保存。 这一切都运行良好。 但是,我不知道如何设置位图的分辨率。
在 C# 下从另一个实用程序进行一些测试时,我可以创建位图并设置分辨率。 为此,我运行了一个例程来生成相同的文件内容,其分辨率参数为 1 到 300。 除了“biCompression”DWORD 属性中的值外,每个图像的结果都完全相同。 默认的屏幕分辨率为 96x96,但对于 300x300 的打印机,甚至有些分辨率为 203x203 的打印机,需要明显更改。
Hopefully someone has an answer, and it's not TOO complex. I'm working on a C++ dll (no C# or .Net, fully static DLL).
Anyhow, its woring on buildin monochrome bitmaps. I have all of it working EXCEPT the resolution. I get the Device Context, Get Compatible Device Context, build bitmap, draw what I need to (as black/white), and can save. All this works fine. However, I can't figure out how to set the resolution of the bitmap.
While doing some testing from another utility under C#, I can create a bitmap and set the resolution. In doing so, I ran a routine to generate the same file content with a parameter from 1 to 300 for the resolution. Each image came out exactly the same EXCEPT for the values in the "biCompression" DWORD property. The default is the screen resolution of 96x96, but need to obviously change for printers of 300x300, and even some at 203x203 resolution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你绝对确定吗? 您观察到的行为的描述对我来说听起来很可疑,我怀疑您用来编写位图的代码或读回它们的代码。
Are you absolutely sure? The description of the behavior you observe sounds fishy to me and I would suspect the code that you're using to write your bitmaps or your code that reads them back in.
您确定不想设置
biXPelsPerMeter
和biYPelsPerMeter
吗? 这两个字段告诉您 X 和 Y 方向每米有多少像素,您可以使用它来设置 DPI。biCompression
仅处理位图的压缩类型,例如 RLE、JPG、PNG 等。Are you sure you don't want to set
biXPelsPerMeter
andbiYPelsPerMeter
? Those two fields tell you how many pixels per meter in X and Y, which you can use to set the DPI.biCompression
only deals with the compression type of the bitmap, e.g., RLE, JPG, PNG, etc.感谢您的意见,但我也会研究 biXPelsPerMeter 和 biYPels...。 我会仔细检查格式以及设置的内容...如果是这样,您可能已经用第二双眼睛(思想)来解决我的问题。
谢谢
Thanks for input, but I'll look into the biXPelsPerMeter an biYPels... too. I'll double check the format, and what was set... if so, you may have hit it with a second set of eyes (minds) on my issue.
Thanks