DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/* Copyright 2005-2007 Adobe Systems Incorporated Use, modification and distribution are subject to 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). See http://opensource.adobe.com/gil for most recent version including documentation. */ /*************************************************************************************************/ #ifndef GIL_COLOR_BASE_HPP #define GIL_COLOR_BASE_HPP //////////////////////////////////////////////////////////////////////////////////////// /// \file /// \brief pixel class and related utilities /// \author Lubomir Bourdev and Hailin Jin \n /// Adobe Systems Incorporated /// \date 2005-2007 \n Last updated on May 6, 2007 /// //////////////////////////////////////////////////////////////////////////////////////// #include
#include
#include
#include
#include
#include
#include "gil_config.hpp" #include "utilities.hpp" #include "gil_concept.hpp" namespace boost { namespace gil { // Forward-declare template
P* memunit_advanced(const P* p, std::ptrdiff_t diff); // Forward-declare semantic_at_c template
typename disable_if
,typename kth_semantic_element_reference_type
::type>::type semantic_at_c(ColorBase& p); template
typename kth_semantic_element_const_reference_type
::type semantic_at_c(const ColorBase& p); // Forward declare element_reference_type template
struct element_reference_type; template
struct element_const_reference_type; template
struct kth_element_type; template
struct kth_element_type
: public kth_element_type
{}; template
struct kth_element_reference_type; template
struct kth_element_reference_type
: public kth_element_reference_type
{}; template
struct kth_element_const_reference_type; template
struct kth_element_const_reference_type
: public kth_element_const_reference_type
{}; namespace detail { template
struct mapping_transform : public mpl::at
>::type >::type {}; /// \defgroup ColorBaseModelHomogeneous detail::homogeneous_color_base /// \ingroup ColorBaseModel /// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// If the element type models Regular, this class models HomogeneousColorBaseValueConcept. /// \brief A homogeneous color base holding one color element. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// \ingroup ColorBaseModelHomogeneous template
struct homogeneous_color_base
{ private: Element _v0; public: typedef Layout layout_t; typename element_reference_type
::type at(mpl::int_<0>) { return _v0; } typename element_const_reference_type
::type at(mpl::int_<0>) const { return _v0; } homogeneous_color_base() {} homogeneous_color_base(Element v) : _v0(v) {} // grayscale pixel values are convertible to channel type operator Element () const { return _v0; } template
homogeneous_color_base(const homogeneous_color_base
& c) : _v0(at_c<0>(c)) {} }; /// \brief A homogeneous color base holding two color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// \ingroup ColorBaseModelHomogeneous template
struct homogeneous_color_base
{ private: Element _v0, _v1; public: typedef Layout layout_t; typename element_reference_type
::type at(mpl::int_<0>) { return _v0; } typename element_const_reference_type
::type at(mpl::int_<0>) const { return _v0; } typename element_reference_type
::type at(mpl::int_<1>) { return _v1; } typename element_const_reference_type
::type at(mpl::int_<1>) const { return _v1; } homogeneous_color_base() {} explicit homogeneous_color_base(Element v) : _v0(v), _v1(v) {} homogeneous_color_base(Element v0, Element v1) : _v0(v0), _v1(v1) {} template
homogeneous_color_base(const homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)) {} // Support for l-value reference proxy copy construction template
homogeneous_color_base( homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)) {} // Support for planar_pixel_iterator construction and dereferencing template
homogeneous_color_base(P* p,bool) : _v0(&semantic_at_c<0>(*p)), _v1(&semantic_at_c<1>(*p)) {} template
Ref deref() const { return Ref(*semantic_at_c<0>(*this), *semantic_at_c<1>(*this)); } // Support for planar_pixel_reference offset constructor template
homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff) : _v0(*memunit_advanced(semantic_at_c<0>(ptr),diff)), _v1(*memunit_advanced(semantic_at_c<1>(ptr),diff)) {} // Support for planar_pixel_reference operator[] Element at_c_dynamic(size_t i) const { if (i==0) return _v0; return _v1; } }; /// \brief A homogeneous color base holding three color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// \ingroup ColorBaseModelHomogeneous template
struct homogeneous_color_base
{ private: Element _v0, _v1, _v2; public: typedef Layout layout_t; typename element_reference_type
::type at(mpl::int_<0>) { return _v0; } typename element_const_reference_type
::type at(mpl::int_<0>) const { return _v0; } typename element_reference_type
::type at(mpl::int_<1>) { return _v1; } typename element_const_reference_type
::type at(mpl::int_<1>) const { return _v1; } typename element_reference_type
::type at(mpl::int_<2>) { return _v2; } typename element_const_reference_type
::type at(mpl::int_<2>) const { return _v2; } homogeneous_color_base() {} explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v) {} homogeneous_color_base(Element v0, Element v1, Element v2) : _v0(v0), _v1(v1), _v2(v2) {} template
homogeneous_color_base(const homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)) {} // Support for l-value reference proxy copy construction template
homogeneous_color_base( homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)) {} // Support for planar_pixel_iterator construction and dereferencing template
homogeneous_color_base(P* p,bool) : _v0(&semantic_at_c<0>(*p)), _v1(&semantic_at_c<1>(*p)), _v2(&semantic_at_c<2>(*p)) {} template
Ref deref() const { return Ref(*semantic_at_c<0>(*this), *semantic_at_c<1>(*this), *semantic_at_c<2>(*this)); } // Support for planar_pixel_reference offset constructor template
homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff) : _v0(*memunit_advanced(semantic_at_c<0>(ptr),diff)), _v1(*memunit_advanced(semantic_at_c<1>(ptr),diff)), _v2(*memunit_advanced(semantic_at_c<2>(ptr),diff)) {} // Support for planar_pixel_reference operator[] Element at_c_dynamic(size_t i) const { switch (i) { case 0: return _v0; case 1: return _v1; } return _v2; } }; /// \brief A homogeneous color base holding four color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// \ingroup ColorBaseModelHomogeneous template
struct homogeneous_color_base
{ private: Element _v0, _v1, _v2, _v3; public: typedef Layout layout_t; typename element_reference_type
::type at(mpl::int_<0>) { return _v0; } typename element_const_reference_type
::type at(mpl::int_<0>) const { return _v0; } typename element_reference_type
::type at(mpl::int_<1>) { return _v1; } typename element_const_reference_type
::type at(mpl::int_<1>) const { return _v1; } typename element_reference_type
::type at(mpl::int_<2>) { return _v2; } typename element_const_reference_type
::type at(mpl::int_<2>) const { return _v2; } typename element_reference_type
::type at(mpl::int_<3>) { return _v3; } typename element_const_reference_type
::type at(mpl::int_<3>) const { return _v3; } homogeneous_color_base() {} explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v) {} homogeneous_color_base(Element v0, Element v1, Element v2, Element v3) : _v0(v0), _v1(v1), _v2(v2), _v3(v3) {} template
homogeneous_color_base(const homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)), _v3(at_c
::value>(c)) {} // Support for l-value reference proxy copy construction template
homogeneous_color_base( homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)), _v3(at_c
::value>(c)) {} // Support for planar_pixel_iterator construction and dereferencing template
homogeneous_color_base(P* p,bool) : _v0(&semantic_at_c<0>(*p)), _v1(&semantic_at_c<1>(*p)), _v2(&semantic_at_c<2>(*p)), _v3(&semantic_at_c<3>(*p)) {} template
Ref deref() const { return Ref(*semantic_at_c<0>(*this), *semantic_at_c<1>(*this), *semantic_at_c<2>(*this), *semantic_at_c<3>(*this)); } // Support for planar_pixel_reference offset constructor template
homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff) : _v0(*memunit_advanced(semantic_at_c<0>(ptr),diff)), _v1(*memunit_advanced(semantic_at_c<1>(ptr),diff)), _v2(*memunit_advanced(semantic_at_c<2>(ptr),diff)), _v3(*memunit_advanced(semantic_at_c<3>(ptr),diff)) {} // Support for planar_pixel_reference operator[] Element at_c_dynamic(size_t i) const { switch (i) { case 0: return _v0; case 1: return _v1; case 2: return _v2; } return _v3; } }; /// \brief A homogeneous color base holding five color elements. Models HomogeneousColorBaseConcept or HomogeneousColorBaseValueConcept /// \ingroup ColorBaseModelHomogeneous template
struct homogeneous_color_base
{ private: Element _v0, _v1, _v2, _v3, _v4; public: typedef Layout layout_t; typename element_reference_type
::type at(mpl::int_<0>) { return _v0; } typename element_const_reference_type
::type at(mpl::int_<0>) const { return _v0; } typename element_reference_type
::type at(mpl::int_<1>) { return _v1; } typename element_const_reference_type
::type at(mpl::int_<1>) const { return _v1; } typename element_reference_type
::type at(mpl::int_<2>) { return _v2; } typename element_const_reference_type
::type at(mpl::int_<2>) const { return _v2; } typename element_reference_type
::type at(mpl::int_<3>) { return _v3; } typename element_const_reference_type
::type at(mpl::int_<3>) const { return _v3; } typename element_reference_type
::type at(mpl::int_<4>) { return _v4; } typename element_const_reference_type
::type at(mpl::int_<4>) const { return _v4; } homogeneous_color_base() {} explicit homogeneous_color_base(Element v) : _v0(v), _v1(v), _v2(v), _v3(v), _v4(v) {} homogeneous_color_base(Element v0, Element v1, Element v2, Element v3, Element v4) : _v0(v0), _v1(v1), _v2(v2), _v3(v3), _v4(v4) {} template
homogeneous_color_base(const homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)), _v3(at_c
::value>(c)), _v4(at_c
::value>(c)) {} // Support for l-value reference proxy copy construction template
homogeneous_color_base( homogeneous_color_base
& c) : _v0(at_c
::value>(c)), _v1(at_c
::value>(c)), _v2(at_c
::value>(c)), _v3(at_c
::value>(c)), _v4(at_c
::value>(c)) {} // Support for planar_pixel_iterator construction and dereferencing template
homogeneous_color_base(P* p,bool) : _v0(&semantic_at_c<0>(*p)), _v1(&semantic_at_c<1>(*p)), _v2(&semantic_at_c<2>(*p)), _v3(&semantic_at_c<3>(*p)), _v4(&semantic_at_c<4>(*p)) {} template
Ref deref() const { return Ref(*semantic_at_c<0>(*this), *semantic_at_c<1>(*this), *semantic_at_c<2>(*this), *semantic_at_c<3>(*this), *semantic_at_c<4>(*this)); } // Support for planar_pixel_reference offset constructor template
homogeneous_color_base(const Ptr& ptr, std::ptrdiff_t diff) : _v0(*memunit_advanced(semantic_at_c<0>(ptr),diff)), _v1(*memunit_advanced(semantic_at_c<1>(ptr),diff)), _v2(*memunit_advanced(semantic_at_c<2>(ptr),diff)), _v3(*memunit_advanced(semantic_at_c<3>(ptr),diff)), _v4(*memunit_advanced(semantic_at_c<4>(ptr),diff)) {} // Support for planar_pixel_reference operator[] Element at_c_dynamic(size_t i) const { switch (i) { case 0: return _v0; case 1: return _v1; case 2: return _v2; case 3: return _v3; } return _v4; } }; // The following way of casting adjacent channels (the contents of color_base) into an array appears to be unsafe // -- there is no guarantee that the compiler won't add any padding between adjacent channels. // Note, however, that GIL _must_ be compiled with compiler settings ensuring there is no padding in the color base structs. // This is because the color base structs must model the interleaved organization in memory. In other words, the client may // have existing RGB image in the form "RGBRGBRGB..." and we must be able to represent it with an array of RGB color bases (i.e. RGB pixels) // with no padding. We have tested with char/int/float/double channels on gcc and VC and have so far discovered no problem. // We have even tried using strange channels consisting of short + char (3 bytes). With the default 4-byte alignment on VC, the size // of this channel is padded to 4 bytes, so an RGB pixel of it will be 4x3=12 bytes. The code below will still work properly. // However, the client must nevertheless ensure that proper compiler settings are used for their compiler and their channel types. template
typename element_reference_type
>::type dynamic_at_c(homogeneous_color_base
& cb, std::size_t i) { assert(i
(&cb))[i]; } template
typename element_const_reference_type
>::type dynamic_at_c(const homogeneous_color_base
& cb, std::size_t i) { assert(i
(&cb))[i]; } template
typename element_reference_type
>::type dynamic_at_c(const homogeneous_color_base
& cb, std::size_t i) { assert(i
typename element_const_reference_type
>::type dynamic_at_c(const homogeneous_color_base
& cb, std::size_t i) { assert(i
struct kth_element_type
, K> { typedef Element type; }; template
struct kth_element_reference_type
, K> : public add_reference
{}; template
struct kth_element_const_reference_type
, K> : public add_reference
::type> {}; /// \brief Provides mutable access to the K-th element, in physical order /// \ingroup ColorBaseModelHomogeneous template
inline typename add_reference
::type at_c( detail::homogeneous_color_base
& p) { return p.at(mpl::int_
()); } /// \brief Provides constant access to the K-th element, in physical order /// \ingroup ColorBaseModelHomogeneous template
inline typename add_reference
::type>::type at_c(const detail::homogeneous_color_base
& p) { return p.at(mpl::int_
()); } namespace detail { struct swap_fn { template
void operator()(T& x, T& y) const { using std::swap; swap(x,y); } }; } template
inline void swap(detail::homogeneous_color_base
& x, detail::homogeneous_color_base
& y) { static_for_each(x,y,detail::swap_fn()); } } } // namespace boost::gil #endif
color_base.hpp
Page URL
File URL
Prev
7/34
Next
Download
( 20 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.