Browse Source

Finish rebranding of Krita as Chalk


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19
tpearson 7 years ago
parent
commit
698569f842
100 changed files with 13262 additions and 14 deletions
  1. 1
    1
      Doxyfile.temp
  2. 1
    1
      README
  3. 1
    1
      README.APPS
  4. 11
    11
      README.PACKAGERS
  5. 20
    0
      chalk/AUTHORS
  6. 1
    0
      chalk/ChangeLog
  7. 93
    0
      chalk/HACKING
  8. 259
    0
      chalk/IMAGE_LIBRARIES
  9. 47
    0
      chalk/Makefile.am
  10. 13
    0
      chalk/README
  11. 181
    0
      chalk/TODO
  12. 59
    0
      chalk/UIcomments
  13. 95
    0
      chalk/chalk.desktop
  14. 199
    0
      chalk/chalk.rc
  15. 23
    0
      chalk/chalk_part_init.cc
  16. 35
    0
      chalk/chalk_readonly.rc
  17. 45
    0
      chalk/chalkcolor/Makefile.am
  18. 4
    0
      chalk/chalkcolor/README
  19. 11
    0
      chalk/chalkcolor/TODO
  20. 38
    0
      chalk/chalkcolor/chalk_colorspace.desktop
  21. 20
    0
      chalk/chalkcolor/colorspaces/Makefile.am
  22. 296
    0
      chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cc
  23. 93
    0
      chalk/chalkcolor/colorspaces/kis_alpha_colorspace.h
  24. 571
    0
      chalk/chalkcolor/colorspaces/kis_lab_colorspace.cc
  25. 153
    0
      chalk/chalkcolor/colorspaces/kis_lab_colorspace.h
  26. 624
    0
      chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cc
  27. 112
    0
      chalk/chalkcolor/colorspaces/kis_xyz_colorspace.h
  28. 762
    0
      chalk/chalkcolor/kis_abstract_colorspace.cc
  29. 312
    0
      chalk/chalkcolor/kis_abstract_colorspace.h
  30. 484
    0
      chalk/chalkcolor/kis_basic_histogram_producers.cc
  31. 197
    0
      chalk/chalkcolor/kis_basic_histogram_producers.h
  32. 115
    0
      chalk/chalkcolor/kis_channelinfo.h
  33. 185
    0
      chalk/chalkcolor/kis_color.cc
  34. 90
    0
      chalk/chalkcolor/kis_color.h
  35. 427
    0
      chalk/chalkcolor/kis_color_conversions.cc
  36. 49
    0
      chalk/chalkcolor/kis_color_conversions.h
  37. 39
    0
      chalk/chalkcolor/kis_colorspace.cc
  38. 450
    0
      chalk/chalkcolor/kis_colorspace.h
  39. 222
    0
      chalk/chalkcolor/kis_colorspace_factory_registry.cc
  40. 121
    0
      chalk/chalkcolor/kis_colorspace_factory_registry.h
  41. 39
    0
      chalk/chalkcolor/kis_colorspace_iface.cc
  42. 43
    0
      chalk/chalkcolor/kis_colorspace_iface.h
  43. 138
    0
      chalk/chalkcolor/kis_composite_op.cc
  44. 103
    0
      chalk/chalkcolor/kis_composite_op.h
  45. 125
    0
      chalk/chalkcolor/kis_f16half_base_colorspace.cc
  46. 107
    0
      chalk/chalkcolor/kis_f16half_base_colorspace.h
  47. 125
    0
      chalk/chalkcolor/kis_f32_base_colorspace.cc
  48. 83
    0
      chalk/chalkcolor/kis_f32_base_colorspace.h
  49. 67
    0
      chalk/chalkcolor/kis_histogram_producer.cc
  50. 129
    0
      chalk/chalkcolor/kis_histogram_producer.h
  51. 208
    0
      chalk/chalkcolor/kis_profile.cc
  52. 98
    0
      chalk/chalkcolor/kis_profile.h
  53. 148
    0
      chalk/chalkcolor/kis_u16_base_colorspace.cc
  54. 80
    0
      chalk/chalkcolor/kis_u16_base_colorspace.h
  55. 118
    0
      chalk/chalkcolor/kis_u8_base_colorspace.cc
  56. 77
    0
      chalk/chalkcolor/kis_u8_base_colorspace.h
  57. 16
    0
      chalk/chalkcolor/tests/Makefile.am
  58. 227
    0
      chalk/chalkcolor/tests/kis_color_conversions_tester.cpp
  59. 44
    0
      chalk/chalkcolor/tests/kis_color_conversions_tester.h
  60. 91
    0
      chalk/chalkpart.desktop
  61. 15
    0
      chalk/colorspaces/Makefile.am
  62. 11
    0
      chalk/colorspaces/README
  63. 30
    0
      chalk/colorspaces/cmyk_u16/Makefile.am
  64. 85
    0
      chalk/colorspaces/cmyk_u16/chalk_cmyk_u16_plugin.desktop
  65. 61
    0
      chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.cc
  66. 38
    0
      chalk/colorspaces/cmyk_u16/cmyk_u16_plugin.h
  67. 714
    0
      chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.cc
  68. 123
    0
      chalk/colorspaces/cmyk_u16/kis_cmyk_u16_colorspace.h
  69. 20
    0
      chalk/colorspaces/cmyk_u8/Makefile.am
  70. 99
    0
      chalk/colorspaces/cmyk_u8/chalkcmykplugin.desktop
  71. 66
    0
      chalk/colorspaces/cmyk_u8/cmyk_plugin.cc
  72. 38
    0
      chalk/colorspaces/cmyk_u8/cmyk_plugin.h
  73. 7
    0
      chalk/colorspaces/cmyk_u8/cmykplugin.rc
  74. 76
    0
      chalk/colorspaces/cmyk_u8/composite.h
  75. 710
    0
      chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.cc
  76. 126
    0
      chalk/colorspaces/cmyk_u8/kis_cmyk_colorspace.h
  77. 5
    0
      chalk/colorspaces/cmyk_u8/templates/.directory
  78. 8
    0
      chalk/colorspaces/cmyk_u8/templates/Makefile.am
  79. BIN
      chalk/colorspaces/cmyk_u8/templates/cr48-action-template_cmyk_empty.png
  80. BIN
      chalk/colorspaces/cmyk_u8/templates/crsc-action-template_cmyk_empty.svgz
  81. 100
    0
      chalk/colorspaces/cmyk_u8/templates/white_2000x800.desktop
  82. BIN
      chalk/colorspaces/cmyk_u8/templates/white_2000x800.kra
  83. 29
    0
      chalk/colorspaces/gray_u16/Makefile.am
  84. 83
    0
      chalk/colorspaces/gray_u16/chalk_gray_u16_plugin.desktop
  85. 63
    0
      chalk/colorspaces/gray_u16/gray_u16_plugin.cc
  86. 38
    0
      chalk/colorspaces/gray_u16/gray_u16_plugin.h
  87. 658
    0
      chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc
  88. 118
    0
      chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.h
  89. 31
    0
      chalk/colorspaces/gray_u8/Makefile.am
  90. 97
    0
      chalk/colorspaces/gray_u8/chalkgrayplugin.desktop
  91. 77
    0
      chalk/colorspaces/gray_u8/gray_plugin.cc
  92. 37
    0
      chalk/colorspaces/gray_u8/gray_plugin.h
  93. 7
    0
      chalk/colorspaces/gray_u8/grayplugin.rc
  94. 997
    0
      chalk/colorspaces/gray_u8/kis_gray_colorspace.cc
  95. 114
    0
      chalk/colorspaces/gray_u8/kis_gray_colorspace.h
  96. 48
    0
      chalk/colorspaces/gray_u8/templates/.directory
  97. 8
    0
      chalk/colorspaces/gray_u8/templates/Makefile.am
  98. BIN
      chalk/colorspaces/gray_u8/templates/cr48-action-template_gray_empty.png
  99. BIN
      chalk/colorspaces/gray_u8/templates/crsc-action-template_gray_empty.svgz
  100. 0
    0
      chalk/colorspaces/gray_u8/templates/white_640x480.desktop

+ 1
- 1
Doxyfile.temp View File

@@ -61,7 +61,7 @@ INPUT                  = example \
61 61
                          koshell \
62 62
                          kplato \
63 63
                          kpresenter \
64
-			 krita \
64
+			 chalk \
65 65
 			 kspread kugar kword lib 
66 66
 FILE_PATTERNS          = *.h
67 67
 RECURSIVE              = YES

+ 1
- 1
README View File

@@ -25,7 +25,7 @@ The applications currently included in KOffice are:
25 25
   Flowcharting program
26 26
 - Kexi
27 27
   Integrated data management
28
-- Krita
28
+- Chalk
29 29
   A pixel graphics tool
30 30
 - KFormula
31 31
   A mathematical formula editor

+ 1
- 1
README.APPS View File

@@ -18,7 +18,7 @@ in the 1.6 cycle:
18 18
 - lib/kross
19 19
 - kchart
20 20
 - kexi
21
-- krita
21
+- chalk
22 22
 - kdgantt
23 23
 - kplato
24 24
 - doc

+ 11
- 11
README.PACKAGERS View File

@@ -18,7 +18,7 @@ Table Of Contents
18 18
 1. Database drivers (MySQL, PostgreSQL)
19 19
 2. Development files
20 20
  2.1. KexiDB development files
21
- 2.2. Krita development files 
21
+ 2.2. Chalk development files 
22 22
 3. Scripting support
23 23
 4. Microsoft Access Import (optional, recommended)
24 24
 5. Quick command-line tests of Kexi installation
@@ -78,13 +78,13 @@ The files are:
78 78
 The installation can be tested by building the MS Access import plugin
79 79
 as described in the Microsoft Access import plugin section below.
80 80
 
81
-2.2. Krita development files 
81
+2.2. Chalk development files 
82 82
 
83
-Location: koffice/krita/core, koffice/krita/sdk,
84
-koffice/krita/kritacolor, koffice/krita/ui
83
+Location: koffice/chalk/core, koffice/chalk/sdk,
84
+koffice/chalk/chalkcolor, koffice/chalk/ui
85 85
 
86 86
 These directories contain header files that are installed and can be
87
-used by plugin developers to extend Krita with new tools, colorspaces,
87
+used by plugin developers to extend Chalk with new tools, colorspaces,
88 88
 paint-ops and more.  If your distribution packages development files
89 89
 separately, it may be a good idea to make a package with these headers.
90 90
 
@@ -93,7 +93,7 @@ separately, it may be a good idea to make a package with these headers.
93 93
 --------------------
94 94
 
95 95
 Preliminary support for Ruby and Python scripting is available for
96
-Krita and Kexi.
96
+Chalk and Kexi.
97 97
 It can be disabled by passing the '--disable-scripting' option to
98 98
 'configure'.
99 99
 
@@ -131,15 +131,15 @@ For example, the Python scripting package may contain:
131 131
   share/apps/kexi/scripts/importxhtml/ImportXHTML.rc
132 132
   share/apps/kexi/scripts/projectdocumentor/ProjectDocumentor.py
133 133
   share/apps/kexi/scripts/projectdocumentor/ProjectDocumentor.rc
134
-  share/apps/krita/scripts/invert.py
135
-  share/apps/krita/scripts/reshapehisto.py
134
+  share/apps/chalk/scripts/invert.py
135
+  share/apps/chalk/scripts/reshapehisto.py
136 136
 
137 137
 and the Ruby scripting package may contain:
138 138
   lib/kde3/krossruby.so
139 139
   lib/kde3/krossruby.la
140
-  share/apps/krita/scripts/ruby/invert.rb
141
-  share/apps/krita/scripts/ruby/changecs.rb
142
-  share/apps/krita/scripts/ruby/randompaint.rb
140
+  share/apps/chalk/scripts/ruby/invert.rb
141
+  share/apps/chalk/scripts/ruby/changecs.rb
142
+  share/apps/chalk/scripts/ruby/randompaint.rb
143 143
 
144 144
 
145 145
 4. Microsoft Access Import (optional, recommended)

+ 20
- 0
chalk/AUTHORS View File

@@ -0,0 +1,20 @@
1
+Adrian Page <Adrian.Page@tesco.net>
2
+Andrew Richards <physajr@phys.canterbury.ac.nz>
3
+Bart Coppens <kde@bartcoppens.be>
4
+Boudewijn Rempt <boud@valdyas.org>
5
+Carsten Pfeiffer <pfeiffer@kde.org>
6
+Casper Boemann <cbr@boemann.dk>
7
+Cyrille Berger <cyb@lepi.org>
8
+Danny Allen <dannya40uk@yahoo.co.uk>
9
+Dirk Schoenberger <dirk.schoenberger@sz-online.de>
10
+Gábor Lehel <illissius@gmail.com>
11
+John Califf <jcaliff@compuzone.net>
12
+Matthias Elter <elter@kde.org>
13
+Melchior Franz <melchior@kde.org>
14
+Michael Koch <koch@kde.org>
15
+Michael Thaler <michael.thaler@ph.tum.de> 
16
+Patrick Julien <freak@codepimps.org>
17
+Roger Larsson <roger.larsson@norran.net>
18
+Sven Langkamp <longamp@reallygood.de>
19
+
20
+Current maintainer: Boudewijn Rempt <boud@valdyas.org>

+ 1
- 0
chalk/ChangeLog View File

@@ -0,0 +1 @@
1
+We really should use cvs2changelog or something like that...

+ 93
- 0
chalk/HACKING View File

@@ -0,0 +1,93 @@
1
+Since 1999, people have been hacking on Chalk. Everyone brought their
2
+own coding style, their own code conventions, their own likes and
3
+dislikes. Me, (Boudewijn that is), I like indents of four spaces, and
4
+no scope prefixes for variables. However, in the interests of
5
+consistency, these are the rules new code should adhere to:
6
+
7
+
8
+Indentation
9
+
10
+	With four spaces. Use the default Java indentation
11
+	style of (X)Emacs or KDevelop -- also for brace placement.
12
+
13
+Includes
14
+
15
+	Avoid as much as possible #includes in header files; use forward declarations
16
+	of classes.
17
+
18
+Initializers
19
+
20
+	Avoid as much as possible initializers in the body of the constructor. Use
21
+	initializer lists instead.
22
+
23
+Scope prefixes
24
+
25
+	Use only m_ for class-level variables. No other scope prefixes; no g_, l_,
26
+	no 'p' for pointer variables.
27
+
28
+Shared pointers
29
+
30
+	Use shared pointers wherever possible.
31
+
32
+Getter/setter
33
+
34
+	Chalk doesn't use Qt's properties -- yet. If you want to introduce use of
35
+	properties, convert any and all classes in Chalk before committing.
36
+
37
+	Getter/setters are named 'x() for getters and setX(int x) for setters. If you
38
+	come across violations of this rule, change the code.	
39
+
40
+Class naming
41
+
42
+	If you use a well-known design pattern, name the class according to the design
43
+	pattern. All files should start with 'kis_', all classes with the 'Kis' prefix.
44
+	In filenames, separate words with an underscore; in classnames use capital letters. 
45
+	Example: kis_new_class.h/KisNewClass.
46
+
47
+	The only exception to this rule are interfaces.
48
+	Example: kis_tool.h/KisToolInterface.
49
+
50
+Function naming
51
+
52
+	Functions should be named in camelBackedFashion, to conform to Qt's standards.
53
+	If you encounter functions in c_style_like_this, feel free to rename. Also:
54
+	verbNoun -- i.e., rotateLayer, not layer_rotate. The latter is a true c-ism,
55
+	introduced by a language that needs to prefix the 'class' name to every function
56
+	in order to have something that not quite OO.
57
+
58
+Variable/Parameter names
59
+
60
+	Variable/parameter names start with an undercast letter. A name composed of different
61
+	words is done in camelBackedStyle.
62
+
63
+Designer
64
+
65
+	Chalk has started to use designer. All dialogs and all widgets that have a tqlayout
66
+	manager must be done in designer. We don't add code nor add signal/slot connections
67
+	in designer
68
+
69
+Enums
70
+
71
+	All enums should be prefixed with 'enum'.
72
+
73
+Namespaces
74
+
75
+	Currently, we only use anonymous (right term?) namespaces for things like undo
76
+	commands. For the rest, some classes have a 'Kis' prefix, others don't. This should
77
+	be made consistent, and we might want to use namespaces to keep all of Chalk
78
+	inside.
79
+
80
+Files and classes
81
+
82
+	It's preferred (and strongly preferred) to have only one class per .h/.cpp file.
83
+	(Which is logical, because otherwise you won't be able to keep to the naming scheme.)
84
+
85
+Spaces
86
+
87
+	Keep the source airy and open. (However, maybe I was wrong in wanting spaces around ->...)
88
+
89
+Slots and Q_SIGNALS
90
+
91
+	Prefix Q_SLOTS with slot and Q_SIGNALS with sig: slotUpdateSelection, sigSelectionUpdated.
92
+
93
+Boudewijn Rempt

+ 259
- 0
chalk/IMAGE_LIBRARIES View File

@@ -0,0 +1,259 @@
1
+WARNING: OBSOLETE (Chalk's internal code has become much better by now)
2
+
3
+From time to time, people come up with the suggestion to use an
4
+existing imaging library with Chalk, to replace our own core. This
5
+file contains a list of all libraries known to me, and a short
6
+evaluation. 
7
+
8
+Perhaps, one day, we will decide to either use an existing library, or
9
+remodel our core after one of those. Of the libraries present, except
10
+for our own Chalk, Vigra look like it's the best bet from a technical
11
+point of view, with Vips a good runner-up.
12
+
13
+
14
+* Chalk  (http://koffice.kde.org/chalk)
15
+
16
+Chalk contains its own 2D image library, consisting of the tile
17
+manager, the layer classes and KisPainter. We really should separate
18
+this 2d lib from the interface code, and put it in a real lib with 
19
+a well-defined interface.
20
+
21
+Advantages:
22
+
23
+	- Already works
24
+	- Optimized for interactive work
25
+	- Allows different colour models
26
+	- Uses GraphicsMagick or ImageMagick for loading and saving.
27
+
28
+Disadvantages:
29
+	
30
+	- Does not work well with different channel depths
31
+	- Not integrated with CMS
32
+	- TileManager complicated and slow for pixel reading and
33
+	  writing.
34
+	  
35
+* Gimp (http://www.gimp.org)
36
+
37
+The Gimp contains a complex core that allows interactive painting of
38
+images with a channel depth of 8 bits.
39
+
40
+Advantages:
41
+
42
+	- Well tested, very complete
43
+	- Optimized for interactive usage
44
+
45
+Disadvantages:
46
+
47
+	- Written in C.
48
+	- Not readily available as a library.
49
+	- Depends on glib and gtk
50
+	- 8-bit only
51
+	- No colour models
52
+	- Has problems handling really large images
53
+
54
+* Vigra (http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/)
55
+
56
+Vigra is a C++ imaging library written by Ullrich Koetthe to
57
+demonstrate his Phd thesis on flexible image algorithms.
58
+
59
+Advantages:
60
+
61
+	- Supports very large images
62
+	- Supports colour models
63
+	- Supports different bit depths through templating
64
+	- C++
65
+	- Relatively small
66
+	- Relatively well-documented
67
+
68
+Disadvantages:
69
+
70
+	- License incompatible with GPL?
71
+	- Not optimized for interactive use
72
+	- Unsure about future development since this was a research
73
+	  project.
74
+
75
+* Vips (http://www.vips.ecs.soton.ac.uk/)
76
+
77
+Vips is a C library with a C++ layer. It has been designed for
78
+handling very large images, mainly in the context of research into
79
+paintings in museums like the National Gallery. It comes with a gtk2
80
+gui.
81
+
82
+Advantages:
83
+
84
+	- Handles very large images
85
+	- Handles colour models
86
+	- Handles different bit depths
87
+	- C++ interface
88
+
89
+Disadvantages:
90
+
91
+	- Not optimized for paintbox type apps (even though it is
92
+	  possible).
93
+	- Very large.
94
+
95
+* VXL (http://vxl.sourceforge.net/)
96
+
97
+VXL is a collection of small libraries that are used for compution
98
+vision and imaging purposes in an academic setting.
99
+
100
+Advantages:
101
+
102
+	- Handles very large images
103
+	- C++
104
+
105
+Disadvantages:
106
+
107
+	- Not recently updated
108
+	- Comes with its own core libraries that replace standard C++
109
+	- Optimized for simple rgb images.
110
+	- No license at all
111
+	- Badly documented
112
+
113
+* CImg (http://cimg.sourceforge.net/)
114
+
115
+CImg is a very cool, very small library that offers some extremely
116
+innovative image effects, like inpainting of damaged or noise images.
117
+
118
+Advantages:
119
+	
120
+	- Small
121
+	- GPL
122
+	- Cool stuff
123
+
124
+Disadvantages:
125
+
126
+	- Everything, including GUI stuff, in one header file.
127
+	- badly documented.
128
+
129
+
130
+* Gegl (http://www.gegl.org/)
131
+
132
+Gegl was intended to become the Gimp 2.0 core, but development had
133
+stalled so much that the move to Gegl didn't happen before Gimp 2.0.
134
+However, the Thawte millionaire whose name has escaped me, has
135
+promised to support gegl development financially, freeing the
136
+developer to work full-time on it. It is, more or less, an attempt to
137
+write a templated library in C++ with the help of a custom language to
138
+describe image operations.
139
+
140
+Advantages:
141
+	
142
+	- It's got money behind it
143
+	- Small
144
+	- Optimized for interactive use
145
+
146
+Disadvantages:
147
+
148
+	- Not finished yet
149
+	- C
150
+	- Complex hack around the fact that C is a low-level language
151
+
152
+* libart_lgpl (http://www.levien.com/libart/)
153
+
154
+Libart isn't really an image library, but rather a canvas that can be
155
+used to paint images on. It is optimized for vector graphics, and is
156
+used by Karbon to render tqshapes before display.
157
+
158
+Advantages:
159
+
160
+	- Raph Levien is really good at this stuff, so libart is
161
+	  quality
162
+
163
+Disadvantages:
164
+
165
+	- C
166
+	- It isn't an image library, really
167
+
168
+
169
+* java2D (http://java.sun.com/j2se/1.4.2/docs/guide/2d/index.html)
170
+
171
+
172
+Java2D is more or less complete library to write a paint app around.
173
+It offers image types, colour spaces, kernel convolutions and text.
174
+It's in Java, of course, and the free re-implementation is not done
175
+yet, and besides, is based around Cairo.
176
+
177
+Advantages:
178
+	
179
+	- Neat OO design
180
+	- Complete
181
+
182
+Disadvantages:
183
+
184
+	- Java
185
+	- Not free
186
+	- Has some legacy cruft.
187
+
188
+* ImageMagick/GraphicsMagick (http://imagemagick.org/, http://www.graphicsmagick.org/)
189
+
190
+GraphicsMagick is ImageMagick with a different license, and a
191
+focus on API stability. GM and IM now also differ slightly in terms of
192
+features offered. Chalk used to be based around IM (which can still be
193
+seen in many places in the code). The IM core was dropped in favour of
194
+the present core because it turned out that IM was not re-entrant,
195
+making it hard to use in an interactive application.
196
+
197
+Advantages:
198
+
199
+	- Mature
200
+	- C++ interface
201
+	- Full-featured
202
+	- RGB and CMYK (but not more)
203
+	- License compatible with Chalk
204
+	- Under active development
205
+
206
+Disadvantages:
207
+
208
+	- Bit-depth a compile-time option
209
+	- Not re-entrant: not optimized for interactive use.
210
+
211
+* Paintlib2 (http://www.paintlib.de/paintlib/)
212
+
213
+A portable (windows/Linux) library for image loading, manipulation and
214
+saving. The same kind of thing as IM/GM, but not quite as mature.
215
+
216
+Advantages:
217
+
218
+Disadvantages:
219
+ 	
220
+	- No support for larger bit depths per channel
221
+	- Windows (bmp) centric
222
+	- Development seems to have stopped in 2000
223
+
224
+
225
+* Antigrain (http://www.antigrain.com/)
226
+
227
+Antigrain is a graphics lib that specializes in high-quality anti-aliasing. It can be 
228
+useful to mine for algorithms, but is mainly a library to render vector data to bitmaps,
229
+just like libart or cairo.
230
+
231
+Advantages:
232
+
233
+	- High quality algorithms
234
+	- Completely free license.
235
+	- Colour-space agnostic
236
+
237
+Disadvantages:
238
+
239
+	- Not a complete 2D library
240
+	- self-admittedly complex and hard to use.
241
+	- No support for greater bit-depths.
242
+
243
+* The Visualization Toolkit (VTK, http://public.kitware.com/VTK/)
244
+
245
+A very big C++ library for 2d and 3d image processing and visualisation. It's
246
+too big to easily evaluate for me.
247
+
248
+Advantages
249
+	
250
+	- It is used in other Qt applications, like Julius
251
+	- Probably very good
252
+
253
+Disadvantages
254
+
255
+	- The book is very expensive
256
+	- Uses its own make equivalent, CMake
257
+	- Very large
258
+
259
+* Java Advanced Imaging

+ 47
- 0
chalk/Makefile.am View File

@@ -0,0 +1,47 @@
1
+INCLUDES  = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) $(all_includes)
2
+
3
+## The common lib, shared between the part, the plugins, and the filters
4
+lib_LTLIBRARIES = libchalkcommon.la
5
+libchalkcommon_la_SOURCES = dummy.cc
6
+libchalkcommon_la_LDFLAGS = $(all_libraries) $(LIB_QT) -version-info 1:0 -no-undefined
7
+libchalkcommon_la_LIBADD = sdk/libchalksdk.la core/libchalkimage.la ui/libchalkui.la chalkcolor/libchalkcolor.la $(LCMS_LIBS) $(LIB_KOFFICEUI) $(LIB_KOPAINTER) $(LIB_KOPALETTE) $(LIB_XINPUTEXT)
8
+
9
+## The part
10
+kde_module_LTLIBRARIES = libchalkpart.la
11
+libchalkpart_la_SOURCES = chalk_part_init.cc
12
+libchalkpart_la_LDFLAGS = $(all_libraries) $(LIB_QT) -L../lib/kofficecore/.libs/ -lkofficecore -L../lib/kofficeui/.libs/ -lkofficeui -L../lib/store/.libs/ -lkstore -L../chalk/ui/.libs -lchalkui -module $(KDE_PLUGIN)
13
+libchalkpart_la_LIBADD = libchalkcommon.la
14
+
15
+METASOURCES = AUTO
16
+
17
+## The kdeinit loadable module and executable
18
+kdeinit_LTLIBRARIES = chalk.la
19
+bin_PROGRAMS =
20
+chalk_la_SOURCES = main.cc
21
+chalk_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT)
22
+chalk_la_LIBADD = $(LIB_KOFFICECORE)
23
+
24
+xdg_apps_DATA = chalk.desktop
25
+kdemimedir = $(kde_mimedir)/application
26
+
27
+rcdir = $(kde_datadir)/chalk
28
+rc_DATA = chalk.rc chalk_readonly.rc
29
+
30
+SUBDIRS = sdk chalkcolor core ui . dtd colorspaces plugins data pics 
31
+# Needed to compile libchalkcommon.la, which has no source files to itself
32
+# but everything in static libs.
33
+dummy.cc:
34
+	echo > dummy.cc
35
+
36
+messages: rc.cpp
37
+	$(EXTRACTRC) `find . -name \*.ui` >> rc.cpp
38
+	$(EXTRACTRC) `find . -name \*.rc` >> rc.cpp
39
+	perl extracti18n.pl > i18ndata
40
+	$(XGETTEXT) i18ndata rc.cpp `find . -name \*.cc -o -name \*.h -o -name \*.cpp` ui/kis_aboutdata.h -o $(podir)/chalk.pot
41
+	rm -f i18ndata
42
+
43
+DOXYGEN_EXCLUDE = CImg.h colorspaces plugins chalkcolor/colorspaces core/tiles
44
+include $(top_srcdir)/admin/Doxyfile.am
45
+
46
+kde_services_DATA = chalkpart.desktop
47
+

+ 13
- 0
chalk/README View File

@@ -0,0 +1,13 @@
1
+Chalk
2
+
3
+Chalk is a paint application for bitmap images. It's also, according to
4
+the Dictionary of Phrase and Fable:
5
+
6
+The first of four Hindu periods contained in the great Yuga, when the
7
+genius of Truth and Right, in the form of bull, stood firm on his four
8
+feet, and man gained nothing by iniquity.
9
+
10
+In the Mahabharata, the name 'chalk' is used in a context where this
11
+can be translated with 'perfect' - the perfect age.
12
+
13
+Chalk is Swedish for chalk (or pencil?) and rita means "to write".

+ 181
- 0
chalk/TODO View File

@@ -0,0 +1,181 @@
1
+After 1.5 cleanups
2
+
3
+* Move core/ui class private members to d-pointers
4
+* Selections, adj. masks, wetness, heigh masks (all 8-bit mask ideas)
5
+  as sublayers to paint layers, and make them movable between layers
6
+  and x,y, toggle on/off.
7
+* Fix KisFilter::colorSpaceIndependence/worksWith overlap
8
+* Add api & gui to exclude channels from compositing
9
+* Add a mechanism for cspaces to start long-running filters when a paintdev
10
+  is created -- and a gui to turn that on and off, perhaps something analogous
11
+  to a channels box
12
+* Make set of filter categories extensible
13
+* BUG 121975: selections and group layers.
14
+* Add end poly entry to the popup menu when the poly tool is active (note:
15
+  make this more generically useful for tools. Great idea by David Herman
16
+* Paint direct should be paint directly
17
+          
18
+UI stuff:
19
+
20
+* color picker: top combo should be as wide as the whole widget; the widget is a bit too big,
21
+  we should try to make the listview a lot smaller. Maybe just use labels here?
22
+* The edit palette dialog two-step should be changed into a single dialog
23
+          
24
+Code organization
25
+
26
+Transform tool (CBR)
27
+
28
+	* Implement native integer versions for bell, bspline, lanczos3 and mitchell filters
29
+	* The option widget should be connected
30
+	* Figure out why scaling down produces sum of weights <255 (Hermite filter)
31
+	* Implement gui, create cursors and update visitor for shearing
32
+
33
+Integration
34
+
35
+	* A chalk document embedded in KWord has the wrong scaling and transparency
36
+	* A chalk document embedded in another document prints at the wrong place
37
+	* Embedded KOffice objects don't paint themselves correctly
38
+	* There is currently no kimgio module for Chalk images: implement one by
39
+	  saving a rendered png image into the chalk file and extracting that from
40
+	  kimgio. (Saving of a png image in .kra files is done; now we just need to 
41
+          add the kimgio file)
42
+        * There is no easy way to get back from editing an embedded document (if the image is larger
43
+          than the window)
44
+          
45
+Colorspace independence (found with the test colorstrategy)
46
+
47
+	* Check and double check the cms capabilities: especially the use of
48
+          profiles in the render/convert/edit paths.
49
+	* Merge grayscale layers back into one color image.
50
+    
51
+Core
52
+
53
+     * The fill painter (and perhaps other paitners, too) should call addDirtyRect, and the floodfill
54
+          tool should use that rect to blit and notify the image, instead of notifying the complete image.s
55
+	* Fix image resolution handling (zooming, pixel-for-pixel, 100% == zoomed to dpi/xdpi etc.)
56
+	* Loading and saving of selections
57
+	* Anti-aliased filling (requires some simple colorspace function to merge 2 Pixels)
58
+	* Load/save configuration of everything user-settable.
59
+	* Long painter operations (e.g., convolution painter) should use the
60
+          progressbar and be cancelable.
61
+    * Color adjustment filters seem to have a problem with partially selected pixels
62
+
63
+File Format:
64
+
65
+	* Save & load all annotations in .kra files
66
+	* Save & load more information, like PNG comments, gamma information, etc
67
+
68
+
69
+Import/Export
70
+
71
+    * Fix gimp XCF PSD and import/export (ImageMagick hacking...)
72
+	* Fix imports to import metadata.
73
+
74
+User Interface
75
+    * Add an explanatory textframe to the scaling filter combobox.
76
+    * Add a good crosshair cursor and a crosshair cursor that extends to the rulers.
77
+    * Add a cheatsheet widget that integrates with knewstuff to have tutorials that people
78
+      can download and follow from Chalk.
79
+    * Add opacity widget (One that grows more white or transparent (showing those gray blocks) based on the
80
+	  input)
81
+    * Add out-of-gamut selection
82
+    * Fix layout problems in tool option widgets.
83
+    * Disable dragging the toolbox from dock position to dock position (see Karbon)
84
+    * Disable all relevant actions when a layer is locked or invisible. See bug #90456. Show locked status of current layer in statusbar.
85
+    * Add link check to new image dialog to sync width and height
86
+    * The description field in color settings is empty
87
+    * Implement the following dialogs / widgets:
88
+		    - Variations (#Boudewijn)
89
+		    - Gradient: remove the autogradient dialog and make into a proper
90
+				gradient dialog, and allow saving gradients.
91
+
92
+    * Show which tool is associated with which pointer (mouse, stylus, eraser, other stylusses) In the statusbar.
93
+    * Allow guides to be disabled. Allow diagonal guides (useful for perspective drawings) Bug #108398
94
+    * Allow snapping to guides.
95
+    * Create templates for often-used image formats. Add save-as-template
96
+    * Add deselect with rmb -- maybe also selectable actions with other tools on rmb?
97
+    * Fix crop tool: when pressing shift, keep aspect ratio, implement gray mask.
98
+	  (Michael Thaler)
99
+    * Allow shape tools to be filled with gradients
100
+
101
+	Dockers
102
+		* Tabs in dockers drag-and-droppable (vector of docker
103
+		  windows, create new docker if tab dropped outside existing
104
+		  docker window)
105
+		* Add bird's eye view tab to dockers.
106
+		* Add action (macro) docker
107
+		* Add navigation/zoom docker
108
+		* Add history docker
109
+
110
+    * Doing a copy of a selection, but having the wrong layer selected gives 
111
+      me an empty selection (all transparent).  Pressing paste should say so 
112
+      (popup) instead of creating a new useless layer.
113
+    * the selection tools should allow pressing shift to go to 'substract' 
114
+      mode without adjusting the combobox for the current tool.  (a different 
115
+      pointer would be nice as well)
116
+
117
+    * Pressing save for the first time gives me the 'save document as' dialog 
118
+      which is set to 'png' as default file format.
119
+      I suggest to set the default format (in the "save as" dialog) to the chalk 
120
+      format for any image that has more then 1 layer.  
121
+
122
+
123
+Selections
124
+
125
+    * On shearing, the whole image is mirrored, not the selected
126
+	  bits.
127
+    * Add opacity slider to selection painting tools so you can
128
+          select something 50%.
129
+
130
+Profiles
131
+
132
+	* Add an input profile combobox to the import image & scan dialogs
133
+	* Add an export profile combobox to the export image/print dialogs
134
+    * Add loading and saving of profiles associated with images in .chalk 
135
+          files.
136
+    * Export profiles in tiff, png and jpg (this and the previous item
137
+      depend on ImageMagick or GraphicsMagick supporting this in some way.)
138
+    * Support out-of-gamut warning indications for parts of an image 
139
+      containing unprintable colours (no idea how to implement this). -> this
140
+      is pretty easy with lcms
141
+	* preferences dialog can show non-existent profile for the monitor profile -> confusing
142
+
143
+
144
+Tools
145
+
146
+	* Zoom tool should zoom out when alt is pressed. Show zoom-minus cursor in that case
147
+	* Implement the following tools or paintops: 
148
+		    - fix airbrush tool (add rate option, add increase
149
+		      of brush size if kept in one place)
150
+		    - color changer, smudge tool,sharpen tool, blur
151
+		      tool, dodge tool, burn tool, sponge tool (These
152
+		      last are perhaps more generally: painting with
153
+		      filters tool)
154
+		    - stamp tool (paint with patttern/image selection) (#Cyrille)
155
+		    - Text tool (use kotext with a transparent background here?)
156
+		    - Measure tool
157
+	            - calligraphic pen tool
158
+ 
159
+	* Pressure sensivitize all relevant tools (e.g. line tool)
160
+    * Add resize slider to freehand tools that resizes the mean brush size.
161
+	* Implement path tools (Michael Thaler?)
162
+	* Sumi-e brush tool
163
+	* Natural media tools (chalk, ink, oil, watercolour -- fun!)
164
+
165
+Plugins
166
+
167
+	* As many filters as possible :-)
168
+
169
+Modules
170
+
171
+	* Add color models for HSV, YUV etc.
172
+	* Add Wet & Sticky model (in progress already)
173
+	* Implement Curtiss et. al. for watercolour (Levien, wet dreams. In progress)
174
+	* The composite ops in RGB -> composite.h do not take mask into account
175
+	 - this goes for COPY and CLEAR in grayscale also
176
+
177
+Printing
178
+
179
+	* No use of the resolution parameter (but the resolution dialog is still only a .ui file and not implemented at all)
180
+	* Use gutenprint or something better for image printing.
181
+

+ 59
- 0
chalk/UIcomments View File

@@ -0,0 +1,59 @@
1
+Color palettes ;
2
+
3
+You can drag a color from the preview swatches but it is changing the
4
+selected one at click and since dropping drops on the selected one, the 
5
+concept of duplicating the foreground to the background by dragging is 
6
+impossible.  I suggest to do selecting of foreground/background color on 
7
+mouse release instead.
8
+
9
+<BSAR: I don't understand this at all -- not sure what you're talking about.>
10
+
11
+Selections
12
+
13
+When you did a 'select all' and then create a selection nothing happens 
14
+since you can't select more then you already did.  For that reason I 
15
+suggest to make select all and deselect lead to a similar situation where 
16
+adding a selection or substracting one will be smart and do make the 
17
+result of that select or deselect visible.  In either case selecting a 
18
+part in both a fully selected and fully deselected image should lead to 
19
+the same result.
20
+
21
+<BSAR: not going to do this: in the next release, it will be
22
+always clear whether there's a selection because we're going to show it as a
23
+child layer. For now, determining whether the extent of a selection is as big
24
+as the extent of a layer, and whether the whole selection is completely 100%
25
+selected is going to be too expensive>
26
+
27
+
28
+Thomas Zander
29
+
30
+
31
+Missing tooltips (Carsten N.)
32
+
33
+LEGEND: NTAA No Tooltip At All
34
+ 
35
+Missing tooltips:
36
+ 
37
+KComboBox in the toolbar (the with 'Pixel Brush' for example)
38
+ 
39
+Overview-widget: NTAA
40
+ 
41
+Histogram: No Tooltip. Well, there is nothing but the histogram, there should be at least something...
42
+ 
43
+Context-Widgets of the tools:
44
+ 
45
+Star: NTAA
46
+ 
47
+Brush: NTAA
48
+ 
49
+Line: NTAA
50
+ 
51
+Rectangle: NTAA
52
+ 
53
+Ellispse: NTAA
54
+ 
55
+Polygone: NTAA
56
+ 
57
+Polyline: NTAA
58
+ 
59
+Duplicate Brush: NTAA

+ 95
- 0
chalk/chalk.desktop View File

@@ -0,0 +1,95 @@
1
+[Desktop Entry]
2
+Name=Chalk
3
+Name[hi]=के-रिता
4
+Name[km]= Chalk
5
+Name[lo]=ກຣິຕາ
6
+Name[ne]=क्रिता
7
+Exec=chalk %U
8
+DocPath=chalk/index.html
9
+Comment=Edit and paint images
10
+Comment[bg]=Редактиране и оцветяване на изображения
11
+Comment[ca]=Edita i pinta imatges
12
+Comment[da]=Redigér og mal billeder
13
+Comment[de]=Bilder zeichnen und bearbeiten
14
+Comment[el]=Επεξεργασία και ζωγραφική εικόνων
15
+Comment[eo]=Redakti kaj pentri bildojn
16
+Comment[es]=Editar y pintar imágenes
17
+Comment[et]=Piltide töötlemine ja joonistamine
18
+Comment[fa]=ویرایش و رنگ‌آمیزی تصاویر
19
+Comment[fi]=Muokkaa ja maalaa kuvia
20
+Comment[fr]=Création et retouche d'images
21
+Comment[fy]=Ofbyldings bewurkje en skilderje
22
+Comment[gl]=Edita e pinta imaxes
23
+Comment[he]=עריכה וצביעת תמונות
24
+Comment[hu]=Képek szerkesztése
25
+Comment[it]=Modifica e disegna immagini
26
+Comment[ja]=描画と画像の編集
27
+Comment[km]=កែសម្រួល និង​គូរ​រូបភាព
28
+Comment[lv]=Labot un zīmēt attēlus
29
+Comment[nb]=Rediger og mal bilder
30
+Comment[nds]=Biller malen un bewerken
31
+Comment[ne]=छविहरू सम्पादन र पेन्ट गर्नुहोस्
32
+Comment[nl]=Afbeeldingen bewerken en schilderen
33
+Comment[pl]=Edycja i tworzenie obrazków
34
+Comment[pt]=Editar e pintar as imagens
35
+Comment[pt_BR]=Editar e pintar as imagens
36
+Comment[ru]=Растровые рисунки
37
+Comment[se]=Doaimmat ja mále govaid
38
+Comment[sk]=Editivať a maľovať obrázky
39
+Comment[sl]=Urejajte in ustvarjajte slike
40
+Comment[sr]=Уређујте и правите слике
41
+Comment[sr@Latn]=Uređujte i pravite slike
42
+Comment[sv]=Redigera och måla bilder
43
+Comment[uk]=Створення і редагування зображень
44
+Comment[uz]=Rasm bilan ishlash dasturi
45
+Comment[uz@cyrillic]=Расм билан ишлаш дастури
46
+Comment[zh_TW]=編輯與畫圖片
47
+GenericName=Painting and Image Editing
48
+GenericName[bg]=Редактор на графични изображения
49
+GenericName[ca]=Programa d'edició d'imatges
50
+GenericName[da]=Maling & billedredigering
51
+GenericName[de]=Mal- und Bildbearbeitungsprogramm
52
+GenericName[el]=Επεξεργασία και ζωγραφική εικόνων
53
+GenericName[eo]=Pentrado kaj Bildredaktado
54
+GenericName[es]=Pintura y edición de imágenes
55
+GenericName[et]=Joonistamine ja pilditöötlus
56
+GenericName[fa]=رنگ‌آمیزی و ویرایش تصویر
57
+GenericName[fi]=Maalaus ja kuvankäsittely
58
+GenericName[fr]=Peinture et retouche d'images
59
+GenericName[fy]=Ofbyldingsmanupilaasje
60
+GenericName[ga]=Péinteáil agus Eagarthóireacht Íomhánna
61
+GenericName[gl]=Debuxo e Edición de Imaxes
62
+GenericName[he]=טיפול ועריכת תמונות
63
+GenericName[hu]=Rajzoló és képszerkesztő
64
+GenericName[is]=Málun og myndsýsl
65
+GenericName[it]=Disegno e modifica di immagini
66
+GenericName[ja]=描画と画像編集
67
+GenericName[km]=គូរ​គំនូរ និង​កែសម្រួល​រូបភាព
68
+GenericName[lv]=Zīmēšana un attēlu apstrāde
69
+GenericName[nb]=Program for maling og bilderedigering
70
+GenericName[nds]=Malen un Biller bewerken
71
+GenericName[ne]=पेन्टिङ्ग र छवि सम्पादन
72
+GenericName[nl]=Afbeeldingsmanipulatie
73
+GenericName[pl]=Edycja zdjęć oraz rysunków
74
+GenericName[pt]=Pintura e Manipulação de Imagens
75
+GenericName[pt_BR]=Pintura e Edição de Imagens
76
+GenericName[ru]=Растровые изображения
77
+GenericName[se]=Málen- ja govvagieđaheapmi
78
+GenericName[sk]=Program pre úpravu a maľovanie obrázkov
79
+GenericName[sl]=Slikanje in urejanje slik
80
+GenericName[sr]=Цртање и уређивање слика
81
+GenericName[sr@Latn]=Crtanje i uređivanje slika
82
+GenericName[sv]=Målning och bildredigering
83
+GenericName[uk]=Малювання і редагування зображень
84
+GenericName[uz]=Rasmlar bilan ishlaydigan dastur
85
+GenericName[uz@cyrillic]=Расмлар билан ишлайдиган дастур
86
+GenericName[zh_CN]=绘图和图像编辑
87
+GenericName[zh_TW]=繪圖與影像編輯
88
+MimeType=application/x-chalk
89
+Type=Application
90
+Icon=chalk
91
+Categories=Qt;KDE;Graphics;
92
+X-KDE-NativeMimeType=application/x-chalk
93
+X-KDE-StartupNotify=true
94
+X-DCOP-ServiceType=Multi
95
+X-Chalk-Version=2

+ 199
- 0
chalk/chalk.rc View File

@@ -0,0 +1,199 @@
1
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Chalk" version="15">
2
+
3
+<MenuBar>
4
+ <Menu name="Edit"><text>&amp;Edit</text>
5
+  <Action name="koffice_undo"/>
6
+  <Action name="koffice_redo"/>
7
+  <Separator/>
8
+  <Action name="cut"/>
9
+  <Action name="copy"/>
10
+  <Action name="copy_merged"/>
11
+  <Action name="paste"/>
12
+  <Action name="paste_new"/>
13
+  <Action name="clear"/>
14
+  <Action name="fill_selection_foreground_color"/>
15
+  <Action name="fill_selection_background_color"/>
16
+  <Action name="fill_selection_pattern"/>
17
+  <Separator/>
18
+  <Action name="revert"/>
19
+  <Separator/>
20
+  <Menu name="Resources"><text>&amp;Resources</text>
21
+   <Action name="add_palette"/>
22
+   <Action name="edit_palette"/>
23
+  </Menu>
24
+ </Menu>
25
+
26
+ <Menu name="View"><text>&amp;View</text>
27
+  <Action name="fullscreen"/>
28
+  <Separator/>
29
+  <Action name="view_newview"/>
30
+  <ActionList name="view_closeallviews"/>
31
+  <Separator/>
32
+  <ActionList name="view_split"/>
33
+  <Action name="zoom_in"/>
34
+  <Action name="zoom_out"/>
35
+  <Action name="actual_pixels"/>
36
+  <Action name="actual_size"/>
37
+  <Action name="fit_to_canvas"/>
38
+  <Separator/>
39
+  <Action name="view_ruler"/>
40
+  <!--Action name="view_guidelines"/-->
41
+  <Separator/>
42
+  <Action name="view_toggle_grid" />
43
+  <Menu name="view_fast_grid_config"><text>Grid Spacing</text>
44
+   <Action name="view_fast_grid_1x1" />
45
+   <Action name="view_fast_grid_2x2" />
46
+   <Action name="view_fast_grid_5x5" />
47
+   <Action name="view_fast_grid_10x10" />
48
+   <Action name="view_fast_grid_20x20" />
49
+   <Action name="view_fast_grid_40x40" />
50
+  </Menu>
51
+  <Seperator/>
52
+  <Action name="view_toggle_perspective_grid" />
53
+  <Action name="view_clear_perspective_grid" />
54
+  <Separator/>
55
+  <Action name="view_palette_action_menu"/>
56
+  <Separator/>
57
+  <Action name="refresh_canvas"/>
58
+ </Menu>
59
+
60
+
61
+<Menu name="Image"><text>&amp;Image</text>
62
+  <Action name="img_properties"/>
63
+  <Action name="resizeimgtolayer"/>
64
+  <Action name="duplicate_image"/>
65
+</Menu>
66
+
67
+<Menu name="Layer"><text>&amp;Layer</text>
68
+  <Menu name="LayerNew"><text>New</text>
69
+  	<Action name="insert_layer"/>
70
+	<Action name="insert_part_layer"/>
71
+        <Action name="insert_adjustment_layer"/>
72
+  	<Action name="insert_image_as_layer"/>
73
+  	<Action name="cut_selection_to_new_layer"/>
74
+  	<Action name="copy_selection_to_new_layer"/>
75
+  </Menu>	
76
+  <Action name="remove_layer"/>
77
+  <Action name="duplicate_layer"/>
78
+  <Action name="hide_layer"/>
79
+  <Action name="link_layer"/>
80
+  <Separator/>
81
+  <Menu name="LayerNew"><text>Mask</text>
82
+    <Action name="create_mask"/>
83
+    <Action name="mask_fromsel"/>
84
+    <Action name="mask_tosel"/>
85
+    <Action name="apply_mask"/>
86
+    <Action name="remove_mask"/>
87
+    <Seperator/>
88
+    <Action name="edit_mask"/>
89
+    <Action name="show_mask"/>
90
+  </Menu>
91
+  <Separator/>
92
+  <Action name="raiselayer"/>
93
+  <Action name="lowerlayer"/>
94
+  <Action name="toplayer"/>
95
+  <Action name="bottomlayer"/>
96
+  <Separator/>
97
+  <Action name="resizelayertoowner"/>
98
+  <Separator/>
99
+  <Action name="save_layer_as_image"/>
100
+  <Action name="layer_to_image"/>
101
+<Separator/>
102
+  <Action name="mirrorLayerX"/>
103
+  <Action name="mirrorLayerY"/>
104
+  <Separator/>
105
+  <Action name="layer_properties"/>
106
+  <Separator/>
107
+  <Action name="merge_layer"/>
108
+  <Action name="flatten_image"/>
109
+</Menu>
110
+
111
+
112
+<Menu name="Select"><text>Sele&amp;ct</text>
113
+    <Action name="select_all"/>
114
+    <Action name="deselect"/>
115
+    <Action name="reselect"/>
116
+    <Action name="invert"/>
117
+    <Separator/>
118
+    <Action name="feather"/>
119
+   <Action name = "grow"/>
120
+   <Action name = "similar"/>
121
+   <Separator/>
122
+   <Action name="toggle_display_selection"/>
123
+</Menu>
124
+
125
+<Menu name="Filter"><text>Filte&amp;r</text>
126
+	<Action name="filter_apply_again"/>
127
+	<Separator/>
128
+    <Action name="adjust_filters"/>
129
+	<Action name="artistic_filters"/>
130
+	<Action name="blur_filters"/>
131
+	<Action name="color_filters"/>
132
+	<Action name="decor_filters"/>
133
+	<Action name="edge_filters"/>
134
+	<Action name="enhance_filters"/>
135
+	<Action name="emboss_filters"/>
136
+    <Action name="map_filters"/>
137
+    <Action name="nonphotorealistic_filters"/>
138
+	<Action name="misc_filters"/>
139
+</Menu>
140
+
141
+<Menu name="Tools"><text>&amp;Tools</text>
142
+</Menu>
143
+
144
+
145
+<Menu name="settings"><text>Settings</text>
146
+  <Separator group="settings_show"/>
147
+  <Action name="preferences" group="settings_configure"/>
148
+</Menu>
149
+
150
+</MenuBar>
151
+
152
+<ToolBar name="edit_toolbar" position="top"><Text>Edit</Text>
153
+  <Action name="koffice_undo"/>
154
+  <Action name="koffice_redo"/>
155
+  <Separator/>
156
+  <Action name="cut"/>
157
+  <Action name="copy"/>
158
+  <Action name="remove"/>
159
+  <Action name="scrap_selection"/>
160
+  <Action name="paste_special"/>
161
+</ToolBar>
162
+
163
+<ToolBar name="navigation" position="top"><Text>Navigation</Text>
164
+  <Action name="refresh_canvas"/>
165
+  <Action name="zoom_in"/>
166
+  <Action name="zoom_out"/>
167
+</ToolBar>
168
+
169
+<ToolBar name="ToolBox" position="left">
170
+    <Text>Chalk</Text>
171
+</ToolBar>
172
+
173
+<ToolBar name="BrushesAndStuff" position="top">
174
+     <Text>Brushes and Stuff</Text>
175
+     <Action name="brushes"/>
176
+     <Action name="gradients"/>
177
+     <Action name="patterns"/>
178
+     <Separator/>
179
+     <Action name="paintops"/>
180
+     <Action name="paintop_options"/>
181
+</ToolBar>
182
+
183
+<Menu name="image_popup">
184
+ <Action name="select_all"/>
185
+ <Action name="deselect"/>
186
+ <Action name="invert"/>
187
+ <Separator/>
188
+ <Action name="duplicate_layer"/>
189
+ <Separator/>
190
+ <Action name="koffice_undo"/>
191
+ <Action name="koffice_redo"/>
192
+ <Separator/>
193
+ <Action name="cut"/>
194
+ <Action name="copy"/>
195
+ <Action name="paste"/>
196
+ <Action name="paste_new"/>
197
+</Menu>
198
+
199
+</kpartgui>

+ 23
- 0
chalk/chalk_part_init.cc View File

@@ -0,0 +1,23 @@
1
+/*
2
+ *  kis_part_init.cc - part of Krayon
3
+ *
4
+ *  Copyright (c) 1999 Matthias Elter <elter@kde.org>
5
+ *
6
+ *  This program is free software; you can redistribute it and/or modify
7
+ *  it under the terms of the GNU General Public License as published by
8
+ *  the Free Software Foundation; either version 2 of the License, or
9
+ *  (at your option) any later version.
10
+ *
11
+ *  This program is distributed in the hope that it will be useful,
12
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ *  GNU General Public License for more details.
15
+ *
16
+ *  You should have received a copy of the GNU General Public License
17
+ *  along with this program; if not, write to the Free Software
18
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
+ */
20
+#include "ui/kis_factory.h"
21
+
22
+
23
+K_EXPORT_COMPONENT_FACTORY( libchalkpart, KisFactory )

+ 35
- 0
chalk/chalk_readonly.rc View File

@@ -0,0 +1,35 @@
1
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Chalk" version="1">
2
+
3
+<MenuBar>
4
+ <Menu name="edit"><text>Edit</text>
5
+  <Separator/>
6
+  <Action name="copy"/>
7
+  <Separator/>
8
+  <Action name="select_all"/>
9
+  <Action name="select_none"/>
10
+  <Action name="flip_selection"/>  
11
+ </Menu>
12
+
13
+ <Menu name="view"><text>View</text>
14
+  <Action name="zoom_in"/>
15
+  <Action name="zoom_out"/>
16
+ </Menu>
17
+
18
+<Menu name="Layer"><text>Layer</text>
19
+  <Action name="hide_layer"/>
20
+  <Action name="previous_layer"/>  
21
+  <Action name="next_layer"/>
22
+</Menu>
23
+
24
+</MenuBar>
25
+
26
+<ToolBar name="edit" position="top"><Text>Edit</Text>
27
+  <Action name="copy"/>
28
+</ToolBar>
29
+
30
+<ToolBar name="navigation" position="top"><Text>Navigation</Text>
31
+  <Action name="zoom_in"/>
32
+  <Action name="zoom_out"/>
33
+</ToolBar>
34
+
35
+</kpartgui>

+ 45
- 0
chalk/chalkcolor/Makefile.am View File

@@ -0,0 +1,45 @@
1
+# all_includes must remain last!
2
+INCLUDES  = $(KOFFICE_INCLUDES) \
3
+    -I$(srcdir) \
4
+    -I$(srcdir)/../sdk \
5
+    -I$(srcdir)/colorspaces \
6
+    $(OPENEXR_CFLAGS) \
7
+    $(all_includes)
8
+
9
+lib_LTLIBRARIES = libchalkcolor.la
10
+
11
+if have_openexr
12
+OPENEXR_SOURCES=kis_f16half_base_colorspace.cc
13
+endif
14
+
15
+libchalkcolor_la_SOURCES = kis_color.cc kis_colorspace.cc \
16
+	kis_colorspace_iface.cc kis_colorspace_iface.skel kis_composite_op.cc kis_profile.cc \
17
+	kis_histogram_producer.cc kis_basic_histogram_producers.cc kis_abstract_colorspace.cc \
18
+	kis_colorspace_factory_registry.cc kis_color_conversions.cc kis_u8_base_colorspace.cc \
19
+	kis_u16_base_colorspace.cc kis_f32_base_colorspace.cc $(OPENEXR_SOURCES)
20
+
21
+libchalkcolor_la_LDFLAGS = -version-info 1:0:0 -no-undefined $(all_libraries)
22
+libchalkcolor_la_LIBADD  = colorspaces/libchalkcolorspaces.la $(LCMS_LIBS) $(LIB_KPARTS) $(LIB_KDECORE) $(LIB_QT) $(OPENEXR_LIBS)
23
+
24
+include_HEADERS =  \
25
+    kis_channelinfo.h \
26
+    kis_color.h \
27
+    kis_colorspace.h \
28
+    kis_composite_op.h \
29
+    kis_profile.h \
30
+    kis_histogram_producer.h \
31
+    kis_basic_histogram_producers.h kis_u8_base_colorspace.h kis_u16_base_colorspace.h kis_f16half_base_colorspace.h kis_f32_base_colorspace.h \
32
+    kis_colorspace_factory_registry.h kis_abstract_colorspace.h
33
+
34
+
35
+if include_kunittest_tests
36
+TESTSDIR = tests
37
+endif
38
+
39
+SUBDIRS = colorspaces . $(TESTSDIR)
40
+
41
+kde_servicetypes_DATA =  chalk_colorspace.desktop
42
+
43
+METASOURCES = AUTO
44
+
45
+

+ 4
- 0
chalk/chalkcolor/README View File

@@ -0,0 +1,4 @@
1
+The color library is a wrapper around lcms and provides colorspaces
2
+that can do things to arrays of bytes that represent pixels. The
3
+number of colorspaces is extensible with plugins. The colorspace
4
+registry is responsible for loading the colorspace plugins.

+ 11
- 0
chalk/chalkcolor/TODO View File

@@ -0,0 +1,11 @@
1
+This library is still dependent upon chalk/sdk for some headers. This
2
+should be changed. The headers concerned are:
3
+
4
+kis_id.h
5
+kis_global.h
6
+kis_annotation.h
7
+kis_integer_maths.h
8
+
9
+Additionally, there is a problem with the histogram producers: those are
10
+tied to the individual base colorspaces, but also need iterators, so they
11
+are in core for the moment.

+ 38
- 0
chalk/chalkcolor/chalk_colorspace.desktop View File

@@ -0,0 +1,38 @@
1
+[Desktop Entry]
2
+Type=ServiceType
3
+X-KDE-ServiceType=Chalk/ColorSpace
4
+Comment=A module implementing a complete colorspace for use with libchalkcolor
5
+Comment[bg]=Модул, реализиращ пълна цветова гама за употреба с libchalkcolor
6
+Comment[ca]=Un mòdul que implementa un complet espai de colors per a usar-lo amb libchalkcolor
7
+Comment[cy]=Modiwl sy'n gweithredoli gofod lliw cyflawn i'w ddefnyddio efo libchalkcolor
8
+Comment[da]=Et modul som implementerer et fuldstændigt farverum til brug med libchalkcolor
9
+Comment[de]=Ein Modul, das einen kompletten Farbraum zur Benutzung mit libchalkcolor implementiert
10
+Comment[el]=Ένα άρθρωμα που υλοποιεί έναν πλήρη χρωματικό χώρο για χρήση με το libchalkcolor
11
+Comment[en_GB]=A module implementing a complete colourspace for use with libchalkcolor
12
+Comment[es]=Un módulo que implementa un espacio de color completo para usar con libchalkcolor
13
+Comment[et]=Täielikku värviruumi teostav moodul (teegile libchalkcolor)
14
+Comment[fa]=پیمانه‌ای که فضای رنگ کاملی برای استفاده با libchalkcolor پیاده می‌کند
15
+Comment[fr]=Un module implantant un espace de couleurs complet à utiliser avec libchalkcolor
16
+Comment[fy]=In module dy in folslein kleurgebiet ymplementearret dat brûkt wurde kin mei libchalkcolor
17
+Comment[gl]=Un módulo que implemente un espazo de cor completo para usar con libchalkcolor
18
+Comment[hu]=Teljes színteret megvalósító modul a libchalkcolor programkönyvtárhoz
19
+Comment[is]=Eining með fullu litasvæði til notkunar með libchalkcolor
20
+Comment[it]=Un modulo che implementa uno spazio dei colori completo per usarlo con libchalkcolor
21
+Comment[km]=ម៉ូឌុល​ដែល​អនុវត្ត​ប្រភេទ​ពណ៌​ពេញលេញ ដើម្បី​ប្រើ​ជាមួយ libchalkcolor
22
+Comment[nb]=En modul som implementerer et komplett fargerom til bruk med libchalkcolor
23
+Comment[nds]=En Moduul, dat en helen Klörenruum för den Bruuk mit libchalkcolor inbuut
24
+Comment[ne]=लिबक्रितारङसँग प्रयोग गर्नका लागि सम्पूर्ण रङ खालीस्थानलाई मोड्युललाई औजार बनाइदै
25
+Comment[nl]=Een module die een volledig kleurgebied implementeert dat gebruikt kan worden met libchalkcolor
26
+Comment[pl]=Moduł implementujący kompletną przestrzeń barw do użytku z libchalkcolor
27
+Comment[pt]=Um módulo que implementa um espaço de cores completo para usar com a 'libchalkcolor'
28
+Comment[pt_BR]=Um módulo que implementa um espaço de cores completo para usar com a 'libchalkcolor'
29
+Comment[ru]=Полная поддержка цветовых пространств в libchalkcolor
30
+Comment[sk]=Modul ktorý poskytuje úplný farebný priestor pre použitie s libchalkcolor
31
+Comment[sl]=Modul, v katerem je izveden celoten barvni prostor za uporabo z libchalkcolor
32
+Comment[sr]=Модул који имплементира потпун простор боја за употребу са libchalkcolor
33
+Comment[sr@Latn]=Modul koji implementira potpun prostor boja za upotrebu sa libchalkcolor
34
+Comment[sv]=En modul som implementerar en fullständig färgrymd för användning med libchalkcolor
35
+Comment[uk]=Модуль впровадження повного простору кольорів для вжитку з libchalkcolor
36
+Comment[zh_TW]=實作完整色彩空間以使用 libchalkcolor 的模組
37
+[PropertyDef::X-Chalk-Version]
38
+Type=int

+ 20
- 0
chalk/chalkcolor/colorspaces/Makefile.am View File

@@ -0,0 +1,20 @@
1
+INCLUDES  = -I$(srcdir)/.. \
2
+	-I$(srcdir)/../../sdk \
3
+	$(KOFFICE_INCLUDES) \
4
+	 $(all_includes)
5
+
6
+noinst_LTLIBRARIES = libchalkcolorspaces.la
7
+
8
+libchalkcolorspaces_la_SOURCES = \
9
+	kis_alpha_colorspace.cc \
10
+	kis_lab_colorspace.cc 
11
+
12
+noinst_HEADERS = \
13
+    kis_alpha_colorspace.h  \
14
+    kis_lab_colorspace.h
15
+
16
+libchalkcolorspaces_la_LIBADD = $(OPENEXR_LIBS)
17
+
18
+libchalkcolorspaces_la_METASOURCES = AUTO
19
+
20
+

+ 296
- 0
chalk/chalkcolor/colorspaces/kis_alpha_colorspace.cc View File

@@ -0,0 +1,296 @@
1
+/*
2
+ *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License as published by
6
+ *  the Free Software Foundation; either version 2 of the License, or
7
+ *  (at your option) any later version.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+ */
18
+
19
+#include <limits.h>
20
+#include <stdlib.h>
21
+
22
+#include <tqimage.h>
23
+
24
+#include <kdebug.h>
25
+#include <klocale.h>
26
+
27
+#include <config.h>
28
+
29
+#include LCMS_HEADER
30
+
31
+#include "kis_alpha_colorspace.h"
32
+#include "kis_u8_base_colorspace.h"
33
+#include "kis_channelinfo.h"
34
+#include "kis_id.h"
35
+#include "kis_integer_maths.h"
36
+
37
+namespace {
38
+    const TQ_UINT8 PIXEL_MASK = 0;
39
+}
40
+
41
+KisAlphaColorSpace::KisAlphaColorSpace(KisColorSpaceFactoryRegistry * tqparent,
42
+                                       KisProfile *p) :
43
+    KisU8BaseColorSpace(KisID("ALPHA", i18n("Alpha tqmask")),  TYPE_GRAY_8, icSigGrayData, tqparent, p)
44
+{
45
+    m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), 0, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
46
+    m_alphaPos = 0;
47
+}
48
+
49
+KisAlphaColorSpace::~KisAlphaColorSpace()
50
+{
51
+}
52
+
53
+void KisAlphaColorSpace::fromTQColor(const TQColor& /*c*/, TQ_UINT8 *dst, KisProfile * /*profile*/)
54
+{
55
+    dst[PIXEL_MASK] = OPACITY_OPAQUE;
56
+}
57
+
58
+void KisAlphaColorSpace::fromTQColor(const TQColor& /*c*/, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * /*profile*/)
59
+{
60
+    dst[PIXEL_MASK] = opacity;
61
+}
62
+
63
+void KisAlphaColorSpace::getAlpha(const TQ_UINT8 *pixel, TQ_UINT8 *alpha) const
64
+{
65
+    *alpha = *pixel;
66
+}
67
+
68
+void KisAlphaColorSpace::toTQColor(const TQ_UINT8 */*src*/, TQColor *c, KisProfile * /*profile*/)
69
+{
70
+    c->setRgb(255, 255, 255);
71
+}
72
+
73
+void KisAlphaColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * /*profile*/)
74
+{
75
+    c->setRgb(255, 255, 255);
76
+    *opacity = src[PIXEL_MASK];
77
+}
78
+
79
+TQ_UINT8 KisAlphaColorSpace::difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2)
80
+{
81
+    // Arithmetic operands smaller than int are converted to int automatically
82
+    return TQABS(src2[PIXEL_MASK] - src1[PIXEL_MASK]);
83
+}
84
+
85
+void KisAlphaColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
86
+{
87
+    if (nColors > 0) {
88
+        TQ_UINT32 total = 0;
89
+
90
+        while(nColors)
91
+        {
92
+            nColors--;
93
+            total += *colors[nColors] * weights[nColors];
94
+        }
95
+        *dst = total / 255;
96
+    }
97
+}
98
+
99
+TQValueVector<KisChannelInfo *> KisAlphaColorSpace::channels() const
100
+{
101
+    return m_channels;
102
+}
103
+
104
+bool KisAlphaColorSpace::convertPixelsTo(const TQ_UINT8 *src,
105
+                     TQ_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
106
+                     TQ_UINT32 numPixels,
107
+                     TQ_INT32 /*renderingIntent*/)
108
+{
109
+    // No lcms trickery here, we are only a opacity channel
110
+    TQ_INT32 size = dstColorSpace->pixelSize();
111
+
112
+    TQ_UINT32 j = 0;
113
+    TQ_UINT32 i = 0;
114
+
115
+    while ( i < numPixels ) {
116
+
117
+        dstColorSpace->fromTQColor(TQt::red, OPACITY_OPAQUE - *(src + i), (dst + j));
118
+
119
+        i += 1;
120
+        j += size;
121
+
122
+    }
123
+    return true;
124
+
125
+}
126
+
127
+
128
+//XXX bitblt of ColorSpaceAlpha does not take tqmask into consideration as this is probably not
129
+// used ever
130
+void KisAlphaColorSpace::bitBlt(TQ_UINT8 *dst,
131
+                TQ_INT32 dststride,
132
+                const TQ_UINT8 *src,
133
+                TQ_INT32 srcRowStride,
134
+                const TQ_UINT8 *srcAlphaMask,
135
+                TQ_INT32 tqmaskRowStride,
136
+                TQ_UINT8 opacity,
137
+                TQ_INT32 rows,
138
+                TQ_INT32 cols,
139
+                const KisCompositeOp& op)
140
+{
141
+
142
+    TQ_UINT8 *d;
143
+    const TQ_UINT8 *s;
144
+     TQ_INT32 i;
145
+    TQ_INT32 linesize;
146
+
147
+    if (rows <= 0 || cols <= 0)
148
+        return;
149
+    switch (op.op()) {
150
+    case COMPOSITE_COPY:
151
+        compositeCopy(dst, dststride, src, srcRowStride, srcAlphaMask, tqmaskRowStride, rows, cols, opacity);
152
+        return;
153
+    case COMPOSITE_CLEAR:
154
+        linesize = sizeof(TQ_UINT8) * cols;
155
+        d = dst;
156
+        while (rows-- > 0) {
157
+            memset(d, OPACITY_TRANSPARENT, linesize);
158
+            d += dststride;
159
+        }
160
+        return;
161
+    case COMPOSITE_ERASE:
162
+        while (rows-- > 0) {
163
+            d = dst;
164
+            s = src;
165
+
166
+            for (i = cols; i > 0; i--, d ++, s ++) {
167
+                if (d[PIXEL_MASK] < s[PIXEL_MASK]) {
168
+                    continue;
169
+                }
170
+                else {
171
+                    d[PIXEL_MASK] = s[PIXEL_MASK];
172
+                }
173
+
174
+            }
175
+
176
+            dst += dststride;
177
+            src += srcRowStride;
178
+        }
179
+        return;
180
+    case COMPOSITE_SUBTRACT:
181
+        while (rows-- > 0) {
182
+            d = dst;
183
+            s = src;
184
+
185
+            for (i = cols; i > 0; i--, d++, s++) {
186
+                if (d[PIXEL_MASK] <= s[PIXEL_MASK]) {
187
+                    d[PIXEL_MASK] = MIN_SELECTED;
188
+                } else {
189
+                    d[PIXEL_MASK] -= s[PIXEL_MASK];
190
+                }
191
+            }
192
+
193
+            dst += dststride;
194
+            src += srcRowStride;
195
+        }
196
+        return;
197
+    case COMPOSITE_ALPHA_DARKEN: 
198
+        while (rows-- > 0) {
199
+            d = dst;
200
+            s = src;
201
+            for (i = cols; i > 0; i--, d++, s++) {
202
+                if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
203
+                    continue;
204
+                int srcAlpha = (s[PIXEL_MASK] * opacity + UINT8_MAX / 2) / UINT8_MAX;
205
+                if (srcAlpha > d[PIXEL_MASK])
206
+                    d[PIXEL_MASK] = srcAlpha;
207
+            }
208
+            dst += dststride;
209
+            src += srcRowStride;
210
+        }
211
+        return;
212
+    case COMPOSITE_OVER:
213
+    default:
214
+        if (opacity == OPACITY_TRANSPARENT)
215
+            return;
216
+        if (opacity != OPACITY_OPAQUE) {
217
+            while (rows-- > 0) {
218
+                d = dst;
219
+                s = src;
220
+                for (i = cols; i > 0; i--, d++, s++) {
221
+                    if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
222
+                        continue;
223
+                    int srcAlpha = (s[PIXEL_MASK] * opacity + UINT8_MAX / 2) / UINT8_MAX;
224
+                    d[PIXEL_MASK] = (d[PIXEL_MASK] * (UINT8_MAX - srcAlpha) + srcAlpha * UINT8_MAX + UINT8_MAX / 2) / UINT8_MAX;
225
+                }
226
+                dst += dststride;
227
+                src += srcRowStride;
228
+            }
229
+        }
230
+        else {
231
+            while (rows-- > 0) {
232
+                d = dst;
233
+                s = src;
234
+                for (i = cols; i > 0; i--, d++, s++) {
235
+                    if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
236
+                        continue;
237
+                    if (d[PIXEL_MASK] == OPACITY_TRANSPARENT || s[PIXEL_MASK] == OPACITY_OPAQUE) {
238
+                        memcpy(d, s, 1);
239
+                        continue;
240
+                    }
241
+                    int srcAlpha = s[PIXEL_MASK];
242
+                    d[PIXEL_MASK] = (d[PIXEL_MASK] * (UINT8_MAX - srcAlpha) + srcAlpha * UINT8_MAX + UINT8_MAX / 2) / UINT8_MAX;
243
+                }
244
+                dst += dststride;
245
+                src += srcRowStride;
246
+            }
247
+        }
248
+
249
+    }
250
+}
251
+
252
+KisCompositeOpList KisAlphaColorSpace::userVisiblecompositeOps() const
253
+{
254
+    KisCompositeOpList list;
255
+
256
+    list.append(KisCompositeOp(COMPOSITE_OVER));
257
+
258
+    return list;
259
+}
260
+
261
+TQString KisAlphaColorSpace::channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
262
+{
263
+    Q_ASSERT(channelIndex < nChannels());
264
+    TQ_UINT32 channelPosition = m_channels[channelIndex]->pos();
265
+
266
+    return TQString().setNum(pixel[channelPosition]);
267
+}
268
+
269
+TQString KisAlphaColorSpace::normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
270
+{
271
+    Q_ASSERT(channelIndex < nChannels());
272
+    TQ_UINT32 channelPosition = m_channels[channelIndex]->pos();
273
+
274
+    return TQString().setNum(static_cast<float>(pixel[channelPosition]) / UINT8_MAX);
275
+}
276
+
277
+
278
+void KisAlphaColorSpace::convolveColors(TQ_UINT8** colors, TQ_INT32 * kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const
279
+{
280
+    TQ_INT32 totalAlpha = 0;
281
+
282
+    while (nColors--)
283
+    {
284
+        TQ_INT32 weight = *kernelValues;
285
+
286
+        if (weight != 0) {
287
+            totalAlpha += (*colors)[PIXEL_MASK] * weight;
288
+        }
289
+        colors++;
290
+        kernelValues++;
291
+    }
292
+
293
+    if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
294
+        dst[PIXEL_MASK] = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT8_MAX);
295
+    }
296
+}

+ 93
- 0
chalk/chalkcolor/colorspaces/kis_alpha_colorspace.h View File

@@ -0,0 +1,93 @@
1
+/*
2
+ *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License as published by
6
+ *  the Free Software Foundation; either version 2 of the License, or
7
+ *  (at your option) any later version.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+ */
18
+#ifndef KIS_COLORSPACE_ALPHA_H_
19
+#define KIS_COLORSPACE_ALPHA_H_
20
+
21
+#include <tqcolor.h>
22
+
23
+#include "kis_global.h"
24
+#include "kis_u8_base_colorspace.h"
25
+
26
+/**
27
+ * The alpha tqmask is a special color strategy that treats all pixels as
28
+ * alpha value with a colour common to the tqmask. The default color is white.
29
+ */
30
+class KisAlphaColorSpace : public KisU8BaseColorSpace {
31
+public:
32
+    KisAlphaColorSpace(KisColorSpaceFactoryRegistry * tqparent,
33
+                       KisProfile *p);
34
+    virtual ~KisAlphaColorSpace();
35
+
36
+public:
37
+    virtual bool willDegrade(ColorSpaceIndependence)
38
+        {
39
+            return false;
40
+        };
41
+
42
+    virtual void fromTQColor(const TQColor& c, TQ_UINT8 *dst, KisProfile * profile = 0);
43
+    virtual void fromTQColor(const TQColor& c, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * profile = 0);
44
+
45
+    virtual void getAlpha(const TQ_UINT8 *pixel, TQ_UINT8 *alpha) const;
46
+
47
+    virtual void toTQColor(const TQ_UINT8 *src, TQColor *c, KisProfile * profile = 0);
48
+    virtual void toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * profile = 0);
49
+
50
+    virtual TQ_UINT8 difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2);
51
+    virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const;
52
+
53
+    virtual TQValueVector<KisChannelInfo *> channels() const;
54
+    virtual TQ_UINT32 nChannels() const { return 1; };
55
+    virtual TQ_UINT32 nColorChannels() const { return 0; };
56
+    virtual TQ_UINT32 pixelSize() const { return 1; };
57
+
58
+    virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
59
+    virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
60
+
61
+    virtual void convolveColors(TQ_UINT8** colors, TQ_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const;
62
+
63
+protected:
64
+
65
+    /**
66
+     * Convert a byte array of srcLen pixels *src to the specified color space
67
+     * and put the converted bytes into the prepared byte array *dst.
68
+     *
69
+     * Returns false if the conversion failed, true if it succeeded
70
+     */
71
+    virtual bool convertPixelsTo(const TQ_UINT8 *src,
72
+                     TQ_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
73
+                     TQ_UINT32 numPixels,
74
+                     TQ_INT32 renderingIntent = INTENT_PERCEPTUAL);
75
+
76
+
77
+
78
+    virtual void bitBlt(TQ_UINT8 *dst,
79
+                TQ_INT32 dststride,
80
+                const TQ_UINT8 *src,
81
+                TQ_INT32 srcRowStride,
82
+                const TQ_UINT8 *srcAlphaMask,
83
+                TQ_INT32 tqmaskRowStride,
84
+                TQ_UINT8 opacity,
85
+                TQ_INT32 rows,
86
+                TQ_INT32 cols,
87
+                const KisCompositeOp& op);
88
+
89
+    KisCompositeOpList userVisiblecompositeOps() const;
90
+
91
+};
92
+
93
+#endif // KIS_COLORSPACE_ALPHA_H_

+ 571
- 0
chalk/chalkcolor/colorspaces/kis_lab_colorspace.cc View File

@@ -0,0 +1,571 @@
1
+ /*
2
+ *  Copyright (c) 2002 Patrick Julien  <freak@codepimps.org>
3
+ *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
4
+ *  Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
5
+ *  Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
6
+ *
7
+ *  This program is free software; you can redistribute it and/or modify
8
+ *  it under the terms of the GNU General Public License as published by
9
+ *  the Free Software Foundation; either version 2 of the License, or
10
+ *  (at your option) any later version.
11
+ *
12
+ *  This program is distributed in the hope that it will be useful,
13
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ *  GNU General Public License for more details.
16
+ *
17
+ *  You should have received a copy of the GNU General Public License
18
+ *  along with this program; if not, write to the Free Software
19
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+ */
21
+
22
+#include <config.h>
23
+#include <limits.h>
24
+#include <stdlib.h>
25
+#include LCMS_HEADER
26
+
27
+#include <tqimage.h>
28
+
29
+#include <kdebug.h>
30
+#include <klocale.h>
31
+
32
+#include "kis_lab_colorspace.h"
33
+#include "kis_color_conversions.h"
34
+#include "kis_integer_maths.h"
35
+
36
+KisLabColorSpace::KisLabColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p)
37
+    : KisU16BaseColorSpace(KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")),
38
+        COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1),
39
+         icSigLabData, tqparent, p)
40
+
41
+{
42
+    m_channels.push_back(new KisChannelInfo(i18n("Lightness"), i18n("L"), CHANNEL_L * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(100,100,100)));
43
+    m_channels.push_back(new KisChannelInfo(i18n("a*"), i18n("a"), CHANNEL_A * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(150,150,150)));
44
+    m_channels.push_back(new KisChannelInfo(i18n("b*"), i18n("b"), CHANNEL_B * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16), TQColor(200,200,200)));
45
+    m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), CHANNEL_ALPHA * sizeof(TQ_UINT16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(TQ_UINT16)));
46
+
47
+    m_alphaPos = CHANNEL_ALPHA * sizeof(TQ_UINT16);
48
+
49
+    init();
50
+}
51
+
52
+KisLabColorSpace::~KisLabColorSpace()
53
+{
54
+}
55
+
56
+TQ_UINT8 * KisLabColorSpace::toLabA16(const TQ_UINT8 * data, const TQ_UINT32 nPixels) const
57
+{
58
+    TQ_UINT8 * pixels = new TQ_UINT8[nPixels * pixelSize()];
59
+    memcpy( pixels,  data,  nPixels * pixelSize() );
60
+    return pixels;
61
+}
62
+
63
+TQ_UINT8 * KisLabColorSpace::fromLabA16(const TQ_UINT8 * labData, const TQ_UINT32 nPixels) const
64
+{
65
+    TQ_UINT8 * pixels = new TQ_UINT8[nPixels * pixelSize()];
66
+    memcpy( pixels, labData,  nPixels * pixelSize() );
67
+    return pixels;
68
+}
69
+
70
+TQ_UINT8 KisLabColorSpace::difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2)
71
+{
72
+    cmsCIELab labF1, labF2;
73
+
74
+    if (getAlpha(src1) == OPACITY_TRANSPARENT || getAlpha(src2) == OPACITY_TRANSPARENT)
75
+        return (getAlpha(src1) == getAlpha(src2) ? 0 : 255);
76
+
77
+    cmsLabEncoded2Float(&labF1, (WORD *)src1);
78
+    cmsLabEncoded2Float(&labF2, (WORD *)src2);
79
+    double diff = cmsDeltaE(&labF1, &labF2);
80
+    if(diff>255)
81
+        return 255;
82
+    else
83
+        return TQ_INT8(diff);
84
+}
85
+
86
+void KisLabColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
87
+{
88
+    TQ_UINT32 totalLightness = 0, totalAlpha = 0;
89
+    TQ_UINT32 totala = 0, totalb = 0;
90
+
91
+    while (nColors--)
92
+    {
93
+        const Pixel *color = reinterpret_cast<const Pixel *>( *colors );
94
+        TQ_UINT32 alphaTimesWeight = UINT8_MULT(color->alpha, *weights);
95
+
96
+        totalLightness += color->lightness * alphaTimesWeight;
97
+        totala += color->a * alphaTimesWeight;
98
+        totalb += color->b * alphaTimesWeight;
99
+        totalAlpha += alphaTimesWeight;
100
+
101
+        weights++;
102
+        colors++;
103
+    }
104
+
105
+    if (totalAlpha > UINT16_MAX) {
106
+        totalAlpha = UINT16_MAX;
107
+    }
108
+
109
+    ((Pixel *)dst)->alpha = totalAlpha;
110
+
111
+    if (totalAlpha > 0) {
112
+        totalLightness /= totalAlpha;
113
+        totala /= totalAlpha;
114
+        totalb /= totalAlpha;
115
+    } // else the values are already 0 too
116
+
117
+    if (totalLightness > MAX_CHANNEL_L) {
118
+        totalLightness = MAX_CHANNEL_L;
119
+    }
120
+
121
+    ((Pixel *)dst)->lightness = totalLightness;
122
+
123
+    if (totala > MAX_CHANNEL_AB) {
124
+        totala = MAX_CHANNEL_AB;
125
+    }
126
+
127
+    ((Pixel *)dst)->a = totala;
128
+
129
+    if (totalb > MAX_CHANNEL_AB) {
130
+        totalb = MAX_CHANNEL_AB;
131
+    }
132
+
133
+    ((Pixel *)dst)->b = totalb;
134
+}
135
+
136
+void KisLabColorSpace::invertColor(TQ_UINT8 * src, TQ_INT32 nPixels)
137
+{
138
+    TQ_UINT32 psize = pixelSize();
139
+
140
+    while (nPixels--)
141
+    {
142
+        Pixel * s = reinterpret_cast<Pixel *>( src );
143
+
144
+        s->lightness = MAX_CHANNEL_L - s->lightness;
145
+        s->a = MAX_CHANNEL_AB - s->a;
146
+        s->b = MAX_CHANNEL_AB - s->b;
147
+
148
+        src += psize;
149
+    }
150
+}
151
+
152
+void KisLabColorSpace::convolveColors(TQ_UINT8** colors, TQ_INT32 * kernelValues, KisChannelInfo::enumChannelFlags channelFlags,
153
+                                      TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const
154
+{
155
+    TQ_INT32 totalL = 0, totalA = 0, totalB = 0, totalAlpha = 0;
156
+
157
+    while ( nColors -- )
158
+    {
159
+        const Pixel * pixel = reinterpret_cast<const Pixel *>( *colors );
160
+        TQ_INT32 weight = *kernelValues;
161
+        if ( weight != 0 ) {
162
+            totalL += pixel->lightness * weight;
163
+            totalA += pixel->a * weight;
164
+            totalB += pixel->b * weight;
165
+            totalAlpha += pixel->alpha * weight;
166
+        }
167
+        colors++;
168
+        kernelValues++;
169
+    }
170
+
171
+
172
+    Pixel * p = reinterpret_cast< Pixel *>( dst );
173
+
174
+    if (channelFlags & KisChannelInfo::FLAG_COLOR) {
175
+        p->lightness = CLAMP( ( totalL / factor) + offset, 0, TQ_UINT16_MAX);
176
+        p->a = CLAMP( ( totalA / factor) + offset, 0, TQ_UINT16_MAX);
177
+        p->b = CLAMP( ( totalB / factor) + offset, 0, TQ_UINT16_MAX);
178
+    }
179
+    if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
180
+        p->alpha = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT16_MAX);
181
+    }
182
+
183
+}
184
+
185
+void KisLabColorSpace::darken(const TQ_UINT8 * src, TQ_UINT8 * dst, TQ_INT32 shade, bool compensate, double compensation, TQ_INT32 nPixels) const
186
+{
187
+    // XXX: Is the 255 right for u16 colorspaces?
188
+    TQ_UINT32 pSize = pixelSize();
189
+    while ( nPixels-- ) {
190
+        const Pixel * s = reinterpret_cast<const Pixel*>( src );
191
+        Pixel * d = reinterpret_cast<Pixel*>( dst );
192
+
193
+        if ( compensate ) {
194
+            d->lightness = static_cast<TQ_UINT16>( ( s->lightness * shade ) / ( compensation * 255 ) );
195
+        }
196
+        else {
197
+            d->lightness = static_cast<TQ_UINT16>( s->lightness * shade / 255 );
198
+        }
199
+        d->a = s->a;
200
+        d->b = s->b;
201
+        d->alpha = s->alpha;
202
+
203
+        src += pSize;
204
+        dst += pSize;
205
+    }
206
+}
207
+
208
+
209
+TQValueVector<KisChannelInfo *> KisLabColorSpace::channels() const
210
+{
211
+    return m_channels;
212
+}
213
+
214
+TQ_UINT32 KisLabColorSpace::nChannels() const
215
+{
216
+    return NUM_CHANNELS;
217
+}
218
+
219
+TQ_UINT32 KisLabColorSpace::nColorChannels() const
220
+{
221
+    return NUM_COLOR_CHANNELS;
222
+}
223
+
224
+TQ_UINT32 KisLabColorSpace::pixelSize() const
225
+{
226
+    return sizeof(Pixel);
227
+}
228
+
229
+void KisLabColorSpace::getSingleChannelPixel(TQ_UINT8 *dst, const TQ_UINT8 *src, TQ_UINT32 channelIndex)
230
+{
231
+    if (channelIndex < NUM_CHANNELS) {
232
+
233
+        const Pixel *srcPixel = reinterpret_cast<const Pixel *>(src);
234
+        Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
235
+
236
+        switch (channelIndex) {
237
+        case CHANNEL_L:
238
+            dstPixel->lightness = srcPixel->lightness;
239
+            dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
240
+            dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
241
+            dstPixel->alpha = U16_OPACITY_TRANSPARENT;
242
+            break;
243
+        case CHANNEL_A:
244
+            dstPixel->lightness = MAX_CHANNEL_L / 2;
245
+            dstPixel->a = srcPixel->a;
246
+            dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
247
+            dstPixel->alpha = U16_OPACITY_TRANSPARENT;
248
+            break;
249
+        case CHANNEL_B:
250
+            dstPixel->lightness = MAX_CHANNEL_L / 2;
251
+            dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
252
+            dstPixel->b = srcPixel->b;
253
+            dstPixel->alpha = U16_OPACITY_TRANSPARENT;
254
+            break;
255
+        case CHANNEL_ALPHA:
256
+            dstPixel->lightness = MAX_CHANNEL_L / 2;
257
+            dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
258
+            dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
259
+            dstPixel->alpha = srcPixel->alpha;
260
+            break;
261
+        }
262
+    }
263
+}
264
+
265
+void KisLabColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmaskRowStart, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
266
+{
267
+    while (rows > 0) {
268
+        const Pixel *src = reinterpret_cast<const Pixel *>(srcRowStart);
269
+        Pixel *dst = reinterpret_cast<Pixel *>(dstRowStart);
270
+        const TQ_UINT8 *tqmask = tqmaskRowStart;
271
+        TQ_INT32 columns = numColumns;
272
+
273
+        while (columns > 0) {
274
+
275
+            TQ_UINT16 srcAlpha = src->alpha;
276
+
277
+            // apply the alphatqmask
278
+            if (tqmask != 0) {
279
+                if (*tqmask != OPACITY_OPAQUE) {
280
+                    srcAlpha = UINT16_MULT(srcAlpha, *tqmask);
281
+                }
282
+                tqmask++;
283
+            }
284
+
285
+            if (srcAlpha != U16_OPACITY_TRANSPARENT) {
286
+
287
+                if (opacity != U16_OPACITY_OPAQUE) {
288
+                    srcAlpha = UINT16_MULT(srcAlpha, opacity);
289
+                }
290
+
291
+                if (srcAlpha == U16_OPACITY_OPAQUE) {
292
+                    memcpy(dst, src, sizeof(Pixel));
293
+                } else {
294
+                    TQ_UINT16 dstAlpha = dst->alpha;
295
+
296
+                    TQ_UINT16 srcBlend;
297
+
298
+                    if (dstAlpha == U16_OPACITY_OPAQUE) {
299
+                        srcBlend = srcAlpha;
300
+                    } else {
301
+                        TQ_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha);
302
+                        dst->alpha = newAlpha;
303
+
304
+                        if (newAlpha != 0) {
305
+                            srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha);
306
+                        } else {
307
+                            srcBlend = srcAlpha;
308
+                        }
309
+                    }
310
+
311
+                    if (srcBlend == U16_OPACITY_OPAQUE) {
312
+                        memcpy(dst, src, sizeof(Pixel));
313
+                    } else {
314
+/*printf("blend is %d\n", srcBlend);
315
+printf("%d %d %d\n", src->lightness, src->a, src->b);
316
+printf("%d %d %d\n", dst->lightness, dst->a, dst->b);
317
+*/
318
+                        dst->lightness = UINT16_BLEND(src->lightness, dst->lightness, srcBlend);
319
+                        dst->a = UINT16_BLEND(src->a, dst->a, srcBlend);
320
+                        dst->b = UINT16_BLEND(src->b, dst->b, srcBlend);
321
+//printf("%d %d %d\n", dst->lightness, dst->a, dst->b);
322
+                    }
323
+                }
324
+            }
325
+
326
+            columns--;
327
+            src++;
328
+            dst++;
329
+        }
330
+
331
+        rows--;
332
+        srcRowStart += srcRowStride;
333
+        dstRowStart += dstRowStride;
334
+        if(tqmaskRowStart) {
335
+            tqmaskRowStart += tqmaskRowStride;
336
+        }
337
+    }
338
+}
339
+
340
+void KisLabColorSpace::compositeErase(TQ_UINT8 *dst,
341
+            TQ_INT32 dstRowSize,
342
+            const TQ_UINT8 *src,
343
+            TQ_INT32 srcRowSize,
344
+            const TQ_UINT8 *srcAlphaMask,
345
+            TQ_INT32 tqmaskRowStride,
346
+            TQ_INT32 rows,
347
+            TQ_INT32 cols,
348
+            TQ_UINT16 /*opacity*/)
349
+{
350
+    while (rows-- > 0)
351
+    {
352
+        const Pixel *s = reinterpret_cast<const Pixel *>(src);
353
+        Pixel *d = reinterpret_cast<Pixel *>(dst);
354
+        const TQ_UINT8 *tqmask = srcAlphaMask;
355
+
356
+        for (TQ_INT32 i = cols; i > 0; i--, s++, d++)
357
+        {
358
+            TQ_UINT16 srcAlpha = s->alpha;
359
+
360
+            // apply the alphatqmask
361
+            if (tqmask != 0) {
362
+                TQ_UINT8 U8_tqmask = *tqmask;
363
+
364
+                if (U8_tqmask != OPACITY_OPAQUE) {
365
+                    srcAlpha = UINT16_BLEND(srcAlpha, U16_OPACITY_OPAQUE, UINT8_TO_UINT16(U8_tqmask));
366
+                }
367
+                tqmask++;
368
+            }
369
+            d->alpha = UINT16_MULT(srcAlpha, d->alpha);
370
+        }
371
+
372
+        dst += dstRowSize;
373
+        src += srcRowSize;
374
+        if(srcAlphaMask) {
375
+            srcAlphaMask += tqmaskRowStride;
376
+        }
377
+    }
378
+}
379
+
380
+void KisLabColorSpace::bitBlt(TQ_UINT8 *dst,
381
+                      TQ_INT32 dstRowStride,
382
+                      const TQ_UINT8 *src,
383
+                      TQ_INT32 srcRowStride,
384
+                      const TQ_UINT8 *tqmask,
385
+                      TQ_INT32 tqmaskRowStride,
386
+                      TQ_UINT8 U8_opacity,
387
+                      TQ_INT32 rows,
388
+                      TQ_INT32 cols,
389
+                      const KisCompositeOp& op)
390
+{
391
+    TQ_UINT16 opacity = UINT8_TO_UINT16(U8_opacity);
392
+
393
+    switch (op.op()) {
394
+    case COMPOSITE_UNDEF:
395
+        // Undefined == no composition
396
+        break;
397
+    case COMPOSITE_OVER:
398
+        compositeOver(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
399
+        break;
400
+    case COMPOSITE_IN:
401
+        //compositeIn(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
402
+        break;
403
+    case COMPOSITE_OUT:
404
+        //compositeOut(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
405
+        break;
406
+    case COMPOSITE_ATOP:
407
+        //compositeAtop(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
408
+        break;
409
+    case COMPOSITE_XOR:
410
+        //compositeXor(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
411
+        break;
412
+    case COMPOSITE_PLUS:
413
+        //compositePlus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
414
+        break;
415
+    case COMPOSITE_MINUS:
416
+        //compositeMinus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
417
+        break;
418
+    case COMPOSITE_ADD:
419
+        //compositeAdd(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
420
+        break;
421
+    case COMPOSITE_SUBTRACT:
422
+        //compositeSubtract(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
423
+        break;
424
+    case COMPOSITE_DIFF:
425
+        //compositeDiff(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
426
+        break;
427
+    case COMPOSITE_MULT:
428
+        //compositeMultiply(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
429
+        break;
430
+    case COMPOSITE_DIVIDE:
431
+        //compositeDivide(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
432
+        break;
433
+    case COMPOSITE_BUMPMAP:
434
+        //compositeBumpmap(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
435
+        break;
436
+    case COMPOSITE_COPY:
437
+        compositeCopy(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, U8_opacity);
438
+        break;
439
+    case COMPOSITE_COPY_RED:
440
+        //compositeCopyRed(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
441
+        break;
442
+    case COMPOSITE_COPY_GREEN:
443
+        //compositeCopyGreen(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
444
+        break;
445
+    case COMPOSITE_COPY_BLUE:
446
+        //compositeCopyBlue(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
447
+        break;
448
+    case COMPOSITE_COPY_OPACITY:
449
+        //compositeCopyOpacity(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
450
+        break;
451
+    case COMPOSITE_CLEAR:
452
+        //compositeClear(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
453
+        break;
454
+    case COMPOSITE_DISSOLVE:
455
+        //compositeDissolve(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
456
+        break;
457
+    case COMPOSITE_DISPLACE:
458
+        //compositeDisplace(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
459
+        break;
460
+#if 0
461
+    case COMPOSITE_MODULATE:
462
+        compositeModulate(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
463
+        break;
464
+    case COMPOSITE_THRESHOLD:
465
+        compositeThreshold(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
466
+        break;
467
+#endif
468
+    case COMPOSITE_NO:
469
+        // No composition.
470
+        break;
471
+    case COMPOSITE_DARKEN:
472
+        //compositeDarken(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
473
+        break;
474
+    case COMPOSITE_LIGHTEN:
475
+        //compositeLighten(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
476
+        break;
477
+    case COMPOSITE_HUE:
478
+        //compositeHue(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
479
+        break;
480
+    case COMPOSITE_SATURATION:
481
+        //compositeSaturation(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
482
+        break;
483
+    case COMPOSITE_VALUE:
484
+        //compositeValue(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
485
+        break;
486
+    case COMPOSITE_COLOR:
487
+        //compositeColor(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
488
+        break;
489
+    case COMPOSITE_COLORIZE:
490
+        //compositeColorize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
491
+        break;
492
+    case COMPOSITE_LUMINIZE:
493
+        //compositeLuminize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
494
+        break;
495
+    case COMPOSITE_SCREEN:
496
+        //compositeScreen(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
497
+        break;
498
+    case COMPOSITE_OVERLAY:
499
+        //compositeOverlay(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
500
+        break;
501
+    case COMPOSITE_ERASE:
502
+        compositeErase(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
503
+        break;
504
+    case COMPOSITE_DODGE:
505
+        //compositeDodge(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
506
+        break;
507
+    case COMPOSITE_BURN:
508
+        //compositeBurn(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
509
+        break;
510
+    case COMPOSITE_ALPHA_DARKEN:
511
+        abstractCompositeAlphaDarken<TQ_UINT16, U16Mult, Uint8ToU16, U16OpacityTest,
512
+                    CHANNEL_ALPHA, NUM_COLOR_CHANNELS, NUM_CHANNELS>(
513
+                    dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride,
514
+                    rows, cols, opacity, U16Mult(), Uint8ToU16(), U16OpacityTest());
515
+        break;
516
+    default:
517
+        break;
518
+    }
519
+}
520
+
521
+KisCompositeOpList KisLabColorSpace::userVisiblecompositeOps() const
522
+{
523
+    KisCompositeOpList list;
524
+
525
+    list.append(KisCompositeOp(COMPOSITE_OVER));
526
+    list.append(KisCompositeOp(COMPOSITE_ALPHA_DARKEN));
527
+
528
+    return list;
529
+}
530
+
531
+TQString KisLabColorSpace::channelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const
532
+{
533
+    const Pixel *pix = reinterpret_cast<const Pixel *>(U8_pixel);
534
+    Q_ASSERT(channelIndex < nChannels());
535
+    switch(channelIndex)
536
+    {
537
+        case CHANNEL_L:
538
+            return TQString().setNum(pix->lightness);
539
+        case CHANNEL_A:
540
+            return TQString().setNum(pix->a);
541
+        case CHANNEL_B:
542
+            return TQString().setNum(pix->b);
543
+        case CHANNEL_ALPHA:
544
+            return TQString().setNum(pix->alpha);
545
+        default:
546
+            return TQString("Error");
547
+    }
548
+}
549
+
550
+TQString KisLabColorSpace::normalisedChannelValueText(const TQ_UINT8 *U8_pixel, TQ_UINT32 channelIndex) const
551
+{
552
+    const Pixel *pix = reinterpret_cast<const Pixel *>(U8_pixel);
553
+    Q_ASSERT(channelIndex < nChannels());
554
+
555
+    // These convert from lcms encoded format to standard ranges.
556
+
557
+    switch(channelIndex)
558
+    {
559
+        case CHANNEL_L:
560
+            return TQString().setNum(100.0 * static_cast<float>(pix->lightness) / MAX_CHANNEL_L);
561
+        case CHANNEL_A:
562
+            return TQString().setNum(100.0 * ((static_cast<float>(pix->a) - CHANNEL_AB_ZERO_OFFSET) / MAX_CHANNEL_AB));
563
+        case CHANNEL_B:
564
+            return TQString().setNum(100.0 * ((static_cast<float>(pix->b) - CHANNEL_AB_ZERO_OFFSET) / MAX_CHANNEL_AB));
565
+        case CHANNEL_ALPHA:
566
+            return TQString().setNum(100.0 * static_cast<float>(pix->alpha) / UINT16_MAX);
567
+        default:
568
+            return TQString("Error");
569
+    }
570
+}
571
+

+ 153
- 0
chalk/chalkcolor/colorspaces/kis_lab_colorspace.h View File

@@ -0,0 +1,153 @@
1
+/*
2
+ *  Copyright (c) 2002 Patrick Julien  <freak@codepimps.org>
3
+ *  Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
4
+ *
5
+ *  This program is free software; you can redistribute it and/or modify
6
+ *  it under the terms of the GNU General Public License as published by
7
+ *  the Free Software Foundation; either version 2 of the License, or
8
+ *  (at your option) any later version.
9
+ *
10
+ *  This program is distributed in the hope that it will be useful,
11
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ *  GNU General Public License for more details.
14
+ *
15
+ *  You should have received a copy of the GNU General Public License
16
+ *  along with this program; if not, write to the Free Software
17
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+ */
19
+#ifndef KIS_STRATEGY_COLORSPACE_LAB_H_
20
+#define KIS_STRATEGY_COLORSPACE_LAB_H_
21
+
22
+#include <tqcolor.h>
23
+
24
+#include <klocale.h>
25
+
26
+#include "kis_global.h"
27
+#include "kis_integer_maths.h"
28
+#include "kis_u16_base_colorspace.h"
29
+
30
+class KisLabColorSpace : public KisU16BaseColorSpace {
31
+public:
32
+    KisLabColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p);
33
+    virtual ~KisLabColorSpace();
34
+
35
+public:
36
+
37
+    /**
38
+     * Return a COPY of the provided data. This method is provided to provide consistency,
39
+     * but you really don't want to be calling it.
40
+     */
41
+    virtual TQ_UINT8 * toLabA16(const TQ_UINT8 * data, const TQ_UINT32 nPixels) const;
42
+
43
+    /**
44
+     * Return a COPY of the provided data. This method is provided for consistency,
45
+     * but you really don't want to call it.
46
+     */
47
+    virtual TQ_UINT8 * fromLabA16(const TQ_UINT8 * labData, const TQ_UINT32 nPixels) const;
48
+
49
+
50
+
51
+    virtual bool willDegrade(ColorSpaceIndependence independence)
52
+        {
53
+            if (independence == TO_RGBA8) 
54
+                return true;
55
+            else
56
+                return false;
57
+        };
58
+
59
+    virtual TQValueVector<KisChannelInfo *> channels() const;
60
+    virtual TQ_UINT32 nChannels() const;
61
+    virtual TQ_UINT32 nColorChannels() const;
62
+    virtual TQ_UINT32 pixelSize() const;
63
+
64
+    virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
65
+    virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
66
+    virtual void getSingleChannelPixel(TQ_UINT8 *dstPixel, const TQ_UINT8 *srcPixel, TQ_UINT32 channelIndex);
67
+
68
+    virtual TQ_UINT8 difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2);
69
+    virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const;
70
+    virtual void invertColor(TQ_UINT8 * src, TQ_INT32 nPixels);
71
+    virtual void convolveColors(TQ_UINT8** colors, TQ_INT32 * kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const;
72
+    
73
+    virtual void darken(const TQ_UINT8 * src, TQ_UINT8 * dst, TQ_INT32 shade, bool compensate, double compensation, TQ_INT32 nPixels) const;
74
+
75
+    virtual KisCompositeOpList userVisiblecompositeOps() const;
76
+
77
+protected:
78
+
79
+    virtual void bitBlt(TQ_UINT8 *dst,
80
+                TQ_INT32 dstRowStride,
81
+                const TQ_UINT8 *src,
82
+                TQ_INT32 srcRowStride,
83
+                const TQ_UINT8 *srcAlphaMask,
84
+                TQ_INT32 tqmaskRowStride,
85
+                TQ_UINT8 opacity,
86
+                TQ_INT32 rows,
87
+                TQ_INT32 cols,
88
+                const KisCompositeOp& op);
89
+
90
+    void compositeOver(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
91
+/*
92
+    void compositeMultiply(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
93
+    void compositeDivide(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
94
+    void compositeScreen(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
95
+    void compositeOverlay(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
96
+    void compositeDodge(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
97
+    void compositeBurn(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
98
+    void compositeDarken(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
99
+    void compositeLighten(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
100
+    void compositeHue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
101
+    void compositeSaturation(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
102
+    void compositeValue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
103
+    void compositeColor(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
104
+*/
105
+    void compositeErase(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *tqmask, TQ_INT32 tqmaskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
106
+
107
+private:
108
+    struct Pixel {
109
+        TQ_UINT16 lightness;
110
+        TQ_UINT16 a;
111
+        TQ_UINT16 b;
112
+        TQ_UINT16 alpha;
113
+    };
114
+    static const TQ_UINT16 U16_OPACITY_OPAQUE = UINT16_MAX;
115
+    static const TQ_UINT16 U16_OPACITY_TRANSPARENT = UINT16_MIN;
116
+
117
+    static const TQ_UINT32 NUM_CHANNELS = 4;
118
+    static const TQ_UINT32 NUM_COLOR_CHANNELS = 3;
119
+
120
+    static const TQ_UINT32 CHANNEL_L = 0;
121
+    static const TQ_UINT32 CHANNEL_A = 1;
122
+    static const TQ_UINT32 CHANNEL_B = 2;
123
+    static const TQ_UINT32 CHANNEL_ALPHA = 3;
124
+
125
+    static const TQ_UINT32 MAX_CHANNEL_L = 0xff00;
126
+    static const TQ_UINT32 MAX_CHANNEL_AB = 0xffff;
127
+    static const TQ_UINT32 CHANNEL_AB_ZERO_OFFSET = 0x8000;
128
+
129
+    friend class KisLabColorSpaceTester;
130
+};
131
+
132
+class KisLabColorSpaceFactory : public KisColorSpaceFactory
133
+{
134
+public:
135
+    /**
136
+     * Chalk definition for use in .kra files and internally: unchanging name +
137
+     * i18n'able description.
138
+     */
139
+    virtual KisID id() const { return KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")); };
140
+
141
+    /**
142
+     * lcms colorspace type definition.
143
+     */
144
+    virtual TQ_UINT32 colorSpaceType() { return (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)); };
145
+
146
+    virtual icColorSpaceSignature colorSpaceSignature() { return icSigLabData; };
147
+    
148
+    virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p) { return new KisLabColorSpace(tqparent, p); };
149
+
150
+    virtual TQString defaultProfile() { return "Lab built-in - (lcms internal)"; };
151
+};
152
+
153
+#endif // KIS_STRATEGY_COLORSPACE_LAB_H_

+ 624
- 0
chalk/chalkcolor/colorspaces/kis_xyz_colorspace.cc View File

<
@@ -0,0 +1,624 @@
1
+/*
2
+ *  Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
3
+ *
4
+ *  This program is free software; you can redistribute it and/or modify
5
+ *  it under the terms of the GNU General Public License as published by
6
+ *  the Free Software Foundation; either version 2 of the License, or
7
+ *  (at your option) any later version.
8
+ *
9
+ *  This program is distributed in the hope that it will be useful,
10
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+ *  GNU General Public License for more details.
13
+ *
14
+ *  You should have received a copy of the GNU General Public License
15
+ *  along with this program; if not, write to the Free Software
16
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+ */
18
+
19
+
20
+#include <limits.h>
21
+#include <stdlib.h>
22
+
23
+#include <config.h>
24
+#include LCMS_HEADER
25
+
26
+#include <tqimage.h>
27
+
28
+#include <klocale.h>
29
+#include <kdebug.h>
30
+
31
+#include "kis_abstract_colorspace.h"
32
+#include "kis_u16_base_colorspace.h"
33
+#include "kis_xyz_colorspace.h"
34
+#include "kis_integer_maths.h"
35
+
36
+#define downscale(quantum)  (quantum) //((unsigned char) ((quantum)/257UL))
37
+#define upscale(value)  (value) // ((TQ_UINT8) (257UL*(value)))
38
+
39
+// XXX: Maybe use TYPE_XYZ_DBL for an extra stimulating performance hit? People shouldn't depend
40
+//      on this fallback...
41
+
42
+KisXyzColorSpace::KisXyzColorSpace(KisColorSpaceFactoryRegistry * tqparent,
43
+                                   KisProfile *p) :
44
+    KisU16BaseColorSpace(KisID("XYZA", i18n("XYZ/Alpha")), (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)), icSigCmykData, tqparent, p)
45
+{
46
+    m_channels.push_back(new KisChannelInfo(i18n("X"), i18n("X"), 0, KisChannelInfo::COLOR, KisChannelInfo::UINT8));
47
+    m_channels.push_back(new KisChannelInfo(i18n("Y"), i18n("Y"), 1, KisChannelInfo::COLOR, KisChannelInfo::UINT8));
48
+    m_channels.push_back(new KisChannelInfo(i18n("Z"), i18n("Z"), 2, KisChannelInfo::COLOR, KisChannelInfo::UINT8));
49
+    m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), 4, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
50
+
51
+    m_alphaPos = PIXEL_ALPHA * sizeof(TQ_UINT16);
52
+
53
+    init();
54
+}
55
+
56
+
57
+KisXyzColorSpace::~KisXyzColorSpace()
58
+{
59
+}
60
+
61
+
62
+TQValueVector<KisChannelInfo *> KisXyzColorSpace::channels() const
63
+{
64
+    return m_channels;
65
+}
66
+
67
+TQ_UINT32 KisXyzColorSpace::nChannels() const
68
+{
69
+    return xyz::MAX_CHANNEL_XYZA;
70
+}
71
+
72
+TQ_UINT32 KisXyzColorSpace::nColorChannels() const
73
+{
74
+    return xyz::MAX_CHANNEL_XYZ;
75
+}
76
+
77
+TQ_UINT32 KisXyzColorSpace::pixelSize() const
78
+{
79
+    return xyz::MAX_CHANNEL_XYZA * sizeof(TQ_UINT16);
80
+}
81
+
82
+KisColorAdjustment * KisXyzColorSpace::createBrightnessContrastAdjustment(TQ_UINT16 *transferValues)
83
+{
84
+    return 0;
85
+}
86
+
87
+void KisXyzColorSpace::applyAdjustment(const TQ_UINT8 *src, TQ_UINT8 *dst, KisColorAdjustment *, TQ_INT32 nPixels)
88
+{
89
+}
90
+
91
+void KisXyzColorSpace::invertColor(TQ_UINT8 * src, TQ_INT32 nPixels)
92
+{
93
+    TQ_INT32 pSize = pixelSize();
94
+    
95
+    while (nPixels--)
96
+    {
97
+        TQ_UINT16 * p = reinterpret_cast<TQ_UINT16 *>(src);
98
+        p[PIXEL_X] = UINT16_MAX - p[PIXEL_X];
99
+        p[PIXEL_Y] = UINT16_MAX - p[PIXEL_Y];
100
+        p[PIXEL_Z] = UINT16_MAX - p[PIXEL_Z];
101
+        src += pSize;