Progress on CDRv4 import

It might be these magic moments which keep one returning to sit in front of the computer: you once again change a few lines here and there, like done before, and out-of-a-sudden something consistent appears on the screen, instead of random lines and dots.

This has now happened a few times since I started to try to import my old Corel Draw v4 files in Calligra. Just, one quickly gets used to what one has achieved, on the week-end I was happy to see this (cmp. the initial picture):

But that picture is still not exactly the one I remember, no wonder, there is quite some data which is not yet interpreted on reading the CDR file. For example in the transformation data so far only the x and y translation information was used, the other values did not yet make sense to me.

But after starring for some time at the corresponding bytes from my files today I finally seem to have found out how those floating values are stored:

  • the first two bytes give the fraction part, by an unsigned 16-bit integer value to be divided by 65535
  • the second two bytes give the integral part, by a signed 16-bit integer.

Never seen that storing approach before ๐Ÿ™‚ Just wondering how a negative value < 0.0 would be stored that way, maybe such a value is not to be expected here?

Using this interpretation gives me something which is quite close to what I remember:

But there are other files which still render awfully. So not yet done here. Also, with some v5 files around I need to look into that format version as well, and also see how all this code work could be integrated with libcdr, so it lives on.


5 thoughts on “Progress on CDRv4 import

  1. Interesting. cdr7 and later seems to store 4 bytes signed integer, which you need to divide by 10000 to have millimeters.
    And coords are relative to the page centre.

    2bytes integer + 2bytes fractional is the way Aldus/Macromedia/Adobe Freehand stores values.

    • Perhaps for v7 some non-imperial-system guy took over the control, as the base unit in v4 seems to be 1/1000 in ๐Ÿ˜› BTW, coords are relative to page centre for v4, too. You can even see how I added adaption for the offset between the two screenshots ๐Ÿ˜‰
      And that pattern to store floating points is more common? Thanks for the pointer, will then make that a built-in type in the binary format description format I work on.

      • >And that pattern to store floating points is more common?

        I wouldn’t say there is “more common” one ๐Ÿ˜‰

        (For linear values)
        CDR7+ — dword/10000 -> mm
        VSD — 8 bytes ieee-754 -> Inches (if memory serves)
        MSPub — 4bytes -> EMU
        FH — int/frac from 2 dwords -> pixels

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s