This topic describes ST_MakeTexture function. This function constructs a texture image.

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 Description
width The width of the texture image.
height The height of the texture image.
url The URL of the texture image.
to_internal Specifies whether to switch to the internal storage mode. Default value: false.
depth The bit depth of the texture image. Valid values:
  • 1: grayscale.
  • 3: RGB. This is the default value.
  • 4: RGBA.
compression The compression method for the data streams of the texture image. Valid values:
  • None: The data streams are not compressed. This is the default value.
  • Zlib: The zlib library is used to compress the data streams.
format The format of the texture image. Valid values:
  • Raw
  • JPEG: default value
  • PNG
wrap The wrap mode of the texture image. Valid values:
  • Wrap: default value
  • Mirror
table_name The name of the table in which the existing texture locates.
column_name The name of the column in which the existing texture locates.
key_value The ID of the existing texture. This parameter is used in the WHERE clause.
schema_name The name of the schema of the existing texture. Default value: public.
data The binary data stream of the texture image.

Description

The binary data streams of texture images can be stored in three modes. You can develop a storage solution for texture images based on your business requirements.
  • Store the binary data streams of texture images in a database. If you use this solution, no external association is required. However, the amount of data in the database is large.
  • Store the binary data streams of texture images in an external file. If you use this solution, less storage of the database is used. However, the access performance is poor.
  • Store the binary data streams of texture images in a separate table of the database. If you use this solution, the database that is used to store the binary data streams is referenced.

Examples

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