| 1 | // Aseprite |
| 2 | // Copyright (C) 2019 Igara Studio S.A. |
| 3 | // Copyright (C) 2017 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifndef FILTERS_BRIGHTNESS_CONTRAST_FILTER_H_INCLUDED |
| 9 | #define FILTERS_BRIGHTNESS_CONTRAST_FILTER_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "doc/color.h" |
| 13 | #include "doc/palette_picks.h" |
| 14 | #include "filters/filter.h" |
| 15 | #include "filters/target.h" |
| 16 | |
| 17 | #include <vector> |
| 18 | |
| 19 | namespace filters { |
| 20 | |
| 21 | class BrightnessContrastFilter : public FilterWithPalette { |
| 22 | public: |
| 23 | BrightnessContrastFilter(); |
| 24 | |
| 25 | double brightness() const { return m_brightness; } |
| 26 | double contrast() const { return m_contrast; } |
| 27 | void setBrightness(double brightness); |
| 28 | void setContrast(double contrast); |
| 29 | |
| 30 | // Filter implementation |
| 31 | const char* getName() override; |
| 32 | void applyToRgba(FilterManager* filterMgr) override; |
| 33 | void applyToGrayscale(FilterManager* filterMgr) override; |
| 34 | void applyToIndexed(FilterManager* filterMgr) override; |
| 35 | |
| 36 | private: |
| 37 | void onApplyToPalette(FilterManager* filterMgr, |
| 38 | const doc::PalettePicks& picks) override; |
| 39 | void applyFilterToRgb(const Target target, doc::color_t& color); |
| 40 | void updateMap(); |
| 41 | |
| 42 | double m_brightness, m_contrast; |
| 43 | std::vector<int> m_cmap; |
| 44 | }; |
| 45 | |
| 46 | } // namespace filters |
| 47 | |
| 48 | #endif |
| 49 | |