1
我想模糊QImage alpha通道。我當前的實現使用不推薦使用的'alphaChannel'方法,並且工作緩慢。模糊QImage alpha通道
QImage blurImage(const QImage & image, double radius)
{
QImage newImage = image.convertToFormat(QImage::Format_ARGB32);
QImage alpha = newImage.alphaChannel();
QImage blurredAlpha = alpha;
for (int x = 0; x < alpha.width(); x++)
{
for (int y = 0; y < alpha.height(); y++)
{
uint color = calculateAverageAlpha(x, y, alpha, radius);
blurredAlpha.setPixel(x, y, color);
}
}
newImage.setAlphaChannel(blurredAlpha);
return newImage;
}
我也試圖使用QGraphicsBlurEffect來實現它,但它不影響阿爾法。
模糊QImage alpha通道的正確方法是什麼?
也許值得使用opencv進行圖像處理。 – UmNyobe