Hey everyone. Iam trying to make a program using structs and pointers on arrays to analyze a bmp picture characteristics. Any good links to study?
Thanks
Hey everyone. Iam trying to make a program using structs and pointers on arrays to analyze a bmp picture characteristics. Any good links to study?
Thanks
So which bit(s) are confusing you?
- structs and arrays in C
- the details of the BMP file format
- image processing techniques in general
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
well iam trying to make the basic struct so i can build on it the rest of the program. I have read the bmp header file format but i can't really understand the difference between the file size and the raw file size
Where is this the raw file size? AFAIK there is a file size and an offset to the bitmap. But you can investigate the header of some real bmp files to confirm how the data is laid out.
Yes i am aware of those two sizes. But the size of the raw bitmap data is the one i don't understand.
The size of the bitmap data would be, (file size - header size) the actual image data. But look at a real bmp file it's easy to confirm this.
yeap that's it!!
thank you very much Subsonics
Well so far so good.. i have build the structs for header and data now the problem is how do i read the data in binary from a bmp picture i have?
Read: File operations Tutorial.
Thanks for the reply! But how about when i want to give the files to the program when i run the program .. can i use argv[] and set e.g. argv[1] = file??
Yes, just like you would handle any other command line argument. If you need a refresher on the topic, you can look at How to access command line parameters-FAQ().
Due not that since argv[1] is a char*, you would need to use strcpy() and not the assignment operator if you wanted to store it in another variable.
Using argv for the file works, no problem.
Something to think about, is how a pixel is represented and color depth. Then there might be padding at the end of each row to "even up" the number of bytes per row, but you will find that out soon enough.Code:FILE *fp = fopen(argv[1], "r");
I never said you said it wouldn't.