Link to home
Start Free TrialLog in
Avatar of Adam409
Adam409

asked on

How to read and write a 24-bit bitmap file

I need to read and write a bitmap file and am unsure on how to begin this...

I have the way i want the read and write functions to work but am not sure as to what header information and such i need to pass to get this to work.
Here is the read function that i need to code:

/*Read Bitmap File function
  Function: readBMPFile(outfile, bmpHeaderRef)
  Purpose:      gets the bitmap from the infile
  Params:      infile - bitmap file of image
                  bmpHeaderRef - a reference to the memory buffer
                  for the header information
  Return:      reference to a memory buffer containing the bitmap
                  data, NULL if unsuccessful reading the image file
  Algorithm:
*/
BYTE * readBMPFile(FILE *inFile,BMPHEADER *bmpHdrPtr)
{
      //Insert code
}


and here is the Write bitmap code that i need to work with
/*write Bitmap to File function
  Function: writeBMPFile(outfile, bmpHeaderRef, bmpDataRef)
  Purpose:      writes the bitmap in memory to the outfile
  Params:      outfile - bitmap file of write image to
                  bmpHeaderRef - a reference to the memory buffer
                  for the header information
                  bmpDataRef - a reference to the memory buffer with
                  the bitmap image data
  Return:      boolean indicating success or failure of write
  Algorithm:
*/
int writeBMPFile(FILE *inFile,BMPHEADER *bmpHdrPtr, BYTE* bmpDataRef)
{
      //Insert code
}


Hopefully someone has a simple solution and could explain there code well enough because i'm a beginner c programmer.

Thanks in Advance.
Avatar of MegaEnforcerBoy
MegaEnforcerBoy

Well, for reading BMP files you just need a picture box anywhere;
You need a variable/handler for it; than associate a picture to that picture box :-)
And for storing of bitmaps...it's a very difficult subject...But you are lucky- for some time I have been thinking about the same question; Nobody could tell me anything. But I found an interesting article in MSDN about it. There are 2 functions for saving a bitmap there; thanks to them I've created a graphics editor |- ))))
Here is the adress:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7zfp.asp
ASKER CERTIFIED SOLUTION
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial