2

Summarization:

  1. 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.

  2. 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".

  3. 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

Community
  • 1
  • 1
SOUser
  • 3,802
  • 5
  • 33
  • 63
  • What don't you open in with Powerpoint and save picture as `.emf` form there and see what size you get. The elaborate scheme in method 2 seems to add many unnecessary steps to the process. Also, the implementation details of *ChemDraw* are probably the source of any differences. – John Alexiou Dec 05 '10 at 13:27
  • Thank you very much for your comments! As you say, ChemDraw is the source of the difference. My concern is whether there is a way to obtain a understanding of the differences? I mean, whether the picture is degraded, why the picture has a smaller size while its width & height have been maintained, and so forth. – SOUser Dec 05 '10 at 13:42
  • EMF is a vector image format. BMP is a raster format. Why would you want to convert BMP to EMF, it seems an odd thing to do. – David Heffernan Dec 05 '10 at 15:20
  • @David: Thank you for your time! I understand that EMF is a vector image format. The reason is, I need to put my pictures into the ChemDraw program (to generate a new, maybe more complicated pictures for scientific publication), and ChemDraw stores as EMF format. However, as mentioned above, I accidentally found out that the EMF picture that the ChemDraw stores is different from the one that I can get from the original BMP. I am very concerned about what exactly has happened to the original picture. :D – SOUser Dec 05 '10 at 17:06
  • @David Heffernan: actually, drawing bitmap on metafile's canvas embeds raster object into container – Free Consulting Dec 05 '10 at 18:35
  • @user205376 I didn't actually know that although now that I think about it I can see that there is no other option. – David Heffernan Dec 05 '10 at 18:57

2 Answers2

1

You wrote:

Base64-decode the XML string, zlib-decompress it, and save it into the picture file "sample_original_bmp2emf_method2.emf".

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.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • @Arnaud: Thank you for your time! I may not make the situation clear. As I wrote, ChemDraw stores the picture as "Base64-encoded zlib-compressed format." If I base64-decode it, zlib-decompress the decoded hex data, the decompressed hex data IS indeed a TRUE .emf file. The header bytes is one proof. I can also save the decompressed hex data into .emf file and open it in mspaint program. "If you zip the emf file of the first method, I'm quite sure you'll get a file with a smaller size..." is a sure thing. What I am concerned is if we compare both uncompressed version, two emf files differ. – SOUser Dec 05 '10 at 17:04
  • @Xichen: so I guess the two emf files don't have the same data. Perhaps the resolution or the color bits are not the same. Use http://frazmitic.free.fr/emfexplorer to see what's the difference between the two emf files. – Arnaud Bouchez Dec 06 '10 at 07:18
  • @Arnaud: Thank you for your comments! As you say, the ChemDraw-processed .EMF picture file probably "loses" certain data. However, the width & height has been maintained. The 24 color bits is also maintained. Thus I don't know what else the ChemDraw could have been done. Thank you for your suggestion! I have downloaded the emfexplorer, and used it to open the .EMF files. However, the purpose of emfexplorer seems to be to render the vector commands inside one .EMF file at different details. It doesn't help with the understanding of the difference of the .EMF files in the my situation, does it? – SOUser Dec 06 '10 at 11:40
  • @Arnaud: You are right. The color bits seem to be 16 bpp in the ChemDraw-processed .EMF picture files. Thank you very much for your comments! (I cannot vote up your answer or others currently, because I do not have enough reputation. I will try later.) – SOUser Dec 08 '10 at 19:54
1

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • @David: Thank you for your comments!! Could you help to recommend certain raster editing softwares? If I can see the difference between the pixels, maybe I can see what changes ChemDraw has done to my original picture. Regarding your second comment, my primary concern is whether the image has been degraded. If I can learn about what changes ChemDraw will do before saving the picture that I paste into it, that will be the best, because then I may also learn about the implementation of the ChemDraw. – SOUser Dec 05 '10 at 19:58
  • @Xichen Li I use Paint.NET but really anything will do. My point is that you are worried that ChemDraw will modify and degrade your image. So why do you care what size it is? Surely what matters is whether or not it modifies or degrades your image! – David Heffernan Dec 05 '10 at 20:18
  • @David: Thank you for your comments! I will look into the manual of Paint. Net and let you know if there is any news. The reason is that, the difference of file size may be a clue that ChemDraw changes/degrades the pasted image? Furthermore, if I can know what exactly happens to the pasted images, I may stop worrying (if the changes/degradations are trivial), or prevent such changes (if they are quite noticeable). – SOUser Dec 05 '10 at 20:45
  • @David: I am sorry but could you help to instruct specifically about how to use Paint .NET to get a understanding of the comparison of the pixels of the two .EMF picture files? I didn't find relevant instruction in the manual. :D – SOUser Dec 06 '10 at 11:34
  • @Xichen Li load up the two images, zoom in a little, look at them side by side, see if you can spot any differences. Once again I ask the question, why do you care how big the files are? Can you see any differences in the images? – David Heffernan Dec 06 '10 at 13:05
  • @David: Thank you for your comments! I cannot spot any differences between the two .EMF picture files by naked eyes. However, me being unable to see differences does not guarantee that the quality of the original picture is not changed, or am I wrong? There is 15 MB less in the ChemDraw-processed picture file. I would then think that there must be something lost, and I would be very happy if I could find out what has happened to my picture file. – SOUser Dec 06 '10 at 13:20
  • @Xichen: If nobody can see a difference then why are you worried? I've said that 3 or 4 times now and I am now giving up! – David Heffernan Dec 06 '10 at 13:29
  • @David: Thank you for your time and efforts to help me! As I mentioned, there must something lost/changed in the ChemDraw-processed picture file. Both uncertainty and curiosity make me want to find out what exactly could have happened. Thanks for your time again! – SOUser Dec 06 '10 at 13:33