View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

BitBltで遊ぶ

back


BitBltで遊ぶです。
BitBltを使うとビットマップ画像を簡単に転送することができるらしいですな。
転送するときにいろいろと面白いことができるのでそれをちょこっと試して見るです。


ソースコードを順番にドゥ〜イットしてみてください。
Alt + d ( Cmd + d )




■BitBltで転送だよん!

まずは転送元になるフォームを作るです。
フォームキャンバスを黄色で塗りつぶし黒の楕円を描くです。
--------------------------------------------
srcFc _ FormCanvas extent: 100@100.
srcFc fillColor: Color yellow.
srcFc fillOval: ((10@10) extent: (60@60)) color: Color black.
srcFc showAt: 50@50.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


画面に転送しましょう。(画面の0@0の位置)
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


転送元の位置を30@30にして転送。
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b sourceOrigin: 30 @ 30.
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


転送先の位置を120@120にして転送。
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b destOrigin: 120@120 .
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


クリッピングしてみるです。転送先の矩形を指定。
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b clipRect: (30@30 extent: 40@40).
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


転送元の位置と転送先の位置を指定して転送。
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b destOrigin: 120@120 .
b sourceOrigin: 30 @ 30.
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------


転送元、転送先、クリッピングを指定して転送。
--------------------------------------------
b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: Form over.
b fillColor: Color red.
b destOrigin: 120@120 .
b sourceOrigin: 30 @ 30.
b clipRect: (120@120 extent: 50@50).
b copyBits.
--------------------------------------------
画面をお掃除。
--------------------------------------------
Display restore.
--------------------------------------------



■コンビネーション・ルールをいろいろ試して見る


転送元を用意する。白地に黒の楕円を描いたフォーム。
--------------------------------------------
srcFc _ FormCanvas extent: 100@100.
srcFc fillColor: Color white.
srcFc fillOval: ((10@10) extent: (60@60)) color: Color black.
--------------------------------------------
"表示する"
--------------------------------------------
srcFc showAt: 50@50.
--------------------------------------------


転送先を用意する。白地に黒の四角形を描いたフォーム。
--------------------------------------------
dstFc _ FormCanvas extent: 100@100.
dstFc fillColor: Color white.
dstFc fillRectangle: ((40@40) extent: (50@50)) color: Color black.
--------------------------------------------
"表示する"
--------------------------------------------
dstFc showAt: 180@50.
--------------------------------------------


さて、用意した2つのフォームを合体させます。
ここでは転送先のフォームを先に画面に表示させ、
その上に転送元のフォームをブレンドさせてます。

まずはカウンタの初期化でござる。
--------------------------------------------
num _ 0.
--------------------------------------------

以下のソースコードを選択して
Do itを繰り返してみてちょんまげ。
コンビネーション・ルール0から15までね。
(真っ黒になったら一回りっす。)
--------------------------------------------
srcFc showAt: 50@50.
dstFc showAt: 180@50.
dstFc showAt: 120@180.

b _ BitBlt toForm: Display.
b sourceForm: srcFc form.
b combinationRule: num.
b destOrigin: 120@180.
b sourceOrigin: 0@0.
b clipRect: (120@180 extent: 100@100).
b copyBits.

num _ num + 1.
num >= 16 ifTrue: [num _ 0].
--------------------------------------------




クラスメソッドの「destForm:」を使うとこんな感じになるかにゃ?
--------------------------------------------
bb _ BitBlt
	destForm: Display
	sourceForm: Form fromUser
	fillColor: nil
	combinationRule: Form over
	destOrigin:  Sensor waitButton 
	sourceOrigin: 0 @ 0
	extent: 100@100
	clipRect: Display computeBoundingBox.
bb copyBits

--------------------------------------------





下の入力ボックスに書き込んで”add to the page”ボタンで登録出来ます。
修正したい場合はページ左のアイコンの”edit”で出てくる画面で編集可能です。
ページ左のアイコンの”uploads”で画像(JPEG,GIF,PNG)のアップロードもできます。


Monday, 31 May 2004, 9:32:31 pm
WarpBltもちょこっとやってみっかな・・・・--thoru

Link to this Page