Welcome to TalkGraphics.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    4

    Question Development question: PATHRELATIVE_OBJECT question

    I am working on a Xar File parser at the moment in C# and I am having problems with the PATHRELATIVE_OBJECT record. I am to parse the data section of this record but I am having difficulty extracting that data. How exactly is this data stored? Is it stored differently in Xara X1 than Xara LX?
    From the documentation it says that the first Unsigned 32 bit integer is the number of points but after that how are the coordinates stored? Is it a sequence of (X,Y) points?

    Here is a code snippet of what I have tried so far. It fails on the next verb I try to grab(The verb value of 255 is invalid). Also I suspect that I am getting the wrong value in num points as I have create multiple bezier paths with different lengths and I still get the value of 6. Any help or insight would be appriciated.

    using (BinaryReader tmpReader = new BinaryReader(new MemoryStream(record.Data)))
    {
    //Determine the number of points
    _numPoints = tmpReader.ReadUInt32();

    for (int i = 0; i < _numPoints; i++)
    {
    List<byte> xList = new List<byte>();
    List<byte> yList = new List<byte>();
    byte verb;
    UInt32 x;
    UInt32 y;
    verb = tmpReader.ReadByte();
    x = tmpReader.ReadUInt32();
    y = tmpReader.ReadUInt32();

    _verbs.Add(verb);
    }
    }
    IP

  2. #2
    Join Date
    Apr 2006
    Location
    Cameron Park California
    Posts
    97

    Default Re: Development question: PATHRELATIVE_OBJECT question

    Have you tried asking your question on the dev email?

    dev@xaraxtreme.org

    This is where the programmers hang out.

    frank
    IP

  3. #3
    Join Date
    Oct 2005
    Posts
    4

    Default Re: Development question: PATHRELATIVE_OBJECT question

    Frank,

    Thanks for the email address.
    rob
    IP

  4. #4
    Join Date
    May 2004
    Location
    Xara Group Ltd
    Posts
    415

    Default Re: Development question: PATHRELATIVE_OBJECT question

    There was an error in the documentation for these records that I thought had been fixed. You should try downloading a new copy of the file format spec. The record does not have a count of the number of points. This should be calculated from the size of the record by dividing it by 9 (there are 9 bytes per point in the path). The verbs and coordinates are stored interleaved. For each point you first read a BYTE which is the verb. Then you need to read the next 8 bytes and manipulate them as follows to get the x and y coord values.

    BYTE b;
    LONG x = 0;
    LONG y = 0;
    ReadBYTE(&b); x += (b << 24);
    ReadBYTE(&b); y += (b << 24);
    ReadBYTE(&b); x += (b << 16);
    ReadBYTE(&b); y += (b << 16);
    ReadBYTE(&b); x += (b << 8);
    ReadBYTE(&b); y += (b << 8);
    ReadBYTE(&b); x += (b << 0);
    ReadBYTE(&b); y += (b << 0);

    The first point simply uses this (x, y) coord directly but the following points are then relative to the previous point. When reading the second and subsequent points you must subtract the read value from the previous point, e.g.:

    pCoord[i].x = pCoord[i-1].x - TempCoord.x;
    pCoord[i].y = pCoord[i-1].y - TempCoord.y;

    Hope this helps,
    Gerry
    IP

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •