GraphicLibrary  0.5.0
SuperSamplingPattern クラス

Supersampling 用パターン [詳解]

SuperSamplingPattern の継承関係図
DrawingArea_IF SSP_ErrorDiffusion SSP_FloydSteinberg SSP_JJN SSP_OrderedDithering

クラス

struct  Pixel
 パターンの要素の型 [詳解]
 

公開メンバ関数

 SuperSamplingPattern (const Coord< int > &sz, int mag)
 実際の大きさと倍率を指定して構築 [詳解]
 
void init ()
 要素を消去して初期化する [詳解]
 
void init (int mag)
 要素を消去して初期化する(同時に倍率を変更する) [詳解]
 
virtual bool pset (Coord< int > vc, RGB col)
 パターンへの描画 [詳解]
 
virtual Coord< int > size () const
 疑似パターン・サイズの取得 [詳解]
 
void put (DrawingArea_IF &draw, Coord< int > s)
 パターンの描画 [詳解]
 
- 基底クラス DrawingArea_IF に属する継承公開メンバ関数
virtual ~DrawingArea_IF ()
 仮想デストラクタ (何もしない)
 

限定公開メンバ関数

bool getPixel (Coord< int > rc, Pixel *pixel) const
 パターンのPixel値を取得する [詳解]
 
bool add (const Coord< int > &rc, const Pixel &pixel) const
 パターンへのPixel値の加算 [詳解]
 

詳解

Supersampling 用パターン

パターンを擬似的に拡大して、その中で描画を行う。実画面にはパターンを縮小して再現する。 実際に拡大した分の要素を用意するのではなく、要素数は実画面と同数としておき、一つの要素が 複数の RGB 成分を持つものとみなす。従って、各要素は RGB 各成分の和とその個数を保持する。

以下はその利用例である。

Coord< int > size( 1024, 768 ); // 画像サイズ
// 描画領域。引数として画像サイズを渡す。
GPattern pattern( size );
// 画像サイズの 1 / 4 の描画領域を用意。
GPattern quarter( Coord< int >( size.x / 2, size.y / 2 ) );
// ここで quarter に対して何らかの画像を描画
SuperSamplingPattern ssp( size, 5 ); // 疑似解像度用パターン(5倍の解像度)
GInterpolation_NN nn; // 補間処理は最近傍法
// quarter の画像を 2 倍 ( 擬似的には 10 倍 ) に拡大処理
ResizePut( quarter, ssp, Coord< int >( 0, 0 ), Coord< int >( ssp.size().x - 1, ssp.size().y - 1 ), nn );
// pattern に処理結果を出力
ssp.put( pattern, Coord< int >( 0, 0 ) );

DrawingArea_IF で用意されている仮想関数 DrawingArea_IF::point は非公開としているため、 SuperSamplingPattern インスタンスを利用して Put 等により他の描画領域に描画を行うことは できない。代わりに、専用のメンバ関数 put が用意されておりこれを利用する。

構築子と解体子

◆ SuperSamplingPattern()

SuperSamplingPattern::SuperSamplingPattern ( const Coord< int > &  sz,
int  mag 
)

実際の大きさと倍率を指定して構築

各要素は Pixel のデフォルト値 ( 全要素がゼロ ) で初期化される。

パターンの大きさ sz の X, Y 座標それぞれ負数の場合はゼロで初期化される。 倍率 mag が負数の場合はゼロで初期化される。

引数
szパターンの実際の大きさ
mag倍率(疑似解像度との比率)

関数詳解

◆ add()

bool SuperSamplingPattern::add ( const Coord< int > &  rc,
const Pixel pixel 
) const
protected

パターンへのPixel値の加算

描画とは異なり、加算回数はカウントされない。誤差項を追加する場合等に利用する。 指定した座標がパターン外部の場合は処理しない。

引数
rc描画する位置(実サイズ上)
pixel加算するPixel値
戻り値
座標がパターンの範囲外ならば falseを返す

◆ getPixel()

bool SuperSamplingPattern::getPixel ( Coord< int >  rc,
Pixel pixel 
) const
protected

パターンのPixel値を取得する

指定した座標がパターン外部の場合、もっとも近いピクセルのPixel値を取得する

引数
rc取得する位置(実サイズ上)
pixel取得したPixel値
戻り値
座標がパターンの範囲外か、またはパターン内に色コードが格納されていなかった場合は falseを返す

◆ init() [1/2]

void SuperSamplingPattern::init ( )
inline

要素を消去して初期化する

各要素は Pixel のデフォルト値 ( 全要素がゼロ ) で初期化される。

◆ init() [2/2]

void SuperSamplingPattern::init ( int  mag)
inline

要素を消去して初期化する(同時に倍率を変更する)

各要素は Pixel のデフォルト値 ( 全要素がゼロ ) で初期化される。 倍率 mag が負数の場合は無視される。

引数
mag変更する倍率

◆ pset()

virtual bool SuperSamplingPattern::pset ( Coord< int >  vc,
RGB  col 
)
virtual

パターンへの描画

擬似サイズ上の座標を指定することに注意。実サイズ上の座標に変換された上で、Pixel の要素に値が加算される。 倍率 mag がゼロ、指定した座標がパターン外部の場合は処理しない

引数
vc描画する位置(疑似サイズ上)
col描画する色コード
戻り値
座標がパターンの範囲外ならば falseを返す

DrawingArea_IFを実装しています。

◆ put()

void SuperSamplingPattern::put ( DrawingArea_IF draw,
Coord< int >  s 
)

パターンの描画

倍率 mag がゼロの場合は何も描画されないことに注意。

引数
draw描画領域
sパターンの描画開始位置

◆ size()

virtual Coord< int > SuperSamplingPattern::size ( ) const
inlinevirtual

疑似パターン・サイズの取得

戻り値
擬似パターンのサイズ

DrawingArea_IFを実装しています。


このクラス詳解は次のファイルから抽出されました: