【问题标题】:Snapshot via ShaderEffectSource is sometimes jaggy通过 ShaderEffectSource 的快照有时是锯齿状的
【发布时间】:2017-09-19 10:55:22
【问题描述】:

我的组件代码是这样的:

import QtQuick 2.5

Item {
    id: root

    width: 315
    height: 315

    property bool active

    Image {
        id: srcImage
        width: root.width
        height: root.height

        source: "/test.png"

        y: root.active ? 0 : 300
    }

    ShaderEffectSource {
        id: snapshotter
        sourceItem: {
            if(root.active) {
                return srcImage;
            } else {
                // Work around a bug that causes the snapshotter to lose its
                // contents. (see http://stackoverflow.com/a/43067294 )
                return snapshotter;
            }
        }
        width: root.width
        height: root.height
        live: root.active
        recursive: sourceItem == snapshotter
        textureSize: Qt.size(root.width, root.height)
        y: live ? 300 : 0
    }
}

我得到了这样的结果(并排破碎和完整):

我找出原因,我会直接发布它作为答案。

【问题讨论】:

  • Shader 输出似乎不支持 qml 中的抗锯齿:stackoverflow.com/questions/40329703/… 甚至可能是一个错误。
  • @dtech:您链接的问题是关于另一个问题 - OpenGL 几何的边缘像素的混叠。在我的情况下,问题在整个纹理中都是可见的。

标签: qt opengl qml qtquick2


【解决方案1】:

我必须确保组件的绝对坐标(相对于窗口)是整数。这样就解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-21
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多