/*! * \file yof_image.hpp * \brief 画像クラス * * \author Kenta Yoshimura * \warning このヘッダを使用する際には boost ( http://www.boost.org/ ) が必要です。 * * Copyright(C) 2003-2004 Kenta Yoshimura All Rights Reserved. * * $Id$ */ #ifndef YOF_IMAGE #define YOF_IMAGE #if !defined(_MSC_VER) | _MSC_VER > 1000 #pragma once #endif #include "yof_types.hpp" #include "yof_basic_image.hpp" namespace yoffy { //! basic_image の特殊化用ラッパ template< class IMAGE > struct image : public IMAGE { typedef IMAGE super; typedef image< IMAGE > self; typedef typename super::iterator iterator; typedef typename super::const_iterator const_iterator; typedef typename super::variable_iterator variable_iterator; typedef typename super::value_type value_type; typedef typename super::difference_type difference_type; typedef typename super::pointer pointer; typedef typename super::const_pointer const_pointer; typedef typename super::reference reference; typedef typename super::const_reference const_reference; typedef typename super::size_type size_type; typedef typename super::reverse_iterator reverse_iterator; typedef typename super::const_reverse_iterator const_reverse_iterator; typedef typename super::collector collector; typedef typename super::clip_iterator clip_iterator; typedef image< typename super::clip_self > clip_self; typedef image< typename super::const_clip_self > const_clip_self; yof_forceinline image() : super() {} /* yof_forceinline image( super & src ) : super( src ) {} yof_forceinline self & operator =( super & src ) { *reinterpret_cast< super * >( this ) = src; return *this; } template< class SRC_ITERATOR > yof_forceinline image( const image< basic_image< SRC_ITERATOR > > & src ) : super( src ) {} template< class SRC_ITERATOR > yof_forceinline self & operator=( const image< basic_image< SRC_ITERATOR > > & src ) { super::operator=( src ); return *this; } */ template< class SRC_ITERATOR > yof_forceinline image( const basic_image< SRC_ITERATOR > & src ) : super( src ) {} template< class SRC_ITERATOR > yof_forceinline self & operator=( const basic_image< SRC_ITERATOR > & src ) { super::operator=( src ); return *this; } // 少なくとも VC7.1 では上の関数が使われない yof_forceinline self & operator=( const self & src ) { super::operator=( src ); return *this; } template< class OPERATOR > yof_forceinline image( const image_operator< OPERATOR > & op ) : super( op ) {} template< class OPERATOR > yof_forceinline self & operator =( const image_operator< OPERATOR > & op ) { super::operator =( op ); return *this; } /*! 画像を新規作成 * \param inWidth 幅 * \param inHeight 高さ * \param clear 0 で初期化する場合は true ( デフォルト ) */ yof_forceinline image( size_type inWidth, size_type inHeight, bool clear = true ) : super( inWidth, inHeight, clear ) {} /*! 画像を参照 * \param inImage 参照する画像のポインタ * \param inWidth 幅 * \param inHeight 高さ */ yof_forceinline image( pointer inImage, size_type inWidth, size_type inHeight ) : super ( inImage, inWidth, inHeight ) {} /*! 画像を参照 * \param inImage 参照する画像のイテレータ * \param inWidth 幅 * \param inHeight 高さ */ yof_forceinline image( iterator inImage, size_type inWidth, size_type inHeight ) : super( inImage, inWidth, inHeight ) {} /*! 画像を参照 * \param inImage 参照する画像の boost:shared_ptr ポインタ * \param inWidth 幅 * \param inHeight 高さ */ yof_forceinline image( collector inImage, size_type inWidth, size_type inHeight ) : super( inImage, inWidth, inHeight ) {} yof_forceinline self & operator =( value_type n ) { super::operator =( n ); return *this; } yof_forceinline self & operator =( struct _icol src ) { super::operator =( src ); return *this; } yof_forceinline self & operator =( struct _irow src ) { super::operator =( src ); return *this; } yof_forceinline self & operator =( struct _iradius src ) { super::operator =( src ); return *this; } yof_forceinline self & operator =( struct _isqlen src ) { super::operator =( src ); return *this; } /*! 画像のクリッピング(領域を限定した参照) * \param inX 開始 X 座標 * \param inY 開始 Y 座標 * \param inWidth 幅 * \param inHeight 高さ * \return クリッピング画像 */ clip_self clip( size_type inX, size_type inY, size_type inWidth, size_type inHeight ) { return clip_self( super::clip( inX, inY, inWidth, inHeight ) ); } /*! 画像のクリッピング(領域を限定した参照) * \param inX 開始 X 座標 * \param inY 開始 Y 座標 * \param inWidth 幅 * \param inHeight 高さ * \return クリッピング画像 */ const_clip_self clip( size_type inX, size_type inY, size_type inWidth, size_type inHeight ) const { return const_clip_self( super::clip( inX, inY, inWidth, inHeight ) ); } /*! 画像の複製 * \return 複製された画像 */ self clone() const { return super::clone(); } image_operator< icol_< value_type > > icol() const { return image_operator< icol_< value_type > >( icol_< value_type >( super::width(), super::height() ) ); } image_operator< irow_< value_type > > irow() const { return image_operator< irow_< value_type > >( irow_< value_type >( super::width(), super::height() ) ); } image_operator< iradius_< value_type > > iradius() const { return image_operator< iradius_< value_type > >( iradius_< value_type >( super::width(), super::height() ) ); } image_operator< isqlen_< value_type > > isqlen() const { return image_operator< isqlen_< value_type > >( isqlen_< value_type >( super::width(), super::height() ) ); } template< class SRC > self & operator +=( const SRC & src ) { return *this = *this * src; } self & operator ++() { return *this = *this + 1; } self operator ++( int ) { self tmp( this->clone() ); *this = *this + 1; return tmp; } template< class SRC > self & operator -=( const SRC & src ) { return *this = *this - src; } self & operator --() { return *this = *this - 1; } self operator --( int ) { self tmp( this->clone() ); *this = *this - 1; return tmp; } template< class SRC > self & operator *=( const SRC & src ) { return *this = *this * src; } template< class SRC > self & operator /=( const SRC & src ) { return *this = *this / src; } template< class SRC > self & operator %=( const SRC & src ) { return *this = *this % src; } template< class SRC > self & operator &=( const SRC & src ) { return *this = *this & src; } template< class SRC > self & operator |=( const SRC & src ) { return *this = *this | src; } template< class SRC > self & operator ^=( const SRC & src ) { return *this = *this ^ src; } }; #define yof_image(type) yoffy::image< yoffy::basic_image< yof_image_iterator( type ) > > #define yof_clipimage(type) yoffy::image< yoffy::basic_image< yof_clipimage_iterator( type ) > > typedef yof_image( bool ) imageb; typedef yof_image( int8_t ) images8; typedef yof_image( int16_t ) images16; typedef yof_image( int32_t ) images32; typedef yof_image( int64_t ) images64; typedef yof_image( uint8_t ) imageu8; typedef yof_image( uint16_t ) imageu16; typedef yof_image( uint32_t ) imageu32; typedef yof_image( uint64_t ) imageu64; typedef yof_image( float ) imagef32; typedef yof_image( double ) imagef64; typedef yof_image( std::complex< float > ) imagec64; typedef yof_image( std::complex< double > ) imagec128; typedef yof_clipimage( bool ) clipimageb; typedef yof_clipimage( int8_t ) clipimages8; typedef yof_clipimage( int16_t ) clipimages16; typedef yof_clipimage( int32_t ) clipimages32; typedef yof_clipimage( int64_t ) clipimages64; typedef yof_clipimage( uint8_t ) clipimageu8; typedef yof_clipimage( uint16_t ) clipimageu16; typedef yof_clipimage( uint32_t ) clipimageu32; typedef yof_clipimage( uint64_t ) clipimageu64; typedef yof_clipimage( float ) clipimagef32; typedef yof_clipimage( double ) clipimagef64; typedef yof_clipimage( std::complex< float > ) clipimagec64; typedef yof_clipimage( std::complex< double > ) clipimagec128; } // namespace yoffy #include "yof_image_operator.hpp" #endif // #ifndef YOF_IMAGE