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.



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.
Comment by frob — February 23, 2012 @ 3:10 pm |
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.
Comment by frinring — February 23, 2012 @ 3:29 pm |
>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
Comment by frob — February 23, 2012 @ 4:09 pm
[...] being stuck in text layouting problems during my work on writing an import filter for CDRv4 files for Calligra, I discovered that the import filter for the xfig format is currently disabled from [...]
Pingback by Reading other files from the past… « Attracted by virtual constructs — March 5, 2012 @ 12:49 am |