点描方法として、透明な背景を選定する
Put 描画命令文へのパラメタ
構文:
Put [ target, ] [ STEP ] ( x,y ), source [ ,( x1,y1 )-( x2,y2 ) ], Trans
パラメタ:
説明:
Trans は、画像バッファを点描する方法として、透明な背景を選定します。
これは
PSET 方法と同様ですが、マスク色を含む画素は、スキップされます。
8ビットのカラー画像では、マスク色は、パレット索引 0 です。
16/32ビットのカラー画像では、マスク色は、Magenta(マゼンタ 赤紫色)です。Magenta は、
RGB(255, 0, 255)です。
アルファ値は、32ビット画像にマスク色がないかどうかチェックするとき、無視されます。
例:
注:FreeBASIC 1.08〜 で、SetEnviron を追加しなくても、日本語環境で描画画面が表示されるように改善されました。
' Sets the graphics method GDI
' 描画方法を GDI に設定
SetEnviron("fbgfx=GDI")
'' 画面を設定します :320 * 200, 1画素あたり16 bits
ScreenRes 320,
200,
16
'' 背景として、マスク色で画像を設定します
Dim img
As Any Ptr =
ImageCreate
( 32,
32,
RGB(255,
0,
255) )
Circle img,
(16,
16),
15,
RGB(255,
255,
0), , ,
1, f
Circle img,
(10,
10),
3,
RGB( 0,
0,
0), , ,
2, f
Circle img,
(23,
10),
3,
RGB( 0,
0,
0), , ,
2, f
Circle img,
(16,
18),
10,
RGB( 0,
0,
0),
3.
14,
6.
28
'' PSET で、画像を置きます。
(画像バッファの、まさしくその内容を与えます)
Draw String (110,
50 -
4),
"Image put with PSET"
Put (60 -
16,
50 -
16), img,
PSet
'' TRANS で画像を置きます
Draw String (110,
150 -
4),
"Image put with TRANS"
Put (60 -
16,
150 -
16), img,
Trans
'' 画像メモリを解放します
ImageDestroy img
'' キー入力を待ちます
Sleep
' Sets the graphics method GDI
' 描画方法を GDI に設定
SetEnviron("fbgfx=GDI")
Function trans32
( ByVal source_pixel
As ulong,
ByVal destination_pixel
As ulong,
ByVal parameter
As Any Ptr ) As ulong
Function trans32 ( ByVal source_pixel As UInteger, ByVal destination_pixel As UInteger, ByVal parameter As Any Ptr ) As UInteger
'' &hff00ff(マゼンタ)でない限り、ソース・ピクセルを返します。
'' それで、転送先のピクセルを返します。
If (source_pixel
And &hffffff
) <> &hff00ff
Then
Return source_pixel
Else
Return destination_pixel
End If
End Function
'' 画面を設定します: 320 * 200(1ピクセルにつき16ビット)
ScreenRes 320,
200,
32
'' 背景としてマスク・カラーで画像を準備します。
Dim img
As Any Ptr =
ImageCreate( 32,
32,
RGB(255,
0,
255) )
Circle img,
(16,
16),
15,
RGB(255,
255,
0), , ,
1, f
Circle img,
(10,
10),
3,
RGB( 0,
0,
0), , ,
2, f
Circle img,
(23,
10),
3,
RGB( 0,
0,
0), , ,
2, f
Circle img,
(16,
18),
10,
RGB( 0,
0,
0),
3.
14,
6.
28
'' PSET で画像を置きます(画像バッファの内容を与えます)
Draw String (110,
50 -
4),
"Image put with PSET"
Put (60 -
16,
50 -
16), img,
PSet
'' TRANS で画像を置きます
Draw String (110,
100 -
4),
"Image put with TRANS"
Put (60 -
16,
100 -
16), img,
Trans
'' TRANS で画像を置きます
Draw String (110,
150 -
4),
"Image put with trans32"
Put (60 -
16,
150 -
16), img,
Custom, @trans32
'' 画像メモリを解放
ImageDestroy img
'' キー入力を待ちます
Sleep
QB との違い:
参照: