このトピックでは、ST_MakeTexture関数について説明します。この関数は、テクスチャ画像を構築します。
構文
texture ST_MakeTexture(integer width,
integer height,
cstring url,
boolean to_internal default false,
integer depth default 3,
cstring format default 'JPEG',
cstring compression default 'None',
cstring wrap default 'Wrap');
texture ST_MakeTexture(cstring table_name,
cstring column_name,
cstring key_value,
cstring schema_name default 'public');
texture ST_MakeTexture(integer width,
integer height,
bytea data,
integer depth default 3,
cstring format default 'JPEG',
cstring compression default 'None',
cstring wrap default 'Wrap');パラメーター
項目 | 説明 |
width | テクスチャ画像の幅。 |
height | テクスチャ画像の高さ。 |
url | テクスチャイメージのURL。 |
to_internal | 内部ストレージモードに切り替えるかどうかを指定します。 デフォルト値:false |
depth | テクスチャイメージのビット深度。 有効な値:
|
compression | テクスチャ画像のデータストリームの圧縮方法。 有効な値:
|
format | テクスチャ画像の形式。 有効な値:
|
wrap | テクスチャ画像のラップモード。 有効な値:
|
table_name | 既存のテクスチャが配置されているテーブルの名前。 |
column_name | 既存のテクスチャが配置されている列の名前。 |
key_value | 既存のテクスチャのID。 このパラメーターはWHERE句で使用されます。 |
schare_name | 既存のテクスチャのスキーマの名前。 デフォルト値 : public |
data | テクスチャ画像のバイナリデータストリーム。 |
説明
テクスチャ画像のバイナリデータストリームは、3つのモードで記憶することができる。 ビジネス要件に基づいて、テクスチャ画像用のストレージソリューションを開発できます。
テクスチャ画像のバイナリデータストリームをデータベースに保存します。 このソリューションを使用する場合、外部の関連付けは必要ありません。 しかし、データベース内のデータ量は大きい。
テクスチャ画像のバイナリデータストリームを外部ファイルに保存します。 このソリューションを使用すると、データベースのストレージが少なくなります。 しかし、アクセス性能は悪い。
テクスチャ画像のバイナリデータストリームをデータベースの別のテーブルに格納します。 このソリューションを使用すると、バイナリデータストリームの格納に使用されるデータベースが参照されます。
例
-- create texture table
CREATE TABLE textures(id integer, the_texture texture);
-- Insert a 225*225 RGBA PNG file, with internal store binary stream
INSERT INTO textures VALUES (1, ST_MakeTexture(225,225,'path/example.png'::cstring, true, 4, 'PNG'));
-- Insert a 225*255 RGB JPEG file, with binary stream in file
INSERT INTO textures VALUES (2, ST_MakeTexture(225,225,'path/example.jpeg'::cstring, false, 3, 'JPEG'));
-- Insert a 256*256 RGB JPEG file, providing the binary stream
INSERT INTO textures VALUES (3, ST_MakeTexture(256,256, '\x123abcd...'::bytea));
-- insert a reference texture which is id=1 in the same table
INSERT INTO textures VALUES (4, ST_MakeTexture('textures'::cstring, 'the_texture'::cstring, 'id=1'));