Solved

How to read and write a 24-bit bitmap file

Posted on 2004-04-23
3
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

756 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