| | |
Help in C program (Image reading)
![]() |
Well what format is this image file in?
BMP format perhaps?
Though most newbies start with mazes defined in ascii art, like this
Find a route through the maze from S to E
BMP format perhaps?
Though most newbies start with mazes defined in ascii art, like this
C Syntax (Toggle Plain Text)
#S######## # # ###### # # # #E########
•
•
Join Date: Apr 2008
Posts: 7
Reputation:
Solved Threads: 0
Salem, after reading all of the web page contents, I'm still having problems even writing out the initial program.
Cos i not so sure which library to use, for normal standard program is #include Studio.h or math.h for calculation etc.
But for this instance, I am getting more confuse. Please advice me about how to go about writing the program. If its possible, can you show me examples instead.
Cheers
ming
Cos i not so sure which library to use, for normal standard program is #include Studio.h or math.h for calculation etc.
But for this instance, I am getting more confuse. Please advice me about how to go about writing the program. If its possible, can you show me examples instead.
Cheers
ming
•
•
Join Date: Sep 2006
Posts: 326
Reputation:
Solved Threads: 22
Do you know about C File I/O?
This is the .bmp format.
http://www.fortunecity.com/skyscrape.../bmpffrmt.html
Open a bitmap in a hex editor as you follow it along.
Then extract the data you want. That's the easy part done.
This is the .bmp format.
http://www.fortunecity.com/skyscrape.../bmpffrmt.html
Open a bitmap in a hex editor as you follow it along.
Then extract the data you want. That's the easy part done.
FILE *fp = fopen( "file.bmp", "rb" ); This opens the fileunsigned char buff[10]; size_t n = fread( buff, sizeof(buff[0]), sizeof(buff), fp );
10 is obviously just an example, but you can read the documentation to find out how big a BMPHEADER structure is, and read that number of bytes instead. Having got that, you get vital information such as
- the width and height of the image
- the number of bits in each pixel
- whether there is a colour table in the file.
You then skip the optional colour table (say by using fseek), then you can start looping reading image data, based on your knowledge of the width, height and bpp of the image format.
•
•
Join Date: Apr 2008
Posts: 7
Reputation:
Solved Threads: 0
Salem, Thanks for getting back to me on this. But when U say
unsigned char buff[10];
size_t n = fread( buff, sizeof(buff[0]), sizeof(buff), fp );
This reads 10 bytes from the file.
Do U mean that this command only allow me to read only 10bytes of data from the file only?
And the .bmp file i'm reading is simply in black and white.
Pls look at http://hereandabove.com/maze/mazeorig.form.html.
And u will have a clearer idea what sort of image i'm trying to read.
Cheers & Thanks
Ming
unsigned char buff[10];
size_t n = fread( buff, sizeof(buff[0]), sizeof(buff), fp );
This reads 10 bytes from the file.
Do U mean that this command only allow me to read only 10bytes of data from the file only?
And the .bmp file i'm reading is simply in black and white.
Pls look at http://hereandabove.com/maze/mazeorig.form.html.
And u will have a clearer idea what sort of image i'm trying to read.
Cheers & Thanks
Ming
![]() |
Similar Threads
- Reading Binary Files in VB (Visual Basic 4 / 5 / 6)
- Parallel Array/Reading In From A File (C++)
- help in reading a file.. (C++)
- help with reading these logs (Viruses, Spyware and other Nasties)
- Computer Program Issues (C++)
- problems with reading video files (Windows NT / 2000 / XP)
- extrapolate an image (C)
- Tapemaking program (Java)
- Building an array for dice program (C#)
Other Threads in the C Forum
- Previous Thread: General Question about execlp/execvp
- Next Thread: Student with a "C" question
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency givemetehcodez global gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop input interest intmain() iso keyboard kilometer km linked linkedlist linux linuxsegmentationfault list locate lowest match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition reversing scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h windowsapi






