Allow strictly blurring images with alpha.

This commit is contained in:
John Preston 2022-09-05 18:55:17 +04:00
parent 95dd2c8465
commit 2e63c6103e
2 changed files with 3 additions and 3 deletions

View file

@ -506,7 +506,7 @@ ReadResult Read(ReadArgs &&args) {
: Option::None); : Option::None);
} }
QImage Blur(QImage &&image) { QImage Blur(QImage &&image, bool ignoreAlpha) {
if (image.isNull()) { if (image.isNull()) {
return std::move(image); return std::move(image);
} }
@ -532,7 +532,7 @@ QImage Blur(QImage &&image) {
if (radius >= 16 || div >= w || div >= h || stride > w * 4) { if (radius >= 16 || div >= w || div >= h || stride > w * 4) {
return std::move(image); return std::move(image);
} }
const auto withalpha = image.hasAlphaChannel(); const auto withalpha = !ignoreAlpha && image.hasAlphaChannel();
if (withalpha) { if (withalpha) {
auto smaller = QImage(image.size(), image.format()); auto smaller = QImage(image.size(), image.format());
{ {

View file

@ -100,7 +100,7 @@ inline constexpr auto is_flag_type(Option) { return true; };
ImageRoundRadius radius, ImageRoundRadius radius,
RectParts corners = RectPart::AllCorners); RectParts corners = RectPart::AllCorners);
[[nodiscard]] QImage Blur(QImage &&image); [[nodiscard]] QImage Blur(QImage &&image, bool ignoreAlpha = false);
[[nodiscard]] QImage Round( [[nodiscard]] QImage Round(
QImage &&image, QImage &&image,
ImageRoundRadius radius, ImageRoundRadius radius,