@Retired Ninja who is correct and I implemented my code based on his/her comments as in the below working code to first initialize he video to use a 16:9 aspect ratio which will get you a full screen in directx 7.0 is what I tested this on:
It is true you do not need a palette when utilizing a 32Bit Per Pixel (BPP) bmp file
void Video::Initialize(void)
{
TRACE("Video::Initialize invoked\n");
try
{
hrRetVal = DirectDrawCreateEx(NULL, (void**)&pDDraw, IID_IDirectDraw7, NULL);
if (DD_OK == hrRetVal)
{
hrRetVal = pDDraw->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT);
if (DD_OK == hrRetVal)
{
// Lets see if the video is supported
hrRetVal = QueryVideoCapability();
if (DD_OK != hrRetVal)
{
Check(hrRetVal);
}
hrRetVal = pDDraw->SetDisplayMode(1600, 900, 32, 60, 0);
if (DD_OK != hrRetVal)
throw (VIDEO_EXCEPTION);
}
else
throw (VIDEO_EXCEPTION);
}
else
throw (VIDEO_EXCEPTION);
}
catch(int exception)
....
.....
Here is working code to read in the 32BPP BMP file as well.
void Bitmap::BMP32::Read(BMP32& a_bmp32, const char* file_name) // the new read that will dispaly 32BPP background
{
TRACE("Bitmap::BMP32::Read invoked on file_name = %s", file_name);
FILE* fp;
//IMAGE an_image;
//SURFACE a_surface;
if ((fp = fopen(file_name, "rb")) != NULL)
{
if (fp != NULL)
{
TRACE("Reading the first Block of data from %s The File Type Data\n", file_name);
/*
uint16_t FileType{ 0x424D };
uint32_t FileSize{ 0 };
uint16_t Reserved1{ 0 };
uint16_t Reserved2{ 0 };
uint32_t PixelDataOffset{ 0 };
*/
fread(&a_bmp32.HeaderSection.FileType, sizeof(a_bmp32.HeaderSection.FileType), 1, fp);
fread(&a_bmp32.HeaderSection.FileSize, sizeof(a_bmp32.HeaderSection.FileSize), 1, fp);
fread(&a_bmp32.HeaderSection.Reserved1, sizeof(a_bmp32.HeaderSection.Reserved1), 1, fp);
fread(&a_bmp32.HeaderSection.Reserved2, sizeof(a_bmp32.HeaderSection.Reserved2), 1, fp);
fread(&a_bmp32.HeaderSection.PixelDataOffset, sizeof(a_bmp32.HeaderSection.PixelDataOffset), 1, fp);
TRACE("Reading in the Second Block of data from %s The Image Info Data\n", file_name);
/*
uint32_t HeaderSize{ 0x28 }; // the size of this structure
uint32_t ImageWidth{ 0 };
uint32_t ImageHeight{ 0 };
uint16_t Planes{ 0 };
uint16_t BitsPerPixel{ 0 };
uint32_t Compression{ 0 };
uint32_t ImageSize{ 0 };
uint32_t XPixelsPerMeter{ 0 };
uint32_t YPixelsPerMeter{ 0 };
uint32_t TotalColors{ 0 };
uint32_t ImportantColors{ 0 };*/
fread(&a_bmp32.InfoSection.HeaderSize, sizeof(a_bmp32.InfoSection.HeaderSize), 1, fp);
fread(&a_bmp32.InfoSection.ImageWidth, sizeof(a_bmp32.InfoSection.ImageWidth), 1, fp); // if ImageWidth % 4 = Zero then we need to take into consideration row padding
fread(&a_bmp32.InfoSection.ImageHeight, sizeof(a_bmp32.InfoSection.ImageHeight), 1, fp);
fread(&a_bmp32.InfoSection.Planes, sizeof(a_bmp32.InfoSection.Planes), 1, fp);
fread(&a_bmp32.InfoSection.BitsPerPixel, sizeof(a_bmp32.InfoSection.BitsPerPixel), 1, fp);
fread(&a_bmp32.InfoSection.Compression, sizeof(a_bmp32.InfoSection.Compression), 1, fp);
fread(&a_bmp32.InfoSection.ImageSize, sizeof(a_bmp32.InfoSection.ImageSize), 1, fp);
fread(&a_bmp32.InfoSection.XPixelsPerMeter, sizeof(a_bmp32.InfoSection.XPixelsPerMeter), 1, fp);
fread(&a_bmp32.InfoSection.YPixelsPerMeter, sizeof(a_bmp32.InfoSection.YPixelsPerMeter), 1, fp);
fread(&a_bmp32.InfoSection.TotalColors, sizeof(a_bmp32.InfoSection.TotalColors), 1, fp);
fread(&a_bmp32.InfoSection.ImportantColors, sizeof(a_bmp32.InfoSection.ImportantColors), 1, fp);
TRACE("Reading in the Third Block of data from %s The Color Palette Data\n", file_name);
/*
uint8_t RedIntensity{ 0 };
uint8_t GreenIntensity{ 0 };
uint8_t BlueIntensity{ 0 };
uint8_t Reserved{ 0 };
*/
// note I have only tested this algorithm on 32BPP BMP images
// in theory the ColorTableSection is skipped on 1,2,4,8 and 16BPP BMP files
// here I skip that section only for 32BPP or 24BPP
if (a_bmp32.InfoSection.BitsPerPixel < 24) {
fread(&a_bmp32.ColorTableSection.RedIntensity, sizeof(a_bmp32.ColorTableSection.RedIntensity), 1, fp);
fread(&a_bmp32.ColorTableSection.GreenIntensity, sizeof(a_bmp32.ColorTableSection.GreenIntensity), 1, fp);
fread(&a_bmp32.ColorTableSection.BlueIntensity, sizeof(a_bmp32.ColorTableSection.BlueIntensity), 1, fp);
fread(&a_bmp32.ColorTableSection.Reserved, sizeof(a_bmp32.ColorTableSection.Reserved), 1, fp);
}
else
{
TRACE("Reading in the Fourth Block of data from %s The Raw Pixel Data\n", file_name);
// what are the dimensions of the surface that was read in
// a_surface.surfrect.left = 0;
// a_surface.surfrect.top = 0;
// a_surface.surfrect.right = a_bmp32.InfoSection.ImageWidth;
//a_surface.surfrect.bottom = a_bmp32.InfoSection.ImageHeight;
// an_image.width = a_bmp32.InfoSection.ImageWidth;
// an_image.height = a_bmp32.InfoSection.ImageHeight;
// an_image.size = a_bmp32.InfoSection.ImageSize;
// an_image.buffer = new BYTE[an_image.size];
// fread(an_image.buffer, sizeof(BYTE), an_image.size, fp);
a_bmp32.buffer = new BYTE[a_bmp32.InfoSection.ImageSize];
fread(a_bmp32.buffer, sizeof(BYTE), a_bmp32.InfoSection.ImageSize, fp);
}
}
if (fp != NULL)
{
fclose(fp);
}
}
else
{
TRACE("Bitmap::Read %s not found\n", file_name);
char message[60];
strcpy(message, "BMP Graphics file not found. ");
strcat(message, file_name);
strcat(message, "\nApplication will now terminate.");
FatalMessageBox(message);
}
}