Convert BITMAPINFO into a unsigned char pointer
-
Hey there, I have a bitmap header information in the struct typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO The total size of this is 1080. Now i want to convert this into a unsigned char pointer. unsigned char * pBMPHeaderData; I already got the raw image data in another unsigned char buffer. unsigned char* pRawBMPData; Now i want to make a complete BMP image by adding the header info and raw data into a new unsigned char pointer. For this i need to convert the BITMAPINFO struct into a unsigned char * So the new buffer will be, unsigned char * pCompleteBMPIMageData = pBMPHeaderData + pRawBMPData; Can anyone tell me how to do this? Thanks in advance.
-
Hey there, I have a bitmap header information in the struct typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO The total size of this is 1080. Now i want to convert this into a unsigned char pointer. unsigned char * pBMPHeaderData; I already got the raw image data in another unsigned char buffer. unsigned char* pRawBMPData; Now i want to make a complete BMP image by adding the header info and raw data into a new unsigned char pointer. For this i need to convert the BITMAPINFO struct into a unsigned char * So the new buffer will be, unsigned char * pCompleteBMPIMageData = pBMPHeaderData + pRawBMPData; Can anyone tell me how to do this? Thanks in advance.
Have a look at CreateDIBSection http://msdn.microsoft.com/en-us/library/windows/desktop/dd183494(v=vs.85).aspx[^] this can be used to combine
BITMPAINFOHEADER
data and the actual bits. Though I realise this doesn't actually give you a char pointer it may be something you can use. -
Hey there, I have a bitmap header information in the struct typedef struct tagBITMAPINFO { BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO The total size of this is 1080. Now i want to convert this into a unsigned char pointer. unsigned char * pBMPHeaderData; I already got the raw image data in another unsigned char buffer. unsigned char* pRawBMPData; Now i want to make a complete BMP image by adding the header info and raw data into a new unsigned char pointer. For this i need to convert the BITMAPINFO struct into a unsigned char * So the new buffer will be, unsigned char * pCompleteBMPIMageData = pBMPHeaderData + pRawBMPData; Can anyone tell me how to do this? Thanks in advance.
What do you mean by "i want to convert this into a unsigned char pointer."? A pointer is merely the address of some block of memory, you do not convert things into pointers. Procedurally to combine the two blocks into a new BMP you need to do the following:
// BYTE is a Windows typedef for unsigned char, and generally makes your purpose clearer
// PBYTE is a typedef for a BYTE*
PBYTE pCompleteBMPIMageData = new BYTE[size of header plus size of raw data];
memcpy(pCompleteBMPIMageData, reinterpret_cast(&BITMAPINFO), sizeof BITMAPINFO);
memcpy(pCompleteBMPIMageData + sizeof BITMAPINFO, pRawBMPData, size of raw data);Veni, vidi, abiit domum
-
What do you mean by "i want to convert this into a unsigned char pointer."? A pointer is merely the address of some block of memory, you do not convert things into pointers. Procedurally to combine the two blocks into a new BMP you need to do the following:
// BYTE is a Windows typedef for unsigned char, and generally makes your purpose clearer
// PBYTE is a typedef for a BYTE*
PBYTE pCompleteBMPIMageData = new BYTE[size of header plus size of raw data];
memcpy(pCompleteBMPIMageData, reinterpret_cast(&BITMAPINFO), sizeof BITMAPINFO);
memcpy(pCompleteBMPIMageData + sizeof BITMAPINFO, pRawBMPData, size of raw data);Veni, vidi, abiit domum
The reason why i want to get the BITMAP Info structure in a unsigned char pointer is because i want to convert that into a base64 encoded string. So it's not about converting a structure into a unsigned char pointer. I want the data in the structure to be populated in a unsigned char pointer so that it could be later used to generate a base64 encoded string for the bitmap image.
-
The reason why i want to get the BITMAP Info structure in a unsigned char pointer is because i want to convert that into a base64 encoded string. So it's not about converting a structure into a unsigned char pointer. I want the data in the structure to be populated in a unsigned char pointer so that it could be later used to generate a base64 encoded string for the bitmap image.
-
The reason why i want to get the BITMAP Info structure in a unsigned char pointer is because i want to convert that into a base64 encoded string. So it's not about converting a structure into a unsigned char pointer. I want the data in the structure to be populated in a unsigned char pointer so that it could be later used to generate a base64 encoded string for the bitmap image.