Skip to main content
8 events
when toggle format what by license comment
Jan 29, 2019 at 9:44 comment added ChrisG You use fread() to read one pixel at a time. You will need the nested loops to iterate over all pixels of the image.
Jan 25, 2019 at 15:51 comment added Bahgat Reda is that mean that nesting loops are useless ? because in the way you explained we are not gonna do anything with nesting loops and fread() and fseek() are sufficient.
Feb 10, 2018 at 11:55 comment added ChrisG Then fread() would read the equivalent of 2*sizeof(RGBTRIPLE) amount from the file.In any case fread() reads size*count Bytes from stream, and puts it into buffer.
Feb 9, 2018 at 5:44 comment added koko loko what would happen if instead of variable count is set on 2 not 1 ?
Aug 23, 2016 at 23:58 comment added ChrisG Imagine the file stream as an array. When you open the file you are at the 0th index. The first time you will read something, that something will start from the 0th byte in that file. You can change the index using fseek(), telling it to move at the beginning of the file (SEEK_SET) in relation to where you are now (SEEK_CUR) or at the end of the file (SEEK_END).
Aug 23, 2016 at 19:47 vote accept C4zZ
Aug 23, 2016 at 19:47 comment added C4zZ Thank you very much for your fast reply Chris! :) So can you go into a little bit more detail? For example, when does the pointer gets set? After I opened the file with "fopen()" or after my first use of the function "fread()"? And on which byte does it gets set? on the 1st or on the 0th? Or is it just set before the bytes and waits until further action?
Aug 23, 2016 at 19:24 history answered ChrisG CC BY-SA 3.0