【问题标题】:Blurring Effect Widget模糊效果小部件
【发布时间】:2013-04-29 00:00:00
【问题描述】:

有没有办法在 Photoshop 中为具有透明模糊效果的小部件创建按钮/矩形,以便通过矩形显示背景图像但它是模糊的?

比如这个越狱tweek的例子:

我尝试使用不透明度使其透明,但我不确定如何实现这种模糊的外观。

【问题讨论】:

    标签: qt photoshop transparent blurry


    【解决方案1】:

    这是为 QImage 快速模糊的代码,只需模糊背景一次并将其设置为背景

    QImage MainWindow::blurred(const QImage& image, const QRect& rect, int radius, bool          alphaOnly)
    {
    int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
    int alpha = (radius < 1) ? 16 : (radius > 17) ? 1 : tab[radius-1];
    
    QImage result = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
    int r1 = rect.top();
    int r2 = rect.bottom();
    int c1 = rect.left();
    int c2 = rect.right();
    
    int bpl = result.bytesPerLine();
    int rgba[4];
    unsigned char* p;
    
    int i1 = 0;
    int i2 = 3;
    
    if (alphaOnly)
    i1 = i2 = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3);
    
    for (int col = c1; col <= c2; col++) {
        p = result.scanLine(r1) + col * 4;
        for (int i = i1; i <= i2; i++)
            rgba[i] = p[i] << 4;
    
        p += bpl;
        for (int j = r1; j < r2; j++, p += bpl)
            for (int i = i1; i <= i2; i++)
                p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
    }
    
    for (int row = r1; row <= r2; row++) {
        p = result.scanLine(row) + c1 * 4;
        for (int i = i1; i <= i2; i++)
            rgba[i] = p[i] << 4;
    
        p += 4;
        for (int j = c1; j < c2; j++, p += 4)
            for (int i = i1; i <= i2; i++)
                p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
    }
    
    for (int col = c1; col <= c2; col++) {
        p = result.scanLine(r2) + col * 4;
        for (int i = i1; i <= i2; i++)
            rgba[i] = p[i] << 4;
    
        p -= bpl;
    for (int j = r1; j < r2; j++, p -= bpl)
        for (int i = i1; i <= i2; i++)
            p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
    }
    
    for (int row = r1; row <= r2; row++) {
        p = result.scanLine(row) + c2 * 4;
        for (int i = i1; i <= i2; i++)
            rgba[i] = p[i] << 4;
    
        p -= 4;
        for (int j = c1; j < c2; j++, p -= 4)
            for (int i = i1; i <= i2; i++)
                p[i] = (rgba[i] += ((p[i] << 4) - rgba[i]) * alpha / 16) >> 4;
    }
    
    return result;
    }
    

    【讨论】:

    • 不幸的是,我对 QML 的了解不够好。顺便说一句,这段代码是为 qt 自己的模糊效果而提取的,它是未经处理的或其他什么,但在最近的版本中,我认为他们可能已经实现了它,也许试试 @AmazingSixty 的建议,虽然我真的不知道这是否可能QML
    【解决方案2】:

    我会复制带有照片的图层并删除您不想模糊的部分(或用蒙版隐藏它们)。模糊效果是通过模糊滤镜实现的。那张照片看起来像镜头模糊。转到滤镜>模糊>镜头模糊。在对话框中的滑块选项上,将半径滑块向右移动(大约 24)。然后在顶部应用一个新图层,将黑色矩形设置为 15% 左右的不透明度。只要黑色矩形和复制的模糊照片大小相同,并且图层锁定在一起,您就会得到那种模糊效果。看起来按钮正在模糊背景。

    【讨论】:

      【解决方案3】:

      我认为您可以使用 QGraphicsEffect 完成一些事情。

      您基本上可以将QGraphicsOpacityEffect 应用于顶部小部件并将QGraphicsBlurEffect 应用于底层小部件。

      阅读documentation有一个清晰的了解。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-08-03
        • 1970-01-01
        • 1970-01-01
        • 2017-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多