ST_MakeTexture

更新时间:
复制 MD 格式

Constructs a texture.

Syntax

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');

Parameters

Parameter Name

Description

width

The width of the texture image.

height

The height of the texture image.

url

The path of the texture image.

to_internal

Specifies whether to use the internal storage mode. The default value is false.

depth

The pixel depth of the texture image. The value must be one of the following:

  • 1: Grayscale.

  • 3: RGB. This is the default value.

  • 4: RGBA.

compression

The compression method for the texture image data stream. The value must be one of the following:

  • None: No compression. This is the default value.

  • Zlib: Zlib compression.

format

The format of the texture image. The value must be one of the following:

  • Raw: The raw pixel matrix.

  • JPEG: The JPEG format. This is the default value.

  • PNG: The PNG format.

wrap

The wrap mode of the texture image. The value must be one of the following:

  • Wrap: The wrap mode. This is the default value.

  • Mirror: The mirror mode.

table_name

The name of the table that contains the existing texture.

column_name

The name of the column that contains the existing texture.

key_value

The unique ID used to query the existing texture. This parameter is used in the WHERE clause.

schema_name

The name of the schema that contains the existing texture. The default value is public.

data

The binary data stream of the texture image.

Description

You can store the binary data of a texture image in three ways. Choose a storage solution based on your scenario:

  • Store the binary data directly in the database. This method does not require an external reference, but it increases the data volume in the database.

  • Store the binary data in an external file. This method uses less database storage capacity, but it results in lower access performance.

  • Store the texture data in a separate table in the database. When you use the data, you can reference the storage information in the database.

Examples

-- Create a texture table.
CREATE TABLE textures(id integer, the_texture texture);

-- Insert a 225×225 RGBA PNG file and store its binary stream internally.
INSERT INTO textures VALUES (1, ST_MakeTexture(225,225,'path/example.png'::cstring, true, 4, 'PNG'));

-- Insert a 225×225 RGB JPEG file whose binary stream is in an external file.
INSERT INTO textures VALUES (2, ST_MakeTexture(225,225,'path/example.jpeg'::cstring, false, 3, 'JPEG'));

-- Insert a 256×256 RGB JPEG file by providing its binary stream.
INSERT INTO textures VALUES (3, ST_MakeTexture(256,256, '\x123abcd...'::bytea));

-- Insert a reference to the texture with id=1 in the same table.
INSERT INTO textures VALUES (4, ST_MakeTexture('textures'::cstring, 'the_texture'::cstring, 'id=1'));