2

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

例如在这个越狱 tweek 的例子中:在此处输入图像描述

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

4

3 回答 3

1

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

于 2013-04-29T13:38:11.507 回答
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;
}
于 2013-04-29T08:59:42.607 回答
0

我认为您可以通过使用QGraphicsEffect.

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

阅读文档以获得清晰的理解。

于 2013-04-29T04:20:01.807 回答