QML Graphics Rendering - GammaAdjust

Author: billy
Copyright statement: The copyright belongs to the author, please contact the author for commercial reprinting, please indicate the source for non-commercial reprinting

Attribute introduction

  • cached : bool
    Output pixels using cache effects, which can improve rendering performance. Every time a source or effect property is changed, the pixels in the cache must be updated. Will increase memory consumption as additional memory buffers are required to store the effect output. So we recommend disabling caching when animating source properties or effect properties. Default is false

  • gamma : real
    A change factor for how the brightness of each pixel changes according to the following equation: brightness = power(raw brightness, 1.0 / gamma); // assume brightness is between 0.0 and 1.0
    Setting gamma values ​​below 1.0 will darken the image, and values ​​above 1.0 will brighten the image. The value ranges from 0.0 (darkest) to inf (brightest). By default, this property is set to 1.0 (no change)

  • source : variant
    Source item for which brightness needs to be adjusted. Note: Allowing the effect to contain itself is not supported

Precautions

  1. GammaAdjust supports OpenGL rendering
  2. GammaAdjust is applied to each pixel according to a curve predefined as a power-law expression, where the characteristic gamma is used as the reciprocal scaling exponent

Display of different numerical effects

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Official example

import QtQuick 2.12
import QtGraphicalEffects 1.12

Item {
    width: 300
    height: 300
    
    Image {
        id: bug
        source: "images/bug.jpg"
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
        visible: false
    }
    
    GammaAdjust {
        anchors.fill: bug
        source: bug
        gamma: 0.45
    }
}

insert image description here

Guess you like

Origin blog.csdn.net/qq_34139994/article/details/120053356