1
/* ============================================================
2
* Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
6
* Copyright 2004 by Renchi Raju
8
* Includes code from gimp version 2.0
9
* LIBGIMP - The GIMP Library
10
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
12
* This program is free software; you can redistribute it
13
* and/or modify it under the terms of the GNU General
14
* Public License as published by the Free Software Foundation;
15
* either version 2, or (at your option)
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* ============================================================ */
30
#include "digikam_export.h"
31
#define MAX3(a, b, c) (QMAX(QMAX(a,b),b))
32
#define MIN3(a, b, c) (QMIN(QMIN(a,b),b))
33
#define ROUND(x) ((int) ((x) + 0.5))
43
class DIGIKAMIMAGEEDITOR_EXPORT ImageIface
47
ImageIface(int w=0, int h=0);
50
uint* getPreviewData();
51
uint* getOriginalData();
52
uint* getSelectedData();
54
void putPreviewData(uint* data);
55
void putOriginalData(const QString &caller, uint* data, int w=-1, int h=-1);
56
void putSelectedData(uint* data);
60
uint* setPreviewSize(int w, int h);
65
// Get selected dimensions.
69
// Get selected (X, Y) position on the top/left corner.
73
void setPreviewBCG(double brightness, double contrast, double gamma);
74
void setOriginalBCG(double brightness, double contrast, double gamma);
76
void paint(QPaintDevice* device, int x, int y, int w, int h);
84
inline static int hsl_value (double n1,
96
value = n1 + (n2 - n1) * (hue / 42.5);
100
value = n1 + (n2 - n1) * ((170 - hue) / 42.5);
104
return ROUND(value * 255.0);
107
inline static void rgb_to_hsl (int& r, int& g, int& b)
124
l = (max + min) / 2.0;
136
s = 255 * (double) delta / (double) (max + min);
138
s = 255 * (double) delta / (double) (511 - max - min);
141
h = (g - b) / (double) delta;
143
h = 2 + (b - r) / (double) delta;
145
h = 4 + (r - g) / (double) delta;
161
inline static void hsl_to_rgb (int& hue, int& saturation, int& lightness)
171
/* achromatic case */
174
saturation = (int) l;
181
m2 = (l * (255 + s)) / 65025.0;
183
m2 = (l + s - (l * s) / 255.0) / 255.0;
185
m1 = (l / 127.5) - m2;
188
hue = hsl_value (m1, m2, h + 85);
189
saturation = hsl_value (m1, m2, h);
190
lightness = hsl_value (m1, m2, h - 85);
195
inline static int rgb_to_l (int red, int green, int blue)
201
max = QMAX (red, blue);
202
min = QMIN (green, blue);
206
max = QMAX (green, blue);
207
min = QMIN (red, blue);
210
return ROUND ((max + min) / 2.0);
216
#endif /* IMAGEIFACE_H */