2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-01 20:42:10 +00:00
Files
gil/example/interleaved_ptr.cpp
Mateusz Łoskot 32fec9f05b Refactor library includes to #include <boost/gil/...>
Group include directives, sort within group:
* In headers of GIL core and extensions:
  1. boost/gil/extension/*
  2. boost/gil/*
  3. boost/*
  4. C++ standard library headers
* In programs:
  1. boost/gil/*
  2. boost/*
  3. C++ standard library headers
  4. "xxx.hpp" for local headers
Add basic guidelines to CONTRIBUTING.md.
Add/Remove #include <boost/config.hpp> or std headers un/necessary.
Rename gil_concept.hpp to concepts.hpp.
Remove gil_all.hpp - we already have all-in-one boost/gil.hpp.
Tidy up and unify copyright and license header.
Tidy up formatting and excessive whitespaces in some comments.
Remove Doxygen block with file description, author, date, etc.
Remove dead or commented pragmas and directives.
Trim trailing whitespaces.
2018-09-28 16:26:34 +02:00

69 lines
2.6 KiB
C++

//
// Copyright 2005-2007 Adobe Systems Incorporated
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#ifdef WIN32
#define _CRT_SECURE_NO_DEPRECATE 1
#pragma warning(disable : 4244) //
#pragma warning(disable : 4996) // MSFT declared it deprecated
#endif
// Example file to demonstrate how to create a model of a pixel iterator
// FIXME: Review and remove if possible: gcc doesn't compile unless we forward-declare at_c before we include gil...
namespace boost { namespace gil {
template <typename ChannelReference, typename Layout> struct interleaved_ref;
template <typename ColorBase> struct element_reference_type;
template <int K, typename ChannelReference, typename Layout>
typename element_reference_type<interleaved_ref<ChannelReference,Layout> >::type
at_c(const interleaved_ref<ChannelReference,Layout>& p);
} }
#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>
#include <iostream>
#include "interleaved_ptr.hpp"
int main(int argc, unsigned char* argv[])
{
using namespace boost::gil;
typedef interleaved_ptr<unsigned char*, rgb_layout_t> rgb8_interleaved_ptr;
typedef interleaved_ptr<const unsigned char*, rgb_layout_t> rgb8c_interleaved_ptr;
boost::function_requires<MutablePixelIteratorConcept<rgb8_interleaved_ptr> >();
boost::function_requires<PixelIteratorConcept<rgb8c_interleaved_ptr> >();
boost::function_requires<MemoryBasedIteratorConcept<memory_based_step_iterator<rgb8_interleaved_ptr> > >();
boost::function_requires<MutablePixelConcept<rgb8_interleaved_ptr::value_type> >();
boost::function_requires<PixelConcept<rgb8c_interleaved_ptr::value_type> >();
typedef type_from_x_iterator<rgb8_interleaved_ptr >::view_t rgb8_interleaved_view_t;
typedef type_from_x_iterator<rgb8c_interleaved_ptr>::view_t rgb8c_interleaved_view_t;
boost::function_requires<MutableImageViewConcept<rgb8_interleaved_view_t> >();
boost::function_requires<ImageViewConcept<rgb8c_interleaved_view_t> >();
rgb8_image_t img;
jpeg_read_image("test.jpg", img);
// Get a raw pointer to the RGB buffer
unsigned char* raw_ptr=&view(img)[0][0];
// Construct a view from it, without casting it to rgb8_pixel_t*
rgb8_interleaved_view_t src_view=interleaved_view(img.width(),img.height(),rgb8_interleaved_ptr(raw_ptr),
view(img).pixels().row_size());
// Apply view transformations and algorithms on it
jpeg_write_view("out-interleaved_ptr.jpg",nth_channel_view(flipped_up_down_view(src_view),1));
return 0;
}