|
-
January 17th, 2013, 04:32 PM
#11
Re: Resizing BMP Files
 Originally Posted by VeNiX
But I don't see how can I remove the looping construct around fwrite() and replace it with a single line, according to the fwrite() manual page:
Code:
size_t fwrite(const void *ptr, size_t size, size_t num, FILE *stream);
The function fwrite() writes num elements of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr.
And while fread() works the same, it worked because I wanted to access each consecutive pixel once, can you give me a hint as to what's the trick here, what am I missing?
You're right, the loop is necessary, because you write the same value multiple times.
Note that you can move the allocation/deallocation for the buffer outside the outermost loop, since the size of the buffer will be the same in each iteration. This will result in less calls to malloc/free, which is faster (unless the compiler already optimized this).
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|