Solved

How to read and write a 24-bit bitmap file

Posted on 2004-04-23
3
315 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c language help - file paths 7 150
Where is my core dump file in Ubuntu? 12 453
How to organize data in excel ? 2 115
C++ vs C compilers 13 160
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

856 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