summaryrefslogtreecommitdiffstats
path: root/src/imageplugins/border/border.h
blob: b213e27a3a43711287da740edc5302fa20234952 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2005-05-25
 * Description : border threaded image filter.
 * 
 * Copyright 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * Copyright 2006-2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * ============================================================ */
  
#ifndef BORDER_H
#define BORDER_H

// TQt includes.

#include <tqstring.h>
#include <tqcolor.h>
#include <tqimage.h>

// Digikam includes.

#include "dimgthreadedfilter.h"

namespace DigikamBorderImagesPlugin
{

class Border : public Digikam::DImgThreadedFilter
{

public:

    enum BorderTypes 
    {
        SolidBorder=0,
        NiepceBorder,
        BeveledBorder,
        PineBorder,
        WoodBorder,
        PaperBorder,
        ParqueBorder,
        IceBorder,
        LeafBorder,
        MarbleBorder,
        RainBorder,
        CratersBorder,
        DriedBorder,
        PinkBorder,
        StoneBorder,
        ChalkBorder,
        GraniteBorder,
        RockBorder,
        WallBorder
    };

public:

    /** Constructor using settings to preserve aspect ratio of image. */
    Border(Digikam::DImg *orgImage, TQObject *parent=0, int orgWidth=0, int orgHeight=0,
           TQString borderPath=TQString(), int borderType=SolidBorder, float borderPercent=0.1,
           Digikam::DColor solidColor = Digikam::DColor(),
           Digikam::DColor niepceBorderColor = Digikam::DColor(),
           Digikam::DColor niepceLineColor = Digikam::DColor(),
           Digikam::DColor bevelUpperLeftColor = Digikam::DColor(),
           Digikam::DColor bevelLowerRightColor = Digikam::DColor(),
           Digikam::DColor decorativeFirstColor = Digikam::DColor(),
           Digikam::DColor decorativeSecondColor = Digikam::DColor());

    /** Constructor using settings to not-preserve aspect ratio of image. */
    Border(Digikam::DImg *orgImage, TQObject *parent=0, int orgWidth=0, int orgHeight=0,
           TQString borderPath=TQString(), int borderType=SolidBorder,
           int borderWidth1=100, int borderWidth2=20, int borderWidth3=20, int borderWidth4=10,
           Digikam::DColor solidColor = Digikam::DColor(),
           Digikam::DColor niepceBorderColor = Digikam::DColor(),
           Digikam::DColor niepceLineColor = Digikam::DColor(),
           Digikam::DColor bevelUpperLeftColor = Digikam::DColor(),
           Digikam::DColor bevelLowerRightColor = Digikam::DColor(),
           Digikam::DColor decorativeFirstColor = Digikam::DColor(),
           Digikam::DColor decorativeSecondColor = Digikam::DColor());

    ~Border(){};

private:  

    virtual void filterImage(void);
    
    
    /** Methods to preserve aspect ratio of image. */
    void solid(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &fg, int borderWidth);
    void niepce(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &fg, int borderWidth, 
                const Digikam::DColor &bg, int lineWidth);
    void bevel(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &topColor, 
               const Digikam::DColor &btmColor, int borderWidth);
    void pattern(Digikam::DImg &src, Digikam::DImg &dest, int borderWidth, const Digikam::DColor &firstColor, 
                 const Digikam::DColor &secondColor, int firstWidth, int secondWidth);

    /** Methods to not-preserve aspect ratio of image. */
    void solid2(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &fg, int borderWidth);
    void niepce2(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &fg, int borderWidth, 
                 const Digikam::DColor &bg, int lineWidth);
    void bevel2(Digikam::DImg &src, Digikam::DImg &dest, const Digikam::DColor &topColor, 
                const Digikam::DColor &btmColor, int borderWidth);
    void pattern2(Digikam::DImg &src, Digikam::DImg &dest, int borderWidth, const Digikam::DColor &firstColor, 
                  const Digikam::DColor &secondColor, int firstWidth, int secondWidth);

private:  

    bool            m_preserveAspectRatio;

    int             m_orgWidth;
    int             m_orgHeight;

    int             m_borderType;
    
    int             m_borderWidth1;
    int             m_borderWidth2;
    int             m_borderWidth3;
    int             m_borderWidth4;

    int             m_borderMainWidth;
    int             m_border2ndWidth;

    float           m_orgRatio;

    TQString         m_borderPath;
    
    Digikam::DColor m_solidColor;
    Digikam::DColor m_niepceBorderColor;
    Digikam::DColor m_niepceLineColor;
    Digikam::DColor m_bevelUpperLeftColor; 
    Digikam::DColor m_bevelLowerRightColor;
    Digikam::DColor m_decorativeFirstColor; 
    Digikam::DColor m_decorativeSecondColor;
};    

}  // NameSpace DigikamBorderImagesPlugin

#endif /* BORDER_H */