Thread: FOURCC to string?

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273

    Lightbulb FOURCC to string?

    Hi,
    I'm trying to interpret a Four Character Code (FOURCC) as a string. FOURCCs are longs representing characters which make up an identifier for multimedia content in AVI files, among others. So, does anyone know a way of converting a long into a char[4]?

  2. #2
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    read below
    - Oskilian
    Last edited by oskilian; 10-06-2001 at 03:24 PM.

  3. #3
    Former Member
    Join Date
    Oct 2001
    Posts
    955
    Well, I was once working on AVI files, so I think I can help you.

    I have four solutions for you:
    - read it as a char[4], that was what I was doing.

    - handle it as a DWORD, make constant values using MAKEDWORD and MAKEWORD

    - do the following:

    union FCC
    {
    DWORD dwValue;
    char[4] cValue;
    } myFcc;

    store your DWORD into dwValue, and then read it from cValue[] as you would on a normal struct, but it's a union, so both members share the same memory position.

    - make a funtion:

    int DwordToFourCC(DWORD fcc, char* buffer)
    {
    //I'm not sure about the order of these, but try messing with them
    buffer[0]=HIBYTE(HIWORD(fcc));
    buffer[1]=LOBYTE(HIWORD(fcc));
    buffer[2]=HIBYTE(LOWORD(fcc));
    buffer[3]=LOBYTE(LOWORD(fcc));
    return 0;
    }

    I haven't tried each one of these, so I'm not sure they would work...

    I can only say that these could work on Visual C++ 6, I'm not sure about other compilers

    Good Luck

    Oskilian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  3. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM