|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83144 - trunk/libs/gil/io/doc
From: chhenning_at_[hidden]
Date: 2013-02-24 19:36:50
Author: chhenning
Date: 2013-02-24 19:36:49 EST (Sun, 24 Feb 2013)
New Revision: 83144
URL: http://svn.boost.org/trac/boost/changeset/83144
Log:
Updated scanline_read_iterator code sample.
Text files modified:
trunk/libs/gil/io/doc/io.qbk | 45 +++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 21 deletions(-)
Modified: trunk/libs/gil/io/doc/io.qbk
==============================================================================
--- trunk/libs/gil/io/doc/io.qbk (original)
+++ trunk/libs/gil/io/doc/io.qbk 2013-02-24 19:36:49 EST (Sun, 24 Feb 2013)
@@ -259,37 +259,40 @@
a scanline_reader is implemented for all supported image formats. The scanline_read_iterators will then allow to traverse
through the image. The following code sample shows the usage:
- // define the reader type
+ typedef tiff_tag tag_t;
+
typedef scanline_reader< typename get_read_device< const char*
- , FormatTag
+ , tag_t
>::type
- , FormatTag
- > reader_t;
+ , tag_t
+ > reader_t;
+
+ reader_t reader = make_scanline_reader( "C:/boost/libs/gil/io/test_images/tiff/test.tif", tag_t() );
- reader_t reader = make_scanline_reader( file_name, FormatTag() );
+ typedef rgba8_image_t image_t;
- Image dst( reader._info._width, reader._info._height );
- vector< byte_t > buffer( reader._scanline_length );
+ image_t dst( reader._info._width, reader._info._height );
+ fill_pixels( view(dst), image_t::value_type() );
- typedef scanline_read_iterator< reader_t > iterator_t;
+ typedef reader_t::iterator_t iterator_t;
- iterator_t it = iterator_t( reader, &buffer.front() );
- iterator_t end = iterator_t();
+ iterator_t it = reader.begin();
+ iterator_t end = reader.end();
for( int row = 0; it != end; ++it, ++row )
{
copy_pixels( interleaved_view( reader._info._width
- , 1
- , ( typename Image::view_t::x_iterator ) *it
- , reader._scanline_length
- )
- , subimage_view( view( dst )
- , 0
- , row
- , reader._info._width
- , 1
- )
- );
+ , 1
+ , ( image_t::view_t::x_iterator ) *it
+ , reader._scanline_length
+ )
+ , subimage_view( view( dst )
+ , 0
+ , row
+ , reader._info._width
+ , 1
+ )
+ );
}
There are many ways to travese an image but for as of now only by scanline is supported.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk