Boost logo

Boost :

Subject: Re: [boost] [gil::io] Feedback for scanline_read_iterator
From: Christian Henning (chhenning_at_[hidden])
Date: 2013-02-19 20:39:03


Hi Phil,

> PSEUDO-CODE!!!!
>
>
> class iterator {
> buffer_t& buffer;
> size_t pending_advance_rows;
>
> public:
> const buffer_t& operator*() {
> while (pending_advance_rows > 1) {
> format_specific_skip_row();
> --pending_advance_rows;
> }
> if (pending_advance_rows == 1) {
> format_specific_read_row_into(buffer);
> --pending_advance_rows;
> }
> return buffer;
> }
>
> void operator++() {
> ++pending_advance_rows;
> }
> };
>

I think the scanline_read_iterator is a little more complicated. I
have uploaded the lateted "iteration" here:

http://svn.boost.org/svn/boost/trunk/boost/gil/extension/io/detail/scanline_read_iterator.hpp

It's crucial that the reader's "read" and "skip" functions are called
appropriately. These two functions behave very differently for
different image formats.
For instance two calls to operator* should not result in two reads. Or
when a user does std::advance( it, 20 ) the iterator needs to call
"skip" 20 times without any "reads".

Jeffery suggested to use two booleans to get the order of calls
correct. Let's hope I got it right this time.

Thanks,
Christian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk