class IMAGE // create a discreet type to be used to instantiate queue template
// single bitmap image width and height
unsigned short width, height;
unsigned int size; // single bitmap image size
DWORD* buffer; // buffer to hold a width X height _size_ image
class Bitmap : protected Surface
void Bitmap::BMP_32::Read(Bitmap::BMP_32& a_bmp32, IMAGE& an_image, SURFACE& a_surface, const char* file_name)
fread(&a_bmp32.HeaderSection.FileType, sizeof(a_bmp32.HeaderSection.FileType), 1, fp);
fread(&a_bmp32.InfoSection.HeaderSize, sizeof(a_bmp32.InfoSection.HeaderSize), 1, fp);
fread(&a_bmp32.ColorTableSection.RedIntensity, sizeof(a_bmp32.ColorTableSection.RedIntensity), 1, fp);
an_image.buffer = new DWORD(IMAGEBUFFERSIZE);
// The following three examples render the same output visually:
// DWORD dwords_read = fread(an_image.buffer, sizeof(DWORD), an_image.size, fp); // dwords_read = 2,073,600
DWORD dwords_read = fread(an_image.buffer, (SCREEN_WIDTH * SCREEN_HEIGHT), 4, fp); // dwords_read = 4
// DWORD dwords_read = fread(an_image.buffer, ((SCREEN_WIDTH * SCREEN_HEIGHT) * 2), 2, fp); // dwords_read = 2
Background Detail: I am building up a class framework to read in 32BPP BMP files, that I am creating on a backsurface, which I then bltfast to the frontsurface and flip to GDI. The 32BPP background BMP that I am reading in is 8294400 in size, but the most I am able to read using “fread()” is 2073600, which is exactly 25% of the original artwork. I am using Visual Studio 2019 Community Edition and fread(&MyBuffer, arg2, arg3, stream) extensively. My application is an MFC application.
I have a need to read in the entire BMP Pixel Data Section into memory, because I am saving this into a queue Abstract Data type. Once I have the BMP in memory the I/O is done to disk and I just make calls to update the backsurface, bltfast and flip to update my scene. I am creating a class library for the BMP code.
Question: Is fread() hitting an upperbound on size limit? If so can someone suggest how I might be able to overcome this problem. If so I am hoping to make a minor substitution for this fread() API call for another C++ call. I cannot do anything too fancy with multiple buffers or doing a lot of I/O, as I have tried that approach already without success.