Nicba1010 icon

I am missing sth

Nicba1010 | PRO | 03/16/15 10:33:54 PM UTC | 0 ⭐ | 462 👁️ | Never ⏰ | []
C++ |

830 B

|

None

|

0 👍

/

0 👎

unsigned char* copyBMP(const char* filename, const char* hidden)
{
    string h = hidden;
    ofstream geneModifier(hidden);
    int i;
    FILE* f = fopen(filename, "rb");
    unsigned char info[54];
    fread(info, sizeof(unsigned char), 54, f); // read the 54-byte header
    for(i = 0; i < sizeof(info); i++)
    {
            geneModifier << info[i];
    }
    // extract image height and width from header
    int width = *(int*)&info[18];
    int height = *(int*)&info[22];
 
    int size = 3 * width * height;
    unsigned char* data = new unsigned char[size]; // allocate 3 bytes per pixel
    fread(data, sizeof(unsigned char), size, f); // read the rest of the data at once
    fclose(f);
    for(i = 0; i < size; i++)
    {
            geneModifier << data[i];
    }
    geneModifier.close();
 
    return data;
}

Comments