7bit ASCII out of 4 byte value

This is a discussion on 7bit ASCII out of 4 byte value within the C++ Programming forums, part of the General Programming Boards category; Hi guys I'm currently writing a program that reads EXIF information out of NEF files (Nikon DSLR Raw format). It's ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    21

    7bit ASCII out of 4 byte value

    Hi guys

    I'm currently writing a program that reads EXIF information out of NEF files (Nikon DSLR Raw format). It's based on the TIFF 6.0 definition.

    My probleme is that in the documentation of TIFF it says that the Value of a IFD Entry can be a ASCII value BUT it's only 7bit long since the last bit is NUL. The Value block is 4 byte long and contains several characters at once. Now i tried this:
    Code:
    unsigned char Text[10];
    for (int a = 0; a < Count; a++)
    {
        fread(&Text[a], 1, 1, pFile);
    }
    cout << "Value: " << Text << endl;
    Count is the number of characters
    pFile is the File i've opened

    When i run the programm it prints nothing as Value so the output is
    "Value: "

    My question is how do i get the characters out of the binary strip?

    Thanks in advance

    Patrick

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    595
    You said they can be ASCII values, but that doesn't mean that they are printable characters. If you want to see the values of the bytes, you can print them as integers:

    Code:
    unsigned char Text[10];
    for (int a = 0; a < Count; a++)
    {
        fread(&Text[a], 1, 1, pFile);
        cout << "Value: " << (unsigned int)Text[a] << " " << endl;
    }
    Then you can look up the values on an ascii chart.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    thank you for your reply you actually brought me to the solution.

    The field is maximum 4 byte big and if the value is bigger the value field contains a offset to the actual value. since the counter was 10 it couldn't fit into that 4 byte field. when reading the field as offset and then apply the read-loop to this offset i get the value that is expected.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 08-30-2010, 09:26 AM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  4. Replies: 11
    Last Post: 03-24-2006, 10:26 AM
  5. error: identifier "byte" is undefined.
    By Hulag in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2003, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21