Resize
Defined in: src/filters/Resize.ts:52
Resize image filter class
Example
Extends
BaseFilter
<"Resize"
,ResizeOwnProps
>
Constructors
new Resize()
new Resize(
options
?):Resize
Defined in: src/filters/BaseFilter.ts:57
Constructor
Parameters
options?
object
& Partial
<ResizeOwnProps
> & Record
<string
, any
> = {}
Options object
Returns
Inherited from
Properties
lanczosLobes
lanczosLobes:
number
Defined in: src/filters/Resize.ts:80
LanczosLobes parameter for lanczos filter, valid for resizeType lanczos
Param
Default
resizeType
resizeType:
TResizeType
Defined in: src/filters/Resize.ts:59
Resize type for webgl resizeType is just lanczos, for canvas2d can be: bilinear, hermite, sliceHack, lanczos.
Default
scaleX
scaleX:
number
Defined in: src/filters/Resize.ts:66
Scale factor for resizing, x axis
Param
Default
scaleY
scaleY:
number
Defined in: src/filters/Resize.ts:73
Scale factor for resizing, y axis
Param
Default
defaults
static
defaults:ResizeOwnProps
=resizeDefaultValues
Defined in: src/filters/Resize.ts:84
Overrides
type
static
type:string
='Resize'
Defined in: src/filters/Resize.ts:82
The class type. Used to identify which class this is.
This is used for serialization purposes and internally it can be used
to identify classes. As a developer you could use instance of Class
but to avoid importing all the code and blocking tree shaking we try
to avoid doing that.
Overrides
uniformLocations
static
uniformLocations:string
[]
Defined in: src/filters/Resize.ts:86
Contains the uniform locations for the fragment shader. uStepW and uStepH are handled by the BaseFilter, each filter class needs to specify all the one that are needed
Overrides
Accessors
type
Get Signature
get type():
Name
Defined in: src/filters/BaseFilter.ts:31
Filter type
Default
Returns
Name
Inherited from
Methods
_setupFrameBuffer()
_setupFrameBuffer(
options
):void
Defined in: src/filters/BaseFilter.ts:205
Parameters
options
Returns
void
Inherited from
_swapTextures()
_swapTextures(
options
):void
Defined in: src/filters/BaseFilter.ts:232
Parameters
options
Returns
void
Inherited from
applyTo()
applyTo(
options
):void
Defined in: src/filters/Resize.ts:197
Apply the resize filter to the image Determines whether to use WebGL or Canvas2D based on the options.webgl flag.
Parameters
options
TWebGLPipelineState
| T2DPipelineState
Returns
void
Overrides
applyTo2d()
applyTo2d(
this
,options
):void
Defined in: src/filters/Resize.ts:223
Parameters
this
ResizeDuring2DResize
options
Returns
void
Overrides
applyToForWebgl()
applyToForWebgl(
this
,options
):void
Defined in: src/filters/Resize.ts:163
Parameters
this
ResizeDuringWEBGLResize
options
Returns
void
applyToWebGL()
applyToWebGL(
options
):void
Defined in: src/filters/BaseFilter.ts:315
Apply this filter using webgl.
Parameters
options
Returns
void
Inherited from
bilinearFiltering()
bilinearFiltering(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:417
bilinearFiltering
Parameters
this
ResizeDuring2DResize
options
oW
number
Original Width
oH
number
Original Height
dW
number
Destination Width
dH
number
Destination Height
Returns
ImageData
bindAdditionalTexture()
bindAdditionalTexture(
gl
,texture
,textureUnit
):void
Defined in: src/filters/BaseFilter.ts:334
Parameters
gl
WebGLRenderingContext
texture
WebGLTexture
textureUnit
number
Returns
void
Inherited from
BaseFilter
.bindAdditionalTexture
createHelpLayer()
createHelpLayer(
options
):void
Defined in: src/filters/BaseFilter.ts:370
If needed by a 2d filter, this functions can create an helper canvas to be used remember that options.targetCanvas is available for use till end of chain.
Parameters
options
Returns
void
Inherited from
createProgram()
createProgram(
gl
,fragmentSource
,vertexSource
):object
Defined in: src/filters/BaseFilter.ts:83
Compile this filter’s shader program.
Parameters
gl
WebGLRenderingContext
The GL canvas context to use for shader compilation.
fragmentSource
string
= ...
fragmentShader source for compilation
vertexSource
string
= ...
vertexShader source for compilation
Returns
object
attributeLocations
attributeLocations:
TWebGLAttributeLocationMap
program
program:
WebGLProgram
uniformLocations
uniformLocations:
TWebGLUniformLocationMap
Inherited from
generateShader()
generateShader(
filterWindow
):string
Defined in: src/filters/Resize.ts:136
Generate vertex and shader sources from the necessary steps numbers
Parameters
filterWindow
number
Returns
string
getAttributeLocations()
getAttributeLocations(
gl
,program
):TWebGLAttributeLocationMap
Defined in: src/filters/BaseFilter.ts:153
Return a map of attribute names to WebGLAttributeLocation objects.
Parameters
gl
WebGLRenderingContext
The canvas context used to compile the shader program.
program
WebGLProgram
The shader program from which to take attribute locations.
Returns
A map of attribute names to attribute locations.
Inherited from
BaseFilter
.getAttributeLocations
getCacheKey()
getCacheKey(
this
):string
Defined in: src/filters/Resize.ts:111
Returns a string that represent the current selected shader code for the filter. Used to force recompilation when parameters change or to retrieve the shader from cache
Parameters
this
ResizeDuringWEBGLResize
Returns
string
Overrides
getFilterWindow()
getFilterWindow(
this
):number
Defined in: src/filters/Resize.ts:106
Parameters
this
ResizeDuringWEBGLResize
Returns
number
getFragmentSource()
getFragmentSource(
this
):string
Defined in: src/filters/Resize.ts:116
Parameters
this
ResizeDuringWEBGLResize
Returns
string
Overrides
BaseFilter.getFragmentSource
getTaps()
getTaps(
this
):any
[]
Defined in: src/filters/Resize.ts:121
Parameters
this
ResizeDuringWEBGLResize
Returns
any
[]
getUniformLocations()
getUniformLocations(
gl
,program
):TWebGLUniformLocationMap
Defined in: src/filters/BaseFilter.ts:169
Return a map of uniform names to WebGLUniformLocation objects.
Parameters
gl
WebGLRenderingContext
The canvas context used to compile the shader program.
program
WebGLProgram
The shader program from which to take uniform locations.
Returns
A map of uniform names to uniform locations.
Inherited from
BaseFilter
.getUniformLocations
getVertexSource()
getVertexSource():
string
Defined in: src/filters/BaseFilter.ts:72
Returns
string
Inherited from
hermiteFastResize()
hermiteFastResize(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:480
hermiteFastResize
Parameters
this
ResizeDuring2DResize
options
oW
number
Original Width
oH
number
Original Height
dW
number
Destination Width
dH
number
Destination Height
Returns
ImageData
isNeutralState()
isNeutralState():
boolean
Defined in: src/filters/Resize.ts:205
Generic isNeutral implementation for one parameter based filters. Used only in image applyFilters to discard filters that will not have an effect on the image Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )
Returns
boolean
Overrides
lanczosCreate()
lanczosCreate(
lobes
): (x
) =>number
Defined in: src/filters/Resize.ts:209
Parameters
lobes
number
Returns
Function
Parameters
x
number
Returns
number
lanczosResize()
lanczosResize(
this
,options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:326
Filter lanczosResize
Parameters
this
ResizeDuring2DResize
options
oW
number
Original Width
oH
number
Original Height
dW
number
Destination Width
dH
number
Destination Height
Returns
ImageData
retrieveShader()
retrieveShader(
options
):TWebGLProgramCacheItem
Defined in: src/filters/BaseFilter.ts:295
Retrieves the cached shader.
Parameters
options
Returns
the compiled program shader
Inherited from
sendAttributeData()
sendAttributeData(
gl
,attributeLocations
,aPositionData
):void
Defined in: src/filters/BaseFilter.ts:192
Send attribute data from this filter to its shader program on the GPU.
Parameters
gl
WebGLRenderingContext
The canvas context used to compile the shader program.
attributeLocations
Record
<string
, number
>
A map of shader attribute names to their locations.
aPositionData
Float32Array
Returns
void
Inherited from
sendUniformData()
sendUniformData(
this
,gl
,uniformLocations
):void
Defined in: src/filters/Resize.ts:94
Send data from this filter to its shader program’s uniforms.
Parameters
this
ResizeDuringWEBGLResize
gl
WebGLRenderingContext
The GL canvas context used to compile this filter’s shader.
uniformLocations
A map of string uniform names to WebGLUniformLocation objects
Returns
void
Overrides
sliceByTwo()
sliceByTwo(
options
,oW
,oH
,dW
,dH
):ImageData
Defined in: src/filters/Resize.ts:261
Filter sliceByTwo
Parameters
options
oW
number
Original Width
oH
number
Original Height
dW
number
Destination Width
dH
number
Destination Height
Returns
ImageData
toJSON()
toJSON():
object
&ResizeOwnProps
Defined in: src/filters/BaseFilter.ts:407
Returns a JSON representation of an instance
Returns
object
& ResizeOwnProps
JSON
Inherited from
toObject()
toObject():
object
&ResizeOwnProps
Defined in: src/filters/BaseFilter.ts:387
Returns object representation of an instance It will automatically export the default values of a filter, stored in the static defaults property.
Returns
object
& ResizeOwnProps
Object representation of an instance
Inherited from
unbindAdditionalTexture()
unbindAdditionalTexture(
gl
,textureUnit
):void
Defined in: src/filters/BaseFilter.ts:345
Parameters
gl
WebGLRenderingContext
textureUnit
number
Returns
void
Inherited from
BaseFilter
.unbindAdditionalTexture
fromObject()
static
fromObject(__namedParameters
,_options
):Promise
<BaseFilter
<string
>>
Defined in: src/filters/BaseFilter.ts:412
Parameters
__namedParameters
Record
<string
, any
>
_options
Returns
Promise
<BaseFilter
<string
>>