« サブセット | メイン | ネイティブでの TJS2 クラスの継承 »

2013年07月29日

吉里吉里Z 開発:: Layer クラスの分割

    

Layer クラスの分割と書いたけど、従来の Layer クラスはそのまま残すことにした。
分割して、TJS2 層で互換性をとることも検討したけど、そのまま残した。
つまり、いくつかクラスが追加されただけ。
以下追加されたクラス(一部実装中)。

class Bitmap {
function Bitmap()
function Bitmap( width : int, height : int, bpp = 32 : int )
function Bitmap( filename : string, colorkey = clNone : int )
function getPixel( x : int, y : int ) : int
function setPixel( x : int, y : int, value : int )
function getMaskPixel( x : int, y : int ) : int
function setMaskPixel( x : int, y : int, value : int )
function independ( copy = true : boolean )
function setSize( width : int, height : int )
function copyFrom( src : Bitmap )
function save( filename : string, type = "bmp" : string )
function load( filename : string, colorkey = clNone : int ) : Dictionay
function loadAsync( filename : string, colorkey = clNone : int ) : bool
property width { set/get }
property height { set/get }
property buffer { get }
property bufferForWrite { get }
property bufferPitch { get }
property loading { get }
}

画像情報を保持するクラスがあるとツール用途などで助かるということで追加。
後、追加検討途中だけどパレットも考えている。
bpp が 8 で、256色の時パレットを扱えるようなもの。
ただ、そのままでは描画出来ないので、32ビット画像へ描画するメソッドも検討中。

class Rect {
function Rect();
function Rect( left : int , top : int , right : int, bottom : int );
function Rect( src : Rect );
function setSize( width : int, height : int );
function setOffset( x : int, y : int );
function isEmpty() : bool
function clip( r : Rect ) : bool
function union( r : Rect ) : bool
function intersects( r : Rect ) : bool
function included( r : Rect ) : bool
function equal( r : Rect ) : bool
property width { set/get : int }
property height { set/get : int }
property left { set/get : int }
property top { set/get : int }
property right { set/get : int }
property bottom { set/get : int }
property nativeArray { get : tjs_int[4] } // for plugin
};

描画系のメソッドを別クラスで作るにあたり、矩形クラスがないと不便ということで追加。

class ImageFunction {
void operateAffine( dst, src, A, B, C, D, E, F, srcrect=null, cliprect=null, affine=true, mode=omAlpha, face=dfAlpha, opa=255, type=stNearest, hda=false)
void operateRect( dst, dleft, dtop, src, srcrect=null, cliprect=null, mode=omAlpha, face=dfAlpha, opa=255, hda=false )
void operateStretch( dst, src, dstrect=null, srcrect=null, cliprect=null, mode=omAlpha, face=dfAlpha, opa=255, type=stNearest hda=false )

void flipLR( bmp, rect=null )
void flipUD( bmp, rect=null )

void adjustGamma( bmp, rgamma=1.0, rfloor=0, rceil=255, ggamma=1.0, gfloor=0, gceil=255, bgamma=1.0, bfloor=0, bceil=255, cliprect=null, isaddalpha=false)
void doBoxBlur( bmp, xblur=1, yblur=1, cliprect=null, isalpha=true);
void doGrayScale( bmp, cliprect=null )

void colorRect( bmp, value, opa=255, rect=null, face=dfAlpha, cliprect=null )
void drawText( bmp, x, y, text, color, opa=255, aa=true, face=dfAlpha, shadowlevel=0, shadowcolor=0x000000, shadowwidth=0, shadowofsx=0, shadowofsy=0, hda=false, clipRect=null )
void fillRect( bmp, value, rect=null, isalpha=true, cliprect=null )
};

組み込みの画像処理系のメソッドをまとめたクラス。
クラスと言っても全て static なので、単なる関数の集まり。
更新された矩形を返した方が良いと思い、現在少し変更中。

これらのクラスを使って、Layer のようなクラスを作れなくはないけど、たぶんだいぶ効率が悪い。
Bitmap を継承したクラスに ImageFunction のメソッドをくっつけた方が使い勝手が良いかもしれない。

後、Layer クラスから Bitmap を得る方法を参照にするかコピーにするか検討中。



投稿者 Takenori : 2013年07月29日 14:59




comments powered by Disqus
Total : Today : Yesterday : なかのひと