byte alignment

Discussion in 'C++' started by Marco, Jan 21, 2005.

  1. Marco

    Marco Guest

    Hi
    I have to read a binary image.
    Info tell me that it is a binary image without encoding but with RLE.
    Also i know it is 4 bytes align.

    What it means ?? How can i read it ??
    I red it is for portability whit different microprocessor. is it right ??

    How can i perform my 4 bytes in rle decode function when i have to check
    first byte (length byte) to understand what i have to do with other bytes
    ???

    tks
    Marco
     
    Marco, Jan 21, 2005
    #1
    1. Advertising

  2. Marco

    Sashi Guest

    Marco, your msg is a little cryptic. Could you clarify a little? If
    possible, zip and mail me your image file: and tell
    me EXACTLY what it is you want to do with this file.
    Sashi
     
    Sashi, Jan 21, 2005
    #2
    1. Advertising

  3. Marco

    Attila Feher Guest

    Marco wrote:
    > Hi
    > I have to read a binary image.
    > Info tell me that it is a binary image without encoding but with RLE.
    > Also i know it is 4 bytes align.
    >
    > What it means ?? How can i read it ??
    > I red it is for portability whit different microprocessor. is it
    > right ??
    >
    > How can i perform my 4 bytes in rle decode function when i have to
    > check first byte (length byte) to understand what i have to do with
    > other bytes ???


    Hi,

    Could you please reword? I have a hard time finding your C++ language
    related question.

    --
    Attila aka WW
     
    Attila Feher, Jan 21, 2005
    #3
  4. Marco

    Marco Guest

    ok i tried to be more clear ( sorry english is not my language...;) )

    I have a text file with image inside.
    I have to read image.
    I can read image data in a unsigned char buffer.

    I know data image is not encoded, but it is compressed with Run-length
    encode.
    an information in file tell me that data image it is 4 byte alignment.
    but i don't know what it means.

    With oter image with same rle algorithm but with 1 byte alignment i have not
    problem.
    With this kind of data i do this...

    value=*str++; // header byte
    if (value<128)
    {
    n=value +1;
    for (i=0;i<n;i++)
    *dest++=*src++;
    }
    else
    {
    if (value>128)
    {
    n=257-value;
    for (i=0;i<n;i++)
    *dest=value;
    *src++
    }
    else
    // end of data
    return;
    }

    cycle it does until i find 128 in header byte

    Can anyone help me ????

    Thank at all.
    Marco
     
    Marco, Jan 21, 2005
    #4
  5. 4 byte aligned would mean that a new record always
    starts at a 4 byte boundary. Thus you should adjust your
    algorithm to do the same.

    The file would contain pads whenever a structure size does
    not end at the four byte boundary.

    Just look at the binary dump of a 4 byte aligned file to
    identify the padding.

    The following article might help:
    http://www.eventhelix.com/RealtimeMantra/ByteAlignmentAndOrdering.htm

    Deepa
    --
    http://www.EventHelix.com/EventStudio
    EventStudio 2.5 - Automate sequence diagram generation
     
    EventHelix.com, Jan 22, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Rathnow

    JNI with 1 byte alignment crashes JVM

    Dave Rathnow, Nov 7, 2003, in forum: Java
    Replies:
    2
    Views:
    1,787
    Gordon Beaton
    Nov 7, 2003
  2. Ares Lagae

    Byte alignment in union

    Ares Lagae, Aug 25, 2003, in forum: C++
    Replies:
    21
    Views:
    4,203
    Michiel Salters
    Sep 1, 2003
  3. Shashi

    Byte Alignment

    Shashi, Nov 10, 2003, in forum: C Programming
    Replies:
    4
    Views:
    573
    Thomas Matthews
    Nov 10, 2003
  4. gamja
    Replies:
    14
    Views:
    713
  5. Replies:
    1
    Views:
    392
    Lawrence Kirby
    Jul 6, 2005
Loading...

Share This Page