MaskedBlur QML Type | Qt Graphical Effects 5.5

- Qt 5.5
- Qt Graphical Effects
- QML Types
- MaskedBlur QML Type
- Qt 5.5.1 Reference Documentation

# MaskedBlur QML Type

Applies a blur effect with a varying intesity. More...

Import Statement: | import QtGraphicalEffects 1.0
Since: | QtGraphicalEffects 1.0
Inherits: | Item

- List of all members, including inherited members

## Properties

- cached : bool
- fast : bool
- maskSource : variant
- radius : real
- samples : int
- source : variant
- transparentBorder : bool

## Detailed Description

MaskedBlur effect softens the image by blurring it. The intensity of the blur can be controlled for each pixel using maskSource so that some parts of the source are blurred more than others. By default the effect produces a high quality result, thus the rendering speed may not be the highest possible. The rendering speed is reduced especially if the samples is large. For use cases that require faster rendering speed and the highest possible visual quality is not necessary, property fast can be set to true.

Source | MaskSource | Effect applied
--- | --- | ---

## Example

The following example shows how to apply the effect.

    import QtQuick 2.0
    import QtGraphicalEffects 1.0

    Item {
        width: 300
        height: 300

        Image {
            id: bug
            source: "images/bug.jpg"
            sourceSize: Qt.size(parent.width, parent.height)
            smooth: true
            visible: false
        }

        LinearGradient {
            id: mask
            anchors.fill: bug
            gradient: Gradient {
                GradientStop { position: 0.2; color: "#ffffffff" }
                GradientStop { position: 0.5; color: "#00ffffff" }
            }
            start: Qt.point(0, 0)
            end: Qt.point(300, 0)
            visible: false
        }

        MaskedBlur {
            anchors.fill: bug
            source: bug
            maskSource: mask
            radius: 16
            samples: 24
        }
    }

## Property Documentation

cached : bool

This property allows the effect output pixels to be cached in order to improve the rendering performance. Every time the source or effect properties are changed, the pixels in the cache must be updated. Memory consumption is increased, because an extra buffer of memory is required for storing the effect output.

It is recommended to disable the cache when the source or the effect properties are animated.

By default, the property is set to `false`.

fast : bool

This property selects the blurring algorithm that is used to produce the blur. Setting this to true enables fast algorithm, setting value to false produces higher quality result.

By default, the property is set to `false`.

Output examples with different fast values |  |
--- | --- | ---
fast: false | fast: true
radius: 16 | radius: 16
samples: 24 | samples: 24
transparentBorder: false | transparentBorder: false

maskSource : variant

This property defines the item that is controlling the final intensity of the blur. The pixel alpha channel value from maskSource defines the actual blur radius that is going to be used for blurring the corresponding source pixel.

Opaque maskSource pixels produce blur with specified radius, while transparent pixels suppress the blur completely. Semitransparent maskSource pixels produce blur with a radius that is interpolated according to the pixel transparency level.

radius : real

This property defines the distance of the neighboring pixels which affect the blurring of an individual pixel. A larger radius increases the blur effect.

Depending on the radius value, value of the samples should be set to sufficiently large to ensure the visual quality.

The value ranges from 0.0 (no blur) to inf. By default, the property is set to `0.0` (no blur).

Output examples with different radius values |  |
--- | --- | ---
radius: 0 | radius: 8 | radius: 16
samples: 24 | samples: 24 | samples: 24
transparentBorder: false | transparentBorder: false | transparentBorder: false
fast: false | fast: false | fast: false

samples : int

This property defines how many samples are taken per pixel when blur calculation is done. Larger value produces better quality, but is slower to render.

Ideally, this value should be twice as large as the highest required radius value, for example, if the radius is animated between 0.0 and 4.0, samples should be set to 8.

The value ranges from 0 to 32. By default, the property is set to `0`.

This property is not intended to be animated. Changing this property may cause the underlying OpenGL shaders to be recompiled.

When fast property is set to true, this property has no effect.

source : variant

This property defines the source item that is going to be blurred.

Note: It is not supported to let the effect include itself, for instance by setting source to the effect's parent.

transparentBorder : bool

This property defines the blur behavior near the edges of the item, where the pixel blurring is affected by the pixels outside the source edges.

If the property is set to `true`, the pixels outside the source are interpreted to be transparent, which is similar to OpenGL clamp-to-border extension. The blur is expanded slightly outside the effect item area.

If the property is set to `false`, the pixels outside the source are interpreted to contain the same color as the pixels at the edge of the item, which is similar to OpenGL clamp-to-edge behavior. The blur does not expand outside the effect item area.

By default, the property is set to `false`.

Output examples with different transparentBorder values |  |
--- | --- | ---
transparentBorder: false | transparentBorder: true
radius: 64 | radius: 64
samples: 24 | samples: 24
fast: true | fast: true