libgpac
Documentation of the core library of GPAC
|
import"evg.idl";
Public Member Functions | |
Texture (unsigned long width, unsigned long height, DOMString pixfmt, ArrayBuffer data, optional unsigned long stride=0, optional unsigned long stride_uv=0) | |
Texture (DOMString filename, optional boolean is_rel_script=false) | |
Texture (ArrayBuffer img_data) | |
Texture (unsigned long width, unsigned long height, DOMString pixfmt, Function param_fun, optional boolean use_screen_coords=false) | |
Texture (Canvas canvas) | |
Texture (FilterPacket packet) | |
Texture () | |
void | set_alpha (unsigned long alpha) |
void | set_alphaf (double alpha) |
Texture | rgb2hsv () |
Texture | hsv2rgb () |
Texture | rgb2yuv (Canvas surf) |
Texture | yuv2rgb (Canvas surf) |
Texture | convolution (ConvolutionKernel k) |
Texture | split (unsigned long idx) |
void | update (FilterPacket packet) |
load (DOMString filename, optional boolean is_rel_script=false) | |
load (ArrayBuffer img_data) | |
set_named (DOMString name) | |
set_pad_color (DOMString color) | |
DOMString | get_pad_color () |
Object | get_pixelf (Float s, Float t, optional bool as_array=false) |
Object | get_pixel (unsigned long x, unsigned long y, optional bool as_array=false) |
Array | diff_score (Texture diff_with, optional DOMString mode="mae", optional boolean split_planes=false) |
Data Fields | |
writeonly unsigned long | filtering |
writeonly ColorMatrix | cmx |
attribute Matrix2D | mx |
attribute boolean | repeat_s |
attribute boolean | repeat_t |
attribute boolean | flip |
readonly attribute boolean | width |
readonly attribute boolean | height |
readonly attribute DOMString | pixfmt |
readonly attribute unsigned long | comp |
readonly attribute ArrayBuffet | data |
texture stencil
Texture::Texture | ( | unsigned long | width, |
unsigned long | height, | ||
DOMString | pixfmt, | ||
ArrayBuffer | data, | ||
optional unsigned long | stride = 0 , |
||
optional unsigned long | stride_uv = 0 |
||
) |
pixel data constructor.
width | width of the texture |
height | height of the texture |
pixfmt | pixel format of the texture |
data | texture data to use |
stride | stride of pixel buffer or of first plane for planar formats |
stride_uv | stride of second plane for planar formats |
image file constructor. Only JPEG and PNG local files are supported. This constructor is used to quickly load an image file without using a filter chain for that
filename | file name on local drive |
is_rel_script | if true, indicates the file path is relative to the script location. Otherwise it is relative to the current directory |
Texture::Texture | ( | ArrayBuffer | img_data | ) |
ArrayBuffer. Only JPEG and PNG local files are supported. This constructor is used to quickly load an image file without using a filter chain for that
img_data | array buffer containing the compressed image data |
Texture::Texture | ( | unsigned long | width, |
unsigned long | height, | ||
DOMString | pixfmt, | ||
Function | param_fun, | ||
optional boolean | use_screen_coords = false |
||
) |
parametric texture constructor. A parametric texture gets its pixel values from a javascript callback function, the resulting value being blended according to the antialiasing level of the pixel. This allows creating rather complex custom textures, in a fashion similar to fragment shaders.
width | width of the texture |
height | height of the texture |
pixfmt | pixel format of the texture |
param_fun | texture data to use. This function is called on the texture object with two parameters x and y indicating the desired pixel in the texture, where (0,0) is top-left; the function shall return a Colorf interface |
use_screen_coords | if set, the calbback function is passed screen coordinates rather than texture coordinates (and width/height of texture are ignored) |
Texture::Texture | ( | Canvas | canvas | ) |
canvas constructor.
canvas | the canvas to use as a texture |
Texture::Texture | ( | FilterPacket | packet | ) |
packet constructor. This is usually needed for planar YUV format where planes are not contiguous in memory (eg output of hardware decoder). The size of the pixel buffer will be derived from the packet's PID properties
packet | the source packet to use as a source for the data |
Texture::Texture | ( | ) |
Empty texture constructor. This is usually needed async texture load.
void Texture::set_alpha | ( | unsigned long | alpha | ) |
sets alpha value for stencil. The alpha is multiplied with the alpha component of the solid brush or gradient color
alpha | the alpha to set, between 0 and 255 |
void Texture::set_alphaf | ( | double | alpha | ) |
sets alpha value for stencil. The alpha is multiplied with the alpha component of the solid brush or gradient color
alpha | the alpha to set, between 0.0 and 1.0 |
Texture Texture::rgb2hsv | ( | ) |
converts texture from RGB/YUV to new HSV texture
Texture Texture::hsv2rgb | ( | ) |
converts texture from HSV to new RGB texture
converts texture from RGB to new YUV texture
surf | the target Canvas |
converts texture from YUV to new RGB texture
surf | the target Canvas |
Texture Texture::convolution | ( | ConvolutionKernel | k | ) |
performs a convolution on the texture
k | the convolution kernel to use |
Texture Texture::split | ( | unsigned long | idx | ) |
splits the given component into a new texture
idx | the component index. 0 is red or greyscale, 1 is alpha (alhpagrey formats) or green, 2 is green and 4 is alpha |
void Texture::update | ( | FilterPacket | packet | ) |
updates pixel data of texture using source packet
packet | the new packet to use for the texture |
load local file into texture. Only JPEG and PNG local files are supported.
filename | file name on local drive |
is_rel_script | if true, indicates the file path is relative to the script location. Otherwise it is relative to the current directory |
Texture::load | ( | ArrayBuffer | img_data | ) |
load file data into texture. Only JPEG and PNG data are supported.
img_data | image file data |
Texture::set_named | ( | DOMString | name | ) |
Makes the texture a named texture for WebGL.
If a texImage2D is done with a named EVG texture:
name | the named texture to use. |
Texture::set_pad_color | ( | DOMString | color | ) |
Sets padding color for texture - see gf_evg_stencil_set_pad_color
The parameters can also be 4 doubles, an array of 4 doubles or an object with 'r', 'g', 'b', 'a' properties. In these cases, the component values must be between 0 and 1
color | the color to use. |
DOMString Texture::get_pad_color | ( | ) |
gets padding color associated for texture
gets RGB pixel value in a texture
s | horizontal normalized texture coordinate of pixel, between 0 (left) and 1.0 (right) |
t | vertical normalized texture coordinate of pixel, between 0 (top) and 1.0 (bottom) |
as_array | if true, the return object is an array of 4 components, otherwise it is a Color object |
Object Texture::get_pixel | ( | unsigned long | x, |
unsigned long | y, | ||
optional bool | as_array = false |
||
) |
gets RGB pixel value in a texture
x | horizontal coordinate of pixel, between 0 (left) and width (right) |
y | vertical coordinate of pixel, between 0 (top) and height (bottom) |
as_array | if true, the return object is an array of 4 components, otherwise it is a Color object |
Array Texture::diff_score | ( | Texture | diff_with, |
optional DOMString | mode = "mae" , |
||
optional boolean | split_planes = false |
||
) |
gets MAE (Mean Absolute Error) and/or MSE (Mean Square Error) metric of texture compared with another texture. Both textures shall have the same size and pixel format.
diff_with | texture to compute difference with |
mode | string indicating metric(s) to compute as a comma-separated list. Currently only 'mae' and 'mse' are supported. |
split_planes | if true, metrics are computed per plane, otherwise averaged on all planes. For YUV textures, if this is not set, metric is only computed on luma plane and alpha plane if present. |
If split_planes is false, the array contains a single object. Otherwise, it contains 4 objects if alpha plane or 3 otherwise, in {R,G,B,A} or {Y,U,V,A} order.
writeonly unsigned long Texture::filtering |
filtering mode - see gf_evg_stencil_set_filter
writeonly ColorMatrix Texture::cmx |
color matrix - see gf_evg_stencil_set_color_matrix. Setting to null resets the color matrix
attribute Matrix2D Texture::mx |
matrix - see gf_evg_stencil_set_matrix. Setting to null resets the matrix
attribute boolean Texture::repeat_s |
horizontal repeat flag
attribute boolean Texture::repeat_t |
vertical repeat flag
attribute boolean Texture::flip |
vertical flip flag
readonly attribute boolean Texture::width |
width in pixels of image (RGB width or luma plane width)
readonly attribute boolean Texture::height |
height in pixels of image (RGB height or luma plane height)
readonly attribute DOMString Texture::pixfmt |
pixel format
readonly attribute unsigned long Texture::comp |
number of components
readonly attribute ArrayBuffet Texture::data |
texture data