What are "the givin libarys"?
How much are you willing to write yourself, and how much are you willing to rely on other library code.
Since you're on windows, maybe this is somewhere to start.
https://docs.microsoft.com/en-us/windows/win32/gdi/bitmaps
https://en.wikipedia.org/wiki/BMP_file_format
> fread(infoPic1, sizeof(unsigned char), 54, Pic1);
Well the first thing you should do is read only up to "DIB header size" to figure out how big the header really is, rather than just assume all bitmaps are the same.
> int widthPic1 = *(int*)&infoPic1[18];
This isn't portable.
Sure, it probably does what you want on your wintel machine.
But at some point, each of these is likely to bite you.
https://en.wikipedia.org/wiki/Data_structure_alignment
https://en.wikipedia.org/wiki/Endianness
https://en.wikipedia.org/wiki/Bus_error
1 2 3 4 5 6 7 8
|
int readIntFromBytes(unsigned char *b) {
int result = b[0] | (b[1]<<8) | (b[2] << 16) | (b[3] << 24);
return result;
}
///
int widthPic1 = readIntFromBytes(&infoPic1[18]);
|
> int sizePic2 = 3 * widthPic2 * heightPic2;
Again, you're assuming a particular kind of bitmap.
As a first exercise, a program to just print all the members of the BITMAPVxHEADER would be a good start, as it would give you some measure of confidence that you could go on to decode the rest of the file successfully.