Code:
int LoadImageFile(const char FileName[64], int FileType, int LoadType, BITMAPINFOHEADER *BMPInfo, unsigned char *BMPData, int FogUsed, double ObjectScaling, unsigned int Special)
{
char BasePath[192]; // the base path, that of which started from
char FullFileName[256]; // the full path combining the base path and the parameter
unsigned int ArrayIndex = 0;
float NewColor = 0;
const float FogIntensity = (float)ObjectScaling;
const float FogRange = (float)visibility;
const float FogColorRed = (float)(FogColor[2]);
const float FogColorGreen = (float)(FogColor[1]);
const float FogColorBlue = (float)(FogColor[0]);
unsigned int CurrentRow;
unsigned int CurrentPixel;
float BaseScaling;
GetCurrentDirectory(MAX_PATH, BasePath);
sprintf(FullFileName, "%s\\images\\%s", BasePath, FileName); // combine the base path and file name
FileHandle = fopen(FullFileName, "rb"); // read the source file to display, binary mode
if (FileHandle == 0) // if the file can't be found
{
sprintf(WarningString, "Error: This file cannot be found:\n%s", FullFileName); // an error since the file can't be found
MessageBox(WindowHandle, WarningString, "File not found", MB_OK | MB_ICONHAND);
return 1; // indicates an error occurred
}
if (FileType == 1) // reading a BMP file
{
if (LoadType == 0) // normal full load
{
fseek(FileHandle, 14, SEEK_SET); // skip the basic file header data but read from the info header
fread(&BMPInfo->biSize, 4, 1, FileHandle); // bytes 0E through 11
fread(&BMPInfo->biWidth, 4, 1, FileHandle); // bytes 12 through 15
fread(&BMPInfo->biHeight, 4, 1, FileHandle); // bytes 16 through 19
fread(&BMPInfo->biPlanes, 2, 1, FileHandle); // bytes 1A and 1B
fread(&BMPInfo->biBitCount, 2, 1, FileHandle); // bytes 1C and 1D
fread(&BMPInfo->biCompression, 4, 1, FileHandle); // bytes 1E through 21
fread(&BMPInfo->biSizeImage, 4, 1, FileHandle); // bytes 22 through 25
fread(&BMPInfo->biXPelsPerMeter, 4, 1, FileHandle); // bytes 26 through 29
fread(&BMPInfo->biYPelsPerMeter, 4, 1, FileHandle); // bytes 2A through 2D
fread(&BMPInfo->biClrUsed, 4, 1, FileHandle); // bytes 2E through 31
fread(&BMPInfo->biClrImportant, 4, 1, FileHandle); // bytes 32 through 35
*BMPData = malloc(BMPInfo->biSizeImage);
fread(BMPData, 1, BMPInfo->biSizeImage, FileHandle); // read the main image data // reads in BGR format
}
if (LoadType == 1) // just a reload
{
fseek(FileHandle, 54, SEEK_SET); // skip to the main image data
fread(BMPData, 1, BMPInfo->biSizeImage, FileHandle); // read the main image data // reads in BGR format
}
}
... // similar case for TGA images, then fog processing and premultiplication
}
... // in WinMain:
SkyBlueInfoPointer = &SkyBlueInfo;
LoadImageFile("scenery\\SkyBlue.bmp", 1, 0, &SkyBlueInfo, &SkyBlueData, 0, 0.0, 0);
SkyBlueDataPointer = &SkyBlueData; // copies the pointer
If I keep the & in the function call for this part, I can't see the warnings list - it's empty. Removing it and I do. With it removed, I get this as the only warning, involving that line with malloc. As is, I get the top warning. By having only the top one have the ampersand, I get the two warnings at the bottom: