Manual of LIBPOLYMNIA

LIBPOLYMNIA

畫像バッファ、及び其の處理に關係するクラス・函數群。

JPEGの讀み書きにlibjpeg、PNGの讀み書きにlibpngを用ゐてゐるので、當ライブラリをビルドする際には、それらを豫めインストールしておく必要がある。(インストールされてゐない場合に、當該處理を切り離すのは將來の課題。個人的には遣りたくないけど。)

屬するクラス・函數等は、特記しない限り、namespace polymniaの下で定義される。

畫像バッファクラステンプレート

polymnia/ibuf.hで定義される。

クラス一覽

struct Point

二次元座標上の點を表す。

メソッド一覽

Point()
デフォルトコンストラクタ。内容は空。
Point(int xx, int yy)
コンストラクタ。初期値を指定する。

公開フィールド一覽

x
x座標値。
y
y座標値。

struct Rect

二次元座標上の軸と平行な邊からなる長方形を表す。

メソッド一覽

Rect()
デフォルトコンストラクタ。内容は空。
Rect(int xx1, int yy1, int xx2, int yy2)
コンストラクタ。初期値を指定する。

公開フィールド一覽

x1
x座標値1。
y1
y座標値1。
x2
x座標値2。
y2
y座標値2。

(x1, y1)と(x2, y2)を對角とする長方形を表す。

class RangeOverException

範圍外にアクセスしようとしたときに投げられる例外のクラス。themis::EmptyExceptionをpublic繼承する。

メソッド一覽

virtual const char* what() const throw()
例外の種類を示す文字列を返す。
文字列 "polymnia::RangeOverException" へのポインタを返す。

template<class C_> class polymnia::ImageBuffer

ピクセル表現がC_である畫像バッファの基底クラステンプレート。

當クラスをインスタンス化することは出來ない。

boost::noncopyableをprivate繼承する。

内部型一覽

ColorType
C_の別名。

コンストラクタ

インスタンス化を防ぐ爲、コンストラクタはprotectedである。

ImageBuffer(int w, int h, int o)
幅w、高さh、スキャンラインオフセットoを内部に設定する。實際にバッファを取得することはない。

メソッド一覽

virtual ~ImageBuffer()
デストラクタ。
int width() const throw()
畫像幅を取得。
int height() const throw()
畫像の高さを取得。
int offset() const throw()
畫像のスキャンラインオフセットを取得。
ColorType* buffer() throw()
畫像バッファの先頭位置を取得。
const ColorType* buffer() const throw()
畫像バッファの先頭位置を取得。
ColorType& pixel(int x, int y) throw()
座標(x, y)のピクセルを參照する。
const ColorType& pixel(int x, int y) const throw()
座標(x, y)のピクセルを參照する。
ColorType& at(int x, int y) throw(RangeOverException)
座標(x, y)のピクセルを參照する。範圍チェックを行ひ、範圍外の場合、例外を投げる。
const ColorType& at(int x, int y) const throw(RangeOverException)
座標(x, y)のピクセルを參照する。範圍チェックを行ひ、範圍外の場合、例外を投げる。
void line(int x1, int y1, int x2, int y2, const ColorType& c)
座標(x1, y1)、座標(x2, y2)を兩端とする線分を描く。ピクセル値はcで指定する。
void box(int x1, int y1, int x2, int y2, const ColorType& c, bool fl=false)
座標(x1, y1)、座標(x2, y2)を對角とする長方形を描く。ピクセル値はcで指定する。flが眞の時は、長方形内を塗り潰す。
void ellipse(int x, int y, int a, int b, const ColorType& c, bool fl=false)
中心座標(x1, y1)、x軸半徑a、y軸半徑bの楕圓を描く。ピクセル値はcで指定する。flが眞の時は、楕圓内を塗り潰す。
void circle(int x, int y, int r, const ColorType& c, bool fl=false)
中心座標(x1, y1)、半徑rの圓を描く。ピクセル値はcで指定する。flが眞の時は、圓内を塗り潰す。
void paintFill(int x, int y, const ColorType& c)
開始座標(x1, y1)から、隣接する同値ピクセルを、ピクセル値cで塗り潰す。
void clear(const ColorType& c)
畫像内ピクセルを全てピクセル値cでクリアする。
void blt(int dx, int dy, ImageBuffer<C_>* src, int sx, int sy, int w, int h)
畫像に、別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。
void blt(int dx, int dy, ImageBuffer<C_>* src, int sx, int sy, int w, int h, const Rect& mask)
畫像に、別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。maskは、實際に値を書き換へてよい範圍を示すマスクを表す。
void blt(int dx, int dy, ImageBuffer<C_>* src, int sx, int sy, int w, int h, const ColorType& tcol)
畫像に、別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。tcolは、透過色を示し、轉寫元のピクセルがtcolの場合は、そのピクセルは轉寫しない。
void blt(int dx, int dy, ImageBuffer<C_>* src, int sx, int sy, int w, int h, const ColorType& tcol, const Rect& mask)
畫像に、別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。tcolは、透過色を示し、轉寫元のピクセルがtcolの場合は、そのピクセルは轉寫しない。maskは、實際に値を書き換へてよい範圍を示すマスクを表す。
template<class C2_> void blt(int dx, int dy, ImageBuffer<C2_>* src, int sx, int sy, int w, int h)
畫像に、色表現の異なる別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。
template<class C2_> void blt(int dx, int dy, ImageBuffer<C2_>* src, int sx, int sy, int w, int h, const Rect& mask)
畫像に、色表現の異なる別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。maskは、實際に値を書き換へてよい範圍を示すマスクを表す。
template<class C2_> void blt(int dx, int dy, ImageBuffer<C2_>* src, int sx, int sy, int w, int h, const C2_& tcol)
畫像に、色表現の異なる別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。tcolは、透過色を示し、轉寫元のピクセルがtcolの場合は、そのピクセルは轉寫しない。
template<class C2_> void blt(int dx, int dy, ImageBuffer<C2_>* src, int sx, int sy, int w, int h, const C2_& tcol, const Rect& mask)
畫像に、色表現の異なる別の畫像srcの内容を轉寫する。轉寫先左上の座標は(dx, dy)、轉寫元左上の座標は(sx, sy)、轉寫する幅はw、轉寫する高さはhで指定する。tcolは、透過色を示し、轉寫元のピクセルがtcolの場合は、そのピクセルは轉寫しない。maskは、實際に値を書き換へてよい範圍を示すマスクを表す。

RGB表現クラス

polymnia/rgb.hで定義される。

class RgbColor

RGB24bitカラーを表現する。

メソッド一覽

RgbColor() throw()
デフォルトコンストラクタ。R, G, B各成分を0で初期化する。
RgbColor(themis::Byte r0, themis::Byte g0, themis::Byte b0) throw()
コンストラクタ。RGB各成分の初期値を指定する。
bool operator==(const RgbColor& other) const throw()
同値比較。全成分の値が同じときに眞を返す。
bool operator!=(const RgbColor& other) const throw()
同値比較。全成分の値が同じではないときに眞を返す。

公開フィールド一覽

r
R成分値。
g
G成分値。
b
B成分値。

具體的な畫像バッファクラス

polymnia/picture.hで定義される。

class Picture

RGB24bitカラーの畫像バッファを表す。

ImageBuffer<RgbColor>を繼承する。

コンストラクタ

ユーザがnewを用ゐてインスタンス化出來ないやうに、コンストラクタはprotectedで定義してゐる。

Picture(unsigned w, unsigned h)
幅と高さを指定して初期化する。内部で必要な大きさのバッファを確保する。

メソッド一覽

virtual ~Picture()
デストラクタ。内部のバッファを解放する。
static Picture* create(unsigned w, unsigned h) throw()
幅と高さを指定して、新しいPictureのインスタンスを生成する。生成失敗時はNULLを返す。
Picture* clone() const throw()
同じ内容のPictureを生成する。生成失敗時はNULLを返す。

class PictureIndexed

RGB24bitカラー256パレットの畫像バッファを表す。

ImageBuffer<themis::Byte>を繼承する。

コンストラクタ

ユーザがnewを用ゐてインスタンス化出來ないやうに、コンストラクタはprotectedで定義してゐる。

PictureIndexed(unsigned w, unsigned h)
幅と高さを指定して初期化する。内部で必要な大きさのバッファを確保する。

メソッド一覽

virtual ~PictureIndexed()
デストラクタ。内部のバッファを解放する。
static PictureIndexed* create(unsigned w, unsigned h) throw()
幅と高さを指定して、新しいPictureIndexedのインスタンスを生成する。生成失敗時はNULLを返す。
Picture* clone() const throw()
同じ内容のPictureIndexedを生成する。生成失敗時はNULLを返す。
RgbColor& palette(int id) throw()
番號idのパレットのRGB値を參照する。
const RgbColor& palette(int id) const throw()
番號idのパレットのRGB値を參照する。
RgbColor* paletteBuffer() throw()
パレットのRGB値バッファの先頭を返す。
const RgbColor* paletteBuffer() const throw()
パレットのRGB値バッファの先頭を返す。
Picture* duplicatePicture() const throw()
同内容のPictureを生成する。

畫像バッファのロード・セーブ用基底クラステンプレート

polymnia/pictio.hで定義される。

template<class P_> class PictLoader

畫像バッファP_をファイルからロードするクラスの抽象基底となるクラステンプレート。

當クラスをインスタンス化することは出來ない。

boost::noncopyableをprivate繼承する。

メソッド一覽

PictLoader() throw()
デフォルトコンストラクタ。中身は空。
virtual ~PictLoader()
デストラクタ。
P_* load(const char* path)
P_* load(const std::string& path)
ファイルから畫像をロードする。具體的な處理はprotectedなvirtual P_* load_(const char*)=0;をオーバーライドして定義する。

template<class P_> class PictSaver

畫像バッファP_をファイルにセーブするクラスの抽象基底となるクラステンプレート。

當クラスをインスタンス化することは出來ない。

boost::noncopyableをprivate繼承する。

メソッド一覽

PictSaver() throw()
コンストラクタ。中身は空。
virtual ~PictSaver()
デストラクタ。
bool save(const P_* pict, const char* path)
bool save(const P_* pict, const std::string& path)
ファイルに畫像をセーブする。具體的な處理はprotectedなvirtual bool save_(const P_*, const char*)=0;をオーバーライドして定義する。