-
January 10th, 2014, 01:44 PM
#1
Convert BITMAPINFO header into 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.
-
January 10th, 2014, 01:48 PM
#2
Re: Convert BITMAPINFO header into unsigned char pointer
You want to make a buffer big enough to hold the header and the bits, then use memcpy to copy the header and the image into the new buffer.
-
January 11th, 2014, 06:23 AM
#3
Re: Convert BITMAPINFO header into unsigned char pointer
Please note the bmiColors[1]. This is where your raw data should start when copied to the new buffer. This trick is widely used in Win32 API when reference to a data of variable size is provided.
Besides, be careful about wording. The word 'convert' is not appropriate here. You cannot convert buffer to a pointer, as this makes no sense: buffer/structure is a memory bytes, pointer is a memory address. Using incorrect terminology typically leads to lots of misunderstandings as well as obscuring the essence of the issue, and inability to solve it proper way as the result.
Last edited by Igor Vartanov; January 11th, 2014 at 06:33 AM.
Best regards,
Igor
-
January 12th, 2014, 02:06 AM
#4
Re: Convert BITMAPINFO header into unsigned char pointer
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|