1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2005-05-25 7 * Description : border threaded image filter. 8 * 9 * Copyright 2005-2021 by Gilles Caulier <caulier dot gilles at gmail dot com> 10 * Copyright 2006-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 11 * Copyright 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com> 12 * Copyright 2010 by Martin Klapetek <martin dot klapetek at gmail dot com> 13 * 14 * This program is free software; you can redistribute it 15 * and/or modify it under the terms of the GNU General 16 * Public License as published by the Free Software Foundation; 17 * either version 2, or (at your option) 18 * any later version. 19 * 20 * This program is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * ============================================================ */ 26 27 #ifndef DIGIKAM_BORDER_FILTER_H 28 #define DIGIKAM_BORDER_FILTER_H 29 30 // Qt includes 31 32 #include <QImage> 33 34 // Local includes 35 36 #include "dimgthreadedfilter.h" 37 #include "digikam_globals.h" 38 #include "bordercontainer.h" 39 40 namespace Digikam 41 { 42 43 class DIGIKAM_EXPORT BorderFilter : public DImgThreadedFilter 44 { 45 Q_OBJECT 46 47 public: 48 49 /** 50 * Constructor using settings to preserve aspect ratio of image. 51 */ 52 explicit BorderFilter(QObject* const parent = nullptr); 53 explicit BorderFilter(DImg* orgImage, QObject* const parent = nullptr, const BorderContainer& settings = BorderContainer()); 54 ~BorderFilter() override; 55 FilterIdentifier()56 static QString FilterIdentifier() 57 { 58 return QLatin1String("digikam:BorderFilter"); 59 } 60 61 static QString DisplayableName(); 62 SupportedVersions()63 static QList<int> SupportedVersions() 64 { 65 return QList<int>() << 1; 66 } 67 CurrentVersion()68 static int CurrentVersion() 69 { 70 return 1; 71 } 72 filterIdentifier()73 QString filterIdentifier() const override 74 { 75 return FilterIdentifier(); 76 } 77 78 FilterAction filterAction() override; 79 void readParameters(const FilterAction& action) override; 80 81 private: 82 83 void filterImage() override; 84 85 /** 86 * Methods to preserve aspect ratio of image. 87 */ 88 void solid(DImg& src, DImg& dest, const DColor& fg, int borderWidth); 89 void niepce(DImg& src, DImg& dest, const DColor& fg, int borderWidth, 90 const DColor& bg, int lineWidth); 91 void bevel(DImg& src, DImg& dest, const DColor& topColor, 92 const DColor& btmColor, int borderWidth); 93 void pattern(DImg& src, DImg& dest, int borderWidth, const DColor& firstColor, 94 const DColor& secondColor, int firstWidth, int secondWidth); 95 96 /** 97 * Methods to not-preserve aspect ratio of image. 98 */ 99 void solid2(DImg& src, DImg& dest, const DColor& fg, int borderWidth); 100 void niepce2(DImg& src, DImg& dest, const DColor& fg, int borderWidth, 101 const DColor& bg, int lineWidth); 102 void bevel2(DImg& src, DImg& dest, const DColor& topColor, 103 const DColor& btmColor, int borderWidth); 104 void pattern2(DImg& src, DImg& dest, int borderWidth, const DColor& firstColor, 105 const DColor& secondColor, int firstWidth, int secondWidth); 106 107 private: 108 109 class Private; 110 Private* const d; 111 }; 112 113 } // namespace Digikam 114 115 #endif // DIGIKAM_BORDER_FILTER_H 116