This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to load an external file

I want to read a bmp file to my program, how can I do that?
Can I read it directly?

Parents
  • If I am understanding your requirements correctly, 010 Editor (an
    inexpensive Windows application) can do this interactively or
    programmatically.

    See
    http://www.sweetscape.com/010editor/

    For example, the tool exported a .bmp file exported to a C source
    file:

    //------------------------------------------------------------
    //-----------       Created with 010 Editor        -----------
    //------         http://www.sweetscape.com/010editor/          ------
    //
    // File    : C:\WINNT\Blue Lace 16.bmp
    // Address : 0 (0x0)
    // Size    : 1272 (0x4F8)
    //------------------------------------------------------------
    unsigned char hexData[1272] = {
        0x42, 0x4D, 0xF8, 0x04, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
        0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00,
        0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x0E,
        0x00, 0x00, 0xC3, 0x0E, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
        0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
        0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80,
        0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0xC0, 0xC0,
        0xC0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
        0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00,
        0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
        0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x44, 0x44,
        0x44, 0x4C, 0x44, 0x44, 0x44, 0x44, 0xC4, 0xC4,
        0x44, 0x44, 0x44, 0x44, 0xC4, 0xC4, 0x44, 0x44,
        /* ... */
        0x44, 0x44, 0x44, 0x44, 0xC4, 0x4C, 0x44, 0x44,
        0x44, 0x44, 0xCC, 0xC4, 0x44, 0x44, 0x00, 0x00
    };

Reply
  • If I am understanding your requirements correctly, 010 Editor (an
    inexpensive Windows application) can do this interactively or
    programmatically.

    See
    http://www.sweetscape.com/010editor/

    For example, the tool exported a .bmp file exported to a C source
    file:

    //------------------------------------------------------------
    //-----------       Created with 010 Editor        -----------
    //------         http://www.sweetscape.com/010editor/          ------
    //
    // File    : C:\WINNT\Blue Lace 16.bmp
    // Address : 0 (0x0)
    // Size    : 1272 (0x4F8)
    //------------------------------------------------------------
    unsigned char hexData[1272] = {
        0x42, 0x4D, 0xF8, 0x04, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
        0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00,
        0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x0E,
        0x00, 0x00, 0xC3, 0x0E, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
        0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00,
        0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80,
        0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0xC0, 0xC0,
        0xC0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
        0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00,
        0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
        0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x44, 0x44,
        0x44, 0x4C, 0x44, 0x44, 0x44, 0x44, 0xC4, 0xC4,
        0x44, 0x44, 0x44, 0x44, 0xC4, 0xC4, 0x44, 0x44,
        /* ... */
        0x44, 0x44, 0x44, 0x44, 0xC4, 0x4C, 0x44, 0x44,
        0x44, 0x44, 0xCC, 0xC4, 0x44, 0x44, 0x00, 0x00
    };

Children