Below is the structures which defines the image. I also have an image class which returns the pixel data of the image. The issue is that I need to somehow set the ColorMap, which "bool loadFromData ( const uchar * data, int len, const char * format = 0 )" will not do if I'm only passing the pixel data. How do I create the QVector of QRgb values to pass to SetColorMap and when am I supposed to call that function? Am I supposed to call SetColorMap after setting the width and height of the image, but before setting the pixel data...or does the order not matter?
Another note: Because this bmp uses a color map it uses one byte per pixel.
// BMP File header
typedef struct
{
unsigned short bfType;
unsigned int bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned int bfOffBits;
}
// BMP file info
typedef struct
{
unsigned int biSize;
int biWidth;
int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
int biXPelsPerMeter;
int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
} BITMAPINFOHEADER;
// Colormap entry
typedef struct
{
unsigned char rgbBlue;
unsigned char rgbGreen;
unsigned char rgbRed;
unsigned char rgbReserved;
} RGBQUAD;
// Bitmap Info
typedef struct
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
} BITMAPINFO;
// BMP File header
typedef struct
{
unsigned short bfType;
unsigned int bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned int bfOffBits;
}
// BMP file info
typedef struct
{
unsigned int biSize;
int biWidth;
int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
int biXPelsPerMeter;
int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
} BITMAPINFOHEADER;
// Colormap entry
typedef struct
{
unsigned char rgbBlue;
unsigned char rgbGreen;
unsigned char rgbRed;
unsigned char rgbReserved;
} RGBQUAD;
// Bitmap Info
typedef struct
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
} BITMAPINFO;
To copy to clipboard, switch view to plain text mode
Bookmarks