reading a .bmp file in c++

后端 未结 3 677
予麋鹿
予麋鹿 2021-02-04 15:58

I\'m trying to load a bmp file for reusing it in opengl. I\'ve found some code via google on how to load a bmp file. I took this code and put in a class Bitmap in my project. Th

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 16:30

    The header needs to be 2 byte aligned.

    #pragma pack(2) // Add this
    
    typedef struct
    {
        unsigned short bfType;
        unsigned int   bfSize;
        unsigned short bfReserved1;
        unsigned short bfReserved2;
        unsigned int   bfOffBits;
    } BITMAPFILEHEADER;
    
    #pragma pack() // and this
    

提交回复
热议问题