如何区分原始.BMP/.EMF图片文件与处理后的.BMP/.EMF文件之间的区别?
总结:
直接计算表明:一张3289 X 4570 X 32bpp的.BMP图片大约需要53MB。同样大小但24bpp的图片大约需要43MB,16bpp的图片大约需要28MB。在我的情况下,ChemDraw 处理的图片文件必须从 24bpp 转换为 16bpp。
进一步比较两个文件的十六进制数据可以更详细地了解 ChemDraw 处理的图片与原始图片之间的差异。具体来说,ChemDraw 存储“EMF_STRETCHDIBITS”而不是“EMF_STRETCHBLT”。需要补充的是,“EMF_STRETCHDIBITS”可以通过在将像素复制到 TMetaFile/TMetaFileCanvas 时调用 StretchDIBits 来完成。还应该注意的是,“EMF_STRETCHDIBITS”的像素应与“EMF_STRETCHBLT”的像素相同。
不幸的是,到目前为止我还没有弄清楚ChemDraw到底是如何处理和存储粘贴的图片的。也就是说,我没有找到为什么ChemDraw存储的像素与我通过编程获得的像素不同。
PS:稍后我会投票赞成这个问题的好答案,因为我暂时没有足够的声誉。感谢所有善意评论的人!
===
您好,
非常感谢您的宝贵时间!
假设我有一张名为“sample_original.bmp”的图片。文件大小为 3289 X 4570,43MB。然后我执行以下操作将其转换为 .EMF 文件(增强型 Windows MetaFile):
方法 1,通过制作一个小型内部 Delphi 程序: (1) 加载.BMP图像文件。 (2) 获取TMetaFile的Canvas(TMetaFileCanvas) (3) 调用Canvas.Draw复制图像。 (4) 保存为.EMF文件,命名为“sample_original_bmp2emf_method1.emf”
方法2: (1) 在mspaint程序中打开.BMP图像文件,选择“全选”,然后选择“复制”。 (2) 打开名为 ChemDraw 的外部程序,创建新文档,然后选择“粘贴”。 (3) 然后我选择将其保存为 XML 兼容的 .cdxml 格式,命名为“sample_original_bmp2emf_method2.cdxml”。 (4) 图片内容(可能已更改或降级?)现在保存在sample_original_bmp2emf_method2.cdxml 文件中。格式是 Base64 编码的 zlib 压缩格式。 (5)我可以对XML字符串进行Base64解码,zlib解压缩它,并将其保存到图片文件“sample_original_bmp2emf_method2.emf”中。
Sample_original_bmp2emf_method2.emf 的文件大小比sample_original_bmp2emf_method1.emf 小 15 MB,但宽度和宽度小于 15 MB。高度一直保持。 此外,如果我在 mspaint 程序中打开“sample_original_bmp2emf_method2.emf”并将其保存回 .bmp 文件格式,则会弹出警告,提示透明信息正在丢失。
您能帮忙评论一下如何区分“sample_original_bmp2emf_method1.emf”和“sample_original_bmp2emf_method1.emf”吗? “sample_original_bmp2emf_method2.emf”?图片变小是因为质量下降吗? 换句话说,这个外部程序可能会对我的原始图片进行哪些更改?
祝您好运,
上述文件可以在以下网址下载:
http://www .rapidspread.com/file.jsp?id=2ighvzoci8
PS:我相信 Andreas Rejbrand 已经足够友善地做出了回答,然后我发表了我的评论。但我现在看不到那些。这应该是系统的正常行为吗?奥奥
Summarization:
Calculations point out in a straight-forward way that: A .BMP picture of 3289 X 4570 X 32bpp takes about 53MB. The picture of same size but 24bpp takes about 43MB, that of 16bpp takes about 28MB. ChemDraw-processed picture file must then be converted from 24bpp to 16bpp in my situation.
Further comparison of the hex data of both files gives more detailed understanding of the difference between ChemDraw-processed picture and the original picture. Specifically, ChemDraw stores "EMF_STRETCHDIBITS" instead of "EMF_STRETCHBLT". It should be added that "EMF_STRETCHDIBITS" can be done by calling StretchDIBits when copying pixels into TMetaFile/TMetaFileCanvas. It should be also noted that pixels for "EMF_STRETCHDIBITS" should be the same as those for "EMF_STRETCHBLT".
Unfortunately, till now I didn't find out how ChemDraw exactly processes and stores pasted pictures. That is to say, I didn't find out why the pixels ChemDraw stored is different from what I can obtain programingly.
PS: I will vote up kind answers regarding this question later because I do not have enough reputation for the moment. Thanks for everybody who has been kind to comment!
===
Hi,
Thanks for your time very much!
Say that I have a picture named "sample_original.bmp". The file size is 3289 X 4570, 43MB. Then I do the following to convert it into a .EMF file (Enhanced Windows MetaFile):
Method 1, by making a small in-house Delphi program:
(1) Load the .BMP image file.
(2) Obtain the Canvas of TMetaFile(TMetaFileCanvas)
(3) Call Canvas.Draw to copy the image.
(4) Save to .EMF file, named "sample_original_bmp2emf_method1.emf"
Method 2:
(1) Open the .BMP image file in the mspaint program, choose "select all", and choose "copy".
(2) Open an external program called ChemDraw, create new document, and choose "paste".
(3) Then I choose to save that in the XML-compatible .cdxml format, named "sample_original_bmp2emf_method2.cdxml".
(4) The content of picture (maybe changed or degraded?) is now saved in the sample_original_bmp2emf_method2.cdxml file. The format is Base64-encoded zlib-compressed format.
(5) I can Base64-decode the XML string, zlib-decompress it, and save it into the picture file "sample_original_bmp2emf_method2.emf".
The file size of sample_original_bmp2emf_method2.emf is smaller by 15 MB than sample_original_bmp2emf_method1.emf, but the width & height has been maintained.
Furthermore, if I open "sample_original_bmp2emf_method2.emf" in the mspaint program and save it back into .bmp file format, a warning pops up that transparent information is losing.
Could you help to comment on how to tell the difference "sample_original_bmp2emf_method1.emf" & "sample_original_bmp2emf_method2.emf"? Is the picture smaller because its quality is decreased?
In other words, what changes to my original picture could possibly be made by this external program?
Best wishes,
The files mentioned above can be downloaded in the following url:
http://www.rapidspread.com/file.jsp?id=2ighvzoci8
PS: I believe that Andreas Rejbrand has be kind enough to made his answer and I then gave my comments. But I cannot see those now. Is it supposed to be normal behavior of the system? o_o
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你写道:
所以它绝对不是 emf 文件,而是某种压缩格式。
或者在转换为 XML 之前将其转换为另一种格式(如矢量)。在这种情况下,生成的图片中的数据比真实位图少。
而第一种方法将为您提供一个大小仅比普通 bmp 文件大几个字节的 emf 文件(即用于封装位图数据的 emf 记录)。
如果你压缩第一种方法的 emf 文件,我很确定你会得到一个比方法二获得的假 emf 更小的文件。
You wrote:
So it's definitively NOT an emf file, but some zipped format..
Or it was converted to another format (like vectorial) before converting to XML. In this case, you've less data in the resulting picture than a real bitmap.
Whereas the first method will give you an emf file with a size of only a few bytes bigger than a plain bmp file (i.e. the emf records used to encapsulate the bitmap data).
If you zip the emf file of the first method, I'm quite sure you'll get a file with a smaller size than the false emf obtained by method two.
为什么不直接比较两张图片呢?在光栅编辑程序中打开它们并比较像素。
为什么你关心文件有多大?当然,重要的是图像是否正确。
Why don't you just compare the two images? Open them in a raster editing program and compare the pixels.
Why do you care how big the files are? Surely what's important is whether or not the image is the right one.