Selaa lähdekoodia

LibGfx: Preseve original alpha when applying tint filter

MacDue 2 vuotta sitten
vanhempi
commit
13beed1722
1 muutettua tiedostoa jossa 7 lisäystä ja 4 poistoa
  1. 7 4
      Userland/Libraries/LibGfx/Filters/TintFilter.h

+ 7 - 4
Userland/Libraries/LibGfx/Filters/TintFilter.h

@@ -15,17 +15,20 @@ class TintFilter : public ColorFilter {
 public:
     TintFilter(Color color, float amount)
         : ColorFilter(amount)
-        , m_color(color)
+        , m_color(Color::from_rgb(color.value()))
     {
     }
 
+    virtual bool amount_handled_in_filter() const override { return true; }
+
     virtual StringView class_name() const override { return "TintFilter"sv; }
 
 protected:
-    Color convert_color(Color) override
+    Color convert_color(Color dest) override
     {
-        // Note: ColorFilter will blend by amount
-        return m_color;
+        return Color::from_rgb(dest.value())
+            .mixed_with(m_color, m_amount)
+            .with_alpha(dest.alpha());
     };
 
 private: