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.