Solved

How to read and write a 24-bit bitmap file

Posted on 2004-04-23
3
311 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:Adam409
3 Comments
 
LVL 1

Expert Comment

by:MegaEnforcerBoy
ID: 10901804
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
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 250 total points
ID: 10906146
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now