![]() |
| ||
| Help in C program (Image reading) Hi, can anyone out help me with my assignment which is to read an image file of a maze and find an exit of it. As I'm still kinda of new @ C programming, I'm having problems even reading the image onto C. Cheers Ming |
| ||
| Re: 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 #S########Find a route through the maze from S to E |
| ||
| Re: Help in C program (Image reading) Salem the image will be of .gif or .bmp format. I can't seems to even find the correct library or codes to even load it. Cheers Ming |
| ||
| Re: Help in C program (Image reading) http://www.wotsit.org/ BMP is dead easy, it's little more than a screen dump of pixels. |
| ||
| Re: Help in C program (Image reading) 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 |
| ||
| Re: Help in C program (Image reading) Perhaps start with an ASCII-art map like I posted above, and then develop the maze solving code. |
| ||
| Re: Help in C program (Image reading) 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. |
| ||
| Re: Help in C program (Image reading) Colin, I tried reading that webpage many time and I still don't have the slightest idea about how to go about it. Is it possible that U can write a little portion about how to read an .bmp file script for me to take a look and its easier for me to understand. Cheers Ming |
| ||
| Re: Help in C program (Image reading) FILE *fp = fopen( "file.bmp", "rb" );This opens the file unsigned char buff[10];This reads 10 bytes from the file. 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. |
| ||
| Re: Help in C program (Image reading) 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 |
| All times are GMT -4. The time now is 11:02 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC