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-ecb5cbfe19da
tags/v3.5.13
tpearson 8 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 \
koshell \
kplato \
kpresenter \
krita \
chalk \
kspread kugar kword lib
FILE_PATTERNS = *.h
RECURSIVE = YES

+ 1
- 1
README View File

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

+ 1
- 1
README.APPS View File

@@ -18,7 +18,7 @@ in the 1.6 cycle:
- lib/kross
- kchart
- kexi
- krita
- chalk
- kdgantt
- kplato
- doc

+ 11
- 11
README.PACKAGERS View File

@@ -18,7 +18,7 @@ Table Of Contents
1. Database drivers (MySQL, PostgreSQL)
2. Development files
2.1. KexiDB development files
2.2. Krita development files
2.2. Chalk development files
3. Scripting support
4. Microsoft Access Import (optional, recommended)
5. Quick command-line tests of Kexi installation
@@ -78,13 +78,13 @@ The files are:
The installation can be tested by building the MS Access import plugin
as described in the Microsoft Access import plugin section below.

2.2. Krita development files
2.2. Chalk development files

Location: koffice/krita/core, koffice/krita/sdk,
koffice/krita/kritacolor, koffice/krita/ui
Location: koffice/chalk/core, koffice/chalk/sdk,
koffice/chalk/chalkcolor, koffice/chalk/ui

These directories contain header files that are installed and can be
used by plugin developers to extend Krita with new tools, colorspaces,
used by plugin developers to extend Chalk with new tools, colorspaces,
paint-ops and more. If your distribution packages development files
separately, it may be a good idea to make a package with these headers.

@@ -93,7 +93,7 @@ separately, it may be a good idea to make a package with these headers.
--------------------

Preliminary support for Ruby and Python scripting is available for
Krita and Kexi.
Chalk and Kexi.
It can be disabled by passing the '--disable-scripting' option to
'configure'.

@@ -131,15 +131,15 @@ For example, the Python scripting package may contain:
share/apps/kexi/scripts/importxhtml/ImportXHTML.rc
share/apps/kexi/scripts/projectdocumentor/ProjectDocumentor.py
share/apps/kexi/scripts/projectdocumentor/ProjectDocumentor.rc
share/apps/krita/scripts/invert.py
share/apps/krita/scripts/reshapehisto.py
share/apps/chalk/scripts/invert.py
share/apps/chalk/scripts/reshapehisto.py

and the Ruby scripting package may contain:
lib/kde3/krossruby.so
lib/kde3/krossruby.la
share/apps/krita/scripts/ruby/invert.rb
share/apps/krita/scripts/ruby/changecs.rb
share/apps/krita/scripts/ruby/randompaint.rb
share/apps/chalk/scripts/ruby/invert.rb
share/apps/chalk/scripts/ruby/changecs.rb
share/apps/chalk/scripts/ruby/randompaint.rb


4. Microsoft Access Import (optional, recommended)

+ 20
- 0
chalk/AUTHORS View File

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

Current maintainer: Boudewijn Rempt <boud@valdyas.org>

+ 1
- 0
chalk/ChangeLog View File

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

+ 93
- 0
chalk/HACKING View File

@@ -0,0 +1,93 @@
Since 1999, people have been hacking on Chalk. Everyone brought their
own coding style, their own code conventions, their own likes and
dislikes. Me, (Boudewijn that is), I like indents of four spaces, and
no scope prefixes for variables. However, in the interests of
consistency, these are the rules new code should adhere to:


Indentation

With four spaces. Use the default Java indentation
style of (X)Emacs or KDevelop -- also for brace placement.

Includes

Avoid as much as possible #includes in header files; use forward declarations
of classes.

Initializers

Avoid as much as possible initializers in the body of the constructor. Use
initializer lists instead.

Scope prefixes

Use only m_ for class-level variables. No other scope prefixes; no g_, l_,
no 'p' for pointer variables.

Shared pointers

Use shared pointers wherever possible.

Getter/setter

Chalk doesn't use Qt's properties -- yet. If you want to introduce use of
properties, convert any and all classes in Chalk before committing.

Getter/setters are named 'x() for getters and setX(int x) for setters. If you
come across violations of this rule, change the code.

Class naming

If you use a well-known design pattern, name the class according to the design
pattern. All files should start with 'kis_', all classes with the 'Kis' prefix.
In filenames, separate words with an underscore; in classnames use capital letters.
Example: kis_new_class.h/KisNewClass.

The only exception to this rule are interfaces.
Example: kis_tool.h/KisToolInterface.

Function naming

Functions should be named in camelBackedFashion, to conform to Qt's standards.
If you encounter functions in c_style_like_this, feel free to rename. Also:
verbNoun -- i.e., rotateLayer, not layer_rotate. The latter is a true c-ism,
introduced by a language that needs to prefix the 'class' name to every function
in order to have something that not quite OO.

Variable/Parameter names

Variable/parameter names start with an undercast letter. A name composed of different
words is done in camelBackedStyle.

Designer

Chalk has started to use designer. All dialogs and all widgets that have a tqlayout
manager must be done in designer. We don't add code nor add signal/slot connections
in designer

Enums

All enums should be prefixed with 'enum'.

Namespaces

Currently, we only use anonymous (right term?) namespaces for things like undo
commands. For the rest, some classes have a 'Kis' prefix, others don't. This should
be made consistent, and we might want to use namespaces to keep all of Chalk
inside.

Files and classes

It's preferred (and strongly preferred) to have only one class per .h/.cpp file.
(Which is logical, because otherwise you won't be able to keep to the naming scheme.)

Spaces

Keep the source airy and open. (However, maybe I was wrong in wanting spaces around ->...)

Slots and Q_SIGNALS

Prefix Q_SLOTS with slot and Q_SIGNALS with sig: slotUpdateSelection, sigSelectionUpdated.

Boudewijn Rempt

+ 259
- 0
chalk/IMAGE_LIBRARIES View File

@@ -0,0 +1,259 @@
WARNING: OBSOLETE (Chalk's internal code has become much better by now)

From time to time, people come up with the suggestion to use an
existing imaging library with Chalk, to replace our own core. This
file contains a list of all libraries known to me, and a short
evaluation.

Perhaps, one day, we will decide to either use an existing library, or
remodel our core after one of those. Of the libraries present, except
for our own Chalk, Vigra look like it's the best bet from a technical
point of view, with Vips a good runner-up.


* Chalk (http://koffice.kde.org/chalk)

Chalk contains its own 2D image library, consisting of the tile
manager, the layer classes and KisPainter. We really should separate
this 2d lib from the interface code, and put it in a real lib with
a well-defined interface.

Advantages:

- Already works
- Optimized for interactive work
- Allows different colour models
- Uses GraphicsMagick or ImageMagick for loading and saving.

Disadvantages:
- Does not work well with different channel depths
- Not integrated with CMS
- TileManager complicated and slow for pixel reading and
writing.
* Gimp (http://www.gimp.org)

The Gimp contains a complex core that allows interactive painting of
images with a channel depth of 8 bits.

Advantages:

- Well tested, very complete
- Optimized for interactive usage

Disadvantages:

- Written in C.
- Not readily available as a library.
- Depends on glib and gtk
- 8-bit only
- No colour models
- Has problems handling really large images

* Vigra (http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/)

Vigra is a C++ imaging library written by Ullrich Koetthe to
demonstrate his Phd thesis on flexible image algorithms.

Advantages:

- Supports very large images
- Supports colour models
- Supports different bit depths through templating
- C++
- Relatively small
- Relatively well-documented

Disadvantages:

- License incompatible with GPL?
- Not optimized for interactive use
- Unsure about future development since this was a research
project.

* Vips (http://www.vips.ecs.soton.ac.uk/)

Vips is a C library with a C++ layer. It has been designed for
handling very large images, mainly in the context of research into
paintings in museums like the National Gallery. It comes with a gtk2
gui.

Advantages:

- Handles very large images
- Handles colour models
- Handles different bit depths
- C++ interface

Disadvantages:

- Not optimized for paintbox type apps (even though it is
possible).
- Very large.

* VXL (http://vxl.sourceforge.net/)

VXL is a collection of small libraries that are used for compution
vision and imaging purposes in an academic setting.

Advantages:

- Handles very large images
- C++

Disadvantages:

- Not recently updated
- Comes with its own core libraries that replace standard C++
- Optimized for simple rgb images.
- No license at all
- Badly documented

* CImg (http://cimg.sourceforge.net/)

CImg is a very cool, very small library that offers some extremely
innovative image effects, like inpainting of damaged or noise images.

Advantages:
- Small
- GPL
- Cool stuff

Disadvantages:

- Everything, including GUI stuff, in one header file.
- badly documented.


* Gegl (http://www.gegl.org/)

Gegl was intended to become the Gimp 2.0 core, but development had
stalled so much that the move to Gegl didn't happen before Gimp 2.0.
However, the Thawte millionaire whose name has escaped me, has
promised to support gegl development financially, freeing the
developer to work full-time on it. It is, more or less, an attempt to
write a templated library in C++ with the help of a custom language to
describe image operations.

Advantages:
- It's got money behind it
- Small
- Optimized for interactive use

Disadvantages:

- Not finished yet
- C
- Complex hack around the fact that C is a low-level language

* libart_lgpl (http://www.levien.com/libart/)

Libart isn't really an image library, but rather a canvas that can be
used to paint images on. It is optimized for vector graphics, and is
used by Karbon to render tqshapes before display.

Advantages:

- Raph Levien is really good at this stuff, so libart is
quality

Disadvantages:

- C
- It isn't an image library, really


* java2D (http://java.sun.com/j2se/1.4.2/docs/guide/2d/index.html)


Java2D is more or less complete library to write a paint app around.
It offers image types, colour spaces, kernel convolutions and text.
It's in Java, of course, and the free re-implementation is not done
yet, and besides, is based around Cairo.

Advantages:
- Neat OO design
- Complete

Disadvantages:

- Java
- Not free
- Has some legacy cruft.

* ImageMagick/GraphicsMagick (http://imagemagick.org/, http://www.graphicsmagick.org/)

GraphicsMagick is ImageMagick with a different license, and a
focus on API stability. GM and IM now also differ slightly in terms of
features offered. Chalk used to be based around IM (which can still be
seen in many places in the code). The IM core was dropped in favour of
the present core because it turned out that IM was not re-entrant,
making it hard to use in an interactive application.

Advantages:

- Mature
- C++ interface
- Full-featured
- RGB and CMYK (but not more)
- License compatible with Chalk
- Under active development

Disadvantages:

- Bit-depth a compile-time option
- Not re-entrant: not optimized for interactive use.

* Paintlib2 (http://www.paintlib.de/paintlib/)

A portable (windows/Linux) library for image loading, manipulation and
saving. The same kind of thing as IM/GM, but not quite as mature.

Advantages:

Disadvantages:
- No support for larger bit depths per channel
- Windows (bmp) centric
- Development seems to have stopped in 2000


* Antigrain (http://www.antigrain.com/)

Antigrain is a graphics lib that specializes in high-quality anti-aliasing. It can be
useful to mine for algorithms, but is mainly a library to render vector data to bitmaps,
just like libart or cairo.

Advantages:

- High quality algorithms
- Completely free license.
- Colour-space agnostic

Disadvantages:

- Not a complete 2D library
- self-admittedly complex and hard to use.
- No support for greater bit-depths.

* The Visualization Toolkit (VTK, http://public.kitware.com/VTK/)

A very big C++ library for 2d and 3d image processing and visualisation. It's
too big to easily evaluate for me.

Advantages
- It is used in other Qt applications, like Julius
- Probably very good

Disadvantages

- The book is very expensive
- Uses its own make equivalent, CMake
- Very large

* Java Advanced Imaging

+ 47
- 0
chalk/Makefile.am View File

@@ -0,0 +1,47 @@
INCLUDES = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) $(all_includes)

## The common lib, shared between the part, the plugins, and the filters
lib_LTLIBRARIES = libchalkcommon.la
libchalkcommon_la_SOURCES = dummy.cc
libchalkcommon_la_LDFLAGS = $(all_libraries) $(LIB_QT) -version-info 1:0 -no-undefined
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)

## The part
kde_module_LTLIBRARIES = libchalkpart.la
libchalkpart_la_SOURCES = chalk_part_init.cc
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)
libchalkpart_la_LIBADD = libchalkcommon.la

METASOURCES = AUTO

## The kdeinit loadable module and executable
kdeinit_LTLIBRARIES = chalk.la
bin_PROGRAMS =
chalk_la_SOURCES = main.cc
chalk_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT)
chalk_la_LIBADD = $(LIB_KOFFICECORE)

xdg_apps_DATA = chalk.desktop
kdemimedir = $(kde_mimedir)/application

rcdir = $(kde_datadir)/chalk
rc_DATA = chalk.rc chalk_readonly.rc

SUBDIRS = sdk chalkcolor core ui . dtd colorspaces plugins data pics
# Needed to compile libchalkcommon.la, which has no source files to itself
# but everything in static libs.
dummy.cc:
echo > dummy.cc

messages: rc.cpp
$(EXTRACTRC) `find . -name \*.ui` >> rc.cpp
$(EXTRACTRC) `find . -name \*.rc` >> rc.cpp
perl extracti18n.pl > i18ndata
$(XGETTEXT) i18ndata rc.cpp `find . -name \*.cc -o -name \*.h -o -name \*.cpp` ui/kis_aboutdata.h -o $(podir)/chalk.pot
rm -f i18ndata

DOXYGEN_EXCLUDE = CImg.h colorspaces plugins chalkcolor/colorspaces core/tiles
include $(top_srcdir)/admin/Doxyfile.am

kde_services_DATA = chalkpart.desktop


+ 13
- 0
chalk/README View File

@@ -0,0 +1,13 @@
Chalk

Chalk is a paint application for bitmap images. It's also, according to
the Dictionary of Phrase and Fable:

The first of four Hindu periods contained in the great Yuga, when the
genius of Truth and Right, in the form of bull, stood firm on his four
feet, and man gained nothing by iniquity.

In the Mahabharata, the name 'chalk' is used in a context where this
can be translated with 'perfect' - the perfect age.

Chalk is Swedish for chalk (or pencil?) and rita means "to write".

+ 181
- 0
chalk/TODO View File

@@ -0,0 +1,181 @@
After 1.5 cleanups

* Move core/ui class private members to d-pointers
* Selections, adj. masks, wetness, heigh masks (all 8-bit mask ideas)
as sublayers to paint layers, and make them movable between layers
and x,y, toggle on/off.
* Fix KisFilter::colorSpaceIndependence/worksWith overlap
* Add api & gui to exclude channels from compositing
* Add a mechanism for cspaces to start long-running filters when a paintdev
is created -- and a gui to turn that on and off, perhaps something analogous
to a channels box
* Make set of filter categories extensible
* BUG 121975: selections and group layers.
* Add end poly entry to the popup menu when the poly tool is active (note:
make this more generically useful for tools. Great idea by David Herman
* Paint direct should be paint directly
UI stuff:

* color picker: top combo should be as wide as the whole widget; the widget is a bit too big,
we should try to make the listview a lot smaller. Maybe just use labels here?
* The edit palette dialog two-step should be changed into a single dialog
Code organization

Transform tool (CBR)

* Implement native integer versions for bell, bspline, lanczos3 and mitchell filters
* The option widget should be connected
* Figure out why scaling down produces sum of weights <255 (Hermite filter)
* Implement gui, create cursors and update visitor for shearing

Integration

* A chalk document embedded in KWord has the wrong scaling and transparency
* A chalk document embedded in another document prints at the wrong place
* Embedded KOffice objects don't paint themselves correctly
* There is currently no kimgio module for Chalk images: implement one by
saving a rendered png image into the chalk file and extracting that from
kimgio. (Saving of a png image in .kra files is done; now we just need to
add the kimgio file)
* There is no easy way to get back from editing an embedded document (if the image is larger
than the window)
Colorspace independence (found with the test colorstrategy)

* Check and double check the cms capabilities: especially the use of
profiles in the render/convert/edit paths.
* Merge grayscale layers back into one color image.
Core

* The fill painter (and perhaps other paitners, too) should call addDirtyRect, and the floodfill
tool should use that rect to blit and notify the image, instead of notifying the complete image.s
* Fix image resolution handling (zooming, pixel-for-pixel, 100% == zoomed to dpi/xdpi etc.)
* Loading and saving of selections
* Anti-aliased filling (requires some simple colorspace function to merge 2 Pixels)
* Load/save configuration of everything user-settable.
* Long painter operations (e.g., convolution painter) should use the
progressbar and be cancelable.
* Color adjustment filters seem to have a problem with partially selected pixels

File Format:

* Save & load all annotations in .kra files
* Save & load more information, like PNG comments, gamma information, etc


Import/Export

* Fix gimp XCF PSD and import/export (ImageMagick hacking...)
* Fix imports to import metadata.

User Interface
* Add an explanatory textframe to the scaling filter combobox.
* Add a good crosshair cursor and a crosshair cursor that extends to the rulers.
* Add a cheatsheet widget that integrates with knewstuff to have tutorials that people
can download and follow from Chalk.
* Add opacity widget (One that grows more white or transparent (showing those gray blocks) based on the
input)
* Add out-of-gamut selection
* Fix layout problems in tool option widgets.
* Disable dragging the toolbox from dock position to dock position (see Karbon)
* Disable all relevant actions when a layer is locked or invisible. See bug #90456. Show locked status of current layer in statusbar.
* Add link check to new image dialog to sync width and height
* The description field in color settings is empty
* Implement the following dialogs / widgets:
- Variations (#Boudewijn)
- Gradient: remove the autogradient dialog and make into a proper
gradient dialog, and allow saving gradients.

* Show which tool is associated with which pointer (mouse, stylus, eraser, other stylusses) In the statusbar.
* Allow guides to be disabled. Allow diagonal guides (useful for perspective drawings) Bug #108398
* Allow snapping to guides.
* Create templates for often-used image formats. Add save-as-template
* Add deselect with rmb -- maybe also selectable actions with other tools on rmb?
* Fix crop tool: when pressing shift, keep aspect ratio, implement gray mask.
(Michael Thaler)
* Allow shape tools to be filled with gradients

Dockers
* Tabs in dockers drag-and-droppable (vector of docker
windows, create new docker if tab dropped outside existing
docker window)
* Add bird's eye view tab to dockers.
* Add action (macro) docker
* Add navigation/zoom docker
* Add history docker

* Doing a copy of a selection, but having the wrong layer selected gives
me an empty selection (all transparent). Pressing paste should say so
(popup) instead of creating a new useless layer.
* the selection tools should allow pressing shift to go to 'substract'
mode without adjusting the combobox for the current tool. (a different
pointer would be nice as well)

* Pressing save for the first time gives me the 'save document as' dialog
which is set to 'png' as default file format.
I suggest to set the default format (in the "save as" dialog) to the chalk
format for any image that has more then 1 layer.


Selections

* On shearing, the whole image is mirrored, not the selected
bits.
* Add opacity slider to selection painting tools so you can
select something 50%.

Profiles

* Add an input profile combobox to the import image & scan dialogs
* Add an export profile combobox to the export image/print dialogs
* Add loading and saving of profiles associated with images in .chalk
files.
* Export profiles in tiff, png and jpg (this and the previous item
depend on ImageMagick or GraphicsMagick supporting this in some way.)
* Support out-of-gamut warning indications for parts of an image
containing unprintable colours (no idea how to implement this). -> this
is pretty easy with lcms
* preferences dialog can show non-existent profile for the monitor profile -> confusing


Tools

* Zoom tool should zoom out when alt is pressed. Show zoom-minus cursor in that case
* Implement the following tools or paintops:
- fix airbrush tool (add rate option, add increase
of brush size if kept in one place)
- color changer, smudge tool,sharpen tool, blur
tool, dodge tool, burn tool, sponge tool (These
last are perhaps more generally: painting with
filters tool)
- stamp tool (paint with patttern/image selection) (#Cyrille)
- Text tool (use kotext with a transparent background here?)
- Measure tool
- calligraphic pen tool
* Pressure sensivitize all relevant tools (e.g. line tool)
* Add resize slider to freehand tools that resizes the mean brush size.
* Implement path tools (Michael Thaler?)
* Sumi-e brush tool
* Natural media tools (chalk, ink, oil, watercolour -- fun!)

Plugins

* As many filters as possible :-)

Modules

* Add color models for HSV, YUV etc.
* Add Wet & Sticky model (in progress already)
* Implement Curtiss et. al. for watercolour (Levien, wet dreams. In progress)
* The composite ops in RGB -> composite.h do not take mask into account
- this goes for COPY and CLEAR in grayscale also

Printing

* No use of the resolution parameter (but the resolution dialog is still only a .ui file and not implemented at all)
* Use gutenprint or something better for image printing.


+ 59
- 0
chalk/UIcomments View File

@@ -0,0 +1,59 @@
Color palettes ;

You can drag a color from the preview swatches but it is changing the
selected one at click and since dropping drops on the selected one, the
concept of duplicating the foreground to the background by dragging is
impossible. I suggest to do selecting of foreground/background color on
mouse release instead.

<BSAR: I don't understand this at all -- not sure what you're talking about.>

Selections

When you did a 'select all' and then create a selection nothing happens
since you can't select more then you already did. For that reason I
suggest to make select all and deselect lead to a similar situation where
adding a selection or substracting one will be smart and do make the
result of that select or deselect visible. In either case selecting a
part in both a fully selected and fully deselected image should lead to
the same result.

<BSAR: not going to do this: in the next release, it will be
always clear whether there's a selection because we're going to show it as a
child layer. For now, determining whether the extent of a selection is as big
as the extent of a layer, and whether the whole selection is completely 100%
selected is going to be too expensive>


Thomas Zander


Missing tooltips (Carsten N.)

LEGEND: NTAA No Tooltip At All
Missing tooltips:
KComboBox in the toolbar (the with 'Pixel Brush' for example)
Overview-widget: NTAA
Histogram: No Tooltip. Well, there is nothing but the histogram, there should be at least something...
Context-Widgets of the tools:
Star: NTAA
Brush: NTAA
Line: NTAA
Rectangle: NTAA
Ellispse: NTAA
Polygone: NTAA
Polyline: NTAA
Duplicate Brush: NTAA

+ 95
- 0
chalk/chalk.desktop View File

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

+ 199
- 0
chalk/chalk.rc View File

@@ -0,0 +1,199 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Chalk" version="15">

<MenuBar>
<Menu name="Edit"><text>&amp;Edit</text>
<Action name="koffice_undo"/>
<Action name="koffice_redo"/>
<Separator/>
<Action name="cut"/>
<Action name="copy"/>
<Action name="copy_merged"/>
<Action name="paste"/>
<Action name="paste_new"/>
<Action name="clear"/>
<Action name="fill_selection_foreground_color"/>
<Action name="fill_selection_background_color"/>
<Action name="fill_selection_pattern"/>
<Separator/>
<Action name="revert"/>
<Separator/>
<Menu name="Resources"><text>&amp;Resources</text>
<Action name="add_palette"/>
<Action name="edit_palette"/>
</Menu>
</Menu>

<Menu name="View"><text>&amp;View</text>
<Action name="fullscreen"/>
<Separator/>
<Action name="view_newview"/>
<ActionList name="view_closeallviews"/>
<Separator/>
<ActionList name="view_split"/>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
<Action name="actual_pixels"/>
<Action name="actual_size"/>
<Action name="fit_to_canvas"/>
<Separator/>
<Action name="view_ruler"/>
<!--Action name="view_guidelines"/-->
<Separator/>
<Action name="view_toggle_grid" />
<Menu name="view_fast_grid_config"><text>Grid Spacing</text>
<Action name="view_fast_grid_1x1" />
<Action name="view_fast_grid_2x2" />
<Action name="view_fast_grid_5x5" />
<Action name="view_fast_grid_10x10" />
<Action name="view_fast_grid_20x20" />
<Action name="view_fast_grid_40x40" />
</Menu>
<Seperator/>
<Action name="view_toggle_perspective_grid" />
<Action name="view_clear_perspective_grid" />
<Separator/>
<Action name="view_palette_action_menu"/>
<Separator/>
<Action name="refresh_canvas"/>
</Menu>


<Menu name="Image"><text>&amp;Image</text>
<Action name="img_properties"/>
<Action name="resizeimgtolayer"/>
<Action name="duplicate_image"/>
</Menu>

<Menu name="Layer"><text>&amp;Layer</text>
<Menu name="LayerNew"><text>New</text>
<Action name="insert_layer"/>
<Action name="insert_part_layer"/>
<Action name="insert_adjustment_layer"/>
<Action name="insert_image_as_layer"/>
<Action name="cut_selection_to_new_layer"/>
<Action name="copy_selection_to_new_layer"/>
</Menu>
<Action name="remove_layer"/>
<Action name="duplicate_layer"/>
<Action name="hide_layer"/>
<Action name="link_layer"/>
<Separator/>
<Menu name="LayerNew"><text>Mask</text>
<Action name="create_mask"/>
<Action name="mask_fromsel"/>
<Action name="mask_tosel"/>
<Action name="apply_mask"/>
<Action name="remove_mask"/>
<Seperator/>
<Action name="edit_mask"/>
<Action name="show_mask"/>
</Menu>
<Separator/>
<Action name="raiselayer"/>
<Action name="lowerlayer"/>
<Action name="toplayer"/>
<Action name="bottomlayer"/>
<Separator/>
<Action name="resizelayertoowner"/>
<Separator/>
<Action name="save_layer_as_image"/>
<Action name="layer_to_image"/>
<Separator/>
<Action name="mirrorLayerX"/>
<Action name="mirrorLayerY"/>
<Separator/>
<Action name="layer_properties"/>
<Separator/>
<Action name="merge_layer"/>
<Action name="flatten_image"/>
</Menu>


<Menu name="Select"><text>Sele&amp;ct</text>
<Action name="select_all"/>
<Action name="deselect"/>
<Action name="reselect"/>
<Action name="invert"/>
<Separator/>
<Action name="feather"/>
<Action name = "grow"/>
<Action name = "similar"/>
<Separator/>
<Action name="toggle_display_selection"/>
</Menu>

<Menu name="Filter"><text>Filte&amp;r</text>
<Action name="filter_apply_again"/>
<Separator/>
<Action name="adjust_filters"/>
<Action name="artistic_filters"/>
<Action name="blur_filters"/>
<Action name="color_filters"/>
<Action name="decor_filters"/>
<Action name="edge_filters"/>
<Action name="enhance_filters"/>
<Action name="emboss_filters"/>
<Action name="map_filters"/>
<Action name="nonphotorealistic_filters"/>
<Action name="misc_filters"/>
</Menu>

<Menu name="Tools"><text>&amp;Tools</text>
</Menu>


<Menu name="settings"><text>Settings</text>
<Separator group="settings_show"/>
<Action name="preferences" group="settings_configure"/>
</Menu>

</MenuBar>

<ToolBar name="edit_toolbar" position="top"><Text>Edit</Text>
<Action name="koffice_undo"/>
<Action name="koffice_redo"/>
<Separator/>
<Action name="cut"/>
<Action name="copy"/>
<Action name="remove"/>
<Action name="scrap_selection"/>
<Action name="paste_special"/>
</ToolBar>

<ToolBar name="navigation" position="top"><Text>Navigation</Text>
<Action name="refresh_canvas"/>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
</ToolBar>

<ToolBar name="ToolBox" position="left">
<Text>Chalk</Text>
</ToolBar>

<ToolBar name="BrushesAndStuff" position="top">
<Text>Brushes and Stuff</Text>
<Action name="brushes"/>
<Action name="gradients"/>
<Action name="patterns"/>
<Separator/>
<Action name="paintops"/>
<Action name="paintop_options"/>
</ToolBar>

<Menu name="image_popup">
<Action name="select_all"/>
<Action name="deselect"/>
<Action name="invert"/>
<Separator/>
<Action name="duplicate_layer"/>
<Separator/>
<Action name="koffice_undo"/>
<Action name="koffice_redo"/>
<Separator/>
<Action name="cut"/>
<Action name="copy"/>
<Action name="paste"/>
<Action name="paste_new"/>
</Menu>

</kpartgui>

+ 23
- 0
chalk/chalk_part_init.cc View File

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


K_EXPORT_COMPONENT_FACTORY( libchalkpart, KisFactory )

+ 35
- 0
chalk/chalk_readonly.rc View File

@@ -0,0 +1,35 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Chalk" version="1">

<MenuBar>
<Menu name="edit"><text>Edit</text>
<Separator/>
<Action name="copy"/>
<Separator/>
<Action name="select_all"/>
<Action name="select_none"/>
<Action name="flip_selection"/>
</Menu>

<Menu name="view"><text>View</text>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
</Menu>

<Menu name="Layer"><text>Layer</text>
<Action name="hide_layer"/>
<Action name="previous_layer"/>
<Action name="next_layer"/>
</Menu>

</MenuBar>

<ToolBar name="edit" position="top"><Text>Edit</Text>
<Action name="copy"/>
</ToolBar>

<ToolBar name="navigation" position="top"><Text>Navigation</Text>
<Action name="zoom_in"/>
<Action name="zoom_out"/>
</ToolBar>

</kpartgui>

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

@@ -0,0 +1,45 @@
# all_includes must remain last!
INCLUDES = $(KOFFICE_INCLUDES) \
-I$(srcdir) \
-I$(srcdir)/../sdk \
-I$(srcdir)/colorspaces \
$(OPENEXR_CFLAGS) \
$(all_includes)

lib_LTLIBRARIES = libchalkcolor.la

if have_openexr
OPENEXR_SOURCES=kis_f16half_base_colorspace.cc
endif

libchalkcolor_la_SOURCES = kis_color.cc kis_colorspace.cc \
kis_colorspace_iface.cc kis_colorspace_iface.skel kis_composite_op.cc kis_profile.cc \
kis_histogram_producer.cc kis_basic_histogram_producers.cc kis_abstract_colorspace.cc \
kis_colorspace_factory_registry.cc kis_color_conversions.cc kis_u8_base_colorspace.cc \
kis_u16_base_colorspace.cc kis_f32_base_colorspace.cc $(OPENEXR_SOURCES)

libchalkcolor_la_LDFLAGS = -version-info 1:0:0 -no-undefined $(all_libraries)
libchalkcolor_la_LIBADD = colorspaces/libchalkcolorspaces.la $(LCMS_LIBS) $(LIB_KPARTS) $(LIB_KDECORE) $(LIB_QT) $(OPENEXR_LIBS)

include_HEADERS = \
kis_channelinfo.h \
kis_color.h \
kis_colorspace.h \
kis_composite_op.h \
kis_profile.h \
kis_histogram_producer.h \
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 \
kis_colorspace_factory_registry.h kis_abstract_colorspace.h


if include_kunittest_tests
TESTSDIR = tests
endif

SUBDIRS = colorspaces . $(TESTSDIR)

kde_servicetypes_DATA = chalk_colorspace.desktop

METASOURCES = AUTO



+ 4
- 0
chalk/chalkcolor/README View File

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

+ 11
- 0
chalk/chalkcolor/TODO View File

@@ -0,0 +1,11 @@
This library is still dependent upon chalk/sdk for some headers. This
should be changed. The headers concerned are:

kis_id.h
kis_global.h
kis_annotation.h
kis_integer_maths.h

Additionally, there is a problem with the histogram producers: those are
tied to the individual base colorspaces, but also need iterators, so they
are in core for the moment.

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

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

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

@@ -0,0 +1,20 @@
INCLUDES = -I$(srcdir)/.. \
-I$(srcdir)/../../sdk \
$(KOFFICE_INCLUDES) \
$(all_includes)

noinst_LTLIBRARIES = libchalkcolorspaces.la

libchalkcolorspaces_la_SOURCES = \
kis_alpha_colorspace.cc \
kis_lab_colorspace.cc

noinst_HEADERS = \
kis_alpha_colorspace.h \
kis_lab_colorspace.h

libchalkcolorspaces_la_LIBADD = $(OPENEXR_LIBS)

libchalkcolorspaces_la_METASOURCES = AUTO



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

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <limits.h>
#include <stdlib.h>

#include <tqimage.h>

#include <kdebug.h>
#include <klocale.h>

#include <config.h>

#include LCMS_HEADER

#include "kis_alpha_colorspace.h"
#include "kis_u8_base_colorspace.h"
#include "kis_channelinfo.h"
#include "kis_id.h"
#include "kis_integer_maths.h"

namespace {
const TQ_UINT8 PIXEL_MASK = 0;
}

KisAlphaColorSpace::KisAlphaColorSpace(KisColorSpaceFactoryRegistry * tqparent,
KisProfile *p) :
KisU8BaseColorSpace(KisID("ALPHA", i18n("Alpha tqmask")), TYPE_GRAY_8, icSigGrayData, tqparent, p)
{
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), 0, KisChannelInfo::ALPHA, KisChannelInfo::UINT8));
m_alphaPos = 0;
}

KisAlphaColorSpace::~KisAlphaColorSpace()
{
}

void KisAlphaColorSpace::fromTQColor(const TQColor& /*c*/, TQ_UINT8 *dst, KisProfile * /*profile*/)
{
dst[PIXEL_MASK] = OPACITY_OPAQUE;
}

void KisAlphaColorSpace::fromTQColor(const TQColor& /*c*/, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * /*profile*/)
{
dst[PIXEL_MASK] = opacity;
}

void KisAlphaColorSpace::getAlpha(const TQ_UINT8 *pixel, TQ_UINT8 *alpha) const
{
*alpha = *pixel;
}

void KisAlphaColorSpace::toTQColor(const TQ_UINT8 */*src*/, TQColor *c, KisProfile * /*profile*/)
{
c->setRgb(255, 255, 255);
}

void KisAlphaColorSpace::toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * /*profile*/)
{
c->setRgb(255, 255, 255);
*opacity = src[PIXEL_MASK];
}

TQ_UINT8 KisAlphaColorSpace::difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2)
{
// Arithmetic operands smaller than int are converted to int automatically
return TQABS(src2[PIXEL_MASK] - src1[PIXEL_MASK]);
}

void KisAlphaColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
{
if (nColors > 0) {
TQ_UINT32 total = 0;

while(nColors)
{
nColors--;
total += *colors[nColors] * weights[nColors];
}
*dst = total / 255;
}
}

TQValueVector<KisChannelInfo *> KisAlphaColorSpace::channels() const
{
return m_channels;
}

bool KisAlphaColorSpace::convertPixelsTo(const TQ_UINT8 *src,
TQ_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
TQ_UINT32 numPixels,
TQ_INT32 /*renderingIntent*/)
{
// No lcms trickery here, we are only a opacity channel
TQ_INT32 size = dstColorSpace->pixelSize();

TQ_UINT32 j = 0;
TQ_UINT32 i = 0;

while ( i < numPixels ) {

dstColorSpace->fromTQColor(TQt::red, OPACITY_OPAQUE - *(src + i), (dst + j));

i += 1;
j += size;

}
return true;

}


//XXX bitblt of ColorSpaceAlpha does not take tqmask into consideration as this is probably not
// used ever
void KisAlphaColorSpace::bitBlt(TQ_UINT8 *dst,
TQ_INT32 dststride,
const TQ_UINT8 *src,
TQ_INT32 srcRowStride,
const TQ_UINT8 *srcAlphaMask,
TQ_INT32 tqmaskRowStride,
TQ_UINT8 opacity,
TQ_INT32 rows,
TQ_INT32 cols,
const KisCompositeOp& op)
{

TQ_UINT8 *d;
const TQ_UINT8 *s;
TQ_INT32 i;
TQ_INT32 linesize;

if (rows <= 0 || cols <= 0)
return;
switch (op.op()) {
case COMPOSITE_COPY:
compositeCopy(dst, dststride, src, srcRowStride, srcAlphaMask, tqmaskRowStride, rows, cols, opacity);
return;
case COMPOSITE_CLEAR:
linesize = sizeof(TQ_UINT8) * cols;
d = dst;
while (rows-- > 0) {
memset(d, OPACITY_TRANSPARENT, linesize);
d += dststride;
}
return;
case COMPOSITE_ERASE:
while (rows-- > 0) {
d = dst;
s = src;

for (i = cols; i > 0; i--, d ++, s ++) {
if (d[PIXEL_MASK] < s[PIXEL_MASK]) {
continue;
}
else {
d[PIXEL_MASK] = s[PIXEL_MASK];
}

}

dst += dststride;
src += srcRowStride;
}
return;
case COMPOSITE_SUBTRACT:
while (rows-- > 0) {
d = dst;
s = src;

for (i = cols; i > 0; i--, d++, s++) {
if (d[PIXEL_MASK] <= s[PIXEL_MASK]) {
d[PIXEL_MASK] = MIN_SELECTED;
} else {
d[PIXEL_MASK] -= s[PIXEL_MASK];
}
}

dst += dststride;
src += srcRowStride;
}
return;
case COMPOSITE_ALPHA_DARKEN:
while (rows-- > 0) {
d = dst;
s = src;
for (i = cols; i > 0; i--, d++, s++) {
if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
continue;
int srcAlpha = (s[PIXEL_MASK] * opacity + UINT8_MAX / 2) / UINT8_MAX;
if (srcAlpha > d[PIXEL_MASK])
d[PIXEL_MASK] = srcAlpha;
}
dst += dststride;
src += srcRowStride;
}
return;
case COMPOSITE_OVER:
default:
if (opacity == OPACITY_TRANSPARENT)
return;
if (opacity != OPACITY_OPAQUE) {
while (rows-- > 0) {
d = dst;
s = src;
for (i = cols; i > 0; i--, d++, s++) {
if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
continue;
int srcAlpha = (s[PIXEL_MASK] * opacity + UINT8_MAX / 2) / UINT8_MAX;
d[PIXEL_MASK] = (d[PIXEL_MASK] * (UINT8_MAX - srcAlpha) + srcAlpha * UINT8_MAX + UINT8_MAX / 2) / UINT8_MAX;
}
dst += dststride;
src += srcRowStride;
}
}
else {
while (rows-- > 0) {
d = dst;
s = src;
for (i = cols; i > 0; i--, d++, s++) {
if (s[PIXEL_MASK] == OPACITY_TRANSPARENT)
continue;
if (d[PIXEL_MASK] == OPACITY_TRANSPARENT || s[PIXEL_MASK] == OPACITY_OPAQUE) {
memcpy(d, s, 1);
continue;
}
int srcAlpha = s[PIXEL_MASK];
d[PIXEL_MASK] = (d[PIXEL_MASK] * (UINT8_MAX - srcAlpha) + srcAlpha * UINT8_MAX + UINT8_MAX / 2) / UINT8_MAX;
}
dst += dststride;
src += srcRowStride;
}
}

}
}

KisCompositeOpList KisAlphaColorSpace::userVisiblecompositeOps() const
{
KisCompositeOpList list;

list.append(KisCompositeOp(COMPOSITE_OVER));

return list;
}

TQString KisAlphaColorSpace::channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
{
Q_ASSERT(channelIndex < nChannels());
TQ_UINT32 channelPosition = m_channels[channelIndex]->pos();

return TQString().setNum(pixel[channelPosition]);
}

TQString KisAlphaColorSpace::normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const
{
Q_ASSERT(channelIndex < nChannels());
TQ_UINT32 channelPosition = m_channels[channelIndex]->pos();

return TQString().setNum(static_cast<float>(pixel[channelPosition]) / UINT8_MAX);
}


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
{
TQ_INT32 totalAlpha = 0;

while (nColors--)
{
TQ_INT32 weight = *kernelValues;

if (weight != 0) {
totalAlpha += (*colors)[PIXEL_MASK] * weight;
}
colors++;
kernelValues++;
}

if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
dst[PIXEL_MASK] = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT8_MAX);
}
}

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

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_COLORSPACE_ALPHA_H_
#define KIS_COLORSPACE_ALPHA_H_

#include <tqcolor.h>

#include "kis_global.h"
#include "kis_u8_base_colorspace.h"

/**
* The alpha tqmask is a special color strategy that treats all pixels as
* alpha value with a colour common to the tqmask. The default color is white.
*/
class KisAlphaColorSpace : public KisU8BaseColorSpace {
public:
KisAlphaColorSpace(KisColorSpaceFactoryRegistry * tqparent,
KisProfile *p);
virtual ~KisAlphaColorSpace();

public:
virtual bool willDegrade(ColorSpaceIndependence)
{
return false;
};

virtual void fromTQColor(const TQColor& c, TQ_UINT8 *dst, KisProfile * profile = 0);
virtual void fromTQColor(const TQColor& c, TQ_UINT8 opacity, TQ_UINT8 *dst, KisProfile * profile = 0);

virtual void getAlpha(const TQ_UINT8 *pixel, TQ_UINT8 *alpha) const;

virtual void toTQColor(const TQ_UINT8 *src, TQColor *c, KisProfile * profile = 0);
virtual void toTQColor(const TQ_UINT8 *src, TQColor *c, TQ_UINT8 *opacity, KisProfile * profile = 0);

virtual TQ_UINT8 difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2);
virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const;

virtual TQValueVector<KisChannelInfo *> channels() const;
virtual TQ_UINT32 nChannels() const { return 1; };
virtual TQ_UINT32 nColorChannels() const { return 0; };
virtual TQ_UINT32 pixelSize() const { return 1; };

virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;

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;

protected:

/**
* Convert a byte array of srcLen pixels *src to the specified color space
* and put the converted bytes into the prepared byte array *dst.
*
* Returns false if the conversion failed, true if it succeeded
*/
virtual bool convertPixelsTo(const TQ_UINT8 *src,
TQ_UINT8 *dst, KisAbstractColorSpace * dstColorSpace,
TQ_UINT32 numPixels,
TQ_INT32 renderingIntent = INTENT_PERCEPTUAL);



virtual void bitBlt(TQ_UINT8 *dst,
TQ_INT32 dststride,
const TQ_UINT8 *src,
TQ_INT32 srcRowStride,
const TQ_UINT8 *srcAlphaMask,
TQ_INT32 tqmaskRowStride,
TQ_UINT8 opacity,
TQ_INT32 rows,
TQ_INT32 cols,
const KisCompositeOp& op);

KisCompositeOpList userVisiblecompositeOps() const;

};

#endif // KIS_COLORSPACE_ALPHA_H_

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

@@ -0,0 +1,571 @@
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <config.h>
#include <limits.h>
#include <stdlib.h>
#include LCMS_HEADER

#include <tqimage.h>

#include <kdebug.h>
#include <klocale.h>

#include "kis_lab_colorspace.h"
#include "kis_color_conversions.h"
#include "kis_integer_maths.h"

KisLabColorSpace::KisLabColorSpace(KisColorSpaceFactoryRegistry * tqparent, KisProfile *p)
: KisU16BaseColorSpace(KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")),
COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1),
icSigLabData, tqparent, p)

{
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)));
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)));
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)));
m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), CHANNEL_ALPHA * sizeof(TQ_UINT16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(TQ_UINT16)));

m_alphaPos = CHANNEL_ALPHA * sizeof(TQ_UINT16);

init();
}

KisLabColorSpace::~KisLabColorSpace()
{
}

TQ_UINT8 * KisLabColorSpace::toLabA16(const TQ_UINT8 * data, const TQ_UINT32 nPixels) const
{
TQ_UINT8 * pixels = new TQ_UINT8[nPixels * pixelSize()];
memcpy( pixels, data, nPixels * pixelSize() );
return pixels;
}

TQ_UINT8 * KisLabColorSpace::fromLabA16(const TQ_UINT8 * labData, const TQ_UINT32 nPixels) const
{
TQ_UINT8 * pixels = new TQ_UINT8[nPixels * pixelSize()];
memcpy( pixels, labData, nPixels * pixelSize() );
return pixels;
}

TQ_UINT8 KisLabColorSpace::difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2)
{
cmsCIELab labF1, labF2;

if (getAlpha(src1) == OPACITY_TRANSPARENT || getAlpha(src2) == OPACITY_TRANSPARENT)
return (getAlpha(src1) == getAlpha(src2) ? 0 : 255);

cmsLabEncoded2Float(&labF1, (WORD *)src1);
cmsLabEncoded2Float(&labF2, (WORD *)src2);
double diff = cmsDeltaE(&labF1, &labF2);
if(diff>255)
return 255;
else
return TQ_INT8(diff);
}

void KisLabColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
{
TQ_UINT32 totalLightness = 0, totalAlpha = 0;
TQ_UINT32 totala = 0, totalb = 0;

while (nColors--)
{
const Pixel *color = reinterpret_cast<const Pixel *>( *colors );
TQ_UINT32 alphaTimesWeight = UINT8_MULT(color->alpha, *weights);

totalLightness += color->lightness * alphaTimesWeight;
totala += color->a * alphaTimesWeight;
totalb += color->b * alphaTimesWeight;
totalAlpha += alphaTimesWeight;

weights++;
colors++;
}

if (totalAlpha > UINT16_MAX) {
totalAlpha = UINT16_MAX;
}

((Pixel *)dst)->alpha = totalAlpha;

if (totalAlpha > 0) {
totalLightness /= totalAlpha;
totala /= totalAlpha;
totalb /= totalAlpha;
} // else the values are already 0 too

if (totalLightness > MAX_CHANNEL_L) {
totalLightness = MAX_CHANNEL_L;
}

((Pixel *)dst)->lightness = totalLightness;

if (totala > MAX_CHANNEL_AB) {
totala = MAX_CHANNEL_AB;
}

((Pixel *)dst)->a = totala;

if (totalb > MAX_CHANNEL_AB) {
totalb = MAX_CHANNEL_AB;
}

((Pixel *)dst)->b = totalb;
}

void KisLabColorSpace::invertColor(TQ_UINT8 * src, TQ_INT32 nPixels)
{
TQ_UINT32 psize = pixelSize();

while (nPixels--)
{
Pixel * s = reinterpret_cast<Pixel *>( src );

s->lightness = MAX_CHANNEL_L - s->lightness;
s->a = MAX_CHANNEL_AB - s->a;
s->b = MAX_CHANNEL_AB - s->b;

src += psize;
}
}

void KisLabColorSpace::convolveColors(TQ_UINT8** colors, TQ_INT32 * kernelValues, KisChannelInfo::enumChannelFlags channelFlags,
TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const
{
TQ_INT32 totalL = 0, totalA = 0, totalB = 0, totalAlpha = 0;

while ( nColors -- )
{
const Pixel * pixel = reinterpret_cast<const Pixel *>( *colors );
TQ_INT32 weight = *kernelValues;
if ( weight != 0 ) {
totalL += pixel->lightness * weight;
totalA += pixel->a * weight;
totalB += pixel->b * weight;
totalAlpha += pixel->alpha * weight;
}
colors++;
kernelValues++;
}


Pixel * p = reinterpret_cast< Pixel *>( dst );

if (channelFlags & KisChannelInfo::FLAG_COLOR) {
p->lightness = CLAMP( ( totalL / factor) + offset, 0, TQ_UINT16_MAX);
p->a = CLAMP( ( totalA / factor) + offset, 0, TQ_UINT16_MAX);
p->b = CLAMP( ( totalB / factor) + offset, 0, TQ_UINT16_MAX);
}
if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
p->alpha = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT16_MAX);
}

}

void KisLabColorSpace::darken(const TQ_UINT8 * src, TQ_UINT8 * dst, TQ_INT32 shade, bool compensate, double compensation, TQ_INT32 nPixels) const
{
// XXX: Is the 255 right for u16 colorspaces?
TQ_UINT32 pSize = pixelSize();
while ( nPixels-- ) {
const Pixel * s = reinterpret_cast<const Pixel*>( src );
Pixel * d = reinterpret_cast<Pixel*>( dst );

if ( compensate ) {
d->lightness = static_cast<TQ_UINT16>( ( s->lightness * shade ) / ( compensation * 255 ) );
}
else {
d->lightness = static_cast<TQ_UINT16>( s->lightness * shade / 255 );
}
d->a = s->a;
d->b = s->b;
d->alpha = s->alpha;

src += pSize;
dst += pSize;
}
}


TQValueVector<KisChannelInfo *> KisLabColorSpace::channels() const
{
return m_channels;
}

TQ_UINT32 KisLabColorSpace::nChannels() const
{
return NUM_CHANNELS;
}

TQ_UINT32 KisLabColorSpace::nColorChannels() const
{
return NUM_COLOR_CHANNELS;
}

TQ_UINT32 KisLabColorSpace::pixelSize() const
{
return sizeof(Pixel);
}

void KisLabColorSpace::getSingleChannelPixel(TQ_UINT8 *dst, const TQ_UINT8 *src, TQ_UINT32 channelIndex)
{
if (channelIndex < NUM_CHANNELS) {

const Pixel *srcPixel = reinterpret_cast<const Pixel *>(src);
Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);

switch (channelIndex) {
case CHANNEL_L:
dstPixel->lightness = srcPixel->lightness;
dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
dstPixel->alpha = U16_OPACITY_TRANSPARENT;
break;
case CHANNEL_A:
dstPixel->lightness = MAX_CHANNEL_L / 2;
dstPixel->a = srcPixel->a;
dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
dstPixel->alpha = U16_OPACITY_TRANSPARENT;
break;
case CHANNEL_B:
dstPixel->lightness = MAX_CHANNEL_L / 2;
dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
dstPixel->b = srcPixel->b;
dstPixel->alpha = U16_OPACITY_TRANSPARENT;
break;
case CHANNEL_ALPHA:
dstPixel->lightness = MAX_CHANNEL_L / 2;
dstPixel->a = CHANNEL_AB_ZERO_OFFSET;
dstPixel->b = CHANNEL_AB_ZERO_OFFSET;
dstPixel->alpha = srcPixel->alpha;
break;
}
}
}

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)
{
while (rows > 0) {
const Pixel *src = reinterpret_cast<const Pixel *>(srcRowStart);
Pixel *dst = reinterpret_cast<Pixel *>(dstRowStart);
const TQ_UINT8 *tqmask = tqmaskRowStart;
TQ_INT32 columns = numColumns;

while (columns > 0) {

TQ_UINT16 srcAlpha = src->alpha;

// apply the alphatqmask
if (tqmask != 0) {
if (*tqmask != OPACITY_OPAQUE) {
srcAlpha = UINT16_MULT(srcAlpha, *tqmask);
}
tqmask++;
}

if (srcAlpha != U16_OPACITY_TRANSPARENT) {

if (opacity != U16_OPACITY_OPAQUE) {
srcAlpha = UINT16_MULT(srcAlpha, opacity);
}

if (srcAlpha == U16_OPACITY_OPAQUE) {
memcpy(dst, src, sizeof(Pixel));
} else {
TQ_UINT16 dstAlpha = dst->alpha;

TQ_UINT16 srcBlend;

if (dstAlpha == U16_OPACITY_OPAQUE) {
srcBlend = srcAlpha;
} else {
TQ_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha);
dst->alpha = newAlpha;

if (newAlpha != 0) {
srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha);
} else {
srcBlend = srcAlpha;
}
}

if (srcBlend == U16_OPACITY_OPAQUE) {
memcpy(dst, src, sizeof(Pixel));
} else {
/*printf("blend is %d\n", srcBlend);
printf("%d %d %d\n", src->lightness, src->a, src->b);
printf("%d %d %d\n", dst->lightness, dst->a, dst->b);
*/
dst->lightness = UINT16_BLEND(src->lightness, dst->lightness, srcBlend);
dst->a = UINT16_BLEND(src->a, dst->a, srcBlend);
dst->b = UINT16_BLEND(src->b, dst->b, srcBlend);
//printf("%d %d %d\n", dst->lightness, dst->a, dst->b);
}
}
}

columns--;
src++;
dst++;
}

rows--;
srcRowStart += srcRowStride;
dstRowStart += dstRowStride;
if(tqmaskRowStart) {
tqmaskRowStart += tqmaskRowStride;
}
}
}

void KisLabColorSpace::compositeErase(TQ_UINT8 *dst,
TQ_INT32 dstRowSize,
const TQ_UINT8 *src,
TQ_INT32 srcRowSize,
const TQ_UINT8 *srcAlphaMask,
TQ_INT32 tqmaskRowStride,
TQ_INT32 rows,
TQ_INT32 cols,
TQ_UINT16 /*opacity*/)
{
while (rows-- > 0)
{
const Pixel *s = reinterpret_cast<const Pixel *>(src);
Pixel *d = reinterpret_cast<Pixel *>(dst);
const TQ_UINT8 *tqmask = srcAlphaMask;

for (TQ_INT32 i = cols; i > 0; i--, s++, d++)
{
TQ_UINT16 srcAlpha = s->alpha;

// apply the alphatqmask
if (tqmask != 0) {
TQ_UINT8 U8_tqmask = *tqmask;

if (U8_tqmask != OPACITY_OPAQUE) {
srcAlpha = UINT16_BLEND(srcAlpha, U16_OPACITY_OPAQUE, UINT8_TO_UINT16(U8_tqmask));
}
tqmask++;
}
d->alpha = UINT16_MULT(srcAlpha, d->alpha);
}

dst += dstRowSize;
src += srcRowSize;
if(srcAlphaMask) {
srcAlphaMask += tqmaskRowStride;
}
}
}

void KisLabColorSpace::bitBlt(TQ_UINT8 *dst,
TQ_INT32 dstRowStride,
const TQ_UINT8 *src,
TQ_INT32 srcRowStride,
const TQ_UINT8 *tqmask,
TQ_INT32 tqmaskRowStride,
TQ_UINT8 U8_opacity,
TQ_INT32 rows,
TQ_INT32 cols,
const KisCompositeOp& op)
{
TQ_UINT16 opacity = UINT8_TO_UINT16(U8_opacity);

switch (op.op()) {
case COMPOSITE_UNDEF:
// Undefined == no composition
break;
case COMPOSITE_OVER:
compositeOver(dst, dstRowStride, src, srcRowStride, tqmask, tqmaskRowStride, rows, cols, opacity);
break;