| | |
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: 327
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 |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open opensource owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






