delaboratory-0.8/0000755000175100001440000000000012005331274013042 5ustar jacekusersdelaboratory-0.8/INSTALL0000644000175100001440000000172111713052054014075 0ustar jacekusersYou can download binary packages for Windows from project website. Packages for Linux distributions are also available (see "Installation" on Wiki). -------------------------------- COMPILATION -------------------------------- --------------------------- requirements --------------------------- you need: - wxGTK - libtiff - libxml2 --------------------------- make --------------------------- to compile just type: make if you want to install in /usr/local/bin, type (from root): make install --------------------------- debug --------------------------- to compile debug version use: make DEBUG=YES before changing build type you should clean the build: make clean --------------------------- architecture (optimization) --------------------------- please set your architecture in Makefile correctly # choose your architecture OPTFLAGS=-march=i686 #OPTFLAGS=-march=core2 (as you can see default is i686, and it won't work on 64-bit systems) delaboratory-0.8/COPYING0000644000175100001440000010451311570506246014112 0ustar jacekusers GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . delaboratory-0.8/core/0000755000175100001440000000000012005331266013773 5ustar jacekusersdelaboratory-0.8/core/channels.h0000644000175100001440000000300511764477311015752 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CHANNELS_H #define _DE_CHANNELS_H // RGB #define DE_CHANNEL_RED 0 #define DE_CHANNEL_GREEN 1 #define DE_CHANNEL_BLUE 2 // BW #define DE_CHANNEL_GRAYSCALE 0 // LAB #define DE_CHANNEL_L 0 #define DE_CHANNEL_A 1 #define DE_CHANNEL_B 2 // LCH #define DE_CHANNEL_C 1 #define DE_CHANNEL_H 2 // CMY/CMYK #define DE_CHANNEL_CYAN 0 #define DE_CHANNEL_MAGENTA 1 #define DE_CHANNEL_YELLOW 2 #define DE_CHANNEL_KEY 3 // HSL/HSV #define DE_CHANNEL_HUE 0 #define DE_CHANNEL_SATURATION 1 #define DE_CHANNEL_LIGHTNESS 2 #define DE_CHANNEL_VALUE 2 // XYZ #define DE_CHANNEL_X 0 #define DE_CHANNEL_Y 1 #define DE_CHANNEL_Z 2 #endif delaboratory-0.8/core/static_image.h0000644000175100001440000000400412004112446016567 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_STATIC_IMAGE_H #define _DE_STATIC_IMAGE_H #include "color_space.h" #include "mutex_read_write.h" #include "size.h" #include "mutex.h" #include class deStaticImage { private: deColorSpace colorSpace; std::vector channels; std::vector mutexes; deSize size; mutable deMutex mutex; int lastRotate; const deValue* startReadStatic(int index); void finishReadStatic(int index); deStaticImage(const deStaticImage& i); deStaticImage& operator = (const deStaticImage& i); public: deStaticImage(); virtual ~deStaticImage(); void setColorSpace(deColorSpace c); deColorSpace getColorSpace() const; deValue* startWriteStatic(int index); void finishWriteStatic(int index); void setSize(const deSize& _size); deSize getStaticImageSize() const; void lock(); void unlock(); void setInfo(const std::string& s); bool isEmpty() const; void copyToChannel(int channel, deValue* destination, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, deSize destinationSize, bool mirrorX, bool mirrorY, int rotate, deValue contrast); deValue getAspect() const; }; #endif delaboratory-0.8/core/preset.cc0000644000175100001440000000266611764477311015633 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "preset.h" #include "property_numeric.h" void dePreset::apply(deBaseLayerWithProperties& layer) const { std::map::const_iterator i; for (i = numericValues.begin(); i != numericValues.end(); i++) { dePropertyNumeric* p = layer.getPropertyNumeric(i->first); if (p) { p->set(i->second); } } std::vector::const_iterator j; for (j = operations.begin(); j != operations.end(); j++) { layer.executeOperation(*j); } } void dePreset::addNumericValue(const std::string& n, deValue v) { numericValues[n] = v; } void dePreset::addOperation(const std::string& n) { operations.push_back(n); } delaboratory-0.8/core/palette.h0000644000175100001440000000430311765506775015627 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PALETTE_H #define _DE_PALETTE_H #include #include "value.h" #include "color_space.h" #include class deColor4 { private: deValue v1; deValue v2; deValue v3; deValue v4; public: deColor4(deValue _v1, deValue _v2, deValue _v3, deValue _v4) :v1(_v1), v2(_v2), v3(_v3), v4(_v4) { }; virtual ~deColor4() { }; deValue getV1() {return v1;}; deValue getV2() {return v2;}; deValue getV3() {return v3;}; deValue getV4() {return v4;}; deValue calcDistance(const deColor4& c) const { deValue d1 = c.v1 - v1; deValue d2 = c.v2 - v2; deValue d3 = c.v3 - v3; deValue d4 = c.v4 - v4; deValue d = d1 * d1 + d2 * d2 + d3 * d3 + d4 * d4; return sqrt(d); }; }; class dePalette3 { private: deColorSpace colorSpace; std::vector colors; public: dePalette3(deColorSpace _colorSpace); virtual ~dePalette3(); void addColor(const deColor4& color); void optimize(const dePalette3& source, int n, deValue margin); deColor4 getColor(int index); int getSize() const {return colors.size();}; void getMinMax(int index, deValue& min, deValue& max); bool find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& L); }; #endif delaboratory-0.8/core/test_image.h0000644000175100001440000000155511765506775016320 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_TEST_IMAGE_H #define _DE_TEST_IMAGE_H class deStaticImage; void generateTestImage(deStaticImage& image, int s); #endif delaboratory-0.8/core/base_layer_with_source.cc0000644000175100001440000000475011774674304021050 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "base_layer_with_source.h" #include "layer_stack.h" #include "copy_channel.h" #include "logger.h" #include "str.h" deBaseLayerWithSource::deBaseLayerWithSource(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) :deBaseLayerWithProperties(_colorSpace, _channelManager), sourceLayerIndex(_sourceLayerIndex), layerStack(_layerStack) { } deBaseLayerWithSource::~deBaseLayerWithSource() { } const deBaseLayer& deBaseLayerWithSource::getSourceLayer() const { const deBaseLayer* layer = layerStack.getLayer(sourceLayerIndex); return *layer; } const deBaseLayer& deBaseLayerWithSource::getOriginalLayer() const { const deBaseLayer* layer = layerStack.getLayer(0); return *layer; } const deImage& deBaseLayerWithSource::getSourceImage() const { return getSourceLayer().getLayerImage(); } const deImage& deBaseLayerWithSource::getOriginalImage() const { return getOriginalLayer().getLayerImage(); } const deImage& deBaseLayerWithSource::getOtherLayerImage(int a) const { deBaseLayer* applied = layerStack.getLayer(a); const deImage& appliedImage = applied->getLayerImage(); return appliedImage; } deColorSpace deBaseLayerWithSource::getSourceColorSpace() const { return getSourceLayer().getColorSpace(); } int deBaseLayerWithSource::getLayerStackSize() const { return layerStack.getSize(); } void deBaseLayerWithSource::copySourceChannel(int channel) { logInfo("copy source channel " + str(channel)); const deValue* s = getSourceImage().startRead(channel); deValue* d = mainLayerImage.startWrite(channel); copyChannel(s, d, mainLayerImage.getChannelSize().getN()); mainLayerImage.finishWrite(channel); getSourceImage().finishRead(channel); } delaboratory-0.8/core/base_layer_with_properties.h0000644000175100001440000000501511764477311021577 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BASE_LAYER_WITH_PROPERTIES_H #define _DE_BASE_LAYER_WITH_PROPERTIES_H #include "base_layer.h" class deBaseLayerWithProperties:public deBaseLayer { private: deBaseLayerWithProperties(const deBaseLayerWithProperties& layer); deBaseLayerWithProperties& operator = (const deBaseLayerWithProperties& layer); protected: std::vector properties; std::vector presets; void createPropertyNumeric(const std::string& _name, deValue _min, deValue _max); void createPropertyChoice(const std::string& _name, const std::vector& _choices); void createPropertyBoolean(const std::string& _name); public: deBaseLayerWithProperties(deColorSpace _colorSpace, deChannelManager& _channelManager); virtual ~deBaseLayerWithProperties(); deProperty* getProperty(const std::string& _name); const deProperty* getProperty(const std::string& _name) const; dePropertyNumeric* getPropertyNumeric(const std::string& _name); const dePropertyNumeric* getPropertyNumeric(const std::string& _name) const; dePropertyChoice* getPropertyChoice(const std::string& _name); const dePropertyChoice* getPropertyChoice(const std::string& _name) const; dePropertyBoolean* getPropertyBoolean(const std::string& _name); const dePropertyBoolean* getPropertyBoolean(const std::string& _name) const; void getProperties(std::vector& names) const; deValue getNumericValue(const std::string& name) const; void applyPreset(const std::string& name); void getPresets(std::vector& names); dePreset* createPreset(const std::string& name); virtual void executeOperation(const std::string& o) {}; }; #endif delaboratory-0.8/core/str.h0000644000175100001440000000270111777136356014776 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_STR_H #define _DE_STR_H #include #include "value.h" /* returns str before ".", so for "abcde.jpg" returns "abcde" */ std::string getBaseName(const std::string& s); /* returns str after ".", so for "abcde.jpg" returns "jpg" */ std::string getExtension(const std::string& s); std::string removePathAndExtension(const std::string& fileName); std::string getPath(const std::string& fileName); std::string str(deValue n); std::string str(int n); std::string str(long n); std::string str(unsigned int n); std::string str(bool b); deValue getValue(const std::string& s); int getInt(const std::string& s); bool getBool(const std::string& s); std::string insertIndex(const std::string& s, int index); #endif delaboratory-0.8/core/preset_button.h0000644000175100001440000000260611766762751017071 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PRESET_BUTTON_H #define _DE_PRESET_BUTTON_H class deLayerProcessor; class deWindow; class deBaseLayerWithProperties; class deLayerFrame; #include "button.h" class dePresetButton:public deButton { private: const std::string preset; deLayerProcessor& layerProcessor; deBaseLayerWithProperties& layer; int layerIndex; deLayerFrame& frame; public: dePresetButton(deWindow& window, deBaseLayerWithProperties& _layer, const std::string& name, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _frame); virtual ~dePresetButton(); virtual void onClick(); }; #endif delaboratory-0.8/core/layer_processor.h0000644000175100001440000001022011772646457017377 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_PROCESSOR_H #define _DE_LAYER_PROCESSOR_H class deMainWindow; class deLayerStack; class deViewManager; class deChannelManager; class deProgressDialog; class deLayer; class deLogger; class deLayerFrameManager; class deLayerProcessorThreads; class deGUI; #include #include "size.h" #include "renderer.h" #include "semaphore.h" #include "base_layer.h" enum { DE_PROCESSING_START, DE_PROCESSING_END, DE_RENDERING_START, DE_RENDERING_END, DE_HISTOGRAM_START, DE_HISTOGRAM_END, DE_DCRAW_START, DE_DCRAW_END, DE_DEBUG_START, DE_DEBUG_END }; class deLayerProcessor { private: deLayerProcessorThreads* threads; deLayerStack& layerStack; deViewManager* viewManager; deLayerFrameManager& layerFrameManager; mutable deMutex layerProcessMutex; deMutex histogramMutex; deMutex prepareImageMutex; deMutex updateImageMutex; deMutex updateImagesMutex; deRenderer renderer; deChannelManager& previewChannelManager; deMainWindow& mainWindow; bool closing; deLayerProcessType layerProcessType; int layerProcessChannel; int firstLayerToUpdate; int lastValidLayer; void updateImages(int a, int channel, bool action); bool updateLayerImage(); void repaintImageInLayerProcessor(); deLayerProcessor(const deLayerProcessor&); deLayerProcessor& operator = (const deLayerProcessor&); void checkUpdateImagesRequest(); int getLastLayerToUpdate(); void lockLayers() const; void unlockLayers() const; void lockHistogram(); void unlockHistogram(); void lockPrepareImage(); void unlockPrepareImage(); void lockUpdateImage(); void unlockUpdateImage(); void updateWarning(); public: deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deMainWindow& _mainWindow); virtual ~deLayerProcessor(); int getLastValidLayer() const; void setViewManager(deViewManager* _viewManager); void updateAllImages(bool calcHistogram); bool updateImagesSmart(deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, const deSize& size, deGUI& gui); void markUpdateSingleChannel(int index, int channel); void markUpdateAllChannels(int index); void markUpdateBlendAllChannels(int index); void onChangeView(int a); void lockLayerProcessor(); void unlockLayerProcessor(); void startWorkerThread(); void tickWork(); void onDestroyAll(); void onChangeViewMode(); void onGUIUpdate(); void removeTopLayerInLayerProcessor(); void addLayerInLayerProcessor(deBaseLayer* layer); void stopWorkerThread(); void sendRepaintEvent(); bool prepareImage(); void generateHistogram(); void onGenerateHistogram(); void sendHistogramEvent(); void setPreviewSize(const deSize& size, bool canSkip); void onImageLoad(); void forceUpdateSize(); bool isClosing() const {return closing;}; void render(deCanvas& canvas); void removeAllLayers(); void sendInfoEvent(int i); void setHistogramChannel(int channel); }; #endif delaboratory-0.8/core/layer_with_blending.h0000644000175100001440000000343211766762751020203 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_WITH_BLENDING_H #define _DE_LAYER_WITH_BLENDING_H #include "switchable_layer.h" #include "blend_mode.h" #include "property_choice.h" class deLayerWithBlending:public deSwitchableLayer { private: deImage imageBlendPass; virtual const deImage& getLayerImage() const; virtual bool updateBlendAllChannels(); bool tryBlendSpecial(); void blendSpecial(); protected: virtual void processSingleChannel(int channel); virtual bool updateImage(); virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; public: deLayerWithBlending(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deLayerWithBlending(); deBlendMode getBlendMode() const; deValue getOpacity() const; void setBlendMode(deBlendMode mode); void setOpacity(deValue _opacity); bool updateBlend(int i); virtual void allocateChannels(); }; #endif delaboratory-0.8/core/skin_color_chart.cc0000644000175100001440000000640411765506775017656 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "skin_color_chart.h" void getFelixVonLuschan(std::vector& skins) { skins.push_back(deSkinRGB(244, 242, 245)); skins.push_back(deSkinRGB(236, 235, 233)); skins.push_back(deSkinRGB(250, 249, 247)); skins.push_back(deSkinRGB(253, 251, 230)); skins.push_back(deSkinRGB(253, 246, 230)); skins.push_back(deSkinRGB(254, 247, 229)); skins.push_back(deSkinRGB(249, 241, 239)); skins.push_back(deSkinRGB(243, 234, 229)); skins.push_back(deSkinRGB(244, 241, 234)); skins.push_back(deSkinRGB(251, 252, 244)); skins.push_back(deSkinRGB(251, 247, 235)); skins.push_back(deSkinRGB(254, 246, 225)); skins.push_back(deSkinRGB(255, 249, 225)); skins.push_back(deSkinRGB(255, 249, 224)); skins.push_back(deSkinRGB(241, 231, 195)); skins.push_back(deSkinRGB(239, 226, 173)); skins.push_back(deSkinRGB(224, 210, 147)); skins.push_back(deSkinRGB(242, 226, 151)); skins.push_back(deSkinRGB(235, 214, 159)); skins.push_back(deSkinRGB(235, 217, 133)); skins.push_back(deSkinRGB(227, 196, 103)); skins.push_back(deSkinRGB(225, 193, 106)); skins.push_back(deSkinRGB(223, 193, 123)); skins.push_back(deSkinRGB(222, 184, 119)); skins.push_back(deSkinRGB(199, 164, 100)); skins.push_back(deSkinRGB(188, 151, 98)); skins.push_back(deSkinRGB(155, 107, 67)); skins.push_back(deSkinRGB(142, 88, 62)); skins.push_back(deSkinRGB(121, 77, 48)); skins.push_back(deSkinRGB(100, 49, 22)); skins.push_back(deSkinRGB(101, 48, 32)); skins.push_back(deSkinRGB(96, 49, 33)); skins.push_back(deSkinRGB(87, 50, 41)); skins.push_back(deSkinRGB(64, 32, 21)); skins.push_back(deSkinRGB(49, 37, 41)); skins.push_back(deSkinRGB(27, 28, 27)); } void getSkinRanges(std::vector& ranges) { deSkinRange t1; t1.first = 1; t1.last = 5; t1.description = "Very light or \"white\" type"; ranges.push_back(t1); deSkinRange t2; t2.first = 6; t2.last = 10; t2.description = "Light"; ranges.push_back(t2); deSkinRange t3; t3.first = 11; t3.last = 15; t3.description = "Light intermediate"; ranges.push_back(t3); deSkinRange t4; t4.first = 16; t4.last = 21; t4.description = "Dark intermediate"; ranges.push_back(t4); deSkinRange t5; t5.first = 22; t5.last = 28; t5.description = "Dark or \"brown\" type"; ranges.push_back(t5); deSkinRange t6; t6.first = 29; t6.last = 36; t6.description = "Very dark or \"black\" type"; ranges.push_back(t6); } delaboratory-0.8/core/color_space.cc0000644000175100001440000000140111764477311016604 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "color_space.h" delaboratory-0.8/core/power.h0000644000175100001440000000202411764477311015313 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_POWER_H #define _DE_POWER_H #define POWER_CACHE_SIZE 65536 class dePower { private: double power; double values[POWER_CACHE_SIZE]; double scale; public: dePower(double _power, int s); ~dePower(); double get(double v); }; #endif delaboratory-0.8/core/copy_channel.cc0000644000175100001440000000167011764477311016765 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "copy_channel.h" #include void copyChannel(const deValue* src, deValue* dst, int n) { int i; for (i = 0; i < n; i++) { deValue v = src[i]; dst[i] = v; } } delaboratory-0.8/core/conversion_processor.h0000644000175100001440000000250111777136356020450 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CONVERSION_PROCESSOR_H #define _DE_CONVERSION_PROCESSOR_H #include "conversion_cpu.h" class deConversionProcessor { private: public: deConversionProcessor(); virtual ~deConversionProcessor(); void convertImage(const deImage& sourceImage, deImage& image, deConversionCPU& cpu); bool renderImageToRGBNew(const deImage& image, unsigned char* data); bool convert(deColorSpace sourceColorSpace, deValue v1, deValue v2, deValue v3, deValue v4, deColorSpace targetColorSpace, deValue &r1, deValue& r2, deValue& r3, deValue& r4); }; #endif delaboratory-0.8/core/base_layer_with_source.h0000644000175100001440000000314011774674304020702 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BASE_LAYER_WITH_SOURCE_H #define _DE_BASE_LAYER_WITH_SOURCE_H #include "base_layer_with_properties.h" class deLayerStack; class deBaseLayerWithSource:public deBaseLayerWithProperties { private: int sourceLayerIndex; deLayerStack& layerStack; const deBaseLayer& getSourceLayer() const; const deBaseLayer& getOriginalLayer() const; protected: void copySourceChannel(int channel); public: deBaseLayerWithSource(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deBaseLayerWithSource(); const deImage& getOriginalImage() const; const deImage& getSourceImage() const; const deImage& getOtherLayerImage(int a) const; deColorSpace getSourceColorSpace() const; int getLayerStackSize() const; }; #endif delaboratory-0.8/core/layer_factory.h0000644000175100001440000000251111764477311017023 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_FACTORY_H #define _DE_LAYER_FACTORY_H class deLayer; class deBaseLayer; #include #include #include "color_space.h" class deLayerStack; class deLayerProcessor; class deChannelManager; class deViewManager; class deImage; class deStaticImage; deBaseLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, deStaticImage& sourceImage); void getSupportedActions(std::vector& actions); std::string getActionDescription(const std::string& a); #endif delaboratory-0.8/core/skin_color_chart.h0000644000175100001440000000253511765506775017521 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SKIN_COLOR_CHART_H #define _DE_SKIN_COLOR_CHART_H #include "value.h" #include #include struct deSkinCMYK { deValue c; deValue m; deValue y; deValue k; deSkinCMYK(int _c, int _m, int _y, int _k) :c(_c), m(_m), y(_y), k(_k) { } }; struct deSkinRGB { int r; int g; int b; deSkinRGB(int _r, int _g, int _b) :r(_r), g(_g), b(_b) { } }; struct deSkinRange { int first; int last; std::string description; }; void getFelixVonLuschan(std::vector& skins); void getSkinRanges(std::vector& ranges); #endif delaboratory-0.8/core/sampler.cc0000644000175100001440000000251411764477311015764 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "sampler.h" deSampler::deSampler() { x = -1; y = -1; colorSpace = deColorSpaceCMYK; enabled = false; selected = false; } deSampler::~deSampler() { } void deSampler::setPosition(deValue _x, deValue _y) { x = _x; y = _y; } void deSampler::setColorSpace(deColorSpace c) { colorSpace = c; } bool deSampler::isEnabled() const { return enabled; } void deSampler::enable() { enabled = true; } void deSampler::disable() { enabled = false; } bool deSampler::isSelected() const { return selected; } void deSampler::setSelected(bool s) { selected = s; } delaboratory-0.8/core/sampler_manager.cc0000644000175100001440000000643211777136356017466 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "sampler_manager.h" #include "layer_processor.h" #include deSamplerManager::deSamplerManager() { size = 5; int i; for (i = 0; i < size; i++) { deSampler s; samplers.push_back(s); } selected = -1; moving = false; } deSamplerManager::~deSamplerManager() { } deSampler* deSamplerManager::getSampler(int index) { if ((index < 0) || ((unsigned int)index >= samplers.size())) { return NULL; } return &(samplers[index]); } bool deSamplerManager::select(deValue x, deValue y) { int i; for (i = 0; i < size; i++) { deSampler& s = samplers[i]; s.setSelected(false); } for (i = 0; i < size; i++) { deSampler& s = samplers[i]; if (s.isEnabled()) { deValue dx = s.getX() - x; deValue dy = s.getY() - y; deValue r = sqrt(dx*dx + dy*dy); if (r < 0.01) { selected = i; s.setSelected(true); return true; } } } for (i = 0; i < size; i++) { deSampler& s = samplers[i]; if (!s.isEnabled()) { s.enable(); selected = i; s.setSelected(true); return true; } } return false; } bool deSamplerManager::onClick(deValue x, deValue y) { if (!moving) { return false; } if (select(x,y)) { deSampler& s = samplers[selected]; s.setPosition(x, y); return true; } return false; } bool deSamplerManager::onMove(deValue x, deValue y) { if (!moving) { return false; } if (selected >= 0) { deSampler& s = samplers[selected]; if ((x < -0.01) || (y < -0.01) || (x>1.01) || (y>1.01)) { s.disable(); selected = -1; s.setSelected(false); } else { s.setPosition(x, y); } return true; } return false; } bool deSamplerManager::onRelease() { int i; for (i = 0; i < size; i++) { deSampler& s = samplers[i]; s.setSelected(false); } selected = -1; return true; } void deSamplerManager::setMoving(bool m) { moving = m; } bool deSamplerManager::getMoving() const { return moving; } void deSamplerManager::clear() { std::vector::iterator i; for (i = samplers.begin(); i != samplers.end(); i++) { (*i).disable(); } } delaboratory-0.8/core/color_matrix.cc0000644000175100001440000001244711777136356017036 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "color_matrix.h" #include #include deColorMatrix::deColorMatrix(int _w, int _h) { width = _w; height = _h; minX = 0; minY = 0; maxX = 1; maxY = 1; int n = width * height; matrix = new deValue [n]; density = new int [n]; } deColorMatrix::~deColorMatrix() { delete [] matrix; delete [] density; } void deColorMatrix::clear() { int n = width * height; int i; for (i = 0; i < n; i++) { matrix[i] = -1; density[i] = 0; } } void deColorMatrix::buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min) { minX = 0; minY = 0; maxX = 1; maxY = 1; clear(); build(channelH, channelV, channelA, n); int xx; int yy; int minxx = width; int maxxx = -1; int minyy = height; int maxyy = -1; for (xx = 0; xx < width; xx++) { for (yy = 0; yy < height; yy++) { int pos = width * yy + xx; if (density[pos] >= min) { if (xx < minxx) { minxx = xx; } if (yy < minyy) { minyy = yy; } if (xx > maxxx) { maxxx = xx; } if (yy > maxyy) { maxyy = yy; } } } } if (minxx > 0) { minxx--; } if (minyy > 0) { minyy--; } if (maxxx < width - 1) { maxxx++; } if (maxyy < height - 1) { maxyy++; } minX = (deValue) minxx / width; minY = (deValue) minyy / height; maxX = (deValue) maxxx / width; maxY = (deValue) maxyy / height; deValue margin = -0.01; if (maxX < 0.5 - margin) { maxX = 0.5 - margin; } if (maxY < 0.5 - margin) { maxY = 0.5 - margin; } if (minX > 0.5 + margin) { minX = 0.5 + margin; } if (minY > 0.5 + margin) { minY = 0.5 + margin; } clear(); build(channelH, channelV, channelA, n); } void deColorMatrix::build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n) { if (!channelH) { return; } if (!channelV) { return; } if (!channelA) { return; } int i; for (i = 0; i < n; i++) { deValue h = channelH[i]; deValue v = channelV[i]; deValue a = channelA[i]; if ((h >= 0) && (h < 1) && (v >= 0) && (v < 1) && ((a >= 0) && (a < 1))) { int x = (h - minX) / (maxX - minX) * width; int y = (v - minY) / (maxY - minY) * height; if ((x >= 0) && (y >= 0) && (x < width) && (y < height)) { int pos = width * y + x; int d = density[pos]; if (d == 0) { density[pos] = 1; matrix[pos] = a; } else { density[pos]++; matrix[pos] += a; } } } } int nn = width * height; for (i = 0; i < nn; i++) { int d = density[i]; if (d > 0) { matrix[i] /= d; } } } deValue deColorMatrix::get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const { vx = minX + ((deValue) x / width) * (maxX - minX); deValue vx2 = minX + ((deValue) (x+1) / width) * (maxX - minX); deValue vx3 = minX + ((deValue) (x-1) / width) * (maxX - minX); deValue dx = fabs(0.5 - vx); deValue dx2 = fabs(0.5 - vx2); deValue dx3 = fabs(0.5 - vx3); vy = minY + ((deValue) y / height) * (maxY - minY); deValue vy2 = minY + ((deValue) (y+1) / height) * (maxY - minY); deValue vy3 = minY + ((deValue) (y-1) / height) * (maxY - minY); deValue dy = fabs(0.5 - vy); deValue dy2 = fabs(0.5 - vy2); deValue dy3 = fabs(0.5 - vy3); center = false; if ((dx < dx2) && (dx < dx3)) { center = true; } if ((dy < dy2) && (dy < dy3)) { center = true; } if (x < 0) { return -1; } if (y < 0) { return -1; } if (x >= width) { return -1; } if (y >= height) { return -1; } int pos = width * y + x; if (density[pos] < min) { return -1; } deValue result = matrix[pos]; return result; } delaboratory-0.8/core/preset.h0000644000175100001440000000273711764477311015474 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PRESET_H #define _DE_PRESET_H #include #include "value.h" #include "base_layer_with_properties.h" class dePreset { private: dePreset(const dePreset&); dePreset& operator =(const dePreset&); std::map numericValues; std::vector operations; protected: const std::string name; public: dePreset(const std::string& _name) :name(_name) { } virtual ~dePreset() { } std::string getName() {return name;}; void apply(deBaseLayerWithProperties& layer) const; void addNumericValue(const std::string& n, deValue v); void addOperation(const std::string& n); }; #endif delaboratory-0.8/core/channel_manager.h0000644000175100001440000000353211766762751017275 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CHANNEL_MANAGER_H #define _DE_CHANNEL_MANAGER_H #include "size.h" #include #include #include "mutex.h" #include "mutex_read_write.h" class deImage; class deLogger; class deChannelManager { private: deSize channelSize; deMutex mutex; std::vector channels; std::vector mutexes; std::set trashed; deChannelManager(const deChannelManager& m); deChannelManager& operator =(const deChannelManager& m); public: deChannelManager(); virtual ~deChannelManager(); void setChannelSize(const deSize& size, bool reallocate); deSize getChannelSizeFromChannelManager() const; int reserveNewChannel(); void freeChannel(int index); void tryAllocateChannel(int index); void tryDeallocateChannel(int index); bool isImageEmpty() const; const deValue* startRead(int index); void finishRead(int index); deValue* startWrite(int index); void finishWrite(int index); void lock(); void unlock(); }; #endif delaboratory-0.8/core/flatten_layers.cc0000644000175100001440000000673611767175713017353 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "flatten_layers.h" #include "progress_dialog.h" #include "logger.h" #include "layer_stack.h" #include "base_layer.h" #include "channel_manager.h" #include "image_io.h" #include "str.h" #include bool flattenLayers(int view, deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, deLayerStack& layerStack, deChannelManager& previewChannelManager) { bool result = true; logInfo("flattenLayers"); std::map channelUsage; int i; int n = layerStack.getSize(); for (i = 0; i < n; i++) { const deBaseLayer* layer = layerStack.startReadLayer(i); layer->updateChannelUsage(channelUsage, i); layerStack.finishReadLayer(i); } unsigned int index; int progress = 0; for (index = 0; index <= (unsigned int)view; index++) { logInfo("flattenLayers index: " + str(index)); std::map::iterator i; int previous = index - 1; if (previous >= 0) { for (i = channelUsage.begin(); i != channelUsage.end(); i++) { int c = i->first; int l = i->second; if (l == previous) { logInfo("deallocate " + str(c)); previewChannelManager.tryDeallocateChannel(c); } } } deBaseLayer* layer = layerStack.getLayer(index); std::string label = str(index); progressDialog.update(progress, label); layer->allocateChannels(); logInfo("flattenLayers process index: " + str(index)); bool r = layer->processFull(); if (r) { if (saveAll) { const deImage& image = layer->getLayerImage(); const std::string f = insertIndex(fileName, index); saveImage(f, image, type, previewChannelManager); } } else { logError("flattenLayers - error on layer " + str(index)); result = false; // stop loop index = view + 1; } if (view > 0) { progress = 100 * index / view; } else { progress = 100; } progressDialog.update(progress, label); } progressDialog.update(100, "finished"); if ((result) && (!saveAll)) { logInfo("flattenLayers save final image"); // take the final image deBaseLayer* layer = layerStack.getLayer(view); const deImage& image = layer->getLayerImage(); // save it result = saveImage(fileName, image, type, previewChannelManager); } logInfo("flattenLayers DONE"); return result; } delaboratory-0.8/core/copy_channel.h0000644000175100001440000000156511764477311016632 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COPY_CHANNEL_H #define _DE_COPY_CHANNEL_H #include "value.h" void copyChannel(const deValue* src, deValue* dst, int n); #endif delaboratory-0.8/core/static_image.cc0000644000175100001440000001105412004112446016730 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "static_image.h" #include "logger.h" #include "color_space_utils.h" #include "str.h" #include "copy_channel.h" #include "scale_channel.h" deStaticImage::deStaticImage() :colorSpace(deColorSpaceInvalid), size(0,0) { lastRotate = -1; int n = 3; int i; for (i = 0; i < n; i++) { channels.push_back(NULL); mutexes.push_back(new deMutexReadWrite(4)); } } void deStaticImage::setColorSpace(deColorSpace c) { if (getColorSpaceSize(c) == 3) { colorSpace = c; } } deStaticImage::~deStaticImage() { unsigned int i; for (i = 0; i < channels.size(); i++) { if (channels[i]) { delete [] channels[i]; } delete mutexes[i]; } } deColorSpace deStaticImage::getColorSpace() const { return colorSpace; } void deStaticImage::setSize(const deSize& _size) { if (size == _size) { return; } size = _size; logInfo("static image set size " + str(size.getW()) + "x" + str(size.getH())); int n = 3; int i; for (i = 0; i < n; i++) { if (channels[i]) { delete [] channels[i]; } channels[i] = new deValue[size.getN()]; } } void deStaticImage::lock() { mutex.lock(); } void deStaticImage::unlock() { mutex.unlock(); } const deValue* deStaticImage::startReadStatic(int index) { int n = 3; if (index < 0) { logError("deStaticImage::startReadStatic index: " + str(index)); return NULL; } if (index >= n) { logError("deStaticImage::startReadStatic index: " + str(index)); return NULL; } mutexes[index]->lockRead(); return channels[index]; } deValue* deStaticImage::startWriteStatic(int index) { int n = 3; if (index < 0) { logError("deStaticImage::startWriteStatic index: " + str(index)); return NULL; } if (index >= n) { logError("deStaticImage::startWriteStatic index: " + str(index)); return NULL; } mutexes[index]->lockWrite(); return channels[index]; } void deStaticImage::finishReadStatic(int index) { int n = 3; if (index < 0) { logError("deStaticImage::finishReadStatic index: " + str(index)); return; } if (index >= n) { logError("deStaticImage::finishReadStatic index: " + str(index)); return; } mutexes[index]->unlockRead(); } void deStaticImage::finishWriteStatic(int index) { int n = 3; if (index < 0) { logError("deStaticImage::finishWriteStatic index: " + str(index)); return; } if (index >= n) { logError("deStaticImage::finishWriteStatic index: " + str(index)); return; } mutexes[index]->unlockWrite(); } bool deStaticImage::isEmpty() const { return size.isEmpty(); } void deStaticImage::copyToChannel(int channel, deValue* destination, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, deSize ds, bool mirrorX, bool mirrorY, int rotate, deValue contrast) { lastRotate = rotate; int w = ds.getW(); int h = ds.getH(); if (w <= 0) { logError("can't copy static image w: " + str(w)); return; } if (h <= 0) { logError("can't copy static image h: " + str(h)); return; } const deValue* source = startReadStatic(channel); int ws = size.getW(); int hs = size.getH(); scaleChannel(source, destination, z_x1, z_y1, z_x2, z_y2, w, h, mirrorX, mirrorY, rotate, ws, hs, contrast); finishReadStatic(channel); } deSize deStaticImage::getStaticImageSize() const { if ((lastRotate == 90) || (lastRotate==270)) { return size.rotated(); } else { return size; } } deValue deStaticImage::getAspect() const { deValue aspect = size.getAspect(); return aspect; } delaboratory-0.8/core/layer_frame.h0000644000175100001440000000260311766762751016457 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_FRAME_H #define _DE_LAYER_FRAME_H #include "frame.h" #include "value.h" class deActionLayer; class deBaseLayer; class deLayerFrameManager; class deLayerFrame:public deFrame { protected: deBaseLayer& layer; deLayerFrameManager& frameManager; int index; public: deLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerFrameManager& _frameManager, int _index); virtual ~deLayerFrame(); virtual void setUIFromLayer() = 0; virtual bool onImageClick(deValue x, deValue y) {return false;}; virtual bool onKey(int key) {return false;}; }; #endif delaboratory-0.8/core/size.h0000644000175100001440000000253711764477311015142 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SIZE_H #define _DE_SIZE_H #include #include "value.h" class deSize { private: int w; int h; public: deSize(int _w, int _h); virtual ~deSize(); deSize rotated() const; int getW() const {return w;}; int getH() const {return h;}; int getN() const {return w*h;}; float getAspect() const; std::string str() const; bool isEmpty() const; }; bool operator ==(const deSize& a, const deSize& b); bool operator !=(const deSize& a, const deSize& b); deSize fitInside(const deSize& area, deValue aspect); #endif delaboratory-0.8/core/value.cc0000644000175100001440000000156111764477311015436 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "value.h" void clip(deValue& v) { if (v < 0) { v = 0; } else if (v > 1) { v = 1; } } delaboratory-0.8/core/color_matrix.h0000644000175100001440000000266311765506775016702 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COLOR_MATRIX_H #define _DE_COLOR_MATRIX_H #include "value.h" class deColorMatrix { private: int width; int height; deValue minX; deValue minY; deValue maxX; deValue maxY; deValue* matrix; int* density; public: deColorMatrix(int _w, int _h); virtual ~deColorMatrix(); void clear(); void build(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n); void buildZoomed(const deValue* channelH, const deValue* channelV, const deValue* channelA, int n, int min); deValue get(int x, int y, int min, deValue& vx, deValue& vy, bool& center) const; }; #endif delaboratory-0.8/core/view_manager.h0000644000175100001440000000332711764477311016632 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PREVIEW_MANAGER_H #define _DE_PREVIEW_MANAGER_H class deProject; class deLayerProcessor; class deZoomManager; #include "color_space.h" #include "value.h" class deViewManager { private: int view; deProject& project; deLayerProcessor& layerProcessor; deZoomManager& zoomManager; bool single; int channel; public: deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager); virtual ~deViewManager(); void setView(int v); int getView() const; void setSingleChannel(int _channel); void setNormal(); deColorSpace getColorSpace() const; bool isSingleChannel() const {return single;}; int getChannel() const {return channel;}; void setHistogramChannel(int channel); deValue getRealScale() const; void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); void setLastView(); }; #endif delaboratory-0.8/core/palette.cc0000644000175100001440000001026311765506775015767 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "palette.h" dePalette3::dePalette3(deColorSpace _colorSpace) :colorSpace(_colorSpace) { } dePalette3::~dePalette3() { } void dePalette3::addColor(const deColor4& color) { colors.push_back(color); } void dePalette3::optimize(const dePalette3& source, int n, deValue margin) { int ss = source.colors.size(); deValue** distances = new deValue * [ss]; int i; int j; for (i = 0; i < ss; i++) { distances[i] = new deValue [ss]; for (j = 0; j < ss; j++) { deValue d = 0; if (i != j) { d = source.colors[i].calcDistance(source.colors[j]); } distances[i][j] = d; } } bool no_more = false; while ((colors.size() < (unsigned int)n) && (!no_more)) { int winner = -1; int max = 0; for (i = 0; i < ss; i++) { int counter = 0; for (j = 0; j < ss; j++) { deValue d = distances[i][j]; if (d != 0) { if ( d < margin ) { counter++; } } } if (counter > max) { winner = i; max = counter; } } if (winner >= 0) { colors.push_back(source.colors[winner]); for (i = 0; i < ss; i++) { deValue d = distances[winner][i]; if (d != 0) { if ( d < margin ) { for (j = 0; j < ss; j++) { distances[i][j] = 0; distances[j][i] = 0; } } } } } else { no_more = true; } } for (i = 0; i < ss; i++) { delete [] distances[i]; } delete [] distances; } deColor4 dePalette3::getColor(int index) { return colors[index]; } void dePalette3::getMinMax(int index, deValue& min, deValue& max) { int n = colors.size(); int i; min = -1; max = -1; for (i = 0; i < n; i++) { deColor4& color = colors[i]; deValue v; switch (index) { case 1: v = color.getV1(); break; case 2: v = color.getV2(); break; case 3: v = color.getV3(); break; default: break; } if (min < 0) { min = v; max = v; } else { if (v < min) { min = v; } if (v > max) { max = v; } } } } bool dePalette3::find23(deValue minA, deValue maxA, deValue minB, deValue maxB, deValue& resultL) { int n = colors.size(); int i; deValue sum = 0.0; int found = 0; for (i = 0; i < n; i++) { deColor4& color = colors[i]; deValue L = color.getV1(); deValue A = color.getV2(); deValue B = color.getV3(); if ((A >= minA) && (A < maxA) && (B >= minB) && (B < maxB)) { sum += L; found++; } } resultL = sum / found; return (found > 0); } delaboratory-0.8/core/layer_frame.cc0000644000175100001440000000234511766762751016620 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_frame.h" #include "layer_frame_manager.h" #include "logger.h" #include "str.h" deLayerFrame::deLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerFrameManager& _frameManager, int _index) :deFrame(parent, name), layer(_layer), frameManager(_frameManager), index(_index) { frameManager.addLayerFrame(index, this); } deLayerFrame::~deLayerFrame() { logInfo(" ~deLayerFrame"); frameManager.removeLayerFrame(index); logInfo(" ~deLayerFrame DONE"); } delaboratory-0.8/core/base_layer_with_properties.cc0000644000175100001440000001335511777136356021750 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "base_layer_with_properties.h" #include "color_space_utils.h" #include "logger.h" #include "semaphore.h" #include "str.h" #include "property_numeric.h" #include "property_boolean.h" #include "property_choice.h" #include "preset.h" deBaseLayerWithProperties::deBaseLayerWithProperties(deColorSpace _colorSpace, deChannelManager& _channelManager) :deBaseLayer(_colorSpace, _channelManager) { } deBaseLayerWithProperties::~deBaseLayerWithProperties() { std::vector::iterator i; while (properties.size() > 0) { i = properties.begin(); delete *i; properties.erase(i); } std::vector::iterator j; while (presets.size() > 0) { j = presets.begin(); delete *j; presets.erase(j); } } void deBaseLayerWithProperties::createPropertyNumeric(const std::string& _name, deValue _min, deValue _max) { std::vector::iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; if (property->getName() == _name) { return; } } properties.push_back(new dePropertyNumeric(_name, _min, _max)); } void deBaseLayerWithProperties::createPropertyChoice(const std::string& _name, const std::vector& _choices) { std::vector::iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; if (property->getName() == _name) { return; } } properties.push_back(new dePropertyChoice(_name, _choices)); } void deBaseLayerWithProperties::createPropertyBoolean(const std::string& _name) { std::vector::iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; if (property->getName() == _name) { return; } } properties.push_back(new dePropertyBoolean(_name)); } deProperty* deBaseLayerWithProperties::getProperty(const std::string& _name) { std::vector::iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; if (property->getName() == _name) { return property; } } logError("property " + _name + " not found"); return NULL; } const deProperty* deBaseLayerWithProperties::getProperty(const std::string& _name) const { std::vector::const_iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; if (property->getName() == _name) { return property; } } return NULL; } void deBaseLayerWithProperties::getProperties(std::vector& names) const { std::vector::const_iterator i; for (i = properties.begin(); i != properties.end(); i++) { deProperty* property = *i; names.push_back(property->getName()); } } dePropertyNumeric* deBaseLayerWithProperties::getPropertyNumeric(const std::string& _name) { return dynamic_cast(getProperty(_name)); } const dePropertyNumeric* deBaseLayerWithProperties::getPropertyNumeric(const std::string& _name) const { return dynamic_cast(getProperty(_name)); } dePropertyChoice* deBaseLayerWithProperties::getPropertyChoice(const std::string& _name) { return dynamic_cast(getProperty(_name)); } const dePropertyChoice* deBaseLayerWithProperties::getPropertyChoice(const std::string& _name) const { return dynamic_cast(getProperty(_name)); } dePropertyBoolean* deBaseLayerWithProperties::getPropertyBoolean(const std::string& _name) { return dynamic_cast(getProperty(_name)); } const dePropertyBoolean* deBaseLayerWithProperties::getPropertyBoolean(const std::string& _name) const { return dynamic_cast(getProperty(_name)); } deValue deBaseLayerWithProperties::getNumericValue(const std::string& name) const { const dePropertyNumeric* p = getPropertyNumeric(name); if (p) { return p->get(); } return 0; } void deBaseLayerWithProperties::applyPreset(const std::string& name) { std::vector::iterator i; for (i = presets.begin(); i != presets.end(); i++) { dePreset* preset = *i; if (preset->getName() == name) { preset->apply(*this); } } } void deBaseLayerWithProperties::getPresets(std::vector& names) { std::vector::iterator i; for (i = presets.begin(); i != presets.end(); i++) { dePreset* preset = *i; if (preset) { names.push_back(preset->getName()); } else { logError("NULL preset found"); } } } dePreset* deBaseLayerWithProperties::createPreset(const std::string& name) { dePreset* preset = new dePreset(name); presets.push_back(preset); return preset; } delaboratory-0.8/core/switchable_layer.cc0000644000175100001440000000533012004107775017631 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "switchable_layer.h" #include "color_space_utils.h" #include "property_boolean.h" deSwitchableLayer::deSwitchableLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) :deBaseLayerWithSource(_colorSpace, _channelManager, _sourceLayerIndex, _layerStack) { int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { std::string n = getChannelName(colorSpace, i); createPropertyBoolean(n); getPropertyBoolean(n)->setSizer("channels"); getPropertyBoolean(n)->setBlendOnly(); enableChannel(i); } } deSwitchableLayer::~deSwitchableLayer() { } void deSwitchableLayer::disableNotLuminance() { int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { if (!isChannelLuminance(colorSpace, i)) { disableChannel(i); } } } void deSwitchableLayer::disableNotForSharpen() { int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { if (!shouldChannelBeSharpened(colorSpace, i)) { disableChannel(i); } } } void deSwitchableLayer::disableAll() { int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { disableChannel(i); } } bool deSwitchableLayer::isChannelEnabled(int index) const { std::string n = getChannelName(colorSpace, index); const dePropertyBoolean* p = getPropertyBoolean(n); if (!p) { return false; } return p->get(); } void deSwitchableLayer::enableChannel(int index) { std::string n = getChannelName(colorSpace, index); dePropertyBoolean* p = getPropertyBoolean(n); if (p) { p->set(true); } } void deSwitchableLayer::disableChannel(int index) { std::string n = getChannelName(colorSpace, index); dePropertyBoolean* p = getPropertyBoolean(n); if (p) { p->set(false); } } delaboratory-0.8/core/sampler_manager.h0000644000175100001440000000311011777136356017316 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SAMPLER_MANAGER_H #define _DE_SAMPLER_MANAGER_H #include "sampler.h" #include class deSamplerManager { private: std::vector samplers; int selected; int size; bool moving; bool select(deValue x, deValue y); deSamplerManager(const deSamplerManager&); deSamplerManager& operator =(const deSamplerManager&); public: deSamplerManager(); virtual ~deSamplerManager(); int getNumberOfSamplers() const {return samplers.size();}; deSampler* getSampler(int index); bool onClick(deValue x, deValue y); bool onMove(deValue x, deValue y); bool onRelease(); int getSelected() const {return selected;}; void setMoving(bool m); bool getMoving() const; void clear(); }; #endif delaboratory-0.8/core/power.cc0000644000175100001440000000233011764477311015451 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "power.h" #include #include "logger.h" #include "str.h" dePower::dePower(double _power, int s) { power = _power; scale = (POWER_CACHE_SIZE - 1.0) / s; int i; for (i = 0; i < POWER_CACHE_SIZE; i++) { double p = i / scale; values[i] = pow(p, power); } } dePower::~dePower() { } double dePower::get(double v) { int i = v * scale; if ((i >= 0) && (i < POWER_CACHE_SIZE)) return values[i]; return pow(v, power); } delaboratory-0.8/core/operation_processor.cc0000644000175100001440000001513711777136356020432 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "operation_processor.h" #include "layer_processor.h" #include "logger.h" #include "project.h" #include "layer_stack.h" #include "base_layer_with_properties.h" #include "color_space_utils.h" deOperationProcessor::deOperationProcessor(deLayerProcessor& _layerProcessor, deProject& _project) :layerProcessor(_layerProcessor), project(_project) { } deOperationProcessor::~deOperationProcessor() { } void deOperationProcessor::addNewLayerOnTop(deBaseLayer* layer) { logInfo("before add new layer on top"); layerProcessor.addLayerInLayerProcessor(layer); logInfo("after add new layer on top"); } void deOperationProcessor::removeTopLayer() { logInfo("before remove top layer"); layerProcessor.removeTopLayerInLayerProcessor(); logInfo("after remove top layer"); } void deOperationProcessor::execute(const std::string& operation) { if (operation == "remove") { removeTopLayer(); project.onRemoveTopLayer(); return; } bool ok = false; if (tryExecuteBasicOperation(operation)) { ok = true; } else { deBaseLayer* layer = project.createNewLayer(operation); if (layer) { addNewLayerOnTop(layer); ok = true; } } if (ok) { project.onAddNewLayer(); } } void deOperationProcessor::initProfile(const std::string& profile) { if (profile == "cmyk_auto_levels") { execute("CMYK"); execute("levels"); } if (profile == "bw") { execute("BW"); } if (profile == "c2g") { execute("c2g"); } if (profile == "vignette") { execute("LAB"); execute("vignette"); } } bool deOperationProcessor::executeOperation(deColorSpace colorSpace, const std::string& operation) { deViewManager& viewManager = project.getViewManager(); viewManager.setLastView(); deColorSpace currentColorSpace = viewManager.getColorSpace(); if (colorSpace != currentColorSpace) { deBaseLayer* layer1 = project.createNewLayer(getColorSpaceName(colorSpace)); if (layer1) { addNewLayerOnTop(layer1); viewManager.setLastView(); } else { return false; } } deBaseLayer* layer2 = project.createNewLayer(operation); if (layer2) { addNewLayerOnTop(layer2); viewManager.setLastView(); } else { return false; } project.openLayerFrame(project.getLayerStack().getSize() - 1); return true; } bool deOperationProcessor::tryExecuteBasicOperation(const std::string& operation) { if (operation == "CMYK curves") { return executeOperation(deColorSpaceCMYK, "curves"); } if (operation == "CMYK levels") { return executeOperation(deColorSpaceCMYK, "levels"); } if (operation == "LAB vignette") { return executeOperation(deColorSpaceLAB, "vignette"); } if (operation == "LAB local contrast") { return executeOperation(deColorSpaceLAB, "local_contrast"); } if (operation == "BW local contrast") { return executeOperation(deColorSpaceBW, "local_contrast"); } if (operation == "RGB curves") { return executeOperation(deColorSpaceRGB, "curves"); } if (operation == "RGB levels") { return executeOperation(deColorSpaceRGB, "levels"); } if (operation == "LAB curves") { return executeOperation(deColorSpaceLAB, "curves"); } if (operation == "BW curve") { return executeOperation(deColorSpaceBW, "curves"); } if (operation == "BW vignette") { return executeOperation(deColorSpaceBW, "vignette"); } if (operation == "RGB tone") { return executeOperation(deColorSpaceRGB, "tone"); } if (operation == "RGB shadows") { return executeOperation(deColorSpaceRGB, "recover_shadows"); } if (operation == "RGB highlights") { return executeOperation(deColorSpaceRGB, "recover_highlights"); } if (operation == "BW gradient") { return executeOperation(deColorSpaceBW, "gradient"); } if (operation == "RGB gradient") { return executeOperation(deColorSpaceRGB, "gradient"); } if (operation == "CMYK gradient") { return executeOperation(deColorSpaceCMYK, "gradient"); } if (operation == "LAB gradient") { return executeOperation(deColorSpaceLAB, "gradient"); } if (operation == "LAB wb") { return executeOperation(deColorSpaceLAB, "white_balance"); } if (operation == "LAB saturation") { return executeOperation(deColorSpaceLAB, "saturation"); } if (operation == "HSV equalizer") { return executeOperation(deColorSpaceHSV, "equalizer"); } if (operation == "LCH equalizer") { return executeOperation(deColorSpaceLCH, "equalizer"); } return false; } void getSupportedColorsOperations(std::vector& actions) { actions.push_back("CMYK curves"); actions.push_back("CMYK levels"); actions.push_back("RGB curves"); actions.push_back("RGB levels"); actions.push_back("LAB wb"); actions.push_back("LAB saturation"); actions.push_back("LAB curves"); actions.push_back("BW curve"); actions.push_back("HSV equalizer"); actions.push_back("LCH equalizer"); } void getSupportedOtherOperations(std::vector& actions) { actions.push_back("RGB shadows"); actions.push_back("RGB highlights"); actions.push_back("LAB vignette"); actions.push_back("LAB local contrast"); actions.push_back("BW vignette"); actions.push_back("BW local contrast"); actions.push_back("LAB gradient"); actions.push_back("BW gradient"); actions.push_back("RGB gradient"); actions.push_back("CMYK gradient"); } delaboratory-0.8/core/layer_with_blending.cc0000644000175100001440000002051212004110361020301 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_with_blending.h" #include "channel_manager.h" #include "blend_channel.h" #include "color_space_utils.h" #include #include "str.h" #include "property_numeric.h" #include "property_boolean.h" #include "logger.h" #include "blend_color_luminosity.h" #include "update_blend.h" deLayerWithBlending::deLayerWithBlending(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayerIndex, deLayerStack& _layerStack) :deSwitchableLayer(_colorSpace, _channelManager, _sourceLayerIndex, _layerStack), imageBlendPass(_colorSpace, _channelManager) { createPropertyNumeric("opacity", 0, 1); createPropertyChoice("blend mode", getSupportedBlendModeNames(colorSpace)); dePropertyChoice* blendMode = getPropertyChoice("blend mode"); if (blendMode) { blendMode->setSizer("blend"); blendMode->setBlendOnly(); } createPropertyBoolean("invert"); getPropertyBoolean("invert")->setSizer("blend"); setBlendMode(deBlendNormal); deProperty* p = getPropertyNumeric("opacity"); if (p) { p->setBlendOnly(); } setOpacity(1.0); } deLayerWithBlending::~deLayerWithBlending() { } deValue deLayerWithBlending::getOpacity() const { return getNumericValue("opacity"); } void deLayerWithBlending::setOpacity(deValue _opacity) { dePropertyNumeric* p = getPropertyNumeric("opacity"); if (p) { p->set(_opacity); } } void deLayerWithBlending::setBlendMode(deBlendMode mode) { dePropertyChoice* blendMode = getPropertyChoice("blend mode"); if (blendMode) { blendMode->set(getBlendModeName(mode)); } } bool deLayerWithBlending::updateBlend(int i) { #ifdef DEBUG_LOG logInfo("update blend " + str(i) + " START"); #endif const deValue* source = getSourceImage().startRead(i); const deValue* overlay = mainLayerImage.startRead(i); deValue* destination = imageBlendPass.startWrite(i); deValue* maskPixels = NULL; int channelSize = mainLayerImage.getChannelSize().getN(); deValue o = getOpacity(); if (!isChannelEnabled(i)) { o = 0.0; } dePropertyBoolean* pinv = getPropertyBoolean("invert"); bool inverted = false; if (pinv) { inverted = pinv->get(); } if (inverted) { blendChannel(overlay, source, destination, maskPixels, getBlendMode(), o, channelSize); } else { blendChannel(source, overlay, destination, maskPixels, getBlendMode(), o, channelSize); } getSourceImage().finishRead(i); mainLayerImage.finishRead(i); imageBlendPass.finishWrite(i); #ifdef DEBUG_LOG logInfo("update blend " + str(i) + " DONE"); #endif return true; } const deImage& deLayerWithBlending::getLayerImage() const { return imageBlendPass; } void deLayerWithBlending::updateChannelUsage(std::map& channelUsage, int layerIndex) const { getSourceImage().updateChannelUsage(channelUsage, layerIndex); mainLayerImage.updateChannelUsage(channelUsage, layerIndex); imageBlendPass.updateChannelUsage(channelUsage, layerIndex); } bool deLayerWithBlending::updateBlendAllChannels() { if (tryBlendSpecial()) { return true; } updateBlendOnThread(*this); return true; } void deLayerWithBlending::processSingleChannel(int channel) { #ifdef DEBUG_LOG logInfo("layer with blending processs single channel " + str(channel)); #endif deBaseLayer::processSingleChannel(channel); if (!tryBlendSpecial()) { updateBlend(channel); } #ifdef DEBUG_LOG logInfo("layer with blending processs single channel DONE"); #endif } bool deLayerWithBlending::updateImage() { #ifdef DEBUG_LOG logInfo("layer with blending update image"); #endif bool result = deBaseLayer::updateImage(); if (result) { result = updateBlendAllChannels(); } #ifdef DEBUG_LOG logInfo("layer with blending update image DONE"); #endif return result; } deBlendMode deLayerWithBlending::getBlendMode() const { const dePropertyChoice* blendMode = getPropertyChoice("blend mode"); std::string m = blendMode->get(); deBlendMode mode = blendModeFromString(m); return mode; } void deLayerWithBlending::blendSpecial() { #ifdef DEBUG_LOG logInfo("blend special START"); #endif deBlendMode mode = getBlendMode(); int cs = getColorSpaceSize(colorSpace); const deValue* source0 = getSourceImage().startRead(0); const deValue* source1 = getSourceImage().startRead(1); const deValue* source2 = getSourceImage().startRead(2); const deValue* source3 = NULL; if (cs == 4) { source3 = getSourceImage().startRead(3); } const deValue* overlay0 = mainLayerImage.startRead(0); const deValue* overlay1 = mainLayerImage.startRead(1); const deValue* overlay2 = mainLayerImage.startRead(2); const deValue* overlay3 = NULL; if (cs == 4) { overlay3 = mainLayerImage.startRead(3); } deValue* destination0 = imageBlendPass.startWrite(0); deValue* destination1 = imageBlendPass.startWrite(1); deValue* destination2 = imageBlendPass.startWrite(2); deValue* destination3 = NULL; if (cs == 4) { destination3 = imageBlendPass.startWrite(3); } int n = mainLayerImage.getChannelSize().getN(); deValue o = getOpacity(); if (mode == deBlendColor) { if (colorSpace == deColorSpaceRGB) { blendColorRGB(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); } if (colorSpace == deColorSpaceProPhoto) { blendColorProPhoto(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); } if (colorSpace == deColorSpaceCMYK) { blendColorCMYK(source0, source1, source2, source3, overlay0, overlay1, overlay2, overlay3, destination0, destination1, destination2, destination3, n, o); } } if (mode == deBlendLuminosity) { if (colorSpace == deColorSpaceRGB) { blendLuminosityRGB(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); } if (colorSpace == deColorSpaceProPhoto) { blendLuminosityProPhoto(source0, source1, source2, overlay0, overlay1, overlay2, destination0, destination1, destination2, n, o); } if (colorSpace == deColorSpaceCMYK) { blendLuminosityCMYK(source0, source1, source2, source3, overlay0, overlay1, overlay2, overlay3, destination0, destination1, destination2, destination3, n, o); } } getSourceImage().finishRead(0); getSourceImage().finishRead(1); getSourceImage().finishRead(2); mainLayerImage.finishRead(0); mainLayerImage.finishRead(1); mainLayerImage.finishRead(2); imageBlendPass.finishWrite(0); imageBlendPass.finishWrite(1); imageBlendPass.finishWrite(2); if (cs == 4) { getSourceImage().finishRead(3); mainLayerImage.finishRead(3); imageBlendPass.finishWrite(3); } #ifdef DEBUG_LOG logInfo("blend special DONE"); #endif } bool deLayerWithBlending::tryBlendSpecial() { deBlendMode mode = getBlendMode(); if (mode == deBlendColor) { blendSpecial(); return true; } if (mode == deBlendLuminosity) { blendSpecial(); return true; } return false; } void deLayerWithBlending::allocateChannels() { deBaseLayer::allocateChannels(); imageBlendPass.allocateChannels(); } delaboratory-0.8/core/generic_layer_frame.h0000644000175100001440000000343111766762751020153 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GENERIC_LAYER_FRAME_H #define _DE_GENERIC_LAYER_FRAME_H #include "layer_frame.h" class deLayerProcessor; #include class dePropertyNumericUI; class dePropertyChoiceUI; class dePropertyBooleanUI; class dePropertyLevelsUI; class dePropertyCurvesUI; class dePropertyMixerUI; class deGenericLayerFrame:public deLayerFrame { protected: std::vector numerics; std::vector choices; std::vector booleans; std::vector levels; std::vector curves; std::vector mixers; deLayerProcessor& layerProcessor; public: deGenericLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager, int _index); virtual ~deGenericLayerFrame(); virtual void setUIFromLayer(); virtual bool onImageClick(deValue x, deValue y); virtual bool onKey(int key); }; #endif delaboratory-0.8/core/switchable_layer.h0000644000175100001440000000261511765775026017513 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SWITCHABLE_LAYER_H #define _DE_SWITCHABLE_LAYER_H #include "base_layer_with_source.h" #include class deSwitchableLayer:public deBaseLayerWithSource { protected: void disableAll(); void disableNotLuminance(); void disableNotForSharpen(); virtual bool isChannelNeutral(int index) {return false;}; public: deSwitchableLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deSwitchableLayer(); bool isChannelEnabled(int index) const; void enableChannel(int index); void disableChannel(int index); }; #endif delaboratory-0.8/core/zoom_manager.cc0000644000175100001440000000534311764477311017002 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "zoom_manager.h" #include "str.h" #include "logger.h" deZoomManager::deZoomManager() { selectionMode = false; fullZoomOut(); } deZoomManager::~deZoomManager() { } void deZoomManager::fullZoomOut() { z_x1 = 0; z_y1 = 0; z_x2 = 1; z_y2 = 1; } bool deZoomManager::isInSelectionMode() const { return selectionMode; } void deZoomManager::enableSelectionMode() { selectionMode = true; s_x1 = 0; s_x2 = 0; s_y1 = 0; s_y2 = 0; } bool deZoomManager::onClick(deValue x, deValue y) { s_x1 = x; s_x2 = x; s_y1 = y; s_y2 = y; return true; } bool deZoomManager::onMove(deValue x, deValue y) { if (x > 1) { x = 1; } if (y > 1) { y = 1; } if (x < s_x1) { x = s_x1; } if (y < s_y1) { y = s_y1; } s_x2 = x; s_y2 = y; return true; } bool deZoomManager::onRelease() { if ((s_x1 < s_x2) && (s_y1 < s_y2)) { deValue x1 = z_x1 + s_x1 * (z_x2 - z_x1); deValue x2 = z_x1 + s_x2 * (z_x2 - z_x1); deValue y1 = z_y1 + s_y1 * (z_y2 - z_y1); deValue y2 = z_y1 + s_y2 * (z_y2 - z_y1); z_x1 = x1; z_x2 = x2; z_y1 = y1; z_y2 = y2; logInfo("set zoom x1: " + str(z_x1) + " x2: " + str(z_x2) + " y1: " + str(z_y1) + " y2: " + str(z_y2)); } else { fullZoomOut(); } selectionMode = false; return true; } void deZoomManager::getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) { _x1 = s_x1; _y1 = s_y1; _x2 = s_x2; _y2 = s_y2; } void deZoomManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) { _x1 = z_x1; _y1 = z_y1; _x2 = z_x2; _y2 = z_y2; } bool deZoomManager::isZoomed() const { if (z_x1 > 0.0) { return true; } if (z_y1 > 0.0) { return true; } if (z_x2 < 1.0) { return true; } if (z_y2 < 1.0) { return true; } return false; } delaboratory-0.8/core/value.h0000644000175100001440000000150611764477311015277 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_VALUE_H #define _DE_VALUE_H #define deValue float void clip(deValue& v); #endif delaboratory-0.8/core/zoom_manager.h0000644000175100001440000000302411764477311016636 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_ZOOM_MANAGER_H #define _DE_ZOOM_MANAGER_H #include "value.h" class deZoomManager { private: bool selectionMode; deValue s_x1; deValue s_y1; deValue s_x2; deValue s_y2; deValue z_x1; deValue z_y1; deValue z_x2; deValue z_y2; public: deZoomManager(); virtual ~deZoomManager(); bool isInSelectionMode() const; void enableSelectionMode(); bool onClick(deValue x, deValue y); bool onMove(deValue x, deValue y); bool onRelease(); void getSelection(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); void getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2); void fullZoomOut(); bool isZoomed() const; }; #endif delaboratory-0.8/core/generic_layer_frame.cc0000644000175100001440000001776311766762751020326 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "generic_layer_frame.h" #include "base_layer.h" #include "base_layer_with_source.h" #include "property_numeric_ui.h" #include "property_choice_ui.h" #include "property_boolean_ui.h" #include "property_levels_ui.h" #include "property_curves_ui.h" #include "property_mixer_ui.h" #include "property_numeric.h" #include "property_levels.h" #include "property_curves.h" #include "property_mixer.h" #include "property_boolean.h" #include "property_choice.h" #include "preset_button.h" #include "layer_processor.h" deGenericLayerFrame::deGenericLayerFrame(deWindow& parent, const std::string& name, deBaseLayer& _layer, deLayerProcessor& _layerProcessor, deLayerFrameManager& _frameManager, int _index) :deLayerFrame(parent, name, _layer, _frameManager, _index), layerProcessor(_layerProcessor) { deBaseLayerWithProperties* layerWP = dynamic_cast(&layer); addSizer("channels"); addSizer("blend"); std::vector names; std::vector::iterator i; deWindow& window = getWindow(); names.clear(); if (layerWP) { layerWP->getProperties(names); } int width = 400; int widthn = 120; int widthl = 35; for (i = names.begin(); i != names.end(); i++) { std::string n = *i; deProperty* property = layerWP->getProperty(n); dePropertyNumeric* numeric = dynamic_cast(property); if (numeric) { dePropertyNumericUI* p = new dePropertyNumericUI(window, *numeric, _layerProcessor, _index, width - widthn - widthl, widthn, widthl); numerics.push_back(p); addWidget(p->getWindow()); } dePropertyChoice* choice = dynamic_cast(property); if (choice) { dePropertyChoiceUI* p = new dePropertyChoiceUI(window, *choice, _layerProcessor, _index, *this); choices.push_back(p); std::string s = property->getSizer(); if (s.size() > 0) { addWidget(s, p->getWindow()); } else { addWidget(p->getWindow()); } } dePropertyBoolean* boolean = dynamic_cast(property); if (boolean) { dePropertyBooleanUI* p = new dePropertyBooleanUI(window, *boolean, _layerProcessor, _index); booleans.push_back(p); std::string s = property->getSizer(); if (s.size() > 0) { addWidget(s, p->getWindow()); } else { addWidget(p->getWindow()); } } dePropertyLevels* propertyLevels = dynamic_cast(property); if (propertyLevels) { deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); dePropertyLevelsUI* p = new dePropertyLevelsUI(window, *propertyLevels, _layerProcessor, _index, layerWithSource, width); levels.push_back(p); addWidget(p->getWindow()); } dePropertyCurves* propertyCurves = dynamic_cast(property); if (propertyCurves) { deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); dePropertyCurvesUI* p = new dePropertyCurvesUI(window, *propertyCurves, _layerProcessor, _index, layerWithSource, width); curves.push_back(p); addWidget(p->getWindow()); } dePropertyMixer* propertyMixer = dynamic_cast(property); if (propertyMixer) { deBaseLayerWithSource& layerWithSource = dynamic_cast(layer); dePropertyMixerUI* p = new dePropertyMixerUI(window, *propertyMixer, _layerProcessor, _index, layerWithSource, width); mixers.push_back(p); addWidget(p->getWindow()); } } addSizer("presets"); names.clear(); if (layerWP) { layerWP->getPresets(names); for (i = names.begin(); i != names.end(); i++) { std::string n = *i; dePresetButton* b = new dePresetButton(window, *layerWP, n, _layerProcessor, _index, *this); addWidget("presets", b->getWindow()); } } fit(); } deGenericLayerFrame::~deGenericLayerFrame() { // we need to destroy our UI data here std::vector::iterator i; for (i = numerics.begin(); i != numerics.end(); i++) { delete (*i); } std::vector::iterator j; for (j = levels.begin(); j != levels.end(); j++) { delete (*j); } { std::vector::iterator j; for (j = curves.begin(); j != curves.end(); j++) { delete (*j); } } std::vector::iterator k; for (k = choices.begin(); k != choices.end(); k++) { delete (*k); } std::vector::iterator l; for (l = booleans.begin(); l != booleans.end(); l++) { delete (*l); } { std::vector::iterator l; for (l = mixers.begin(); l != mixers.end(); l++) { delete (*l); } } } void deGenericLayerFrame::setUIFromLayer() { layer.beforeSetUIFromLayer(); std::vector::iterator i; for (i = numerics.begin(); i != numerics.end(); i++) { (*i)->setFromProperty(); } std::vector::iterator j; for (j = levels.begin(); j != levels.end(); j++) { (*j)->setFromProperty(); } { std::vector::iterator j; for (j = curves.begin(); j != curves.end(); j++) { (*j)->setFromProperty(); } } std::vector::iterator k; for (k = choices.begin(); k != choices.end(); k++) { (*k)->setFromProperty(); } std::vector::iterator l; for (l = booleans.begin(); l != booleans.end(); l++) { (*l)->setFromProperty(); } { std::vector::iterator l; for (l = mixers.begin(); l != mixers.end(); l++) { (*l)->setFromProperty(); } } } bool deGenericLayerFrame::onImageClick(deValue x, deValue y) { if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) { return false; } { std::vector::iterator j; for (j = curves.begin(); j != curves.end(); j++) { (*j)->onImageClick(x,y); } } if (layer.onImageClick(x, y)) { setUIFromLayer(); layerProcessor.markUpdateAllChannels(index); return true; } return false; } bool deGenericLayerFrame::onKey(int key) { { std::vector::iterator j; for (j = curves.begin(); j != curves.end(); j++) { if ((*j)->onKey(key)) { setUIFromLayer(); layerProcessor.markUpdateAllChannels(index); return true; } } } return false; } delaboratory-0.8/core/conversion_cpu.h0000644000175100001440000000621011771267025017211 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CONVERSION_CPU_H #define _DE_CONVERSION_CPU_H #include "value.h" class deImage; class deChannelManager; #include "color_space.h" #define CPU_REGISTER_OVERFLOW 0 #define CPU_REGISTER_CMYK_KEY_SUB 1 #define CPU_REGISTER_CMYK_KEY_MAX 2 #define CPU_REGISTER_CMYK_MIN_SUM 3 #define CPU_REGISTER_BW_MIXER_R 4 #define CPU_REGISTER_BW_MIXER_G 5 #define CPU_REGISTER_BW_MIXER_B 6 #define CPU_REGISTER_CONTRAST 7 #define CPU_REGISTER_SATURATION 8 #define CPU_REGISTER_PSEUDOGREY 9 #define CPU_REGISTERS 10 class deConversionCPU { private: public: typedef void (*deFunction)(deConversionCPU& cpu); deValue* input; deValue* output; deValue* registers; deConversionCPU(int size); virtual ~deConversionCPU(); void switchIO(); void incOverflow(); void convertImage3x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage3x4(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage4x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage3x1(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage1x3(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage4x1(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); void convertImage1x4(const deImage& sourceImage, deImage& image, deFunction f1, deFunction f2); bool renderImage1(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); bool renderImage3(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); bool renderImage4(const deImage& image, deConversionCPU::deFunction f, unsigned char* data); }; void rgb2cmy(deConversionCPU& cpu); void cmy2rgb(deConversionCPU& cpu); void cmy2cmyk(deConversionCPU& cpu); void cmyk2cmy(deConversionCPU& cpu); void rgb2prophoto(deConversionCPU& cpu); void prophoto2rgb(deConversionCPU& cpu); void empty(deConversionCPU& cpu); void rgb2lab(deConversionCPU& cpu); void lab2rgb(deConversionCPU& cpu); void prophoto2lab(deConversionCPU& cpu); void lab2prophoto(deConversionCPU& cpu); void cmyk2lab(deConversionCPU& cpu); void lab2cmyk(deConversionCPU& cpu); deConversionCPU::deFunction getConversion(deColorSpace sourceColorSpace, deColorSpace targetColorSpace); #endif delaboratory-0.8/core/layer_factory.cc0000644000175100001440000001514611766762751017200 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_factory.h" #include "layer_stack.h" #include "curves_layer.h" #include "equalizer_layer.h" #include "fill_layer.h" #include "tone_layer.h" #include "saturation_layer.h" #include "white_balance_layer.h" #include "exposure_layer.h" #include "vignette_layer.h" #include "gradient_layer.h" #include "gaussian_blur_layer.h" #include "gaussian_blur_single_layer.h" #include "recover_highlights_layer.h" #include "recover_shadows_layer.h" #include "mixer_layer.h" #include "copy_layer.h" #include "conversion_layer.h" #include "source_image_layer.h" #include "high_pass_layer.h" #include "c2g_layer.h" #include #include "color_space_utils.h" #include "levels_layer.h" #include "local_contrast_layer.h" #include "sharpen_layer.h" #include "auto_dodge_layer.h" #include "auto_burn_layer.h" deBaseLayer* createLayer(const std::string& type, int source, deColorSpace colorSpace, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager, deStaticImage& sourceImage) { if (type == "curves") { return new deCurvesLayer(colorSpace, source, _layerStack, _channelManager); } if (type == "equalizer") { return new deEqualizerLayer(colorSpace, source, _layerStack, _channelManager, _viewManager); } if (type == "mixer") { return new deMixerLayer(colorSpace, source, _layerStack, _channelManager, _viewManager); } if (type == "copy") { return new deCopyLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "levels") { return new deLevelsLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "fill") { return new deFillLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "tone") { return new deToneLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "exposure") { return new deExposureLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "saturation") { return new deSaturationLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "white_balance") { return new deWhiteBalanceLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "local_contrast") { return new deLocalContrastLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "auto_dodge") { return new deAutoDodgeLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "auto_burn") { return new deAutoBurnLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "sharpen") { return new deSharpenLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "high_pass") { return new deHighPassLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "c2g") { return new deC2GLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "vignette") { return new deVignetteLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "gradient") { return new deGradientLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "gaussian_blur") { return new deGaussianBlurLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "gaussian_blur_single") { return new deGaussianBlurSingleLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "recover_highlights") { return new deRecoverHighlightsLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "recover_shadows") { return new deRecoverShadowsLayer(colorSpace, _channelManager, source, _layerStack, _viewManager); } if (type == "conversion") { return new deConversionLayer(colorSpace, _channelManager, source, _layerStack); } if (type == "original") { return new deSourceImageLayer(_channelManager, _viewManager, sourceImage, colorSpace); } return NULL; } void getSupportedActions(std::vector& actions) { actions.push_back("levels"); actions.push_back("curves"); actions.push_back("equalizer"); actions.push_back("exposure"); actions.push_back("saturation"); actions.push_back("white_balance"); actions.push_back("fill"); actions.push_back("tone"); actions.push_back("local_contrast"); actions.push_back("auto_dodge"); actions.push_back("auto_burn"); actions.push_back("sharpen"); actions.push_back("vignette"); actions.push_back("gradient"); actions.push_back("gaussian_blur"); actions.push_back("recover_highlights"); actions.push_back("recover_shadows"); actions.push_back("mixer"); actions.push_back("high_pass"); actions.push_back("c2g"); actions.push_back("copy"); } std::string getActionDescription(const std::string& a) { if (a == "shadows_highlights") { return "sh / hi"; } if (a == "high_pass") { return "high pass"; } if (a == "dodge_burn") { return "d / b"; } if (a == "local_contrast") { return "loc contrast"; } if (a == "gaussian_blur") { return "g. blur"; } if (a == "gaussian_blur_single") { return "g. blur s"; } if (a == "white_balance") { return "wb"; } if (a == "recover_highlights") { return "highlights"; } if (a == "recover_shadows") { return "shadows"; } return a; } delaboratory-0.8/core/renderer.cc0000644000175100001440000000744011765775026016137 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "renderer.h" #include "project.h" #include "image.h" #include "base_layer.h" #include #include "layer_processor.h" #include "str.h" #include "logger.h" #include "channel_manager.h" #include "layer_stack.h" #include "conversion_processor.h" #include "canvas.h" void renderChannel(const deImage& image, int c, unsigned char* data, deChannelManager& channelManager, bool reversed) { const deSize& s = image.getChannelSize(); const deValue* pixels = image.startRead(c); if (!pixels) { logError("can't render channel - NULL pixels"); return; } int n = s.getN(); int i; int pos = 0; for (i = 0; i < n; i++) { deValue s = pixels[i]; if (reversed) { s = 1.0 - s; } unsigned char ss = 255 * s; data[pos] = ss; pos++; data[pos] = ss; pos++; data[pos] = ss; pos++; } image.finishRead(c); } deRenderer::deRenderer(deChannelManager& _channelManager) :size(0,0), channelManager(_channelManager) { } deRenderer::~deRenderer() { } bool deRenderer::prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack) { if (channelManager.isImageEmpty()) { logError("image is empty"); return false; } mutex.lock(); int viewV = viewManager.getView(); int view = layerProcessor.getLastValidLayer(); if (view > viewV) { view = viewV; } if (view < 0) { logError("view < 0"); mutex.unlock(); return false; } const deBaseLayer* layer = layerStack.startReadLayer(view); if (layer) { const deImage& layerImage = layer->getLayerImage(); if (viewManager.isSingleChannel()) { bool reversed = false; deColorSpace colorSpace = layerImage.getColorSpace(); if (colorSpace == deColorSpaceCMYK) { reversed = true; } renderChannel(layerImage, viewManager.getChannel(), getCurrentImageData(), channelManager, reversed); renderedImage.clearError(); } else { deConversionProcessor p; if (!p.renderImageToRGBNew(layerImage, getCurrentImageData())) { logError("render image FAILED"); renderedImage.setError(); } else { renderedImage.clearError(); } } } else { logError("no layer in renderer"); } layerStack.finishReadLayer(view); mutex.unlock(); return true; } bool deRenderer::render(deCanvas& canvas) { mutex.lock(); bool result = renderedImage.render(canvas); if (!result) { canvas.clear(); } mutex.unlock(); return result; } unsigned char* deRenderer::getCurrentImageData() { const deSize& s = channelManager.getChannelSizeFromChannelManager(); renderedImage.setSize(s); return renderedImage.getCurrentImageData(); } delaboratory-0.8/core/project.h0000644000175100001440000000716312004336607015624 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROJECT_H #define _DE_PROJECT_H #include "sampler_manager.h" #include "view_manager.h" #include "logger.h" #include "image.h" #include "size.h" #include "gui.h" class deImagePanel; class deHistogramPanel; class deMainWindow; class deLayerProcessor; class deLayerStack; class deLayerFrameManager; class deLayer; class deStaticImage; class deRawModule; class deZoomManager; class deBaseLayer; class deProgressDialog; class deProject { private: deProject(const deProject& project); deProject& operator =(const deProject& project); deLayerProcessor& layerProcessor; std::string imageFileName; std::string sourceImageFileName; deChannelManager& channelManager; deViewManager viewManager; deStaticImage& sourceImage; deLayerStack& layerStack; deLayerFrameManager& layerFrameManager; deRawModule& rawModule; deZoomManager& zoomManager; deMainWindow& mainWindow; deGUI& gui; void onImageNameUpdate(); bool processFullSizeImage(const std::string& fileName, const std::string& type, bool saveAll, deProgressDialog& progressDialog); void freeImage(); void onScaleSet(); void updateLayerGrid(); bool openImageRAW(const std::string& fileName, bool srgb, bool brighten); public: deProject(deLayerProcessor& _processor, deChannelManager& _channelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager, deMainWindow& _mainWindow, deGUI& _gui); virtual ~deProject(); void onKey(int key); void init(const std::string& fileName); void resetLayerStack(deColorSpace colorSpace); deChannelManager& getPreviewChannelManager(); deSize getSourceImageSize(); deLayerStack& getLayerStack(); deLayerProcessor& getLayerProcessor(); bool isSourceValid() const; const deViewManager& getViewManager() const; deViewManager& getViewManager(); void onChangeView(int a); bool exportFinalImage(const std::string& app, const std::string& type, const std::string& name, deProgressDialog& progressDialog, bool saveAll, const std::string& dir); void onChangeViewMode(); bool openImage(const std::string& fileName, bool raw, bool srgb, bool brighten); void newProject(); void setTestImage(int s); void setHistogramChannel(int channel); void onTimerUpdate(); deBaseLayer* createNewLayer(const std::string& type); void onAddNewLayer(); void onRemoveTopLayer(); deLayerFrameManager& getLayerFrameManager() {return layerFrameManager;}; deValue getSourceAspect() const; deSize onImageAreaChangeSize(const deSize& ps, bool canSkip); void openLayerFrame(int index); }; #endif delaboratory-0.8/core/property.cc0000644000175100001440000000255011764477311016205 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property.h" deProperty::deProperty(const std::string& _name) :name(_name) { label = ""; blendOnly = false; size = false; others = false; } deProperty::~deProperty() { } std::string deProperty::getName() const { return name; } std::string deProperty::getLabel() const { if (label == "") { return name; } else { return label; } } void deProperty::setLabel(const std::string& _label) { label = _label; } void deProperty::setBlendOnly() { blendOnly = true; } void deProperty::setSize() { size = true; } void deProperty::setOthers() { others = true; } delaboratory-0.8/core/flatten_layers.h0000644000175100001440000000211011765506775017177 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_FLATTEN_LAYERS_H #define _DE_FLATTEN_LAYERS_H class deProgressDialog; #include class deLayerStack; class deChannelManager; bool flattenLayers(int view, deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, deLayerStack& layerStack, deChannelManager& previewChannelManager); #endif delaboratory-0.8/core/layer_processor.cc0000644000175100001440000003130112004112446017507 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_processor.h" #include "main_window.h" #include "main_frame_events.h" #include "layer_frame_manager.h" #include "layer_stack.h" #include "view_manager.h" #include #include "base_layer.h" #include "channel_manager.h" #include "str.h" #include "progress_dialog.h" #include #include "logger.h" #include "renderer.h" #include "image_io.h" #include "layer_processor_threads.h" #include "flatten_layers.h" #include "gui.h" deLayerProcessor::deLayerProcessor(deChannelManager& _previewChannelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deMainWindow& _mainWindow) : layerStack(_layerStack), layerFrameManager(_layerFrameManager), renderer(_previewChannelManager), previewChannelManager(_previewChannelManager), mainWindow(_mainWindow) { #ifdef DEBUG_LOG logInfo("layer processor constructor"); #endif viewManager = NULL; firstLayerToUpdate = 0; lastValidLayer = -1; layerProcessType = deLayerProcessInvalid; layerProcessChannel = -1; closing = false; threads = new deLayerProcessorThreads(*this); } void deLayerProcessor::onDestroyAll() { lockLayerProcessor(); lastValidLayer = -1; unlockLayerProcessor(); } deLayerProcessor::~deLayerProcessor() { #ifdef DEBUG_LOG logInfo("layer processor destructor"); #endif delete threads; } void deLayerProcessor::stopWorkerThread() { closing = true; threads->stopWorkerThread(); } void deLayerProcessor::startWorkerThread() { threads->startWorkerThread(); } void deLayerProcessor::setViewManager(deViewManager* _viewManager) { viewManager = _viewManager; } void deLayerProcessor::repaintImageInLayerProcessor() { if (closing) { logInfo("skip repaintImage because closing"); return; } #ifdef DEBUG_LOG logInfo("repaintImage"); #endif threads->renderPost(); generateHistogram(); } void deLayerProcessor::generateHistogram() { if (closing) { logInfo("skip generateHistogram because closing"); return; } threads->histogramPost(); } void deLayerProcessor::sendRepaintEvent() { if (closing) { return; } mainWindow.postEvent(DE_REPAINT_EVENT, 0 ); } void deLayerProcessor::sendInfoEvent(int i) { if (closing) { return; } mainWindow.postEvent(DE_INFO_EVENT, i ); } void deLayerProcessor::sendHistogramEvent() { if (closing) { return; } mainWindow.postEvent(DE_HISTOGRAM_EVENT, 0 ); } void deLayerProcessor::updateAllImages(bool calcHistogram) { updateImages(0, -1, true); } void deLayerProcessor::lockLayers() const { #ifdef DEBUG_LOG logInfo("locking layer process mutex..."); #endif layerProcessMutex.lock(); #ifdef DEBUG_LOG logInfo("layer process mutex locked"); #endif } void deLayerProcessor::unlockLayers() const { #ifdef DEBUG_LOG logInfo("unlocking layer process mutex"); #endif layerProcessMutex.unlock(); } void deLayerProcessor::lockHistogram() { #ifdef DEBUG_LOG logInfo("locking histogram mutex..."); #endif histogramMutex.lock(); #ifdef DEBUG_LOG logInfo("histogram mutex locked"); #endif } void deLayerProcessor::unlockHistogram() { #ifdef DEBUG_LOG logInfo("unlocking histogram mutex"); #endif histogramMutex.unlock(); } void deLayerProcessor::lockUpdateImage() { #ifdef DEBUG_LOG logInfo("locking update image mutex..."); #endif updateImageMutex.lock(); #ifdef DEBUG_LOG logInfo("update image mutex locked"); #endif } void deLayerProcessor::unlockUpdateImage() { #ifdef DEBUG_LOG logInfo("unlocking update image mutex"); #endif updateImageMutex.unlock(); } void deLayerProcessor::lockPrepareImage() { #ifdef DEBUG_LOG logInfo("locking prepare image mutex..."); #endif prepareImageMutex.lock(); #ifdef DEBUG_LOG logInfo("prepare image mutex locked"); #endif } void deLayerProcessor::unlockPrepareImage() { #ifdef DEBUG_LOG logInfo("unlocking prepare image mutex"); #endif prepareImageMutex.unlock(); } void deLayerProcessor::updateImages(int a, int channel, bool action) { if (closing) { return; } lockLayers(); if (a == firstLayerToUpdate) { if (layerProcessChannel != channel) { channel = -1; } } if (a < firstLayerToUpdate) { firstLayerToUpdate = a; } if (channel >= 0) { layerProcessType = deLayerProcessSingleChannel; layerProcessChannel = channel; } else { if (action) { layerProcessType = deLayerProcessFull; } else { layerProcessType = deLayerProcessBlend; } } unlockLayers(); checkUpdateImagesRequest(); } bool deLayerProcessor::updateLayerImage() { #ifdef DEBUG_LOG logInfo("updateLayerImage"); #endif lockUpdateImage(); lockLayers(); bool ok = true; bool result = false; if (firstLayerToUpdate > getLastLayerToUpdate()) { ok = false; } int i = firstLayerToUpdate; deLayerProcessType type = deLayerProcessInvalid; int channel = -1; deBaseLayer* layer = layerStack.getLayer(i); if ((layer) && (ok)) { layer->lockLayer(); type = layerProcessType; channel = layerProcessChannel; layerProcessType = deLayerProcessFull; lastValidLayer = i; firstLayerToUpdate = i + 1; } unlockLayers(); if ((layer) && (ok)) { layer->processLayer(type, channel); layer->unlockLayer(); result = true; } unlockUpdateImage(); updateWarning(); return result; } void deLayerProcessor::updateWarning() { if (closing) { return; } mainWindow.postEvent(DE_WARNING_EVENT, 0 ); } bool deLayerProcessor::updateImagesSmart(deProgressDialog& progressDialog, const std::string& fileName, const std::string& type, bool saveAll, const deSize& size, deGUI& gui) { gui.lockSize(); lockLayerProcessor(); lockHistogram(); lockPrepareImage(); lockUpdateImage(); // remember original size of preview deSize originalSize = previewChannelManager.getChannelSizeFromChannelManager(); // calculate final image in full size int view = viewManager->getView(); previewChannelManager.setChannelSize(size, false); bool result = flattenLayers(view, progressDialog, fileName, type, saveAll, layerStack, previewChannelManager); // bring back original size of preview previewChannelManager.setChannelSize(originalSize, true); unlockUpdateImage(); unlockPrepareImage(); unlockHistogram(); unlockLayerProcessor(); gui.unlockSize(); return result; } void deLayerProcessor::markUpdateSingleChannel(int index, int channel) { #ifdef DEBUG_LOG logInfo("markUpdateSingleChannel " +str(index) + " " + str(channel)); #endif updateImages(index, channel, true); } void deLayerProcessor::markUpdateAllChannels(int index) { updateImages(index, -1, true); } void deLayerProcessor::markUpdateBlendAllChannels(int index) { updateImages(index, -1, false); } void deLayerProcessor::onChangeView(int a) { updateImages(a + 1, -1, true); updateWarning(); } void deLayerProcessor::lockLayerProcessor() { #ifdef DEBUG_LOG logInfo("layer processor lock..."); #endif updateImagesMutex.lock(); #ifdef DEBUG_LOG logInfo("layer processor locked"); #endif } void deLayerProcessor::unlockLayerProcessor() { #ifdef DEBUG_LOG logInfo("layer processor unlock"); #endif updateImagesMutex.unlock(); } void deLayerProcessor::tickWork() { sendInfoEvent(DE_PROCESSING_START); bool result = updateLayerImage(); if (result) { checkUpdateImagesRequest(); repaintImageInLayerProcessor(); } sendInfoEvent(DE_PROCESSING_END); } void deLayerProcessor::onChangeViewMode() { repaintImageInLayerProcessor(); } void deLayerProcessor::onGUIUpdate() { sendRepaintEvent(); } void deLayerProcessor::removeTopLayerInLayerProcessor() { logInfo("removeTopLayer"); lockHistogram(); lockPrepareImage(); lockUpdateImage(); int index = layerStack.getSize() - 1; logInfo("requested remove top layer " + str(index)); if (index > 0) { layerStack.removeTopLayer(); int view = viewManager->getView(); if (view >= layerStack.getSize()) { viewManager->setView( layerStack.getSize() - 1 ); } repaintImageInLayerProcessor(); } unlockUpdateImage(); unlockPrepareImage(); unlockHistogram(); logInfo("removeTopLayer DONE"); } void deLayerProcessor::removeAllLayers() { logInfo("removeAllLayers"); lockHistogram(); lockPrepareImage(); lockUpdateImage(); while (layerStack.getSize() > 0) { layerStack.removeTopLayer(); } repaintImageInLayerProcessor(); unlockUpdateImage(); unlockPrepareImage(); unlockHistogram(); logInfo("removeAllLayers DONE"); } void deLayerProcessor::addLayerInLayerProcessor(deBaseLayer* layer) { layerStack.addLayer(layer); int n = layerStack.getSize(); markUpdateAllChannels(n-1); } void deLayerProcessor::checkUpdateImagesRequest() { lockLayers(); bool ok = true; if (firstLayerToUpdate > getLastLayerToUpdate()) { ok = false; } if (ok) { threads->workerPost(); } unlockLayers(); } int deLayerProcessor::getLastLayerToUpdate() { if (!viewManager) { return 0; } else { int n = viewManager->getView(); return n; } } bool deLayerProcessor::prepareImage() { if (previewChannelManager.isImageEmpty()) { return false; } #ifdef DEBUG_LOG logInfo("prepare image start"); #endif sendInfoEvent(DE_RENDERING_START); bool result = false; lockPrepareImage(); lockLayerProcessor(); if (!closing) { if (viewManager) { result = renderer.prepareImage(*viewManager, *this, layerStack); } } unlockLayerProcessor(); unlockPrepareImage(); sendInfoEvent(DE_RENDERING_END); #ifdef DEBUG_LOG logInfo("prepare image DONE"); #endif return result; } void deLayerProcessor::onGenerateHistogram() { sendInfoEvent(DE_HISTOGRAM_START); lockHistogram(); if (!closing) { mainWindow.generateHistogram(); } unlockHistogram(); sendInfoEvent(DE_HISTOGRAM_END); } void deLayerProcessor::forceUpdateSize() { mainWindow.forceUpdateSize(); } void deLayerProcessor::setPreviewSize(const deSize& size, bool canSkip) { deSize oldSize = previewChannelManager.getChannelSizeFromChannelManager(); if ((oldSize == size) && (canSkip)) { logInfo("skip set preview size"); return; } if (size.getW() < 0) { logError("broken size passed to setPreviewSize, w: " + str(size.getW())); } if (size.getH() < 0) { logError("broken size passed to setPreviewSize, h: " + str(size.getH())); } logInfo("setPreviewSize start"); lockHistogram(); lockPrepareImage(); lockUpdateImage(); previewChannelManager.setChannelSize(size, true); updateAllImages(false); unlockUpdateImage(); unlockPrepareImage(); unlockHistogram(); logInfo("setPreviewSize DONE"); } void deLayerProcessor::onImageLoad() { logInfo("onImageLoad"); lockHistogram(); lockPrepareImage(); lockUpdateImage(); updateAllImages(false); unlockUpdateImage(); unlockPrepareImage(); unlockHistogram(); logInfo("onImageLoad DONE"); } void deLayerProcessor::render(deCanvas& canvas) { renderer.render(canvas); } void deLayerProcessor::setHistogramChannel(int channel) { if (viewManager) { viewManager->setHistogramChannel(channel); } } int deLayerProcessor::getLastValidLayer() const { lockLayers(); int l = lastValidLayer; unlockLayers(); return l; } delaboratory-0.8/core/color_space.h0000644000175100001440000000211211764477311016446 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COLOR_SPACE_H #define _DE_COLOR_SPACE_H #define MAX_COLOR_SPACE_SIZE 4 enum deColorSpace { deColorSpaceInvalid, deColorSpaceRGB, deColorSpaceProPhoto, deColorSpaceBW, deColorSpaceLAB, deColorSpaceCMY, deColorSpaceCMYK, deColorSpaceHSV, deColorSpaceHSL, deColorSpaceXYZ, deColorSpaceLCH }; #endif delaboratory-0.8/core/project.cc0000644000175100001440000003131112004643214015745 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "project.h" #include "message_box.h" #include "image_io.h" #include #include #include "source_image_layer.h" #include "curves_layer.h" #include "conversion_layer.h" #include "str.h" #include #include "layer_factory.h" #include #include "layer_processor.h" #include "external_editor.h" #include "channel_manager.h" #include "layer_stack.h" #include "layer_frame_manager.h" #include "static_image.h" #include "zoom_manager.h" #include "color_space_utils.h" #include "operation_processor.h" #include "main_window.h" #include "conversion_processor.h" #include "test_image.h" #include "main_frame_events.h" #include "raw_module.h" #include "dcraw_support.h" #include "tmp.h" deProject::deProject(deLayerProcessor& _processor, deChannelManager& _channelManager, deLayerStack& _layerStack, deLayerFrameManager& _layerFrameManager, deStaticImage& _sourceImage, deRawModule& _rawModule, deZoomManager& _zoomManager, deMainWindow& _mainWindow, deGUI& _gui) :layerProcessor(_processor), channelManager(_channelManager), viewManager(*this, _processor, _zoomManager), sourceImage(_sourceImage), layerStack(_layerStack), layerFrameManager(_layerFrameManager), rawModule(_rawModule), zoomManager(_zoomManager), mainWindow(_mainWindow), gui(_gui) { imageFileName = ""; sourceImageFileName = ""; logInfo("project constructor"); layerProcessor.setViewManager(&viewManager); resetLayerStack(deColorSpaceRGB); } deProject::~deProject() { logInfo("project destructor"); layerProcessor.lockLayerProcessor(); layerProcessor.unlockLayerProcessor(); layerStack.clear(); } void deProject::setHistogramChannel(int channel) { logInfo("project set histogram channel " + str(channel)); gui.updateHistogramMode(channel); layerProcessor.generateHistogram(); } void deProject::onKey(int key) { if (key == '`') { viewManager.setNormal(); } if (key == '1') { viewManager.setSingleChannel(0); } if (key == '2') { viewManager.setSingleChannel(1); } if (key == '3') { viewManager.setSingleChannel(2); } if (key == '4') { viewManager.setSingleChannel(3); } /* if (key == WXK_F1) { setHistogramChannel(0); } if (key == WXK_F2) { setHistogramChannel(1); } if (key == WXK_F3) { setHistogramChannel(2); } if (key == WXK_F4) { setHistogramChannel(3); } */ layerFrameManager.onKey(key); } void deProject::init(const std::string& fileName) { bool ok = false; if (openImage(fileName, true, false, false)) { ok = true; } else if (openImage(fileName, false, false, false)) { ok = true; } if (!ok) { std::string s = "unable to open image: " + fileName; logError(s); showMessageBox(s); return; } } void deProject::freeImage() { } void deProject::setTestImage(int s) { if (rawModule.isActive()) { showMessageBox("RAW module is already active"); return; } generateTestImage(sourceImage, s); gui.updateImageAreaSize(); resetLayerStack(sourceImage.getColorSpace()); imageFileName = "test"; } void deProject::resetLayerStack(deColorSpace colorSpace) { logInfo("reset layer stack"); layerProcessor.removeAllLayers(); deBaseLayer* layer = createLayer("original", -1, colorSpace, layerStack, channelManager, viewManager, sourceImage); if (layer) { layer->allocateChannels(); layerProcessor.addLayerInLayerProcessor(layer); } layerProcessor.updateAllImages(true); updateLayerGrid(); viewManager.setLastView(); } deChannelManager& deProject::getPreviewChannelManager() { return channelManager; } deSize deProject::getSourceImageSize() { deSize size = sourceImage.getStaticImageSize(); deValue x1; deValue y1; deValue x2; deValue y2; zoomManager.getZoom(x1, y1, x2, y2); deValue w = size.getW() * (x2 - x1); deValue h = size.getH() * (y2 - y1); return deSize(w, h); } deValue deProject::getSourceAspect() const { const deBaseLayer* layer = layerStack.startReadLayer(0); deValue aspect = -1; const deSourceImageLayer* source = dynamic_cast(layer); if (source) { deValue x1; deValue y1; deValue x2; deValue y2; zoomManager.getZoom(x1, y1, x2, y2); deValue dx = x2 - x1; deValue dy = y2 - y1; if ((dx > 0) && (dy > 0)) { deValue a = dy / dx; aspect = source->getAspect() / a; } } layerStack.finishReadLayer(0); return aspect; } deLayerStack& deProject::getLayerStack() { return layerStack; } deLayerProcessor& deProject::getLayerProcessor() { return layerProcessor; } void deProject::onChangeView(int a) { logInfo("change view from " + str(a) + " START"); layerProcessor.onChangeView(a); gui.updateViewModePanelNames(); gui.updateHistogramNames(); mainWindow.rebuild(); logInfo("change view from " + str(a) + " DONE"); } const deViewManager& deProject::getViewManager() const { return viewManager; } deViewManager& deProject::getViewManager() { return viewManager; } bool deProject::exportFinalImage(const std::string& app, const std::string& type, const std::string& name, deProgressDialog& progressDialog, bool saveAll, const std::string& dir) { // FIXME without dynamic channel allocation all channels are allocated from start - so it will crash with out of memory logInfo("exportFinalImage..."); zoomManager.fullZoomOut(); // name is taken from file dialog, it can be empty when we are exporting to external editor // but in this case we need correct imageFileName if ((name == "") && (imageFileName == "")) { showMessageBox( "exporting final image failed - no file name set"); return false; } std::string fileName; if (name == "") { // path is a directory for temporary save, used only when exporting to external editor std::string path = getTmp(); if (dir.size() > 0) { // now used also when exporting all images into one dir path = dir; } // we save file in the temporary directory fileName = path + "/" + imageFileName + "." + type; } else { // wa save file in the location taken from file dialog fileName = name; } bool result = processFullSizeImage(fileName, type, saveAll, progressDialog); if (!result) { showMessageBox( "exporting final image failed - error during update images\n(probably out of memory)"); } if (result) { // execute external editor if (app.size() > 0) { executeExternalEditor(fileName, app); } } // calculate image in preview size to continue editing layerProcessor.updateAllImages(true); gui.updateImageAreaSize(); return result; } bool deProject::processFullSizeImage(const std::string& fileName, const std::string& type, bool saveAll, deProgressDialog& progressDialog) { logInfo("processFullSizeImage..."); bool result = layerProcessor.updateImagesSmart(progressDialog, fileName, type, saveAll, sourceImage.getStaticImageSize(), gui); return result; } void deProject::onChangeViewMode() { gui.updateViewModePanelMode(); } void deProject::newProject() { resetLayerStack(deColorSpaceRGB); viewManager.setLastView(); updateLayerGrid(); } bool deProject::openImageRAW(const std::string& fileName, bool srgb, bool brighten) { bool valid = isRawValid(fileName); if (!valid) { logError("not a valid RAW " + fileName); return false; } /* std::string info; info = getRawInfo(fileName); if (info.size() == 0) { logError("empty RAW info in " + fileName); return false; } */ layerProcessor.sendInfoEvent(DE_DCRAW_START); if (rawModule.loadRAW(fileName, sourceImage, true, srgb, brighten)) { logInfo("found RAW " + fileName); bool failure = false; while (!rawModule.updateRawLoading(failure)) { sleep(200); if (failure) { logError("failed RAW load " + fileName); layerProcessor.sendInfoEvent(DE_DCRAW_END); return false; } } bool result = rawModule.loadRAW(fileName, sourceImage, false, srgb, brighten); if (!result) { return false; } mainWindow.startRawTimer(); } else { logError("failed RAW " + fileName); layerProcessor.sendInfoEvent(DE_DCRAW_END); return false; } return true; } bool deProject::openImage(const std::string& fileName, bool raw, bool srgb, bool brighten) { freeImage(); logInfo("open image " + fileName); deColorSpace oldColorSpace = sourceImage.getColorSpace(); if (raw) { if (!openImageRAW(fileName, srgb, brighten)) { return false; } } else { logInfo("trying JPEG/TIFF image " + fileName); if (!loadImage(fileName, sourceImage)) { logError("load JPEG/TIFF image failed: " + fileName); return false; } } imageFileName = removePathAndExtension(fileName); onImageNameUpdate(); sourceImageFileName = fileName; gui.updateImageAreaSize(); layerProcessor.updateAllImages(true); deColorSpace newColorSpace = sourceImage.getColorSpace(); if (oldColorSpace != newColorSpace) { resetLayerStack(newColorSpace); onChangeView(0); } return true; } bool deProject::isSourceValid() const { return (!channelManager.isImageEmpty()); } deBaseLayer* deProject::createNewLayer(const std::string& type) { logInfo("createNewLayer " + type); int s = viewManager.getView(); deBaseLayer* layer = NULL; const deBaseLayer* vLayer = layerStack.startReadLayer(s); if (vLayer) { deColorSpace colorSpace = vLayer->getColorSpace(); layer = createLayer(type, s, colorSpace, layerStack, channelManager, viewManager, sourceImage); } layerStack.finishReadLayer(s); if (!layer) { deColorSpace colorSpace = colorSpaceFromString(type); if (colorSpace != deColorSpaceInvalid) { layer = createLayer("conversion", s, colorSpace, layerStack, channelManager, viewManager, sourceImage); } } if (layer) { logInfo("allocate channels in new layer " + type); layer->allocateChannels(); } return layer; } void deProject::onImageNameUpdate() { mainWindow.setImageName(imageFileName, sourceImage.getStaticImageSize()); } void deProject::onTimerUpdate() { bool failure = false; bool result = rawModule.updateRawLoading(failure); if ((result) || (failure)) { layerProcessor.sendInfoEvent(DE_DCRAW_END); mainWindow.stopRawTimer(); } if (result) { mainWindow.postEvent(DE_IMAGE_LOAD_EVENT, 0); } } void deProject::updateLayerGrid() { gui.updateLayerGrid(); } void deProject::onAddNewLayer() { viewManager.setLastView(); updateLayerGrid(); } void deProject::onRemoveTopLayer() { viewManager.setLastView(); updateLayerGrid(); } deSize deProject::onImageAreaChangeSize(const deSize& ps, bool canSkip) { deValue aspect = getSourceAspect(); if (aspect <= 0) { logInfo("image area panel update size skipped, aspect is 0"); return deSize(0,0); } deSize fit = fitInside(ps, aspect); layerProcessor.setPreviewSize(fit, canSkip); return fit; } void deProject::openLayerFrame(int index) { deBaseLayer* layer = layerStack.getLayer(index); if (layer) { gui.openLayerFrame(*layer, layerProcessor, layerFrameManager, index); } } delaboratory-0.8/core/layer_stack.cc0000644000175100001440000000602112002551204016573 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_stack.h" #include "base_layer.h" #include "channel_manager.h" #include "str.h" #include "project.h" deLayerStack::deLayerStack() { } deLayerStack::~deLayerStack() { clear(); } void deLayerStack::lock() const { #ifdef DEBUG_LOG logInfo("layer stack lock..."); #endif mutex.lock(); #ifdef DEBUG_LOG logInfo("layer stack locked"); #endif } void deLayerStack::unlock() const { #ifdef DEBUG_LOG logInfo("layer stack unlock"); #endif mutex.unlock(); } void deLayerStack::clear() { while (layers.size() > 0) { removeTopLayer(); } } void deLayerStack::removeTopLayer() { lock(); logInfo("layer stack remove top layer..."); int index = layers.size() - 1; mutexes[index]->lockWrite(); std::vector::iterator i; i = layers.end(); i--; deBaseLayer* layer = *i; layers.erase(i); #ifdef DEBUG_LOG logInfo("layer stack before delete layer"); #endif delete layer; #ifdef DEBUG_LOG logInfo("layer stack after delete layer"); #endif mutexes[index]->unlockWrite(); unlock(); } void deLayerStack::addLayer(deBaseLayer* layer) { lock(); logInfo("layer stack add layer"); layers.push_back(layer); mutexes.push_back(new deMutexReadWrite(4)); unlock(); } int deLayerStack::getSize() const { lock(); int n = layers.size(); unlock(); return n; } deBaseLayer* deLayerStack::getLayer(int id) const { lock(); unsigned int index = id; deBaseLayer* layer = NULL; if ((index < layers.size()) && (id >= 0)) { layer = layers[index]; } unlock(); return layer; } const deBaseLayer* deLayerStack::startReadLayer(int id) const { #ifdef DEBUG_LOG logInfo("start read layer " + str(id)); #endif const deBaseLayer* layer = NULL; lock(); if ((id >= 0) && (id < layers.size())) { mutexes[id]->lockRead(); layer = getLayer(id); } unlock(); #ifdef DEBUG_LOG logInfo("start read layer DONE"); #endif return layer; } void deLayerStack::finishReadLayer(int id) const { #ifdef DEBUG_LOG logInfo("finish read layer " + str(id)); #endif lock(); if ((id >= 0) && (id < layers.size())) { mutexes[id]->unlockRead(); } unlock(); } delaboratory-0.8/core/image.cc0000644000175100001440000001055712002551204015365 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "image.h" #include "channel_manager.h" #include "logger.h" #include "str.h" #include "color_space_utils.h" #include deImage::deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager) :colorSpace(_colorSpace), channelManager(_channelManager) { logInfo("image constructor"); int i; int s = getColorSpaceSize(colorSpace); for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) { if (i < s) { channelsAllocated[i] = channelManager.reserveNewChannel(); } else { channelsAllocated[i] = -1; } } } deImage::~deImage() { logInfo("image destructor"); int i; int s = getColorSpaceSize(colorSpace); for (i = 0; i < s; i++) { int a = channelsAllocated[i]; logInfo("destroying channel " + str(a)); channelManager.freeChannel(a); } } void deImage::allocateChannels() { int s = getColorSpaceSize(colorSpace); int i; for (i = 0; i < s; i++) { channelManager.tryAllocateChannel(channelsAllocated[i]); } } int deImage::getChannelIndex(int n) const { if (n < 0) { logError("deImage::getChannelIndex n: " + str(n)); } else if (n >= MAX_COLOR_SPACE_SIZE) { logError("deImage::getChannelIndex n: " + str(n)); } return channelsAllocated[n]; } deColorSpace deImage::getColorSpace() const { return colorSpace; } void deImage::updateChannelUsage(std::map& channelUsage, int index) const { int i; int s = getColorSpaceSize(colorSpace); for (i = 0; i < s; i++) { int c = channelsAllocated[i]; channelUsage[c] = index; } } const deValue* deImage::startRead(int channel) const { #ifdef DEBUG_LOG logInfo("image start read " + str(channel)); #endif if (channel < 0) { logError("image start read " + str(channel)); return NULL; } else if (channel >= MAX_COLOR_SPACE_SIZE) { logError("image start read " + str(channel)); return NULL; } int index = channelsAllocated[channel]; const deValue* values = channelManager.startRead(index); return values; } void deImage::finishRead(int channel) const { #ifdef DEBUG_LOG logInfo("image finish read " + str(channel)); #endif if (channel < 0) { logError("image finish read " + str(channel)); return; } else if (channel >= MAX_COLOR_SPACE_SIZE) { logError("image finish read " + str(channel)); return; } int index = channelsAllocated[channel]; channelManager.finishRead(index); } deValue* deImage::startWrite(int channel) { #ifdef DEBUG_LOG logInfo("image start write " + str(channel)); #endif if (channel < 0) { logError("image start write " + str(channel)); return NULL; } else if (channel >= MAX_COLOR_SPACE_SIZE) { logError("image start write " + str(channel)); return NULL; } int index = channelsAllocated[channel]; deValue* values = channelManager.startWrite(index); return values; } void deImage::finishWrite(int channel) { #ifdef DEBUG_LOG logInfo("image finish write " + str(channel)); #endif if (channel < 0) { logError("image finish write " + str(channel)); return; } else if (channel >= MAX_COLOR_SPACE_SIZE) { logError("image finish write " + str(channel)); return; } int index = channelsAllocated[channel]; channelManager.finishWrite(index); } const deSize deImage::getChannelSize() const { return channelManager.getChannelSizeFromChannelManager(); } delaboratory-0.8/core/preset_button.cc0000644000175100001440000000253611766762751017231 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "preset_button.h" #include "layer_processor.h" #include "layer_frame.h" #include "base_layer_with_properties.h" dePresetButton::dePresetButton(deWindow& window, deBaseLayerWithProperties& _layer, const std::string& name, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _frame) :deButton(window, name), preset(name), layerProcessor(_layerProcessor), layer(_layer), layerIndex(_layerIndex), frame(_frame) { } dePresetButton::~dePresetButton() { } void dePresetButton::onClick() { layer.applyPreset(preset); frame.setUIFromLayer(); layerProcessor.markUpdateAllChannels(layerIndex); } delaboratory-0.8/core/histogram.h0000644000175100001440000000262611764477311016164 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HISTOGRAM_H #define _DE_HISTOGRAM_H #include #include #include "value.h" class deHistogram { private: std::vector bars; int size; public: deHistogram(int _size); virtual ~deHistogram(); void put(deValue value); void calc(const deValue* pixels, int n); int get(int bar) const; void clear(); int getMax() const; int getSize() const; bool render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2, int margin); void calcLevels(deValue margin1, deValue margin2, deValue& min, deValue& middle, deValue& max); }; #endif delaboratory-0.8/core/layer_stack.h0000644000175100001440000000313411764477311016463 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_STACK_H #define _DE_LAYER_STACK_H #include #include #include "mutex.h" #include "mutex_read_write.h" class deBaseLayer; class deChannelManager; class deMemoryInfoFrame; class deLayerStack { private: std::vector layers; mutable deMutex mutex; std::vector mutexes; deLayerStack(const deLayerStack& ); deLayerStack& operator = (const deLayerStack& ); public: deLayerStack(); virtual ~deLayerStack(); void lock() const; void unlock() const; void clear(); void removeTopLayer(); void addLayer(deBaseLayer* layer); int getSize() const; deBaseLayer* getLayer(int id) const; const deBaseLayer* startReadLayer(int id) const; void finishReadLayer(int id) const; }; #endif delaboratory-0.8/core/image.h0000644000175100001440000000333411766762751015255 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_IMAGE_H #define _DE_IMAGE_H #include "color_space.h" #include "value.h" #include class deChannelManager; #include "size.h" #include "mutex.h" class deImage { private: const deColorSpace colorSpace; int channelsAllocated[MAX_COLOR_SPACE_SIZE]; deChannelManager& channelManager; mutable deMutex mutex; deImage(const deImage& i); deImage& operator = (const deImage& i); public: deImage(const deColorSpace& _colorSpace, deChannelManager& _channelManager); virtual ~deImage(); deColorSpace getColorSpace() const; int getChannelIndex(int n) const; void updateChannelUsage(std::map& channelUsage, int index) const; const deValue* startRead(int channel) const; void finishRead(int channel) const; deValue* startWrite(int channel); void finishWrite(int channel); const deSize getChannelSize() const; void allocateChannels(); }; #endif delaboratory-0.8/core/conversion_processor.cc0000644000175100001440000001413411777136356020613 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "conversion_processor.h" #include "image.h" #include "channel_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" #include "power.h" #include "str.h" void copyImage(const deImage& sourceImage, deImage& image) { int n = getColorSpaceSize(sourceImage.getColorSpace()); int i; for (i = 0; i < n; i++) { const deValue* source = sourceImage.startRead(i); deValue* destination = image.startWrite(i); copyChannel(source, destination, sourceImage.getChannelSize().getN()); image.finishWrite(i); sourceImage.finishRead(i); } } void applyContrastRGB(deConversionCPU& cpu) { deValue a = cpu.registers[CPU_REGISTER_CONTRAST]; deValue b = 0.5 - 0.5 * a; cpu.input[0] = a * cpu.input[0] + b; cpu.input[1] = a * cpu.input[1] + b; cpu.input[2] = a * cpu.input[2] + b; } void applyContrastSaturationLAB(deConversionCPU& cpu) { deValue a1 = cpu.registers[CPU_REGISTER_CONTRAST]; deValue b1 = 0.5 - 0.5 * a1; deValue a2 = cpu.registers[CPU_REGISTER_SATURATION]; deValue b2 = 0.5 - 0.5 * a2; cpu.input[0] = a1 * cpu.input[0] + b1; cpu.input[1] = a2 * cpu.input[1] + b2; cpu.input[2] = a2 * cpu.input[2] + b2; } void applyContrastSaturationLCH(deConversionCPU& cpu) { deValue a1 = cpu.registers[CPU_REGISTER_CONTRAST]; deValue b1 = 0.5 - 0.5 * a1; deValue a2 = cpu.registers[CPU_REGISTER_SATURATION]; cpu.input[0] = a1 * cpu.input[0] + b1; cpu.input[1] = a2 * cpu.input[1]; } deConversionProcessor::deConversionProcessor() { } deConversionProcessor::~deConversionProcessor() { } bool deConversionProcessor::convert(deColorSpace sourceColorSpace, deValue v1, deValue v2, deValue v3, deValue v4, deColorSpace targetColorSpace, deValue &r1, deValue& r2, deValue& r3, deValue& r4) { deConversionCPU cpu(4); deConversionCPU::deFunction f = getConversion(sourceColorSpace, targetColorSpace); if (!f) { return false; } cpu.input[0] = v1; cpu.input[1] = v2; cpu.input[2] = v3; cpu.input[3] = v4; f(cpu); r1 = cpu.output[0]; r2 = cpu.output[1]; r3 = cpu.output[2]; r4 = cpu.output[3]; return true; } bool deConversionProcessor::renderImageToRGBNew(const deImage& image, unsigned char* data) { deColorSpace colorSpace = image.getColorSpace(); deConversionCPU cpu(4); cpu.registers[CPU_REGISTER_OVERFLOW] = 0; int s = getColorSpaceSize(colorSpace); deConversionCPU::deFunction f = getConversion(colorSpace, deColorSpaceRGB); if (!f) { return false; } if (s == 3) { return cpu.renderImage3(image, f, data); } else if (s == 4) { return cpu.renderImage4(image, f, data); } else if (s == 1) { return cpu.renderImage1(image, f, data); }; return false; } void deConversionProcessor::convertImage(const deImage& sourceImage, deImage& image, deConversionCPU& cpu) { deColorSpace sourceColorSpace = sourceImage.getColorSpace(); deColorSpace targetColorSpace = image.getColorSpace(); if (sourceColorSpace == targetColorSpace) { copyImage(sourceImage, image); return; } int ss = getColorSpaceSize(sourceColorSpace); int ds = getColorSpaceSize(targetColorSpace); deConversionCPU::deFunction f1 = empty; if (sourceColorSpace == deColorSpaceProPhoto) { if (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0) { f1 = applyContrastRGB; } } if (sourceColorSpace == deColorSpaceLAB) { if ((cpu.registers[CPU_REGISTER_SATURATION] < 1.0) || (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0)) { f1 = applyContrastSaturationLAB; } } if (sourceColorSpace == deColorSpaceLCH) { if ((cpu.registers[CPU_REGISTER_SATURATION] < 1.0) || (cpu.registers[CPU_REGISTER_CONTRAST] < 1.0)) { f1 = applyContrastSaturationLCH; } } deConversionCPU::deFunction f2 = getConversion(sourceColorSpace, targetColorSpace); if (!f2) { logError("conversion not found"); } if ((ss == 3) && (ds == 3)) { if (f2) { cpu.convertImage3x3(sourceImage, image, f1, f2); return; } } else if ((ss == 3) && (ds == 4)) { if (f2) { cpu.convertImage3x4(sourceImage, image, f1, f2); return; } } else if ((ss == 4) && (ds == 3)) { if (f2) { cpu.convertImage4x3(sourceImage, image, f1, f2); return; } } else if ((ss == 3) && (ds == 1)) { if (f2) { cpu.convertImage3x1(sourceImage, image, f1, f2); return; } } else if ((ss == 1) && (ds == 3)) { if (f2) { cpu.convertImage1x3(sourceImage, image, f1, f2); return; } } if ((ss == 4) && (ds == 1)) { if (f2) { cpu.convertImage4x1(sourceImage, image, f1, f2); return; } } else if ((ss == 1) && (ds == 4)) { if (f2) { cpu.convertImage1x4(sourceImage, image, f1, f2); return; } } logError("convert image FAILED"); } delaboratory-0.8/core/view_manager.cc0000644000175100001440000000534411764477311016771 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "view_manager.h" #include "project.h" #include "base_layer.h" #include "layer_processor.h" #include "str.h" #include "channel_manager.h" #include "layer_stack.h" #include "zoom_manager.h" deViewManager::deViewManager(deProject& _project, deLayerProcessor& _processor, deZoomManager& _zoomManager) :project(_project), layerProcessor(_processor), zoomManager(_zoomManager) { view = 0; single = false; } deViewManager::~deViewManager() { } int deViewManager::getView() const { return view; } void deViewManager::setView(int v) { logInfo("view manager set view " + str(v)); int old = view; view = v; project.onChangeView(old); } void deViewManager::setLastView() { int n = project.getLayerStack().getSize(); n--; setView(n); } void deViewManager::setSingleChannel(int _channel) { single = true; channel = _channel; project.onChangeViewMode(); layerProcessor.onChangeViewMode(); } void deViewManager::setNormal() { single = false; project.onChangeViewMode(); layerProcessor.onChangeViewMode(); } deColorSpace deViewManager::getColorSpace() const { deColorSpace colorSpace = deColorSpaceInvalid; deLayerStack& layerStack = project.getLayerStack(); const deBaseLayer* layer = layerStack.startReadLayer(view); if (layer) { colorSpace = layer->getColorSpace(); } layerStack.finishReadLayer(view); return colorSpace; } void deViewManager::setHistogramChannel(int channel) { project.setHistogramChannel(channel); } deValue deViewManager::getRealScale() const { deSize ps = project.getPreviewChannelManager().getChannelSizeFromChannelManager(); deSize ss = project.getSourceImageSize(); deValue sx = (deValue) ps.getW() / ss.getW(); deValue sy = (deValue) ps.getH() / ss.getH(); deValue s = sx; if (sy < s) { s = sy; } return s; } void deViewManager::getZoom(deValue& _x1, deValue& _y1, deValue& _x2, deValue& _y2) { return zoomManager.getZoom(_x1, _y1, _x2, _y2); } delaboratory-0.8/core/renderer.h0000644000175100001440000000261411765506775016002 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RENDERER_H #define _DE_RENDERER_H class deChannelManager; class deViewManager; class deLayerProcessor; class deLayerStack; #include "size.h" #include "rendered_image.h" #include "mutex.h" class deRenderer { private: deRenderedImage renderedImage; deSize size; deChannelManager& channelManager; deMutex mutex; unsigned char* getCurrentImageData(); public: deRenderer(deChannelManager& _channelManager); virtual ~deRenderer(); bool render(deCanvas& canvas); bool prepareImage(const deViewManager& viewManager, deLayerProcessor& layerProcessor, deLayerStack& layerStack); }; #endif delaboratory-0.8/core/operation_processor.h0000644000175100001440000000322511776613063020261 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_OPERATION_PROCESSOR_H #define _DE_OPERATION_PROCESSOR_H class deLayerProcessor; class deBaseLayer; class deProject; #include #include #include "color_space.h" class deOperationProcessor { private: deLayerProcessor& layerProcessor; deProject& project; void removeTopLayer(); void addNewLayerOnTop(deBaseLayer* layer); bool tryExecuteBasicOperation(const std::string& operation); bool executeOperation(deColorSpace colorSpace, const std::string& operation); public: deOperationProcessor(deLayerProcessor& _layerProcessor, deProject& _project); virtual ~deOperationProcessor(); void execute(const std::string& operation); void initProfile(const std::string& profile); }; void getSupportedColorsOperations(std::vector& actions); void getSupportedOtherOperations(std::vector& actions); #endif delaboratory-0.8/core/histogram.cc0000644000175100001440000001036411766762751016327 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "histogram.h" #include #include "logger.h" deHistogram::deHistogram(int _size) :size(_size) { bars.reserve(size); clear(); } deHistogram::~deHistogram() { } void deHistogram::clear() { int i; for (i = 0; i < size; i++) { bars[i] = 0 ; } } void deHistogram::put(deValue value) { if ((value < 0) || (value > 1)) { return; } int bar = (size-1) * value; bars[bar] ++; } int deHistogram::getMax() const { int i; int m = 0; for (i = 0; i < size; i++) { if (bars[i] > m) { m = bars[i]; } } return m; } int deHistogram::get(int bar) const { return bars[bar]; } int deHistogram::getSize() const { return size; } void deHistogram::calc(const deValue* pixels, int n) { if (!pixels) { logError("NULL pixels in histogram calc"); return; } static int counter = 0; int j; int scale = size - 1; for (j = 0; j < n; j++) { deValue value = pixels[j]; counter++; int bar = scale * value; if ((bar >= 0) && (bar < size)) { bars[bar] ++; } } } bool deHistogram::render(unsigned char* data, int sizeW, int sizeH, unsigned char g1, unsigned char g2, int margin) { int mm = getMax(); if (mm <= 0) { return false; } unsigned char g3 = 230; int x; int y; for (x = 0; x < sizeW; x++) { int xx = x - margin; if ((xx >= 0) && (xx < size)) { int hh = get(xx); int h = sizeH * hh / mm; if (h > sizeH) { h = sizeH; } for (y = 0; y < sizeH - h; y++) { data[3*(y*sizeW+x)] = g1; data[3*(y*sizeW+x)+1] = g1; data[3*(y*sizeW+x)+2] = g1; } for (y = sizeH - h; y < sizeH; y++) { data[3*(y*sizeW+x)] = g2; data[3*(y*sizeW+x)+1] = g2; data[3*(y*sizeW+x)+2] = g2; } } else { for (y = 0; y < sizeH; y++) { data[3*(y*sizeW+x)] = g3; data[3*(y*sizeW+x)+1] = g3; data[3*(y*sizeW+x)+2] = g3; } } } return true; } void deHistogram::calcLevels(deValue margin1, deValue margin2, deValue& min, deValue& middle, deValue& max) { int i; deValue sum = 0.0; for (i = 0; i < size; i++) { deValue b = bars[i]; sum += b; } deValue left = -1; deValue right = -1; deValue leftMiddle = -1; deValue rightMiddle = -1; deValue s = 0.0; for (i = 0; i < size; i++) { deValue b = bars[i]; s += b; deValue p = s / sum; if ((p >= 1.0 - margin1) && (right < 0)) { right = (deValue) i / (size - 1); } if ((p >= 1.0 - margin2) && (rightMiddle < 0)) { rightMiddle = (deValue) i / (size - 1); } } s = 0.0; for (i = size - 1; i >= 0; i--) { deValue b = bars[i]; s += b; deValue p = s / sum; if ((p >= 1.0 - margin1) && (left < 0)) { left = (deValue) i / (size - 1); } if ((p >= 1.0 - margin2) && (leftMiddle < 0)) { leftMiddle = (deValue) i / (size - 1); } } min = left; max = right; middle = (leftMiddle + rightMiddle) / 2.0; } delaboratory-0.8/core/channel_manager.cc0000644000175100001440000002021412002551204017374 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "channel_manager.h" #include #include #include "logger.h" #include "str.h" deChannelManager::deChannelManager() :channelSize(0,0) { #ifdef DEBUG_LOG logInfo("channel manager constructor"); #endif } deChannelManager::~deChannelManager() { #ifdef DEBUG_LOG logInfo("channel manager destructor"); #endif unsigned int i; for (i = 0; i < channels.size(); i++) { lock(); freeChannel(i); delete mutexes[i]; unlock(); } #ifdef DEBUG_LOG logInfo("channel manager destructor DONE"); #endif } void deChannelManager::setChannelSize(const deSize& size, bool reallocate) { lock(); channelSize = size; if (channelSize.getW() < 0) { logError("w: " + str(channelSize.getW()) + " when setting channel size in channel manager"); } if (channelSize.getH() < 0) { logError("h: " + str(channelSize.getH()) + " when setting channel size in channel manager"); } unsigned int i; for (i = 0; i < channels.size(); i++) { logInfo("destroy channel " + str(i)); mutexes[i]->lockWrite(); tryDeallocateChannel(i); if (reallocate) { tryAllocateChannel(i); } mutexes[i]->unlockWrite(); } unlock(); } void deChannelManager::lock() { #ifdef DEBUG_LOG logInfo("channel manager before lock"); #endif mutex.lock(); #ifdef DEBUG_LOG logInfo("channel manager locked"); #endif } void deChannelManager::unlock() { mutex.unlock(); #ifdef DEBUG_LOG logInfo("channel manager unlocked"); #endif } int deChannelManager::reserveNewChannel() { lock(); deValue* channel = NULL; int c = -1; if (trashed.size() > 0) { std::set::iterator i = trashed.begin(); c = *i; trashed.erase(c); channels[c] = channel; logInfo("reused trashed channel " + str(c)); } else { channels.push_back(channel); mutexes.push_back(new deMutexReadWrite(4)); c = channels.size() - 1; logInfo("added channel " + str(c)); } unlock(); return c; } void deChannelManager::freeChannel(int index) { lock(); bool error = false; if (index < 0) { logError("freeChannel index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("freeChannel index >= " + str(s)); error = true; } if (!error) { logInfo("freeChannel before lockWrite"); mutexes[index]->lockWrite(); logInfo("freeChannel after locks"); assert(index >= 0); assert((unsigned int)index < channels.size()); if (channels[index]) { delete [] channels[index]; channels[index] = NULL; trashed.insert(index); logInfo("destroyed channel " + str(index)); } else { } mutexes[index]->unlockWrite(); } unlock(); logInfo("freeChannel after unlocks"); } deSize deChannelManager::getChannelSizeFromChannelManager() const { if (channelSize.getW() < 0) { logError("w: " + str(channelSize.getW()) + " when getting channel size from channel manager"); } if (channelSize.getH() < 0) { logError("h: " + str(channelSize.getH()) + " when getting channel size from channel manager"); } deSize size = channelSize; return size; } void deChannelManager::tryAllocateChannel(int index) { lock(); bool error = false; if (index < 0) { logError("tryAllocateChannel index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("tryAllocateChannel index >= " + str(s)); error = true; } if (!error) { if (!channels[index]) { logInfo("allocating channel " + str(index)); try { deValue* c = new deValue [channelSize.getN()]; if (c) { logInfo("allocated channel " + str(index)); } else { logError("unable to allocate channel " + str(index)); } channels[index] = c; } catch (std::bad_alloc) { logError("bad_alloc exception on allocate channel " + str(index)); channels[index] = NULL; } } } unlock(); } void deChannelManager::tryDeallocateChannel(int index) { lock(); bool error = false; if (index < 0) { logError("tryDeallocateChannel index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("tryDeallocateChannel index >= " + str(s)); error = true; } if (!error) { if (channels[index]) { logInfo("deallocating channel " + str(index)); delete [] channels[index]; channels[index] = NULL; } } unlock(); } bool deChannelManager::isImageEmpty() const { return channelSize.getN() == 0; } const deValue* deChannelManager::startRead(int index) { #ifdef DEBUG_LOG logInfo("startRead " + str(index)); #endif bool error = false; if (index < 0) { logError("startRead index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("startRead index >= " + str(s)); error = true; } deValue* p = NULL; if (!error) { mutexes[index]->lockRead(); p = channels[index]; } return p; } void deChannelManager::finishRead(int index) { #ifdef DEBUG_LOG logInfo("finishRead " + str(index)); #endif bool error = false; if (index < 0) { logError("finishRead index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("finishRead index >= " + str(s)); error = true; } if (!error) { mutexes[index]->unlockRead(); } } deValue* deChannelManager::startWrite(int index) { #ifdef DEBUG_LOG logInfo("startWrite " + str(index)); #endif bool error = false; if (index < 0) { logError("startWrite index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("startWrite index >= " + str(s)); error = true; } deValue* p = NULL; if (!error) { mutexes[index]->lockWrite(); #ifdef DEBUG_LOG logInfo("startWrite " + str(index) + " locked"); #endif p = channels[index]; } return p; } void deChannelManager::finishWrite(int index) { #ifdef DEBUG_LOG logInfo("finishWrite " + str(index)); #endif bool error = false; if (index < 0) { logError("finishWrite index < 0"); error = true; } else if ((unsigned int)index >= channels.size()) { int s = channels.size(); logError("finishWrite index >= " + str(s)); error = true; } if (!error) { mutexes[index]->unlockWrite(); } } delaboratory-0.8/core/base_layer.h0000644000175100001440000000505211766762751016300 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BASE_LAYER_H #define _DE_BASE_LAYER_H #include "color_space.h" #include "mutex.h" #include #include #include "image.h" class deChannelManager; class deViewManager; class deProperty; class dePreset; class dePropertyNumeric; class dePropertyChoice; class dePropertyBoolean; enum deLayerProcessType { deLayerProcessInvalid, deLayerProcessFull, deLayerProcessSingleChannel, deLayerProcessBlend }; class deBaseLayer { private: deBaseLayer(const deBaseLayer& layer); deBaseLayer& operator = (const deBaseLayer& layer); deMutex mutex; virtual bool updateMainImageSingleChannel(int channel) {return false;}; protected: deColorSpace colorSpace; deImage mainLayerImage; virtual bool updateBlendAllChannels() {return false;}; virtual bool updateMainImageNotThreadedWay() {return false;}; virtual bool updateImage(); public: deBaseLayer(deColorSpace _colorSpace, deChannelManager& _channelManager); virtual ~deBaseLayer(); deColorSpace getColorSpace() const; void lockLayer(); void unlockLayer(); void processLayer(deLayerProcessType type, int channel); bool processFull(); virtual void processSingleChannel(int channel); bool updateImageThreadCall(); virtual std::string getType() const = 0; virtual const deImage& getLayerImage() const; virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; virtual std::string getWarning() const {return "OK";}; virtual bool onImageClick(deValue x, deValue y) {return false;}; virtual void beforeSetUIFromLayer() {}; bool processMainImageSingleChannel(int channel); virtual void allocateChannels(); }; #endif delaboratory-0.8/core/conversion_cpu.cc0000644000175100001440000011455112000537656017353 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "conversion_processor.h" #include "image.h" #include "channel_manager.h" #include "color_space_utils.h" #include "logger.h" #include "power.h" #include "str.h" #include static const deValue Xn = 0.951; static const deValue Yn = 1.0; static const deValue Zn = 1.089; static const deValue c6_29 = 6.0 / 29.0; static const deValue c29_6 = 29.0 / 6.0; static const deValue c6_29_2 = c6_29 * c6_29; static const deValue c6_29_3 = c6_29 * c6_29 * c6_29; static const deValue c29_6_2 = c29_6 * c29_6; static const deValue c4_29 = 4.0 / 29.0; deConversionCPU::deConversionCPU(int size) { input = new deValue [size]; output = new deValue [size]; registers = new deValue [CPU_REGISTERS]; registers[CPU_REGISTER_OVERFLOW] = 0; registers[CPU_REGISTER_CMYK_KEY_SUB] = 0.25; registers[CPU_REGISTER_CMYK_KEY_MAX] = 0.8; registers[CPU_REGISTER_CMYK_MIN_SUM] = 1.0; registers[CPU_REGISTER_BW_MIXER_R] = 0.3; registers[CPU_REGISTER_BW_MIXER_G] = 0.6; registers[CPU_REGISTER_BW_MIXER_B] = 0.1; registers[CPU_REGISTER_CONTRAST] = 1.0; registers[CPU_REGISTER_SATURATION] = 1.0; registers[CPU_REGISTER_PSEUDOGREY] = 0.0; } deConversionCPU::~deConversionCPU() { delete [] input; delete [] output; delete [] registers; } void deConversionCPU::switchIO() { deValue* a = input; input = output; output = a; } void deConversionCPU::incOverflow() { registers[CPU_REGISTER_OVERFLOW] ++; } bool deConversionCPU::renderImage1(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) { int n = image.getChannelSize().getN(); const deValue* s0 = image.startRead(0); if (!s0) { logError("NULL in renderImage1"); image.finishRead(0); return false; } int i; int pos = 0; for (i = 0; i < n; i++) { input[0] = s0[i]; f(*this); unsigned char r = 255 * output[0]; data[pos] = r; pos++; unsigned char g = 255 * output[1]; data[pos] = g; pos++; unsigned char b = 255 * output[2]; data[pos] = b; pos++; } image.finishRead(0); return true; } bool deConversionCPU::renderImage3(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) { int n = image.getChannelSize().getN(); const deValue* s0 = image.startRead(0); const deValue* s1 = image.startRead(1); const deValue* s2 = image.startRead(2); if ((!s0) || (!s1) || (!s2)) { logError("NULL in renderImage3"); image.finishRead(0); image.finishRead(1); image.finishRead(2); return false; } int i; int pos = 0; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; f(*this); unsigned char r = 255 * output[0]; data[pos] = r; pos++; unsigned char g = 255 * output[1]; data[pos] = g; pos++; unsigned char b = 255 * output[2]; data[pos] = b; pos++; } image.finishRead(0); image.finishRead(1); image.finishRead(2); return true; } bool deConversionCPU::renderImage4(const deImage& image, deConversionCPU::deFunction f, unsigned char* data) { int n = image.getChannelSize().getN(); const deValue* s0 = image.startRead(0); const deValue* s1 = image.startRead(1); const deValue* s2 = image.startRead(2); const deValue* s3 = image.startRead(3); if ((!s0) || (!s1) || (!s2) || (!s3)) { logError("NULL in renderImage4"); image.finishRead(0); image.finishRead(1); image.finishRead(2); image.finishRead(3); return false; } int i; int pos = 0; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; input[3] = s3[i]; f(*this); unsigned char r = 255 * output[0]; data[pos] = r; pos++; unsigned char g = 255 * output[1]; data[pos] = g; pos++; unsigned char b = 255 * output[2]; data[pos] = b; pos++; } image.finishRead(0); image.finishRead(1); image.finishRead(2); image.finishRead(3); return true; } void deConversionCPU::convertImage3x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); const deValue* s1 = sourceImage.startRead(1); const deValue* s2 = sourceImage.startRead(2); deValue* d0 = image.startWrite(0); deValue* d1 = image.startWrite(1); deValue* d2 = image.startWrite(2); bool ok; if (s0 && s1 && s2 && d0 && d1 && d2) { ok = true; } else { logError("NULL channel in convertImage 3x3"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; f1(*this); f2(*this); d0[i] = output[0]; d1[i] = output[1]; d2[i] = output[2]; } } sourceImage.finishRead(0); sourceImage.finishRead(1); sourceImage.finishRead(2); image.finishWrite(0); image.finishWrite(1); image.finishWrite(2); } void deConversionCPU::convertImage3x4(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); const deValue* s1 = sourceImage.startRead(1); const deValue* s2 = sourceImage.startRead(2); deValue* d0 = image.startWrite(0); deValue* d1 = image.startWrite(1); deValue* d2 = image.startWrite(2); deValue* d3 = image.startWrite(3); bool ok; if (s0 && s1 && s2 && d0 && d1 && d2 && d3) { ok = true; } else { logError("NULL channel in convertImage 3x4"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; f1(*this); f2(*this); d0[i] = output[0]; d1[i] = output[1]; d2[i] = output[2]; d3[i] = output[3]; } } sourceImage.finishRead(0); sourceImage.finishRead(1); sourceImage.finishRead(2); image.finishWrite(0); image.finishWrite(1); image.finishWrite(2); image.finishWrite(3); } void deConversionCPU::convertImage3x1(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); const deValue* s1 = sourceImage.startRead(1); const deValue* s2 = sourceImage.startRead(2); deValue* d0 = image.startWrite(0); bool ok; if (s0 && s1 && s2 && d0) { ok = true; } else { logError("NULL channel in convertImage 3x1"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; f1(*this); f2(*this); d0[i] = output[0]; } } sourceImage.finishRead(0); sourceImage.finishRead(1); sourceImage.finishRead(2); image.finishWrite(0); } void deConversionCPU::convertImage4x1(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); const deValue* s1 = sourceImage.startRead(1); const deValue* s2 = sourceImage.startRead(2); const deValue* s3 = sourceImage.startRead(3); deValue* d0 = image.startWrite(0); bool ok; if (s0 && s1 && s2 && s3 && d0) { ok = true; } else { logError("NULL channel in convertImage 4x1"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; input[3] = s3[i]; f1(*this); f2(*this); d0[i] = output[0]; } } sourceImage.finishRead(0); sourceImage.finishRead(1); sourceImage.finishRead(2); sourceImage.finishRead(3); image.finishWrite(0); } void deConversionCPU::convertImage4x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); const deValue* s1 = sourceImage.startRead(1); const deValue* s2 = sourceImage.startRead(2); const deValue* s3 = sourceImage.startRead(3); deValue* d0 = image.startWrite(0); deValue* d1 = image.startWrite(1); deValue* d2 = image.startWrite(2); bool ok; if (s0 && s1 && s2 && s3 && d0 && d1 && d2) { ok = true; } else { logError("NULL channel in convertImage 4x3"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; input[1] = s1[i]; input[2] = s2[i]; input[3] = s3[i]; f1(*this); f2(*this); d0[i] = output[0]; d1[i] = output[1]; d2[i] = output[2]; } } sourceImage.finishRead(0); sourceImage.finishRead(1); sourceImage.finishRead(2); sourceImage.finishRead(3); image.finishWrite(0); image.finishWrite(1); image.finishWrite(2); } void deConversionCPU::convertImage1x3(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); deValue* d0 = image.startWrite(0); deValue* d1 = image.startWrite(1); deValue* d2 = image.startWrite(2); bool ok; if (s0 && d0 && d1 && d2) { ok = true; } else { logError("NULL channel in convertImage 1x3"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; f1(*this); f2(*this); d0[i] = output[0]; d1[i] = output[1]; d2[i] = output[2]; } } sourceImage.finishRead(0); image.finishWrite(0); image.finishWrite(1); image.finishWrite(2); } void deConversionCPU::convertImage1x4(const deImage& sourceImage, deImage& image, deConversionCPU::deFunction f1, deConversionCPU::deFunction f2) { int n = sourceImage.getChannelSize().getN(); const deValue* s0 = sourceImage.startRead(0); deValue* d0 = image.startWrite(0); deValue* d1 = image.startWrite(1); deValue* d2 = image.startWrite(2); deValue* d3 = image.startWrite(3); bool ok; if (s0 && d0 && d1 && d2 && d3) { ok = true; } else { logError("NULL channel in convertImage 1x4"); ok = false; } if (ok) { int i; for (i = 0; i < n; i++) { input[0] = s0[i]; f1(*this); f2(*this); d0[i] = output[0]; d1[i] = output[1]; d2[i] = output[2]; d3[i] = output[3]; } } sourceImage.finishRead(0); image.finishWrite(0); image.finishWrite(1); image.finishWrite(2); image.finishWrite(3); } void empty(deConversionCPU& cpu) { } void rgb2cmy(deConversionCPU& cpu) { cpu.output[0] = 1.0 - cpu.input[0]; cpu.output[1] = 1.0 - cpu.input[1]; cpu.output[2] = 1.0 - cpu.input[2]; } void bw2rgb(deConversionCPU& cpu) { deValue pg = cpu.registers[CPU_REGISTER_PSEUDOGREY] / 255.0; deValue bw = cpu.input[0]; if (pg == 0) { cpu.output[0] = bw; cpu.output[1] = bw; cpu.output[2] = bw; } else { int bbw = (int) (255 * bw * 16); int m = bbw % 16; deValue r = 0; deValue g = 0; deValue b = 0; if ((m >= 2) && (m <= 4)) { b = 1; } if ((m >= 5) && (m <= 6)) { r = 1; } if ((m >= 7) && (m <= 8)) { r = 1; b = 1; } if ((m >= 9) && (m <= 10)) { g = 1; } if ((m >= 11) && (m <= 13)) { g = 1; b = 1; } if ((m >= 14) && (m <= 15)) { g = 1; r = 1; } r = bw + pg * r; if (r > 1) { r = 1; } g = bw + pg * g; if (g > 1) { g = 1; } b = bw + pg * b; if (b > 1) { b = 1; } cpu.output[0] = r; cpu.output[1] = g; cpu.output[2] = b; } } void rgb2bw(deConversionCPU& cpu) { deValue r = cpu.input[0]; deValue g = cpu.input[1]; deValue b = cpu.input[2]; deValue mr = cpu.registers[CPU_REGISTER_BW_MIXER_R]; deValue mg = cpu.registers[CPU_REGISTER_BW_MIXER_G]; deValue mb = cpu.registers[CPU_REGISTER_BW_MIXER_B]; deValue bw = mr * r + mg * g + mb * b; if (bw < 0) { bw = 0; cpu.incOverflow(); } else if (bw > 1) { bw = 1; cpu.incOverflow(); } cpu.output[0] = bw; } void cmy2rgb(deConversionCPU& cpu) { cpu.output[0] = 1.0 - cpu.input[0]; cpu.output[1] = 1.0 - cpu.input[1]; cpu.output[2] = 1.0 - cpu.input[2]; } void cmy2cmyk(deConversionCPU& cpu) { deValue k; deValue c = cpu.input[0]; deValue m = cpu.input[1]; deValue y = cpu.input[2]; if (c < m) { if (c < y) { k = c; } else { k = y; } } else { if (m < y) { k = m; } else { k = y; } } k = k - cpu.registers[CPU_REGISTER_CMYK_KEY_SUB]; if (k < 0.0) { k = 0.0; } deValue max = cpu.registers[CPU_REGISTER_CMYK_KEY_MAX]; if (k > max) { k = max; } if (c + m + y < cpu.registers[CPU_REGISTER_CMYK_MIN_SUM]) { k = 0.0; } deValue kk = (1 - k); cpu.output[0] = (c - k) / kk; cpu.output[1] = (m - k) / kk; cpu.output[2] = (y - k) / kk; cpu.output[3] = k; } void cmyk2cmy(deConversionCPU& cpu) { deValue k = cpu.input[3]; deValue kk = 1.0 - k; deValue c = cpu.input[0] * kk + k; deValue m = cpu.input[1] * kk + k; deValue y = cpu.input[2] * kk + k; cpu.output[0] = c; cpu.output[1] = m; cpu.output[2] = y; } void rgb2prophoto(deConversionCPU& cpu) { /* from dcraw octave:1> x = [0.529317, 0.330092, 0.140588; 0.098368, 0.873465, 0.028169; 0.016879, 0.117663, 0.865457] x = 0.529317 0.330092 0.140588 0.098368 0.873465 0.028169 0.016879 0.117663 0.865457 */ deValue r = cpu.input[0]; deValue g = cpu.input[1]; deValue b = cpu.input[2]; cpu.output[0] = 0.529317 * r + 0.330092 * g + 0.140588 * b; cpu.output[1] = 0.098368 * r + 0.873465 * g + 0.028169 * b; cpu.output[2] = 0.016879 * r + 0.117663 * g + 0.865457 * b; } void prophoto2rgb(deConversionCPU& cpu) { /* invert matrix from dcraw octave:2> inv(x) ans = 2.0341926 -0.7274198 -0.3067655 -0.2288108 1.2317292 -0.0029216 -0.0085649 -0.1532726 1.1618390 */ deValue pr = cpu.input[0]; deValue pg = cpu.input[1]; deValue pb = cpu.input[2]; deValue r = 2.0341926 * pr -0.7274198 * pg -0.3067655 * pb; deValue g = -0.2288108 * pr + 1.2317292 * pg -0.0029216 * pb; deValue b = -0.0085649 * pr -0.1532726 * pg + 1.1618390 * pb; if (r < 0) { r = 0; cpu.incOverflow(); } else if (r > 1) { r = 1; cpu.incOverflow(); } if (g < 0) { g = 0; cpu.incOverflow(); } else if (g > 1) { g = 1; cpu.incOverflow(); } if (b < 0) { b = 0; cpu.incOverflow(); } else if (b > 1) { b = 1; cpu.incOverflow(); } cpu.output[0] = r; cpu.output[1] = g; cpu.output[2] = b; } void prophoto2xyz(deConversionCPU& cpu) { /* octave:7> z z = 2.0341926 -0.7274198 -0.3067655 -0.2288108 1.2317292 -0.0029216 -0.0085649 -0.1532726 1.1618390 octave:8> y y = 0.412400 0.357600 0.180500 0.212600 0.715200 0.072200 0.019300 0.119200 0.950500 octave:10> y * z ans = 0.7555323 0.1128127 0.0821571 0.2682055 0.7152170 0.0165769 0.0038447 -0.0129027 1.0980591 */ deValue pr = cpu.input[0]; deValue pg = cpu.input[1]; deValue pb = cpu.input[2]; cpu.output[0] = 0.7555323 * pr + 0.1128127* pg + 0.0821571* pb; cpu.output[1] = 0.2682055 * pr + 0.7152170* pg + 0.0165769* pb; cpu.output[2] = 0.0038447 * pr -0.0129027 * pg + 1.0980591* pb; } void rgb2xyz(deConversionCPU& cpu) { deValue r = cpu.input[0]; deValue g = cpu.input[1]; deValue b = cpu.input[2]; cpu.output[0] = 0.4124 * r + 0.3576 * g + 0.1805 * b; cpu.output[1] = 0.2126 * r + 0.7152 * g + 0.0722 * b; cpu.output[2] = 0.0193 * r + 0.1192 * g + 0.9505 * b; } void xyz2rgb(deConversionCPU& cpu) { deValue x = cpu.input[0]; deValue y = cpu.input[1]; deValue z = cpu.input[2]; deValue r = 3.2410 * x - 1.5374 * y - 0.4986 * z; deValue g = -0.9692 * x + 1.8760 * y + 0.0416 * z; deValue b = 0.0556 * x - 0.2040 * y + 1.0570 * z; if (r < 0) { r = 0; cpu.incOverflow(); } else if (r > 1) { r = 1; cpu.incOverflow(); } if (g < 0) { g = 0; cpu.incOverflow(); } else if (g > 1) { g = 1; cpu.incOverflow(); } if (b < 0) { b = 0; cpu.incOverflow(); } else if (b > 1) { b = 1; cpu.incOverflow(); } cpu.output[0] = r; cpu.output[1] = g; cpu.output[2] = b; } void xyz2lab(deConversionCPU& cpu) { static dePower power(1.0 / 3.0, 2); deValue xx = cpu.input[0] / Xn; deValue yy = cpu.input[1] / Yn; deValue zz = cpu.input[2] / Zn; deValue fx; deValue fy; deValue fz; if (xx > c6_29_3) { fx = power.get(xx); } else { fx = 1.0 / 3.0 * c29_6_2 * xx + c4_29; } if (yy > c6_29_3) { fy = power.get(yy); } else { fy = 1.0 / 3.0 * c29_6_2 * yy + c4_29; } if (zz > c6_29_3) { fz = power.get(zz); } else { fz = 1.0 / 3.0 * c29_6_2 * zz + c4_29; } deValue l = 116.0 * fy - 16.0; deValue a = 500.0 * (fx - fy); deValue b = 200.0 * (fy - fz); l /= 100.0; a += 100.0; b += 100.0; a /= 200.0; b /= 200.0; if (l < 0) { l = 0; cpu.incOverflow(); } else if (l > 1) { l = 1; cpu.incOverflow(); } if (a < 0) { a = 0; cpu.incOverflow(); } else if (a > 1) { a = 1; cpu.incOverflow(); } if (b < 0) { b = 0; cpu.incOverflow(); } else if (b > 1) { b = 1; cpu.incOverflow(); } cpu.output[0] = l; cpu.output[1] = a; cpu.output[2] = b; } void lab2lch(deConversionCPU& cpu) { deValue a = cpu.input[1]; deValue b = cpu.input[2]; a = ( a - 0.5) * 200.0; b = ( b - 0.5) * 200.0; deValue _c = sqrt(a * a + b * b); deValue _h = atan2(b, a); _c = _c / 100.0; _h = (_h / ( 2 * M_PI )); if (_h < 0) { _h += 1; } if ( _c > 1) { _c = 1; cpu.incOverflow(); } if ( _c < 0) { _c = 0; cpu.incOverflow(); } cpu.output[0] = cpu.input[0]; cpu.output[1] = _c; cpu.output[2] = _h; } void lch2lab(deConversionCPU& cpu) { deValue c = cpu.input[1]; deValue h = cpu.input[2]; c = c * 100.0; h = h * (2 * M_PI); deValue a = c * cos(h); deValue b = c * sin(h); a = a / 200.0 + 0.5; b = b / 200.0 + 0.5; cpu.output[0] = cpu.input[0]; cpu.output[1] = a; cpu.output[2] = b; } void prophoto2lab(deConversionCPU& cpu) { prophoto2xyz(cpu); cpu.switchIO(); xyz2lab(cpu); } void rgb2cmyk(deConversionCPU& cpu) { rgb2cmy(cpu); cpu.switchIO(); cmy2cmyk(cpu); } void prophoto2cmyk(deConversionCPU& cpu) { prophoto2rgb(cpu); cpu.switchIO(); rgb2cmyk(cpu); } void noConversion(deConversionCPU& cpu) { cpu.switchIO(); } void rgb2lab(deConversionCPU& cpu) { rgb2xyz(cpu); cpu.switchIO(); xyz2lab(cpu); } void rgb2lch(deConversionCPU& cpu) { rgb2lab(cpu); cpu.switchIO(); lab2lch(cpu); } void prophoto2lch(deConversionCPU& cpu) { prophoto2lab(cpu); cpu.switchIO(); lab2lch(cpu); } void cmyk2rgb(deConversionCPU& cpu) { cmyk2cmy(cpu); cpu.switchIO(); cmy2rgb(cpu); } void cmyk2lab(deConversionCPU& cpu) { cmyk2rgb(cpu); cpu.switchIO(); rgb2lab(cpu); } void lab2xyz(deConversionCPU& cpu) { deValue l = cpu.input[0]; deValue a = cpu.input[1]; deValue b = cpu.input[2]; l *= 100.0; a *= 200.0; b *= 200.0; a -= 100.0; b -= 100.0; deValue ll = (l + 16.0) / 116.0; deValue ll_aa = ll + a / 500.0; deValue ll_bb = ll - b / 200.0; deValue ffx; deValue ffy; deValue ffz; if (ll > c6_29) { ffy = ll * ll * ll; } else { ffy = 3.0 * c6_29_2 * (ll - c4_29); } if (ll_aa > c6_29) { ffx = ll_aa * ll_aa * ll_aa; } else { ffx = 3.0 * c6_29_2 * (ll_aa - c4_29); } if (ll_bb > c6_29) { ffz = ll_bb * ll_bb * ll_bb; } else { ffz = 3.0 * c6_29_2 * (ll_bb - c4_29); } cpu.output[0] = Xn * ffx; cpu.output[1] = Yn * ffy; cpu.output[2] = Zn * ffz; } void xyz2prophoto(deConversionCPU& cpu) { /* x = [0.7555323, 0.1128127, 0.0821571; 0.2682055, 0.7152170, 0.0165769; 0.0038447, -0.0129027, 1.0980591] octave:2> inv(x) ans = 1.403314 -0.223181 -0.101627 -0.525984 1.481448 0.016990 -0.011094 0.018189 0.911253 */ deValue x = cpu.input[0]; deValue y = cpu.input[1]; deValue z = cpu.input[2]; cpu.output[0] = 1.403314* x -0.223181* y -0.101627* z; cpu.output[1] = -0.525984* x + 1.481448* y + 0.016990* z; cpu.output[2] = -0.011094* x + 0.018189* y + 0.911253* z; } void lab2prophoto(deConversionCPU& cpu) { lab2xyz(cpu); cpu.switchIO(); xyz2prophoto(cpu); } void lch2prophoto(deConversionCPU& cpu) { lch2lab(cpu); cpu.switchIO(); lab2prophoto(cpu); } void lab2rgb(deConversionCPU& cpu) { lab2xyz(cpu); cpu.switchIO(); xyz2rgb(cpu); } void lab2bw(deConversionCPU& cpu) { lab2rgb(cpu); cpu.switchIO(); rgb2bw(cpu); } void cmyk2bw(deConversionCPU& cpu) { cmyk2rgb(cpu); cpu.switchIO(); rgb2bw(cpu); } void bw2cmyk(deConversionCPU& cpu) { bw2rgb(cpu); cpu.switchIO(); rgb2cmyk(cpu); } void bw2lab(deConversionCPU& cpu) { bw2rgb(cpu); cpu.switchIO(); rgb2lab(cpu); } void bw2lch(deConversionCPU& cpu) { bw2lab(cpu); cpu.switchIO(); lab2lch(cpu); } void lch2bw(deConversionCPU& cpu) { lch2lab(cpu); cpu.switchIO(); lab2bw(cpu); } void lab2cmyk(deConversionCPU& cpu) { lab2rgb(cpu); cpu.switchIO(); rgb2cmy(cpu); cpu.switchIO(); cmy2cmyk(cpu); } void lch2rgb(deConversionCPU& cpu) { lch2lab(cpu); cpu.switchIO(); lab2rgb(cpu); } void lch2cmyk(deConversionCPU& cpu) { lch2rgb(cpu); cpu.switchIO(); rgb2cmyk(cpu); } void cmyk2lch(deConversionCPU& cpu) { cmyk2rgb(cpu); cpu.switchIO(); rgb2lch(cpu); } deValue min3(deValue a, deValue b, deValue c) { if (a < b) { if (a < c) { return a; } else { return c; } } else { if (b < c) { return b; } else { return c; } } } deValue max3(deValue a, deValue b, deValue c) { if (a > b) { if (a > c) { return a; } else { return c; } } else { if (b > c) { return b; } else { return c; } } } void rgb2hsl(deConversionCPU& cpu) { deValue r = cpu.input[0]; deValue g = cpu.input[1]; deValue b = cpu.input[2]; deValue minVal = min3( r, g, b ); deValue maxVal = max3( r, g, b ); deValue delta = maxVal - minVal; deValue sum = minVal + maxVal; deValue l = sum / 2.0; deValue h; deValue s; if (delta == 0) { h = 0; s = 0; } else { if ( l < 0.5 ) { s = delta / sum; } else { s = delta / ( 2.0 - sum ); } deValue deltaR = ( ( ( maxVal - r ) / 6 ) + ( delta / 2 ) ) / delta; deValue deltaG = ( ( ( maxVal - g ) / 6 ) + ( delta / 2 ) ) / delta; deValue deltaB = ( ( ( maxVal - b ) / 6 ) + ( delta / 2 ) ) / delta; if ( r == maxVal ) { h = deltaB - deltaG; } else if ( g == maxVal ) { h = ( 1.0 / 3.0 ) + deltaR - deltaB; } else if ( b == maxVal ) { h = ( 2.0 / 3.0 ) + deltaG - deltaR; } if ( h < 0 ) h += 1; if ( h > 1 ) h -= 1; } cpu.output[0] = h; cpu.output[1] = s; cpu.output[2] = l; } deValue min(deValue a, deValue b, deValue c) { if (a < b) { if (a < c) { return a; } else { return c; } } else { if (b < c) { return b; } else { return c; } } } deValue max(deValue a, deValue b, deValue c) { if (a > b) { if (a > c) { return a; } else { return c; } } else { if (b > c) { return b; } else { return c; } } } deValue hue2rgb( deValue v1, deValue v2, deValue vH ) { if ( vH < 0 ) vH += 1; if ( vH > 1 ) vH -= 1; if ( ( 6.0 * vH ) < 1.0 ) return ( v1 + ( v2 - v1 ) * 6.0 * vH ); if ( ( 2.0 * vH ) < 1.0 ) return ( v2 ); if ( ( 3.0 * vH ) < 2.0 ) return ( v1 + ( v2 - v1 ) * ( ( 2.0 / 3.0 ) - vH ) * 6.0 ); return ( v1 ); } void hsl2rgb(deConversionCPU& cpu) { deValue h = cpu.input[0]; deValue s = cpu.input[1]; deValue l = cpu.input[2]; deValue r = 0.0; deValue g = 0.0; deValue b = 0.0; if ( s == 0 ) { r = l; g = l; b = l; } else { deValue v1; deValue v2; if ( l < 0.5 ) { v2 = l * ( 1 + s ); } else { v2 = ( l + s ) - ( s * l ); } v1 = 2.0 * l - v2; r = hue2rgb( v1, v2, h + ( 1.0 / 3.0 ) ); g = hue2rgb( v1, v2, h ); b = hue2rgb( v1, v2, h - ( 1.0 / 3.0 ) ); } cpu.output[0] = r; cpu.output[1] = g; cpu.output[2] = b; } void rgb2hsv(deConversionCPU& cpu) { deValue r = cpu.input[0]; deValue g = cpu.input[1]; deValue b = cpu.input[2]; deValue h = 0.0; deValue s = 0.0; deValue v = max( r, g, b ); deValue minVal = min( r, g, b ); deValue delta = v - minVal; if (delta == 0) { h = 0; s = 0; } else { s = delta / v; deValue deltaR = ( ( ( v - r ) / 6.0 ) + ( delta / 2.0 ) ) / delta; deValue deltaG = ( ( ( v - g ) / 6.0 ) + ( delta / 2.0 ) ) / delta; deValue deltaB = ( ( ( v - b ) / 6.0 ) + ( delta / 2.0 ) ) / delta; if ( r == v ) { h = deltaB - deltaG; } else if ( g == v ) { h = ( 1.0 / 3.0 ) + deltaR - deltaB; } else if ( b == v ) { h = ( 2.0 / 3.0 ) + deltaG - deltaR; } if ( h < 0 ) h += 1.0; if ( h > 1 ) h -= 1.0; } cpu.output[0] = h; cpu.output[1] = s; cpu.output[2] = v; } void prophoto2hsv(deConversionCPU& cpu) { prophoto2rgb(cpu); cpu.switchIO(); rgb2hsv(cpu); } void prophoto2hsl(deConversionCPU& cpu) { prophoto2rgb(cpu); cpu.switchIO(); rgb2hsl(cpu); } void lab2hsv(deConversionCPU& cpu) { lab2rgb(cpu); cpu.switchIO(); rgb2hsv(cpu); } void lch2hsv(deConversionCPU& cpu) { lch2lab(cpu); cpu.switchIO(); lab2hsv(cpu); } void bw2hsv(deConversionCPU& cpu) { bw2rgb(cpu); cpu.switchIO(); rgb2hsv(cpu); } void lab2hsl(deConversionCPU& cpu) { lab2rgb(cpu); cpu.switchIO(); rgb2hsl(cpu); } void lch2hsl(deConversionCPU& cpu) { lch2lab(cpu); cpu.switchIO(); lab2hsl(cpu); } void bw2hsl(deConversionCPU& cpu) { bw2rgb(cpu); cpu.switchIO(); rgb2hsl(cpu); } void hsv2rgb(deConversionCPU& cpu) { deValue h = cpu.input[0]; deValue s = cpu.input[1]; deValue v = cpu.input[2]; deValue r = 0.0; deValue g = 0.0; deValue b = 0.0; if ( s == 0 ) { r = v; g = v; b = v; } else { deValue var_h = h * 6.0; if ( var_h == 6.0 ) { var_h = 0; } deValue var_i = int( var_h); deValue var_1 = v * ( 1.0 - s ); deValue var_2 = v * ( 1.0 - s * ( var_h - var_i ) ); deValue var_3 = v * ( 1.0 - s * ( 1.0 - ( var_h - var_i ) ) ); if ( var_i == 0 ) { r = v; g = var_3; b = var_1; } else if ( var_i == 1 ) { r = var_2; g = v; b = var_1; } else if ( var_i == 2 ) { r = var_1; g = v; b = var_3; } else if ( var_i == 3 ) { r = var_1; g = var_2; b = v; } else if ( var_i == 4 ) { r = var_3; g = var_1; b = v; } else { r = v; g = var_1; b = var_2; } } cpu.output[0] = r; cpu.output[1] = g; cpu.output[2] = b; } void hsv2cmyk(deConversionCPU& cpu) { hsv2rgb(cpu); cpu.switchIO(); rgb2cmyk(cpu); } void cmyk2hsv(deConversionCPU& cpu) { cmyk2rgb(cpu); cpu.switchIO(); rgb2hsv(cpu); } void cmyk2hsl(deConversionCPU& cpu) { cmyk2rgb(cpu); cpu.switchIO(); rgb2hsl(cpu); } void hsv2lab(deConversionCPU& cpu) { hsv2rgb(cpu); cpu.switchIO(); rgb2lab(cpu); } void hsv2bw(deConversionCPU& cpu) { hsv2rgb(cpu); cpu.switchIO(); rgb2bw(cpu); } void hsv2lch(deConversionCPU& cpu) { hsv2rgb(cpu); cpu.switchIO(); rgb2lch(cpu); } deConversionCPU::deFunction getConversion(deColorSpace sourceColorSpace, deColorSpace targetColorSpace) { if (sourceColorSpace == targetColorSpace) { return noConversion; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceRGB)) { return prophoto2rgb; } if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceRGB)) { return rgb2prophoto; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceLAB)) { return prophoto2lab; } if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceLAB)) { return lab2prophoto; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceLCH)) { return prophoto2lch; } if ((targetColorSpace == deColorSpaceProPhoto) && (sourceColorSpace == deColorSpaceLCH)) { return lch2prophoto; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceLAB)) { return rgb2lab; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSL)) { return rgb2hsl; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSV)) { return rgb2hsv; } if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceHSV)) { return cmyk2hsv; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceHSV)) { return prophoto2hsv; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceHSV)) { return lch2hsv; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceHSV)) { return lab2hsv; } if ((targetColorSpace == deColorSpaceHSV) && (sourceColorSpace == deColorSpaceBW)) { return bw2hsv; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceHSL)) { return rgb2hsl; } if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceHSL)) { return cmyk2hsl; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceHSL)) { return prophoto2hsl; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceHSL)) { return lch2hsl; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceHSL)) { return lab2hsl; } if ((targetColorSpace == deColorSpaceHSL) && (sourceColorSpace == deColorSpaceBW)) { return bw2hsl; } if ((sourceColorSpace == deColorSpaceHSL) && (targetColorSpace == deColorSpaceRGB)) { return hsl2rgb; } if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceRGB)) { return hsv2rgb; } if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceLAB)) { return hsv2lab; } if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceCMYK)) { return hsv2cmyk; } if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceBW)) { return hsv2bw; } if ((sourceColorSpace == deColorSpaceHSV) && (targetColorSpace == deColorSpaceLCH)) { return hsv2lch; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceLCH)) { return rgb2lch; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceRGB)) { return lch2rgb; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceCMYK)) { return lch2cmyk; } if ((targetColorSpace == deColorSpaceLCH) && (sourceColorSpace == deColorSpaceCMYK)) { return cmyk2lch; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceRGB)) { return lab2rgb; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceLCH)) { return lab2lch; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceLAB)) { return lch2lab; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceCMYK)) { return prophoto2cmyk; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceCMYK)) { return rgb2cmyk; } if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceRGB)) { return cmyk2rgb; } if ((sourceColorSpace == deColorSpaceRGB) && (targetColorSpace == deColorSpaceBW)) { return rgb2bw; } if ((sourceColorSpace == deColorSpaceProPhoto) && (targetColorSpace == deColorSpaceBW)) { return rgb2bw; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceBW)) { return lab2bw; } if ((sourceColorSpace == deColorSpaceLCH) && (targetColorSpace == deColorSpaceBW)) { return lch2bw; } if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceBW)) { return cmyk2bw; } if ((sourceColorSpace == deColorSpaceBW) && (targetColorSpace == deColorSpaceRGB)) { return bw2rgb; } if ((sourceColorSpace == deColorSpaceCMYK) && (targetColorSpace == deColorSpaceLAB)) { return cmyk2lab; } if ((sourceColorSpace == deColorSpaceLAB) && (targetColorSpace == deColorSpaceCMYK)) { return lab2cmyk; } if ((targetColorSpace == deColorSpaceLAB) && (sourceColorSpace == deColorSpaceBW)) { return bw2lab; } if ((targetColorSpace == deColorSpaceLCH) && (sourceColorSpace == deColorSpaceBW)) { return bw2lch; } if ((targetColorSpace == deColorSpaceCMYK) && (sourceColorSpace == deColorSpaceBW)) { return bw2cmyk; } logError("no conversion for " + getColorSpaceName(sourceColorSpace) + " -> " + getColorSpaceName(targetColorSpace)); return NULL; } delaboratory-0.8/core/str.cc0000644000175100001440000000536111777136356015141 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "str.h" #include std::string getBaseName(const std::string& s) { int pos = s.rfind("."); return s.substr(0, pos); } std::string getExtension(const std::string& s) { int pos = s.rfind("."); return s.substr(pos + 1, s.size() - pos - 1); } std::string removePathAndExtension(const std::string& fileName) { size_t posDot = fileName.rfind("."); #ifdef _WIN32 size_t posSlash = fileName.rfind("\\"); #else size_t posSlash = fileName.rfind("/"); #endif int posStart; if (posSlash > fileName.size()) { posStart= 0; } else { posStart = posSlash + 1; } return fileName.substr(posStart, posDot - posStart ); } std::string getPath(const std::string& fileName) { #ifdef _WIN32 size_t posSlash = fileName.rfind("\\"); #else size_t posSlash = fileName.rfind("/"); #endif return fileName.substr(0, posSlash ); } std::string str(int n) { std::ostringstream oss; oss << n; return oss.str(); } std::string str(long n) { std::ostringstream oss; oss << n; return oss.str(); } std::string str(unsigned int n) { std::ostringstream oss; oss << n; return oss.str(); } std::string str(deValue n) { std::ostringstream oss; oss << n; return oss.str(); } deValue getValue(const std::string& s) { deValue v; std::istringstream iss(s); iss >> v; return v; } int getInt(const std::string& s) { int v; std::istringstream iss(s); iss >> v; return v; } bool getBool(const std::string& s) { if (s == "true") { return true; } else { // TODO some kind of assert of exception in other case? return false; } } std::string str(bool b) { if (b) { return "true"; } else { return "false"; } } std::string insertIndex(const std::string& s, int index) { std::string b = getBaseName(s); std::string e = getExtension(s); return b + "_" + str(index) + "." + e; } delaboratory-0.8/core/size.cc0000644000175100001440000000347711764477311015304 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "size.h" #include deSize::deSize(int _w, int _h) { w = _w; h = _h; } deSize::~deSize() { } bool operator ==(const deSize& a, const deSize& b) { return ( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); } bool operator !=(const deSize& a, const deSize& b) { return !( ( a.getW() == b.getW() ) && ( a.getH() == b.getH() ) ); } deSize fitInside(const deSize& area, deValue aspect) { if (aspect == 0) { return deSize(0,0); } int w = area.getW(); int h = w / aspect; if (h > area.getH()) { h = area.getH(); w = h * aspect; } return deSize(w,h); } std::string deSize::str() const { std::ostringstream oss; oss << "[w: " << w << " h: " << h << "]"; return oss.str(); } bool deSize::isEmpty() const { if (w > 0) { return false; } if (h > 0) { return false; } return true; } deSize deSize::rotated() const { deSize s(h, w); return s; } float deSize::getAspect() const { if (h > 0) { return (float) w / h; } return 0; } delaboratory-0.8/core/test_image.cc0000644000175100001440000000506311765506775016454 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "test_image.h" #include "static_image.h" #include #include void generateImage1(deValue* pixels0, deValue* pixels1, deValue* pixels2, int w, int h) { int x; int y; int p = 0; deValue margin = 0.1; deValue L = 0.8; deValue A; deValue B; for (y = 0; y < h; y++) { deValue yy = (deValue) y / h; if ((yy > margin) && (yy < 1 - margin)) { B = (yy - margin) / (1.0 - 2 * margin); } else { B = 0; } for (x = 0; x < w; x++) { deValue xx = (deValue) x / w; if ((xx > margin) && (xx < 1 - margin)) { A = (xx - margin) / (1.0 - 2 * margin); } else { A = 0; } if ((A == 0) || (B == 0)) { deValue m = yy; if (xx > m) { m = xx; } pixels0[p] = m; pixels1[p] = 0.5; pixels2[p] = 0.5; } else { pixels0[p] = L; pixels1[p] = A; pixels2[p] = B; } p++; } } } void generateTestImage(deStaticImage& image, int s) { int w = s; int h = s; deColorSpace colorSpace = deColorSpaceLAB; image.lock(); deSize size(w, h); image.setSize(size); image.setColorSpace(colorSpace); deValue* pixels0 = image.startWriteStatic(0); deValue* pixels1 = image.startWriteStatic(1); deValue* pixels2 = image.startWriteStatic(2); generateImage1(pixels0, pixels1, pixels2, w, h); image.finishWriteStatic(0); image.finishWriteStatic(1); image.finishWriteStatic(2); image.unlock(); } delaboratory-0.8/core/sampler.h0000644000175100001440000000265211764477311015631 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SAMPLER_H #define _DE_SAMPLER_H #include "color_space.h" #include "value.h" class deSampler { private: deValue x; deValue y; deColorSpace colorSpace; bool enabled; bool selected; public: deSampler(); virtual ~deSampler(); deValue getX() const {return x;}; deValue getY() const {return y;}; void setPosition(deValue _x, deValue _y); deColorSpace getColorSpace() const {return colorSpace;}; void setColorSpace(deColorSpace c); bool isEnabled() const; void enable(); void disable(); bool isSelected() const; void setSelected(bool s); }; #endif delaboratory-0.8/core/property.h0000644000175100001440000000311011764477311016040 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_H #define _DE_PROPERTY_H #include class deProperty { private: std::string sizer; std::string label; bool blendOnly; bool size; bool others; protected: std::string name; public: deProperty(const std::string& _name); virtual ~deProperty(); std::string getLabel() const; void setLabel(const std::string& _label); std::string getName() const; virtual bool updateBlendOnly() const {return blendOnly;}; void setBlendOnly(); void setSizer(const std::string& _sizer) {sizer = _sizer;}; std::string getSizer() const {return sizer;}; bool affectSize() const {return size;}; void setSize(); bool affectOthers() const {return others;}; void setOthers(); }; #endif delaboratory-0.8/core/base_layer.cc0000644000175100001440000000600412002551204016401 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "base_layer.h" #include "logger.h" #include "str.h" #include "update_main_layer_image.h" deBaseLayer::deBaseLayer(deColorSpace _colorSpace, deChannelManager& _channelManager) :colorSpace(_colorSpace), mainLayerImage(_colorSpace, _channelManager) { } deBaseLayer::~deBaseLayer() { } deColorSpace deBaseLayer::getColorSpace() const { return colorSpace; } void deBaseLayer::lockLayer() { #ifdef DEBUG_LOG logInfo("base layer before lock"); #endif mutex.lock(); #ifdef DEBUG_LOG logInfo("base layer locked"); #endif } void deBaseLayer::unlockLayer() { mutex.unlock(); #ifdef DEBUG_LOG logInfo("base layer unlocked"); #endif } void deBaseLayer::processLayer(deLayerProcessType type, int channel) { #ifdef DEBUG_LOG logInfo("processLayer channel: " + str(channel)); #endif switch (type) { case deLayerProcessFull: { processFull(); break; } case deLayerProcessSingleChannel: { processSingleChannel(channel); break; } case deLayerProcessBlend: { updateBlendAllChannels(); break; } default: break; } #ifdef DEBUG_LOG logInfo("processLayer DONE"); #endif } bool deBaseLayer::processFull() { return updateImage(); } const deImage& deBaseLayer::getLayerImage() const { return mainLayerImage; } void deBaseLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const { mainLayerImage.updateChannelUsage(channelUsage, layerIndex); } void deBaseLayer::processSingleChannel(int channel) { processMainImageSingleChannel(channel); } bool deBaseLayer::processMainImageSingleChannel(int channel) { bool result = true; #ifdef DEBUG_LOG logInfo("base layer process main image single channel"); #endif result = updateMainImageSingleChannel(channel); #ifdef DEBUG_LOG logInfo("base layer process main image single channel DONE"); #endif return result; } bool deBaseLayer::updateImage() { bool result = updateMainImageNotThreadedWay(); if (!result) { updateMainImageAllChannels(*this); result = true; } return result; } void deBaseLayer::allocateChannels() { mainLayerImage.allocateChannels(); } delaboratory-0.8/.depend0000644000175100001440000000000011577155654014313 0ustar jacekusersdelaboratory-0.8/Makefile0000644000175100001440000001306012004651007014500 0ustar jacekusers APP=delaboratory all: ${APP} CXX=g++ ifeq (${OS}, MACOSX) WXCONFIG=/Users/partha/local/wxw-2.9/bin/wx-config else WXCONFIG=wx-config #WXCONFIG=wx-config-2.9 endif FILES = delaboratory main_frame image_io layer_grid_panel image_area_panel image_panel curves_panel frame slider histogram_panel control_panel gradient_panel view_mode_panel help_frame help_color_spaces_frame help_color_spaces_frame2 help_color_spaces_frame3 help_color_spaces_frame4 help_color_spaces_frame5 help_color_spaces_frame6 histogram_mode_panel file_dialogs external_editor choice property_choice_ui check_box property_boolean_ui samplers_panel sampler_panel layer_frame_manager rendered_image dcraw_support raw_module zoom_panel threads_panel color_matrix_frame mutex color_space_utils semaphore main_window canvas canvas_wx bitmap bitmap_wx window window_wx panel_wx property_numeric_ui button warning_panel property_levels_ui mutex_read_write property_mixer_ui channel_selector property_curves_ui tiff logger str_wx update_main_layer_image layer_processor_threads progress_dialog message_box update_blend gui tmp LAYERS = curves_layer mixer_layer auto_dodge_layer auto_burn_layer recover_shadows_layer recover_highlights_layer high_pass_layer vignette_layer source_image_layer gaussian_blur_layer gaussian_blur_single_layer conversion_layer equalizer_layer c2g_layer copy_layer gradient_layer fill_layer levels_layer tone_layer exposure_layer white_balance_layer saturation_layer local_contrast_layer sharpen_layer ALGORITHMS = blur usm c2g scale_channel sample_pixel blend_channel vignette gradient blur_type blend_mode blend_color_luminosity fill_channel radial_lut CORE = base_layer base_layer_with_properties base_layer_with_source channel_manager layer_stack conversion_cpu conversion_processor property color_space value image power size copy_channel histogram layer_factory operation_processor sampler_manager sampler preset static_image view_manager zoom_manager str switchable_layer color_matrix palette layer_processor flatten_layers layer_with_blending test_image skin_color_chart renderer generic_layer_frame layer_frame preset_button project PROPERTIES = property_numeric property_mixer mixer property_curves curve curve_point curve_shape curve_function_bezier property_choice property_boolean property_levels OBJECTS_TMP = ${addsuffix .o, ${FILES}} OBJECTS = ${addprefix obj/, ${OBJECTS_TMP}} LAYERS_OBJECTS_TMP = ${addsuffix .o, ${LAYERS}} LAYERS_OBJECTS = ${addprefix obj/, ${LAYERS_OBJECTS_TMP}} CORE_OBJECTS_TMP = ${addsuffix .o, ${CORE}} CORE_OBJECTS = ${addprefix obj/, ${CORE_OBJECTS_TMP}} PROPERTIES_OBJECTS_TMP = ${addsuffix .o, ${PROPERTIES}} PROPERTIES_OBJECTS = ${addprefix obj/, ${PROPERTIES_OBJECTS_TMP}} ALGORITHMS_OBJECTS_TMP = ${addsuffix .o, ${ALGORITHMS}} ALGORITHMS_OBJECTS = ${addprefix obj/, ${ALGORITHMS_OBJECTS_TMP}} CXXFLAGS= ifeq (${OS}, WINDOWS) # settings for Windows build LDFLAGS=`/opt/wxw/bin/wx-config --libs` `pkg-config --libs libxml-2.0` -L/opt/lib -ltiff CXXFLAGS_WX=`/opt/wxw/bin/wx-config --cxxflags` `pkg-config --cflags libxml-2.0` -I/opt/include OBJECTS += delab.o EXE=.exe else # settings for standard build LDFLAGS=`${WXCONFIG} --libs` `xml2-config --libs` -ltiff CXXFLAGS_WX=`${WXCONFIG} --cxxflags` `xml2-config --cflags` endif # warnings from wxWidgets CXXFLAGS_WX+=-Wno-long-long -Wno-variadic-macros INCLUDES=-I gui_wx -I layers -I algorithms -I core -I properties CXXFLAGS += ${INCLUDES} CXXFLAGS_WX += ${INCLUDES} SOURCES_TMP = ${addsuffix .cc, ${FILES}} SOURCES = ${addprefix gui_wx/, ${SOURCES_TMP}} LAYERS_SOURCES_TMP = ${addsuffix .cc, ${LAYERS}} LAYERS_SOURCES = ${addprefix layers/, ${LAYERS_SOURCES_TMP}} CORE_SOURCES_TMP = ${addsuffix .cc, ${CORE}} CORE_SOURCES = ${addprefix core/, ${CORE_SOURCES_TMP}} PROPERTIES_SOURCES_TMP = ${addsuffix .cc, ${PROPERTIES}} PROPERTIES_SOURCES = ${addprefix properties/, ${PROPERTIES_SOURCES_TMP}} ALGORITHMS_SOURCES_TMP = ${addsuffix .cc, ${ALGORITHMS}} ALGORITHMS_SOURCES = ${addprefix algorithms/, ${ALGORITHMS_SOURCES_TMP}} HEADERS_TMP = ${addsuffix .h, ${FILES}} HEADERS = ${addprefix gui_wx/, ${HEADERS_TMP}} LAYERS_HEADERS_TMP = ${addsuffix .h, ${LAYERS}} LAYERS_HEADERS = ${addprefix layers/, ${LAYERS_HEADERS_TMP}} CORE_HEADERS_TMP = ${addsuffix .h, ${CORE}} CORE_HEADERS = ${addprefix core/, ${CORE_HEADERS_TMP}} PROPERTIES_HEADERS_TMP = ${addsuffix .h, ${PROPERTIES}} PROPERTIES_HEADERS = ${addprefix properties/, ${PROPERTIES_HEADERS_TMP}} ALGORITHMS_HEADERS_TMP = ${addsuffix .h, ${ALGORITHMS}} ALGORITHMS_HEADERS = ${addprefix algorithms/, ${ALGORITHMS_HEADERS_TMP}} STRIP=strip ifeq (${ARCH}, 64) OPTFLAGS=-march=x86-64 else OPTFLAGS=-march=i686 endif # choose your architecture #OPTFLAGS=-march=core2 ifeq (${DEBUG}, YES) # debug stuff CXXFLAGS+=-g -Wall -pedantic else # release stuff CXXFLAGS+=-Ofast ${OPTFLAGS} -DNDEBUG endif include .depend ${APP}: ${CORE_OBJECTS} ${LAYERS_OBJECTS} ${ALGORITHMS_OBJECTS} ${PROPERTIES_OBJECTS} ${OBJECTS} ${CXX} -o ${APP} ${CORE_OBJECTS} ${OBJECTS} ${LAYERS_OBJECTS} ${ALGORITHMS_OBJECTS} ${PROPERTIES_OBJECTS} ${LDFLAGS} ifeq (${DEBUG}, YES) else ${STRIP} ${APP}${EXE} endif obj/%.o: gui_wx/%.cc ${CXX} -c ${CXXFLAGS_WX} -o $@ $< obj/%.o: layers/%.cc ${CXX} -c ${CXXFLAGS} -o $@ $< obj/%.o: core/%.cc ${CXX} -c ${CXXFLAGS} -o $@ $< obj/%.o: properties/%.cc ${CXX} -c ${CXXFLAGS} -o $@ $< obj/%.o: algorithms/%.cc ${CXX} -c ${CXXFLAGS} -o $@ $< depend: $(SOURCES) ${HEADERS} ${CORE_SOURCES} ${CORE_HEADERS} $(CXX) $(CXXFLAGS_WX) ${INCLUDES} -MM $^ >>./.depend; install: cp ${APP} /usr/local/bin clean: rm -f ./.depend touch .depend rm -f ${APP}${EXE} rm -f obj/*.o delaboratory-0.8/properties/0000755000175100001440000000000012005331267015240 5ustar jacekusersdelaboratory-0.8/properties/curve_shape.h0000644000175100001440000000224211764477311017731 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVE_SHAPE_H #define _DE_CURVE_SHAPE_H #include #include "value.h" #include "curve_point.h" #include class deCurveFunctionBezier; class deCurveShape { private: int size; std::vector functions; public: deCurveShape(int _size); ~deCurveShape(); void build(const deCurvePoints& points); deValue calc(deValue value) const; }; #endif delaboratory-0.8/properties/property_mixer.cc0000644000175100001440000000335611764477311020662 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_mixer.h" #include "mixer.h" #include "logger.h" #include "str.h" dePropertyMixer::dePropertyMixer(const std::string& _name, int _size) :deProperty(_name), size(_size) { int i; for (i = 0; i < size; i++) { mixers.push_back( new deMixer(size)); //mixers[i]->reset(i); } } dePropertyMixer::~dePropertyMixer() { int i; for (i = 0; i < size; i++) { delete mixers[i]; } } const deMixer* dePropertyMixer::getMixer(int index) const { if (index < 0) { logError("getMixer index: " + str(index)); return NULL; } if (index >= size) { logError("getMixer index: " + str(index)); return NULL; } return mixers[index]; } deMixer* dePropertyMixer::getMixer(int index) { if (index < 0) { logError("getMixer index: " + str(index)); return NULL; } if (index >= size) { logError("getMixer index: " + str(index)); return NULL; } return mixers[index]; } delaboratory-0.8/properties/property_choice.cc0000644000175100001440000000354511764477311020770 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_choice.h" #include "str.h" #include "logger.h" dePropertyChoice::dePropertyChoice(const std::string& _name, const std::vector _choices) :deProperty(_name), choices(_choices) { value = 0; } dePropertyChoice::~dePropertyChoice() { } void dePropertyChoice::set(std::string s) { std::vector::const_iterator i = choices.begin(); int index = 0; while (i != choices.end()) { if (*i == s) { value = index; return; } i++; index++; } logError("can't set choice value " + s); value = -1; } std::string dePropertyChoice::get() const { if (value < 0) { return ""; } if ((unsigned)value >= choices.size()) { return ""; } return choices[value]; } int dePropertyChoice::getIndex() const { return value; } void dePropertyChoice::setIndex(int index) { value = index; } std::vector createNumbers(int index) { std::vector result; int i; for (i = 0; i < index; i++) { result.push_back(str(i)); } return result; } delaboratory-0.8/properties/property_boolean.cc0000644000175100001440000000205411764477311021147 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_boolean.h" #include "str.h" dePropertyBoolean::dePropertyBoolean(const std::string& _name) :deProperty(_name) { value = false; } dePropertyBoolean::~dePropertyBoolean() { } void dePropertyBoolean::set(bool _value) { value = _value; } bool dePropertyBoolean::get() const { return value; } delaboratory-0.8/properties/curve_point.cc0000644000175100001440000000166611764477311020131 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curve_point.h" deCurvePoint::deCurvePoint(deValue _x, deValue _y) :x(_x), y(_y) { } deCurvePoint::~deCurvePoint() { } void deCurvePoint::move(deValue _x, deValue _y) { x = _x; y = _y; } delaboratory-0.8/properties/property_curves.cc0000644000175100001440000000731412000471414021021 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_curves.h" #include "str.h" dePropertyCurves::dePropertyCurves(const std::string& _name, int _size) :deProperty(_name), size(_size) { horizontalChannel = -1; int i; for (i = 0; i < size; i++) { curves.push_back( new deBaseCurve()); } } dePropertyCurves::~dePropertyCurves() { int i; for (i = 0; i < size; i++) { delete curves[i]; } } void dePropertyCurves::setHorizontalChannel(int channel) { horizontalChannel = channel; } int dePropertyCurves::getHorizontalChannel() const { return horizontalChannel; } bool dePropertyCurves::onKey(int key, int i, deValue p) { deValue v = -1; if (key == 'W') { v = 1.0; } if (key == 'B') { v = 0.0; } if (key == 'A') { if (size == 4) { if (i == 0) { v = 4.0 / 100.0; } if (i == 1) { v = 3.0 / 100.0; } if (i == 2) { v = 15.0 / 100.0; } if (i == 3) { v = 0; } } } if (key == 'S') { if (size == 4) { if (i == 0) { v = 15.0 / 100.0; } if (i == 1) { v = 35.0 / 100.0; } if (i == 2) { v = 55.0 / 100.0; } if (i == 3) { v = 0; } } } if (key == 'D') { if (size == 4) { if (i == 0) { v = 69.0 / 100.0; } if (i == 1) { v = 53.0 / 100.0; } if (i == 2) { v = 54.0 / 100.0; } if (i == 3) { v = 53.0 / 100.0; } } } if (key == 'G') { if (size == 4) { if (i == 0) { v = 9.0 / 100.0; } if (i == 1) { v = 7.0 / 100.0; } if (i == 2) { v = 9.0 / 100.0; } if (i == 3) { v = 0.0 / 100.0; } } } if (key == 'H') { if (size == 4) { if (i == 0) { v = 12.0 / 100.0; } if (i == 1) { v = 17.0 / 100.0; } if (i == 2) { v = 22.0 / 100.0; } if (i == 3) { v = 0.0 / 100.0; } } } if (key == ' ') { v = p; } if (v >= 0) { curves[i]->addPoint(p, v); curves[i]->build(); return true; } return false; } delaboratory-0.8/properties/mixer.h0000644000175100001440000000257111764477311016556 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MIXER_H #define _DE_MIXER_H #include "value.h" #include "mutex.h" class deChannel; class deImage; class deMixer { private: int size; deValue* weights; mutable deMutex mutex; deMixer(const deMixer& mixer); deMixer operator=(const deMixer& mixer); void lock() const; void unlock() const; public: deMixer(int _size); virtual ~deMixer(); deValue getWeight(int c) const; void setWeight(int c, deValue value); void process(const deImage& sourceImage, deValue* destination, int n); bool isNeutral(int index) const; }; #endif delaboratory-0.8/properties/property_mixer.h0000644000175100001440000000226011764477311020515 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_MIXER_H #define _DE_PROPERTY_MIXER_H #include "property.h" #include "mixer.h" #include class deMixer; class dePropertyMixer:public deProperty { private: std::vector mixers; int size; public: dePropertyMixer(const std::string& _name, int _size); virtual ~dePropertyMixer(); const deMixer* getMixer(int index) const; deMixer* getMixer(int index); }; #endif delaboratory-0.8/properties/curve_function_bezier.h0000644000175100001440000000233711764477311022023 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVE_FUNCTION_BEZIER_H #define _DE_CURVE_FUNCTION_BEZIER_H #include "value.h" class deCurveFunctionBezier { private: deValue x0; deValue x3; deValue y0; deValue y1; deValue y2; deValue y3; public: deCurveFunctionBezier(); virtual ~deCurveFunctionBezier(); virtual deValue calc(deValue value) const; void set(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3); }; #endif delaboratory-0.8/properties/property_numeric.h0000644000175100001440000000233311764477311021034 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_NUMERIC_H #define _DE_PROPERTY_NUMERIC_H #include "property.h" #include "value.h" class dePropertyNumeric:public deProperty { private: deValue value; deValue min; deValue max; public: dePropertyNumeric(const std::string& _name, deValue _min, deValue _max); virtual ~dePropertyNumeric(); void set(deValue _value); deValue get() const; deValue getMin() const; deValue getMax() const; }; #endif delaboratory-0.8/properties/curve_shape.cc0000644000175100001440000000700111764477311020065 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curve_shape.h" #include #include "curve_function_bezier.h" #include deCurveShape::deCurveShape(int _size) :size(_size), functions(_size) { } deCurveShape::~deCurveShape() { } deValue deCurveShape::calc(deValue value) const { if ( value <= 0 ) { return functions.at(0).calc(0); } else if (value >= 1) { return functions.at(size-1).calc(1); } else { deValue s = size - 1; int p = s * value; return functions.at(p).calc(value); } } void deCurveShape::build(const deCurvePoints& points) { typedef std::map deNodes; deNodes nodes; deCurvePoints::const_iterator j; for (j = points.begin(); j != points.end(); j++) { const deCurvePoint& point = *j; deValue x = point.getX(); deValue y = point.getY(); nodes.insert(std::pair(x, y)); } /* math formulas from GIMP gimp_curve_plot from gimpcurve.c */ deNodes::const_iterator i; for (i = nodes.begin(); i != nodes.end(); i++) { bool left = false; bool right = false; deValue x0 = (*i).first; deValue y0 = (*i).second; deNodes::const_iterator j = i; deNodes::const_iterator k = i; j++; k++; deValue x3 = x0; deValue y3 = y0; if (j != nodes.end()) { x3 = (*j).first; y3 = (*j).second; k++; if (k != nodes.end()) { right = true; } } deNodes::const_iterator h = i; if (h != nodes.begin()) { h--; left = true; } deValue dx = x3 - x0; deValue dy = y3 - y0; deValue y1; deValue y2; if ((!left) && (!right)) { y1 = y0 + dy / 3.0; y2 = y0 + dy * 2.0 / 3.0; } if ((!left) && (right)) { deValue s = ((*k).second - y0) / ((*k).first - x0); y2 = y3 - s * dx / 3.0; y1 = y0 + (y2 - y0) / 2.0; } if ((left) && (!right)) { deValue s = (y3 - (*h).second) / (x3 - (*h).first); y1 = y0 + s * dx / 3.0; y2 = y3 + (y1 - y3) / 2.0; } if ((left) && (right)) { deValue s1 = (y3 - (*h).second) / (x3 - (*h).first); deValue s2 = ((*k).second - y0) / ((*k).first - x0); y1 = y0 + s1 * dx / 3.0; y2 = y3 - s2 * dx / 3.0; } int p1 = x0 * (size - 1); int p2 = x3 * (size - 1); int iii; for (iii = p1; iii <= p2; iii++) { functions.at(iii).set(x0, x3, y0, y1, y2, y3); } } } delaboratory-0.8/properties/property_curves.h0000644000175100001440000000267711764477311020714 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_CURVES_H #define _DE_PROPERTY_CURVES_H #include "property.h" #include "value.h" #include #include "curve.h" class dePropertyCurves:public deProperty { private: std::vector curves; int size; int horizontalChannel; public: dePropertyCurves(const std::string& _name, int _size); virtual ~dePropertyCurves(); int getSize() const; const deBaseCurve* getCurve(int index) const {return (curves[index]);}; deBaseCurve* getCurve(int index) {return (curves[index]);}; void setHorizontalChannel(int channel); int getHorizontalChannel() const; bool onKey(int key, int i, deValue v); }; #endif delaboratory-0.8/properties/property_levels.cc0000644000175100001440000000411211764477311021017 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_levels.h" #include "str.h" deLevels::deLevels() { min = 0; middle = 0.5; max = 1.0; } deLevels::~deLevels() { } void deLevels::setMin(deValue _value) { min = _value; sort(); } deValue deLevels::getMin() const { return min; } void deLevels::setMiddle(deValue _value) { middle = _value; sort(); } deValue deLevels::getMiddle() const { return middle; } void deLevels::setMax(deValue _value) { max = _value; sort(); } deValue deLevels::getMax() const { return max; } void deLevels::sort() { if ((min <= middle) && (middle <= max)) { return; } deValue m = 0.01; if (middle > 1.0 - m) { middle = 1.0 + m; } if (middle < m) { middle = m; } if (min > middle - m) { min = middle - m; } if (max < middle + m) { max = middle + m; } } bool deLevels::isNeutral() const { if (min != 0.0) { return false; } if (middle != 0.5) { return false; } if (max != 1.0) { return false; } return true; } dePropertyLevels::dePropertyLevels(const std::string& _name, int _size) :deProperty(_name), size(_size) { int i; for (i = 0; i < size; i++) { levels.push_back( deLevels()); } } dePropertyLevels::~dePropertyLevels() { } delaboratory-0.8/properties/property_levels.h0000644000175100001440000000325711764477311020672 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_LEVELS_H #define _DE_PROPERTY_LEVELS_H #include "property.h" #include "value.h" #include class deLevels { private: deValue min; deValue middle; deValue max; void sort(); public: deLevels(); virtual ~deLevels(); void setMin(deValue _value); deValue getMin() const; void setMiddle(deValue _value); deValue getMiddle() const; void setMax(deValue _value); deValue getMax() const; bool isNeutral() const; }; class dePropertyLevels:public deProperty { private: std::vector levels; int size; public: dePropertyLevels(const std::string& _name, int _size); virtual ~dePropertyLevels(); int getSize() const; const deLevels& getLevels(int index) const {return levels[index];}; deLevels& getLevels(int index) {return levels[index];}; }; #endif delaboratory-0.8/properties/curve.cc0000644000175100001440000001305012000535320016661 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curve.h" #include #include #include #include #include "str.h" #include "logger.h" #define CURVE_POINT_PICK_DISTANCE 0.03 #define VERTICAL_STEP 0.01 #define CURVE_SHAPE_SIZE 256 deBaseCurve::deBaseCurve() :shape(CURVE_SHAPE_SIZE) { } deBaseCurve::~deBaseCurve() { } void deBaseCurve::clearPoints() { mutex.lock(); controlPoints.clear(); mutex.unlock(); } int deBaseCurve::addPoint(deValue x, deValue y) { if ((x < 0) || (x > 1)) { return -1; } if (y < 0) { y = 0; } if (y > 1) { y = 1; } /* if ((y < 0) || (y > 1)) { return -1; }*/ mutex.lock(); bool moved = false; int p = -1; int i = 0; deCurvePoints::iterator j; for (j = controlPoints.begin(); j != controlPoints.end(); j++) { deCurvePoint& point = *j; if (point.getX() == x) { point.move(x, y); moved = true; p = i; } i++; } if (!moved) { controlPoints.push_back(deCurvePoint(x,y)); p = controlPoints.size() - 1; } mutex.unlock(); return p; } void deBaseCurve::build() { mutex.lock(); shape.build(controlPoints); mutex.unlock(); } void deBaseCurve::process(const deValue* pixels, deValue* p, int n) const { mutex.lock(); int i; for (i = 0; i < n; i++) { deValue value = pixels[i]; deValue result = shape.calc(value); if (result < 0) { p[i] = 0; } else if (result > 1) { p[i] = 1; } else { p[i] = result; } } mutex.unlock(); } deValue deBaseCurve::calcValue(deValue value) const { return shape.calc(value); } int deBaseCurve::findPoint(deValue x, deValue y) const { mutex.lock(); deCurvePoints::const_iterator j; int i = 0; for (j = controlPoints.begin(); j != controlPoints.end(); j++) { const deCurvePoint& point = *j; deValue xx = x - point.getX(); float yy = y - point.getY(); if (sqrt (xx * xx + yy * yy) < CURVE_POINT_PICK_DISTANCE) { mutex.unlock(); return i; } i++; } mutex.unlock(); return -1; } void deBaseCurve::deletePoint(int p) { if (p < 0) { logError("negative p in curve delete point"); return; } mutex.lock(); if (controlPoints.size() == 0) { logError("empty control points in curve delete point"); mutex.unlock(); return; } deCurvePoints::iterator i = controlPoints.begin(); while (p > 0) { i++; p--; if (i == controlPoints.end()) { int s = controlPoints.size(); logError("end of control points in curve delete point, p was " + str(p) + " size of control points was " + str(s)); mutex.unlock(); return; } } controlPoints.erase(i); mutex.unlock(); } void deBaseCurve::movePoint(int p, deValue x, deValue y) { if (p < 0) { logError("negative p in curve move point"); return; } if ((x < 0) || (x > 1)) { logError("bad x in curve move point"); return; } if ((y < 0) || (y > 1)) { logError("bad y in curve move point"); return; } mutex.lock(); if ((unsigned int)p >= controlPoints.size()) { logError("too big p in curve move point"); mutex.unlock(); return; } deCurvePoints::iterator i = controlPoints.begin(); while (p > 0) { i++; p--; } deValue xx = (*i).getX(); if (xx == 0) { x = 0; } else { if (x == 0) { logInfo("can't move point on curve to x=0"); mutex.unlock(); return; } } if (xx == 1) { x = 1; } else { if (x == 1) { logInfo("can't move point on curve to x=1"); mutex.unlock(); return; } } (*i).move(x, y); mutex.unlock(); } const deCurvePoint& deBaseCurve::getPoint(int n) const { mutex.lock(); deCurvePoints::const_iterator i = controlPoints.begin(); while (n > 0) { i++; n--; } mutex.unlock(); return *i; } const deCurvePoints& deBaseCurve::getControlPoints() const { return controlPoints; } bool deBaseCurve::isNeutral() const { if (controlPoints.size() != 2) { return false; } deCurvePoints::const_iterator i = controlPoints.begin(); deCurvePoint a = *i; if (a.getY() != 0) { return false; } i++; deCurvePoint b = *i; if (b.getY() != 1) { return false; } return true; } delaboratory-0.8/properties/curve.h0000644000175100001440000000327011764477311016553 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVE_H #define _DE_CURVE_H #include "curve_point.h" #include "curve_shape.h" #include #include "mutex.h" #include class deChannel; class deBaseCurve { protected: deCurvePoints controlPoints; deCurveShape shape; mutable deMutex mutex; deBaseCurve(const deBaseCurve& c); deBaseCurve& operator =(const deBaseCurve& c); public: deBaseCurve(); virtual ~deBaseCurve(); void clearPoints(); int addPoint(deValue x, deValue y); void build(); void process(const deValue* source, deValue* destination, int n) const; int findPoint(deValue x, deValue y) const; void deletePoint(int p); void movePoint(int p, deValue x, deValue y); bool isNeutral() const; const deCurvePoints& getControlPoints() const; const deCurvePoint& getPoint(int n) const; deValue calcValue(deValue value) const; }; #endif delaboratory-0.8/properties/property_boolean.h0000644000175100001440000000206711764477311021015 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_BOOLEAN_H #define _DE_PROPERTY_BOOLEAN_H #include "property.h" class dePropertyBoolean:public deProperty { private: bool value; public: dePropertyBoolean(const std::string& _name); virtual ~dePropertyBoolean(); void set(bool _value); bool get() const; }; #endif delaboratory-0.8/properties/property_choice.h0000644000175100001440000000256311764477311020631 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_CHOICE_H #define _DE_PROPERTY_CHOICE_H #include "property.h" #include class dePropertyChoice:public deProperty { private: int value; std::vector choices; public: dePropertyChoice(const std::string& _name, const std::vector _choices); virtual ~dePropertyChoice(); const std::vector& getChoices() const {return choices;}; int getIndex() const; void setIndex(int index); std::string get() const; void set(std::string _value); }; std::vector createNumbers(int index); #endif delaboratory-0.8/properties/curve_point.h0000644000175100001440000000230511764477311017762 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVE_POINT_H #define _DE_CURVE_POINT_H #include "value.h" #include class deCurvePoint { private: deValue x; deValue y; deCurvePoint(); public: deCurvePoint(deValue _x, deValue _y); virtual ~deCurvePoint(); deValue getX() const {return x;}; deValue getY() const {return y;}; void move(deValue _x, deValue _y); }; typedef std::vector deCurvePoints; #endif delaboratory-0.8/properties/mixer.cc0000644000175100001440000000621411764477311016712 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "mixer.h" #include "str.h" #include #include #include "logger.h" #include "image.h" deMixer::deMixer(int _size) :size(_size) { weights = new deValue [size]; } deMixer::~deMixer() { delete [] weights; } deValue deMixer::getWeight(int c) const { lock(); if ((c < 0) || (c >= size)) { unlock(); return 0.0; } unlock(); return weights[c]; } void deMixer::setWeight(int c, deValue value) { if ((c < 0) || (c >= size)) { return; } lock(); weights[c] = value; unlock(); } void deMixer::process(const deImage& sourceImage, deValue* destination, int n) { if (size < 1) { return; } int i; lock(); const deValue *p1 = sourceImage.startRead(0); // FIXME clipping if (size == 1) { for (i = 0; i < n; i++) { deValue result = weights[0] * p1[i]; destination[i] = result; } } if (size > 2) { const deValue *p2 = sourceImage.startRead(1); const deValue *p3 = sourceImage.startRead(2); if (size == 3) { for (i = 0; i < n; i++) { deValue result = weights[0] * p1[i]; result += weights[1] * p2[i]; result += weights[2] * p3[i]; destination[i] = result; } } if (size == 4) { const deValue *p4 = sourceImage.startRead(3); for (i = 0; i < n; i++) { deValue result = weights[0] * p1[i]; result += weights[1] * p2[i]; result += weights[2] * p3[i]; result += weights[3] * p4[i]; destination[i] = result; } sourceImage.finishRead(3); } sourceImage.finishRead(1); sourceImage.finishRead(2); } sourceImage.finishRead(0); unlock(); } bool deMixer::isNeutral(int index) const { int i; for (i = 0; i < size; i++) { if (i == index) { if (weights[i] != 1.0) { return false; } } else { if (weights[i] != 0.0) { return false; } } } return true; } void deMixer::lock() const { mutex.lock(); } void deMixer::unlock() const { mutex.unlock(); } delaboratory-0.8/properties/curve_function_bezier.cc0000644000175100001440000000266211764477311022162 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curve_function_bezier.h" deCurveFunctionBezier::deCurveFunctionBezier() { x0 = 0; x3 = 0; y0 = 0; y1 = 0; y2 = 0; y3 = 0; } void deCurveFunctionBezier::set(deValue _x0, deValue _x3, deValue _y0, deValue _y1, deValue _y2, deValue _y3) { x0 = _x0; x3 = _x3; y0 = _y0; y1 = _y1; y2 = _y2; y3 = _y3; } deCurveFunctionBezier::~deCurveFunctionBezier() { } deValue deCurveFunctionBezier::calc(deValue value) const { deValue d = x3 - x0; if (d == 0.0) { return y0; } deValue t = (value - x0) / d; deValue t1 = 1.0 - t; return (y0 * t1 * t1 * t1) + 3 * (y1 * t1 * t1 * t) + 3 * (y2 * t1 * t * t) + (y3 * t * t * t); } delaboratory-0.8/properties/property_numeric.cc0000644000175100001440000000253111764477311021172 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_numeric.h" #include "str.h" dePropertyNumeric::dePropertyNumeric(const std::string& _name, deValue _min, deValue _max) :deProperty(_name), min(_min), max(_max) { value = (min + max) / 2.0; } dePropertyNumeric::~dePropertyNumeric() { } void dePropertyNumeric::set(deValue _value) { value = _value; if (value > max) { value = max; } if (value < min) { value = min; } } deValue dePropertyNumeric::get() const { return value; } deValue dePropertyNumeric::getMin() const { return min; } deValue dePropertyNumeric::getMax() const { return max; } delaboratory-0.8/obj/0000755000175100001440000000000012005331267013616 5ustar jacekusersdelaboratory-0.8/layers/0000755000175100001440000000000012005331264014340 5ustar jacekusersdelaboratory-0.8/layers/local_contrast_layer.cc0000644000175100001440000000413011774674304021071 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "local_contrast_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" deLocalContrastLayer::deLocalContrastLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 10, 600); reset->addNumericValue("radius", 200); applyPreset("reset"); setOpacity(0.2); disableNotForSharpen(); } deLocalContrastLayer::~deLocalContrastLayer() { } bool deLocalContrastLayer::updateMainImageSingleChannel(int channel) { if (!isChannelEnabled(channel)) { copySourceChannel(channel); return true; } deValue r = getNumericValue("radius") * viewManager.getRealScale();; deValue a = 0.5; deValue t = 0.0; deSize size = mainLayerImage.getChannelSize(); const deValue* source = getSourceImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(channel); bool result = false; if ((source) && (destination)) { result = unsharpMask(source, destination, size, a, r, t, deBoxBlur); } getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return result; } delaboratory-0.8/layers/recover_shadows_layer.cc0000644000175100001440000000343611764477311021265 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "recover_shadows_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" deRecoverShadowsLayer::deRecoverShadowsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 2, 600); reset->addNumericValue("radius", 200); createPropertyChoice("channel", getChannelNames(colorSpace)); applyPreset("reset"); setOpacity(0.5); } deRecoverShadowsLayer::~deRecoverShadowsLayer() { } bool deRecoverShadowsLayer::updateMainImageNotThreadedWay() { deValue r = getNumericValue("radius") * viewManager.getRealScale(); int channel = getPropertyChoice("channel")->getIndex(); bool result = shadowsHighlights(r, channel, getSourceImage(), mainLayerImage, true); return result; } delaboratory-0.8/layers/gradient_layer.h0000644000175100001440000000271411764477311017525 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GRADIENT_LAYER_H #define _DE_GRADIENT_LAYER_H #include "layer_with_blending.h" class deViewManager; class deGradientLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "gradient";}; deViewManager& viewManager; public: deGradientLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deGradientLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "gradient";}; virtual bool onImageClick(deValue x, deValue y); }; #endif delaboratory-0.8/layers/recover_shadows_layer.h0000644000175100001440000000244511764477311021126 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RECOVER_SHADOWS_LAYER_H #define _DE_RECOVER_SHADOWS_LAYER_H #include "layer_with_blending.h" class deRecoverShadowsLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "recover_shadows";}; deViewManager& viewManager; public: deRecoverShadowsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deRecoverShadowsLayer(); virtual bool updateMainImageNotThreadedWay(); }; #endif delaboratory-0.8/layers/mixer_layer.h0000644000175100001440000000315311764477311017052 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MIXER_LAYER_H #define _DE_MIXER_LAYER_H #include "layer_with_blending.h" #include "mixer.h" class deMixerLayer:public deLayerWithBlending { protected: virtual std::string getType() const {return "mixer";}; virtual std::string getLabel() const {return "channel mixer";}; public: deMixerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager); virtual ~deMixerLayer(); deMixer* getMixer(int index); virtual bool isChannelNeutral(int index); void setWeight(int s, int d, deValue value); deValue getWeight(int s, int d); virtual std::string getActionName() {return "mixer";}; virtual bool updateMainImageSingleChannel(int i); virtual void executeOperation(const std::string& operation); }; #endif delaboratory-0.8/layers/gradient_layer.cc0000644000175100001440000000545611774047603017667 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gradient_layer.h" #include "gradient.h" #include "preset.h" #include "view_manager.h" #include "property_numeric.h" deGradientLayer::deGradientLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { if (colorSpace == deColorSpaceCMYK) { setBlendMode(deBlendScreen); } else { setBlendMode(deBlendMultiply); } dePreset* reset = createPreset("reset"); createPropertyNumeric("length", -3.0, 3.0); reset->addNumericValue("length", 1.0); createPropertyNumeric("direction", 0, 360); reset->addNumericValue("direction", 0.0); createPropertyNumeric("center_x", -1, 1); reset->addNumericValue("center_x", 0.0); createPropertyNumeric("center_y", -1, 1); reset->addNumericValue("center_y", 0.0); createPropertyNumeric("sinus", -1, 1); reset->addNumericValue("sinus", 0.0); applyPreset("reset"); disableNotLuminance(); } deGradientLayer::~deGradientLayer() { } bool deGradientLayer::isChannelNeutral(int channel) { return false; } bool deGradientLayer::updateMainImageSingleChannel(int channel) { deSize size = mainLayerImage.getChannelSize(); deValue* destination = mainLayerImage.startWrite(channel); deValue x1; deValue y1; deValue x2; deValue y2; viewManager.getZoom(x1, y1, x2, y2); deValue r = getNumericValue("length"); deValue a = getNumericValue("direction"); deValue cx = getNumericValue("center_x"); deValue cy = getNumericValue("center_y"); deValue sinus = getNumericValue("sinus"); gradientChannel(destination, size, cx, cy, r, a, sinus); mainLayerImage.finishWrite(channel); return true; } bool deGradientLayer::onImageClick(deValue x, deValue y) { dePropertyNumeric* cx = getPropertyNumeric("center_x"); cx->set(2 * x - 1); dePropertyNumeric* cy = getPropertyNumeric("center_y"); cy->set(2 * y - 1); return true; } delaboratory-0.8/layers/recover_highlights_layer.cc0000644000175100001440000000346111764477311021745 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "recover_highlights_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" deRecoverHighlightsLayer::deRecoverHighlightsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 2, 600); reset->addNumericValue("radius", 200); createPropertyChoice("channel", getChannelNames(colorSpace)); applyPreset("reset"); setOpacity(0.5); } deRecoverHighlightsLayer::~deRecoverHighlightsLayer() { } bool deRecoverHighlightsLayer::updateMainImageNotThreadedWay() { deValue r = getNumericValue("radius") * viewManager.getRealScale(); int channel = getPropertyChoice("channel")->getIndex(); bool result = shadowsHighlights(r, channel, getSourceImage(), mainLayerImage, false); return result; } delaboratory-0.8/layers/c2g_layer.cc0000644000175100001440000000673611765775026016556 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "c2g_layer.h" #include "preset.h" #include "view_manager.h" #include "fill_channel.h" #include "color_space_utils.h" #include "blend_channel.h" #include "logger.h" #include "c2g.h" #include "str.h" deC2GLayer::deC2GLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 1, 1000); reset->addNumericValue("radius", 300); createPropertyNumeric("samples", 1, 500); reset->addNumericValue("samples", 10); applyPreset("reset"); } deC2GLayer::~deC2GLayer() { } bool deC2GLayer::updateMainImageNotThreadedWay() { deValue samples = getNumericValue("samples"); logInfo("c2g_layer START samples: " + str(samples)); deSize size = mainLayerImage.getChannelSize(); int n = size.getN(); deValue* mask = NULL; try { mask = new deValue [n]; } catch (std::bad_alloc) { logError("allocating memory in c2g"); if (mask) { delete [] mask; } return false; } // clear destination fillChannel(mask, n, 0.0); deValue r = getNumericValue("radius") * viewManager.getRealScale(); const deValue* source0 = getOriginalImage().startRead(0); const deValue* source1 = getOriginalImage().startRead(1); const deValue* source2 = getOriginalImage().startRead(2); logInfo("c2g_layer before c2g"); c2g(source0, source1, source2, mask, size, r, samples); logInfo("c2g_layer after c2g"); getOriginalImage().finishRead(0); getOriginalImage().finishRead(1); getOriginalImage().finishRead(2); int nc = getColorSpaceSize(colorSpace); int channel; for (channel = 0; channel < nc; channel++) { /* if (!isChannelEnabled(channel)) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); } else */ { //mainLayerImage.enableChannel(channel); deValue* destination = mainLayerImage.startWrite(channel); int i; for (i = 0; i < n; i++) { destination[i] = mask[i]; } mainLayerImage.finishWrite(channel); } } delete [] mask; logInfo("c2g_layer DONE"); return true; } void deC2GLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const { deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); getOriginalImage().updateChannelUsage(channelUsage, layerIndex); } delaboratory-0.8/layers/fill_layer.h0000644000175100001440000000240311764477311016651 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_FILL_LAYER_H #define _DE_FILL_LAYER_H #include "layer_with_blending.h" class deViewManager; class deFillLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "fill";}; public: deFillLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deFillLayer(); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "fill";}; }; #endif delaboratory-0.8/layers/tone_layer.h0000644000175100001440000000234411764477311016674 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_TONE_LAYER_H #define _DE_TONE_LAYER_H #include "layer_with_blending.h" class deToneLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "tone";}; public: deToneLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deToneLayer(); virtual bool updateMainImageNotThreadedWay(); virtual std::string getActionName() {return "tone";}; }; #endif delaboratory-0.8/layers/auto_dodge_layer.cc0000644000175100001440000000500611764477311020175 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "auto_dodge_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" #include "logger.h" deAutoDodgeLayer::deAutoDodgeLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius 1", 10, 100); reset->addNumericValue("radius 1", 20); createPropertyNumeric("radius 2", 5, 50); reset->addNumericValue("radius 2", 10); createPropertyNumeric("threshold", 0.0, 1.0); reset->addNumericValue("threshold", 0.5); applyPreset("reset"); setOpacity(0.5); disableNotForSharpen(); } deAutoDodgeLayer::~deAutoDodgeLayer() { } bool deAutoDodgeLayer::updateMainImageSingleChannel(int channel) { /* if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); return true; } */ deValue r1 = getNumericValue("radius 1") * viewManager.getRealScale();; deValue r2 = getNumericValue("radius 2") * viewManager.getRealScale();; deValue t = getNumericValue("threshold"); deSize size = mainLayerImage.getChannelSize(); // mainLayerImage.enableChannel(channel); const deValue* source = getSourceImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(channel); bool result = false; if ((source) && (destination)) { result = autoDodgeBurn(source, destination, size, r1, r2, t, false); } getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return result; } delaboratory-0.8/layers/exposure_layer.h0000644000175100001440000000230211764477311017573 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_EXPOSURE_LAYER_H #define _DE_EXPOSURE_LAYER_H #include "layer_with_blending.h" class deExposureLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "exposure";}; public: deExposureLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deExposureLayer(); virtual bool updateMainImageSingleChannel(int i); }; #endif delaboratory-0.8/layers/auto_burn_layer.h0000644000175100001440000000241311764477311017722 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_AUTO_BURN_LAYER_H #define _DE_AUTO_BURN_LAYER_H #include "layer_with_blending.h" class deAutoBurnLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "auto_burn";}; deViewManager& viewManager; public: deAutoBurnLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deAutoBurnLayer(); virtual bool updateMainImageSingleChannel(int channel); }; #endif delaboratory-0.8/layers/c2g_layer.h0000644000175100001440000000250211764477311016376 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_C2G_LAYER_H #define _DE_C2G_LAYER_H #include "layer_with_blending.h" class deC2GLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "c2g";}; deViewManager& viewManager; virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; public: deC2GLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deC2GLayer(); virtual bool updateMainImageNotThreadedWay(); }; #endif delaboratory-0.8/layers/source_image_layer.cc0000644000175100001440000000606212004112446020507 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "source_image_layer.h" #include "channel_manager.h" #include #include "view_manager.h" #include "logger.h" #include "static_image.h" #include "str.h" #include "property_boolean.h" #include "property_choice.h" #include "property_numeric.h" deSourceImageLayer::deSourceImageLayer(deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace) :deBaseLayerWithProperties(_colorSpace, _previewChannelManager) , viewManager(_viewManager), sourceImage(_sourceImage) { std::vector r; r.push_back("0"); r.push_back("90"); r.push_back("180"); r.push_back("270"); createPropertyChoice("rotate", r); createPropertyBoolean("horizontal mirror"); createPropertyBoolean("vertical mirror"); getPropertyChoice("rotate")->setSize(); createPropertyNumeric("contrast", 0, 1.0); if (colorSpace == deColorSpaceProPhoto) { getPropertyNumeric("contrast")->set(0.9); } else { getPropertyNumeric("contrast")->set(1.0); } } deSourceImageLayer::~deSourceImageLayer() { } bool deSourceImageLayer::updateMainImageNotThreadedWay() { const deSize ds = mainLayerImage.getChannelSize(); if (ds.getW() == 0) { return false; } deValue z_x1; deValue z_y1; deValue z_x2; deValue z_y2; viewManager.getZoom(z_x1, z_y1, z_x2, z_y2); bool mirrorX = getPropertyBoolean("horizontal mirror")->get(); bool mirrorY = getPropertyBoolean("vertical mirror")->get(); deValue contrast = getNumericValue("contrast"); int rotate = getInt(getPropertyChoice("rotate")->get()); int channel; for (channel = 0; channel < 3; channel++) { deValue* destination = mainLayerImage.startWrite(channel); if (destination) { sourceImage.copyToChannel(channel, destination, z_x1, z_y1, z_x2, z_y2, ds, mirrorX, mirrorY, rotate, contrast); } mainLayerImage.finishWrite(channel); } return true; } deValue deSourceImageLayer::getAspect() const { deValue aspect = sourceImage.getAspect(); if (aspect == 0) { return 0; } int rotate = getInt(getPropertyChoice("rotate")->get()); if ((rotate == 90) || (rotate == 270)) { aspect = 1.0 / aspect; } return aspect; } delaboratory-0.8/layers/levels_layer.h0000644000175100001440000000315111764477311017216 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LEVELS_LAYER_H #define _DE_LEVELS_LAYER_H #include "layer_with_blending.h" class dePropertyLevels; class deLevelsLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "levels";}; void createPropertyLevels(int channel); void calcAutoLevels(int channel, deValue& min, deValue& middle, deValue& max, deValue margin1, deValue margin2); public: deLevelsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deLevelsLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "levels";}; dePropertyLevels* getPropertyLevels(); virtual void executeOperation(const std::string& o); }; #endif delaboratory-0.8/layers/conversion_layer.h0000644000175100001440000000304412004114342020066 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CONVERSION_LAYER_H #define _DE_CONVERSION_LAYER_H #include "base_layer_with_source.h" #include "image.h" class deLayerStack; class deChannelManager; class deConversionLayer:public deBaseLayerWithSource { private: virtual std::string getType() const {return "conversion";}; std::string warning; public: deConversionLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deConversionLayer(); virtual bool updateMainImageNotThreadedWay(); virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; virtual std::string getActionName() {return "conversion setup";}; virtual std::string getWarning() const {return warning;}; }; #endif delaboratory-0.8/layers/white_balance_layer.h0000644000175100001440000000242511764477311020514 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_WHITE_BALANCE_LAYER_H #define _DE_WHITE_BALANCE_LAYER_H #include "layer_with_blending.h" class deWhiteBalanceLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "white balance";}; public: deWhiteBalanceLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deWhiteBalanceLayer(); virtual bool updateMainImageSingleChannel(int i); virtual bool onImageClick(deValue x, deValue y); }; #endif delaboratory-0.8/layers/source_image_layer.h0000644000175100001440000000303311764477311020365 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SOURCE_IMAGE_LAYER_H #define _DE_SOURCE_IMAGE_LAYER_H class deProject; #include "image.h" class deChannelManager; class deViewManager; class deStaticImage; #include "base_layer_with_properties.h" class deSourceImageLayer:public deBaseLayerWithProperties { private: deViewManager& viewManager; deStaticImage& sourceImage; virtual std::string getType() const {return "original";}; virtual bool updateMainImageNotThreadedWay(); public: deSourceImageLayer(deChannelManager& _previewChannelManager, deViewManager& _viewManager, deStaticImage& _sourceImage, deColorSpace _colorSpace); virtual ~deSourceImageLayer(); virtual bool updateMainImageSingleChannel(int channel) {return false;}; deValue getAspect() const; }; #endif delaboratory-0.8/layers/copy_layer.cc0000644000175100001440000000365211777136356017047 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "copy_layer.h" #include "layer_stack.h" #include "conversion_processor.h" #include "str.h" #include "preset.h" #include "logger.h" deCopyLayer::deCopyLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending( _colorSpace, _channelManager, _sourceLayer, _layerStack) { int size = getLayerStackSize(); std::vector numbers = createNumbers(size); createPropertyChoice("layer", numbers); } deCopyLayer::~deCopyLayer() { } bool deCopyLayer::updateMainImageNotThreadedWay() { logInfo("conversion layer start"); deConversionProcessor p; deConversionCPU cpu(4); int l = getPropertyChoice("layer")->getIndex(); const deImage& image = getOtherLayerImage(l); p.convertImage(image, mainLayerImage, cpu); logInfo("conversion layer DONE"); return true; } void deCopyLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const { int l = getPropertyChoice("layer")->getIndex(); const deImage& image = getOtherLayerImage(l); image.updateChannelUsage(channelUsage, layerIndex); deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); } delaboratory-0.8/layers/auto_dodge_layer.h0000644000175100001440000000242111764477311020035 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_AUTO_DODGE_LAYER_H #define _DE_AUTO_DODGE_LAYER_H #include "layer_with_blending.h" class deAutoDodgeLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "auto_dodge";}; deViewManager& viewManager; public: deAutoDodgeLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deAutoDodgeLayer(); virtual bool updateMainImageSingleChannel(int channel); }; #endif delaboratory-0.8/layers/sharpen_layer.h0000644000175100001440000000256611764477311017375 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SHARPEN_LAYER_H #define _DE_SHARPEN_LAYER_H #include "layer_with_blending.h" class deSharpenLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "sharpen";}; deViewManager& viewManager; public: deSharpenLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deSharpenLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "sharpen";}; }; #endif delaboratory-0.8/layers/recover_highlights_layer.h0000644000175100001440000000246711764477311021614 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RECOVER_HIGHLIGHTS_LAYER_H #define _DE_RECOVER_HIGHLIGHTS_LAYER_H #include "layer_with_blending.h" class deRecoverHighlightsLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "recover_highlights";}; deViewManager& viewManager; public: deRecoverHighlightsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deRecoverHighlightsLayer(); virtual bool updateMainImageNotThreadedWay(); }; #endif delaboratory-0.8/layers/copy_layer.h0000644000175100001440000000250711764477311016702 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COPY_LAYER_H #define _DE_COPY_LAYER_H #include "layer_with_blending.h" #include "image.h" class deLayerStack; class deChannelManager; class deCopyLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "copy";}; public: deCopyLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deCopyLayer(); virtual bool updateMainImageNotThreadedWay(); virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; }; #endif delaboratory-0.8/layers/auto_burn_layer.cc0000644000175100001440000000477711764477311020077 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "auto_burn_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" #include "logger.h" deAutoBurnLayer::deAutoBurnLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius 1", 10, 100); reset->addNumericValue("radius 1", 20); createPropertyNumeric("radius 2", 5, 50); reset->addNumericValue("radius 2", 10); createPropertyNumeric("threshold", 0.0, 1.0); reset->addNumericValue("threshold", 0.5); applyPreset("reset"); setOpacity(0.5); disableNotForSharpen(); } deAutoBurnLayer::~deAutoBurnLayer() { } bool deAutoBurnLayer::updateMainImageSingleChannel(int channel) { /* if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); return true; } */ deValue r1 = getNumericValue("radius 1") * viewManager.getRealScale();; deValue r2 = getNumericValue("radius 2") * viewManager.getRealScale();; deValue t = getNumericValue("threshold"); deSize size = mainLayerImage.getChannelSize(); // mainLayerImage.enableChannel(channel); const deValue* source = getSourceImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(channel); bool result = false; if ((source) && (destination)) { result = autoDodgeBurn(source, destination, size, r1, r2, t, true); } getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return result; } delaboratory-0.8/layers/high_pass_layer.h0000644000175100001440000000273111764477311017674 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HIGH_PASS_LAYER_H #define _DE_HIGH_PASS_LAYER_H #include "layer_with_blending.h" class deHighPassLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "high_pass";}; deViewManager& viewManager; virtual void updateChannelUsage(std::map& channelUsage, int layerIndex) const; public: deHighPassLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deHighPassLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageNotThreadedWay(); virtual std::string getActionName() {return "high pass";}; }; #endif delaboratory-0.8/layers/high_pass_layer.cc0000644000175100001440000000775511765775026020052 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "high_pass_layer.h" #include "preset.h" #include "view_manager.h" #include "fill_channel.h" #include "color_space_utils.h" #include "blur.h" #include "blend_channel.h" #include "logger.h" deHighPassLayer::deHighPassLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 1, 20); reset->addNumericValue("radius", 4); createPropertyNumeric("power", 1.0, 20.0); reset->addNumericValue("power", 1.0); applyPreset("reset"); } deHighPassLayer::~deHighPassLayer() { } bool deHighPassLayer::isChannelNeutral(int channel) { return false; } bool deHighPassLayer::updateMainImageNotThreadedWay() { deSize size = mainLayerImage.getChannelSize(); int n = size.getN(); deValue* mask = NULL; try { mask = new deValue [n]; } catch (std::bad_alloc) { logError("allocating memory in USM"); if (mask) { delete [] mask; } return false; } int channel; int nc = getColorSpaceSize(colorSpace); int no = 3; // assume original image has 3 channels // clear destination fillChannel(mask, n, 0.0); deValue t = 0.0; deBlurType type = deGaussianBlur; deValue r = getNumericValue("radius") * viewManager.getRealScale(); int i; /* for (channel = 0; channel < nc; channel++) { mainLayerImage.enableChannel(channel); } */ // calc high pass for (channel = 0; channel < no; channel++) { const deValue* source = getOriginalImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(0); // use 0 channel for blur blurChannel(source, destination, size, r, r, type, t); for (i = 0; i < n; i++) { deValue d = source[i] - destination[i]; mask[i] += d; } getOriginalImage().finishRead(channel); mainLayerImage.finishWrite(0); } deValue p = getNumericValue("power"); for (i = 0; i < n; i++) { deValue d = mask[i]; d = 0.5 + p * d; if (d < 0) { d = 0; } else if (d > 1) { d = 1; } mask[i] = d; } for (channel = 0; channel < nc; channel++) { /* if (!isChannelEnabled(channel)) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); } else */ { deValue* destination = mainLayerImage.startWrite(channel); int i; for (i = 0; i < n; i++) { destination[i] = mask[i]; } mainLayerImage.finishWrite(channel); } } delete [] mask; return true; } void deHighPassLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const { deLayerWithBlending::updateChannelUsage(channelUsage, layerIndex); getOriginalImage().updateChannelUsage(channelUsage, layerIndex); } delaboratory-0.8/layers/fill_layer.cc0000644000175100001440000000403611764477311017013 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "fill_layer.h" #include "fill_channel.h" #include "preset.h" #include "color_space_utils.h" deFillLayer::deFillLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { std::string n = "fill " + getChannelName(colorSpace, i); createPropertyNumeric(n, 0, 1); reset->addNumericValue(n, 0.5); } applyPreset("reset"); setOpacity(0.5); } deFillLayer::~deFillLayer() { } bool deFillLayer::updateMainImageSingleChannel(int channel) { /* if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); return true; } */ // mainLayerImage.enableChannel(channel); std::string p = "fill " + getChannelName(colorSpace, channel); deValue value = getNumericValue(p); deValue* destination = mainLayerImage.startWrite(channel); int n = mainLayerImage.getChannelSize().getN(); fillChannel(destination, n, value); mainLayerImage.finishWrite(channel); return true; } delaboratory-0.8/layers/sharpen_layer.cc0000644000175100001440000000463511764477311017532 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "sharpen_layer.h" #include "usm.h" #include "preset.h" #include "view_manager.h" deSharpenLayer::deSharpenLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 1, 20); reset->addNumericValue("radius", 4); createPropertyNumeric("threshold", 0.0, 0.03); reset->addNumericValue("threshold", 0.0); applyPreset("reset"); setOpacity(0.1); disableNotForSharpen(); } deSharpenLayer::~deSharpenLayer() { } bool deSharpenLayer::isChannelNeutral(int channel) { return false; } bool deSharpenLayer::updateMainImageSingleChannel(int channel) { /* if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); return true; } */ deValue r = getNumericValue("radius") * viewManager.getRealScale(); deValue a = 50.0; deValue t = getNumericValue("threshold"); deSize size = mainLayerImage.getChannelSize(); // mainLayerImage.enableChannel(channel); const deValue* source = getSourceImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(channel); bool result = false; if ((source) && (destination)) { result = unsharpMask(source, destination, size, a, r, t, deGaussianBlur); } getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return result; } delaboratory-0.8/layers/gaussian_blur_layer.cc0000644000175100001440000000371011765775026020726 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gaussian_blur_layer.h" #include "blur.h" #include "preset.h" #include "view_manager.h" #include "logger.h" deGaussianBlurLayer::deGaussianBlurLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 2, 600); reset->addNumericValue("radius", 200); applyPreset("reset"); } deGaussianBlurLayer::~deGaussianBlurLayer() { } bool deGaussianBlurLayer::updateMainImageSingleChannel(int channel) { logInfo("blur start"); deValue r = getNumericValue("radius") * viewManager.getRealScale();; deSize size = mainLayerImage.getChannelSize(); const deValue* source = getSourceImage().startRead(channel); deValue* destination = mainLayerImage.startWrite(channel); bool result = false; deBlurType type = deGaussianBlur; result = blurChannel(source, destination, size, r, r, type, 0.0); getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); logInfo("blur DONE"); return result; } delaboratory-0.8/layers/curves_layer.cc0000644000175100001440000000532511766762751017405 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curves_layer.h" #include #include #include "str.h" #include "color_space_utils.h" #include "channel_manager.h" #include "property_curves.h" #include "preset.h" deCurvesLayer::deCurvesLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); reset->addOperation("reset"); int n = getColorSpaceSize(colorSpace); properties.push_back(new dePropertyCurves("curves", n)); applyPreset("reset"); } deCurvesLayer::~deCurvesLayer() { } bool deCurvesLayer::updateMainImageSingleChannel(int i) { dePropertyCurves* p = getPropertyCurves(); if (!p) { return false; } bool result = false; // render new image const deBaseCurve* curve = p->getCurve(i); const deValue* source = getSourceImage().startRead(i); deValue* destination = mainLayerImage.startWrite(i); if ((source) && (destination)) { curve->process(source, destination, mainLayerImage.getChannelSize().getN()); result = true; } getSourceImage().finishRead(i); mainLayerImage.finishWrite(i); return result; } bool deCurvesLayer::isChannelNeutral(int index) { dePropertyCurves* p = getPropertyCurves(); if (!p) { return false; } deBaseCurve* curve = p->getCurve(index); return curve->isNeutral(); } dePropertyCurves* deCurvesLayer::getPropertyCurves() { deProperty* p = getProperty("curves"); return dynamic_cast(p); } void deCurvesLayer::executeOperation(const std::string& operation) { int n = getColorSpaceSize(colorSpace); dePropertyCurves* p = getPropertyCurves(); int i; for (i = 0; i < n; i++) { deBaseCurve* curve = p->getCurve(i); curve->clearPoints(); curve->addPoint(0, 0); curve->addPoint(1, 1); curve->build(); } } delaboratory-0.8/layers/gaussian_blur_single_layer.cc0000644000175100001440000000442611774674304022271 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gaussian_blur_single_layer.h" #include "blur.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" deGaussianBlurSingleLayer::deGaussianBlurSingleLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 2, 600); reset->addNumericValue("radius", 200); createPropertyChoice("channel", getChannelNames(colorSpace)); applyPreset("reset"); } deGaussianBlurSingleLayer::~deGaussianBlurSingleLayer() { } bool deGaussianBlurSingleLayer::updateMainImageNotThreadedWay() { deSize size = mainLayerImage.getChannelSize(); int n = size.getN(); int nc = getColorSpaceSize(colorSpace); deBlurType type = deGaussianBlur; deValue r = getNumericValue("radius") * viewManager.getRealScale(); int channel = getPropertyChoice("channel")->getIndex(); const deValue* source = getSourceImage().startRead(channel); int i; deValue* destination = mainLayerImage.startWrite(0); blurChannel(source, destination, size, r, r, type, 0.0); getSourceImage().finishRead(channel); for (i = 1; i < nc; i++) { deValue* dd = mainLayerImage.startWrite(i); copyChannel(destination, dd, n); mainLayerImage.finishWrite(i); } mainLayerImage.finishWrite(0); return true; } delaboratory-0.8/layers/local_contrast_layer.h0000644000175100001440000000245211764477311020736 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LOCAL_CONTRAST_LAYER_H #define _DE_LOCAL_CONTRAST_LAYER_H #include "layer_with_blending.h" class deLocalContrastLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "local_contrast";}; deViewManager& viewManager; public: deLocalContrastLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deLocalContrastLayer(); virtual bool updateMainImageSingleChannel(int channel); }; #endif delaboratory-0.8/layers/gaussian_blur_single_layer.h0000644000175100001440000000250111764477311022121 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GAUSSIAN_BLUR_SINGLE_LAYER_H #define _DE_GAUSSIAN_BLUR_SINGLE_LAYER_H #include "layer_with_blending.h" class deGaussianBlurSingleLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "gaussian_blur_single";}; deViewManager& viewManager; public: deGaussianBlurSingleLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deGaussianBlurSingleLayer(); virtual bool updateMainImageNotThreadedWay(); }; #endif delaboratory-0.8/layers/saturation_layer.h0000644000175100001440000000231511764477311020116 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SATURATION_LAYER_H #define _DE_SATURATION_LAYER_H #include "layer_with_blending.h" class deSaturationLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "saturation";}; public: deSaturationLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack); virtual ~deSaturationLayer(); virtual bool updateMainImageSingleChannel(int i); }; #endif delaboratory-0.8/layers/tone_layer.cc0000644000175100001440000000614011771466520017026 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "tone_layer.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" #include "str.h" #include "curve.h" #include "property_boolean.h" deToneLayer::deToneLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); createPropertyChoice("channel", getChannelNames(colorSpace)); int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { std::string nd = "dark " + getChannelName(colorSpace, i); createPropertyNumeric(nd, 0, 1); reset->addNumericValue(nd, 0.0); } for (i = 0; i < n; i++) { std::string nl = "half " + getChannelName(colorSpace, i); createPropertyNumeric(nl, 0, 1); reset->addNumericValue(nl, 0.5); } for (i = 0; i < n; i++) { std::string nl = "light " + getChannelName(colorSpace, i); createPropertyNumeric(nl, 0, 1); reset->addNumericValue(nl, 1.0); } applyPreset("reset"); } deToneLayer::~deToneLayer() { } bool deToneLayer::updateMainImageNotThreadedWay() { deSize size = mainLayerImage.getChannelSize(); int n = size.getN(); int nc = getColorSpaceSize(colorSpace); int c = getPropertyChoice("channel")->getIndex(); const deValue* source = getSourceImage().startRead(c); if (!source) { logError("broken source in tone layer"); return false; } int channel; for (channel = 0; channel < nc; channel++) { std::string nd = "dark " + getChannelName(colorSpace, channel); std::string nh = "half " + getChannelName(colorSpace, channel); std::string nl = "light " + getChannelName(colorSpace, channel); deValue dark = getNumericValue(nd); deValue light = getNumericValue(nl); deValue half = getNumericValue(nh); deValue* destination = mainLayerImage.startWrite(channel); deBaseCurve curve; curve.addPoint(0, dark); curve.addPoint(0.5, half); curve.addPoint(1, light); curve.build(); curve.process(source, destination, n); mainLayerImage.finishWrite(channel); } getSourceImage().finishRead(c); return true; } delaboratory-0.8/layers/vignette_layer.h0000644000175100001440000000271411764477311017555 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_VIGNETTE_LAYER_H #define _DE_VIGNETTE_LAYER_H #include "layer_with_blending.h" class deViewManager; class deVignetteLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "vignette";}; deViewManager& viewManager; public: deVignetteLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deVignetteLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "vignette";}; virtual bool onImageClick(deValue x, deValue y); }; #endif delaboratory-0.8/layers/exposure_layer.cc0000644000175100001440000000765011764477311017744 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "exposure_layer.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" #include "str.h" #include "curve.h" deExposureLayer::deExposureLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); createPropertyNumeric("exposure", -1, 1); reset->addNumericValue("exposure", 0.0); createPropertyNumeric("brightness", -1, 1); reset->addNumericValue("brightness", 0.0); createPropertyNumeric("shadows", -1, 1); reset->addNumericValue("shadows", 0.0); createPropertyNumeric("lights", -1, 1); reset->addNumericValue("lights", 0.0); createPropertyNumeric("black", 0, 1); reset->addNumericValue("black", 0.0); createPropertyNumeric("highlights", 0, 1); reset->addNumericValue("highlights", 1.0); applyPreset("reset"); disableNotLuminance(); } deExposureLayer::~deExposureLayer() { } bool deExposureLayer::updateMainImageSingleChannel(int channel) { /* if ((isChannelNeutral(channel)) || (!isChannelEnabled(channel))) { int s = getSourceImage().getChannelIndex(channel); mainLayerImage.disableChannel(channel, s); return true; } */ deValue exposure = getNumericValue("exposure"); deValue black = getNumericValue("black"); deValue shadows = getNumericValue("shadows"); deValue brightness = getNumericValue("brightness"); deValue lights = getNumericValue("lights"); deValue highlights = getNumericValue("highlights"); deValue x0 = black; deValue x4 = highlights; deValue x2 = (x0 + x4) / 2.0; deValue x1 = (x0 + x2) / 2.0; deValue x3 = (x2 + x4) / 2.0; deValue y0 = exposure + 0.0; deValue y1 = exposure + 0.25 + shadows/4.0 + brightness; deValue y2 = exposure + 0.5 + brightness; deValue y3 = exposure + 0.75 + lights/4.0 + brightness; deValue y4 = exposure + 1.0; const deValue* source = getSourceImage().startRead(channel); //mainLayerImage.enableChannel(channel); deValue* target = mainLayerImage.startWrite(channel); int n = mainLayerImage.getChannelSize().getN(); deBaseCurve curve; if (colorSpace == deColorSpaceCMYK) { if (x4 < 1) { curve.addPoint(0, 1 - y4); } curve.addPoint(1 - x4, 1 - y4); curve.addPoint(1 - x3, 1 - y3); curve.addPoint(1 - x2, 1 - y2); curve.addPoint(1 - x1, 1 - y1); curve.addPoint(1 - x0, 1 - y0); if (x0 > 0) { curve.addPoint(1, 1 - y0); } } else { if (x0 > 0) { curve.addPoint(0, y0); } curve.addPoint(x0, y0); curve.addPoint(x1, y1); curve.addPoint(x2, y2); curve.addPoint(x3, y3); curve.addPoint(x4, y4); if (x4 < 1) { curve.addPoint(1, y4); } } curve.build(); curve.process(source, target, n); getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return true; } delaboratory-0.8/layers/mixer_layer.cc0000644000175100001440000000663711764477311017222 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "mixer_layer.h" //#include "project.h" #include #include "color_space_utils.h" #include "channel_manager.h" #include "property_mixer.h" #include "preset.h" #include "logger.h" deMixerLayer::deMixerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); reset->addOperation("reset"); int n = getColorSpaceSize(colorSpace); properties.push_back(new dePropertyMixer("mixer", n)); applyPreset("reset"); } deMixerLayer::~deMixerLayer() { } bool deMixerLayer::updateMainImageSingleChannel(int channel) { /* if (!isChannelEnabled(channel)) { mainLayerImage.disableChannel(channel, getSourceImage().getChannelIndex(channel)); return true; } */ const deImage& sourceImage = getSourceImage(); //mainLayerImage.enableChannel(channel); //int c = mainLayerImage.getChannelIndex(channel); dePropertyMixer* p = dynamic_cast(getProperty("mixer")); if (!p) { logError("no property mixer"); return false; } int channelSize = mainLayerImage.getChannelSize().getN(); deValue* destination = mainLayerImage.startWrite(channel); p->getMixer(channel)->process(sourceImage, destination, channelSize); mainLayerImage.finishWrite(channel); return true; } deMixer* deMixerLayer::getMixer(int index) { dePropertyMixer* p = dynamic_cast(getProperty("mixer")); if (!p) { return NULL; } return p->getMixer(index); } bool deMixerLayer::isChannelNeutral(int index) { dePropertyMixer* p = dynamic_cast(getProperty("mixer")); if (!p) { return false; } return p->getMixer(index)->isNeutral(index); } void deMixerLayer::setWeight(int s, int d, deValue value) { dePropertyMixer* p = dynamic_cast(getProperty("mixer")); if (!p) { return; } p->getMixer(d)->setWeight(s, value); } deValue deMixerLayer::getWeight(int s, int d) { dePropertyMixer* p = dynamic_cast(getProperty("mixer")); if (!p) { return -1; } return p->getMixer(d)->getWeight(s); } void deMixerLayer::executeOperation(const std::string& operation) { int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { int j; for (j = 0; j < n; j++) { deValue v = 0.0; if (i == j) { v = 1.0; } setWeight(i, j, v); } } } delaboratory-0.8/layers/curves_layer.h0000644000175100001440000000273311766762751017247 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVES_LAYER_H #define _DE_CURVES_LAYER_H #include "layer_with_blending.h" #include "curve.h" class dePropertyCurves; class deCurvesLayer:public deLayerWithBlending { private: dePropertyCurves* getPropertyCurves(); protected: virtual std::string getType() const {return "curves";}; public: deCurvesLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager); virtual ~deCurvesLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int i); virtual std::string getActionName() {return "curves";}; virtual void executeOperation(const std::string& operation); }; #endif delaboratory-0.8/layers/conversion_layer.cc0000644000175100001440000001050512004114342020224 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "conversion_layer.h" #include "layer_stack.h" #include "conversion_processor.h" #include "str.h" #include "preset.h" #include "logger.h" deConversionLayer::deConversionLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deBaseLayerWithSource( _colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); deColorSpace scs = getSourceColorSpace(); if ((scs == deColorSpaceProPhoto) || (scs == deColorSpaceLAB) || (scs == deColorSpaceLCH)) { deValue c = 1.0; createPropertyNumeric("contrast", 0, 1.0); reset->addNumericValue("contrast", c); } if ((scs == deColorSpaceLAB) || (scs == deColorSpaceLCH)) { createPropertyNumeric("saturation", 0, 1); reset->addNumericValue("saturation", 1); } if (colorSpace == deColorSpaceCMYK) { createPropertyNumeric("GCR substract", 0, 1); reset->addNumericValue("GCR substract", 0.25); createPropertyNumeric("GCR Key max", 0, 1); reset->addNumericValue("GCR Key max", 1.0); createPropertyNumeric("GCR CMY min", 0, 3); reset->addNumericValue("GCR CMY min", 0.0); } if (colorSpace == deColorSpaceBW) { createPropertyNumeric("mixer red", -3, 3); reset->addNumericValue("mixer red", 0.3); createPropertyNumeric("mixer green", -3, 3); reset->addNumericValue("mixer green", 0.6); createPropertyNumeric("mixer blue", -3, 3); reset->addNumericValue("mixer blue", 0.1); } if (scs == deColorSpaceBW) { createPropertyNumeric("pseudogrey", 0, 1.0); reset->addNumericValue("pseudogrey", 0); } applyPreset("reset"); } deConversionLayer::~deConversionLayer() { } bool deConversionLayer::updateMainImageNotThreadedWay() { #ifdef DEBUG_LOG logInfo("conversion layer start"); #endif deConversionProcessor p; deConversionCPU cpu(4); cpu.registers[CPU_REGISTER_OVERFLOW] = 0; cpu.registers[CPU_REGISTER_CMYK_KEY_SUB] = getNumericValue("GCR substract"); cpu.registers[CPU_REGISTER_CMYK_KEY_MAX] = getNumericValue("GCR Key max"); cpu.registers[CPU_REGISTER_CMYK_MIN_SUM] = getNumericValue("GCR CMY min"); cpu.registers[CPU_REGISTER_BW_MIXER_R] = getNumericValue("mixer red"); cpu.registers[CPU_REGISTER_BW_MIXER_G] = getNumericValue("mixer green"); cpu.registers[CPU_REGISTER_BW_MIXER_B] = getNumericValue("mixer blue"); cpu.registers[CPU_REGISTER_CONTRAST] = getNumericValue("contrast"); cpu.registers[CPU_REGISTER_SATURATION] = getNumericValue("saturation"); cpu.registers[CPU_REGISTER_PSEUDOGREY] = getNumericValue("pseudogrey"); #ifdef DEBUG_LOG logInfo("conversion layer contrast: " + str(cpu.registers[CPU_REGISTER_CONTRAST])); logInfo("conversion layer saturation: " + str(cpu.registers[CPU_REGISTER_SATURATION])); #endif p.convertImage(getSourceImage(), mainLayerImage, cpu); deValue overflow = cpu.registers[CPU_REGISTER_OVERFLOW]; int n = getSourceImage().getChannelSize().getN(); int percentage = overflow * 10000 / n; if (percentage == 0) { warning = "OK"; } else { deValue p = percentage / 100.0; warning = "conversion OVERFLOW " + str(p) + "%"; } #ifdef DEBUG_LOG logInfo("conversion layer DONE"); #endif return true; } void deConversionLayer::updateChannelUsage(std::map& channelUsage, int layerIndex) const { getSourceImage().updateChannelUsage(channelUsage, layerIndex); deBaseLayer::updateChannelUsage(channelUsage, layerIndex); } delaboratory-0.8/layers/white_balance_layer.cc0000644000175100001440000000700211776613063020645 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "white_balance_layer.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" #include "str.h" #include "curve.h" #include "property_numeric.h" deWhiteBalanceLayer::deWhiteBalanceLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); createPropertyNumeric("green / magenta", -1, 1); reset->addNumericValue("green / magenta", 0.0); createPropertyNumeric("g / m finetune", -1, 1); reset->addNumericValue("g / m finetune", 0.0); createPropertyNumeric("blue / yellow", -1, 1); reset->addNumericValue("blue / yellow", 0.0); createPropertyNumeric("b / y finetune", -1, 1); reset->addNumericValue("b / y finetune", 0.0); applyPreset("reset"); if (colorSpace != deColorSpaceLAB) { disableAll(); } else { disableChannel(0); } } deWhiteBalanceLayer::~deWhiteBalanceLayer() { } bool deWhiteBalanceLayer::updateMainImageSingleChannel(int channel) { deValue s = 0.0; deValue s2 = 0.0; if (channel == 1) { s = getNumericValue("green / magenta"); s2 = getNumericValue("g / m finetune"); } if (channel == 2) { s = getNumericValue("blue / yellow"); s2 = getNumericValue("b/ y finetune"); } s = 0.5 * s + 0.1 * s2; if (s > 0.49) { s = 0.49; } if (s < -0.49) { s = -0.49; } const deValue* source = getSourceImage().startRead(channel); deValue* target = mainLayerImage.startWrite(channel); int n = mainLayerImage.getChannelSize().getN(); deBaseCurve curve; curve.addPoint(0, 0); curve.addPoint(0.5 - s , 0.5); curve.addPoint(1, 1); curve.build(); curve.process(source, target, n); getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return true; } bool deWhiteBalanceLayer::onImageClick(deValue x, deValue y) { if (colorSpace != deColorSpaceLAB) { return false; } const deImage& source = getSourceImage(); const deSize size = source.getChannelSize(); int p = (y * size.getH() ) * size.getW() + (x * size.getW()); const deValue* pixelsA = source.startRead(1); const deValue* pixelsB = source.startRead(2); deValue a = pixelsA[p] - 0.5; deValue b = pixelsB[p] - 0.5; source.finishRead(1); source.finishRead(2); a = -2 * a; b = -2 * b; getPropertyNumeric("green / magenta")->set(a); getPropertyNumeric("g / m finetune")->set(0.0); getPropertyNumeric("blue / yellow")->set(b); getPropertyNumeric("b / y finetune")->set(0.0); return true; } delaboratory-0.8/layers/equalizer_layer.cc0000644000175100001440000000752411776627733020103 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "equalizer_layer.h" #include #include #include "str.h" #include "color_space_utils.h" #include "channel_manager.h" #include "property_curves.h" #include "preset.h" deEqualizerLayer::deEqualizerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); reset->addOperation("reset"); createPropertyChoice("channel", getChannelNames(colorSpace)); getPropertyChoice("channel")->setOthers(); if (colorSpace == deColorSpaceLCH) { getPropertyChoice("channel")->setIndex(2); } int n = getColorSpaceSize(colorSpace); properties.push_back(new dePropertyCurves("curves", n)); setBlendMode(deBlendOverlay); applyPreset("reset"); setHorizontalChannel(); } deEqualizerLayer::~deEqualizerLayer() { } bool deEqualizerLayer::updateMainImageSingleChannel(int i) { dePropertyCurves* p = getPropertyCurves(); if (!p) { return false; } const deBaseCurve* curve = p->getCurve(i); int channel = getPropertyChoice("channel")->getIndex(); const deValue* sourceEq = NULL; const deValue* source = getSourceImage().startRead(i); if (i == channel) { sourceEq = source; } else { sourceEq = getSourceImage().startRead(channel); } deValue* destination = mainLayerImage.startWrite(i); int n = mainLayerImage.getChannelSize().getN(); int j; for (j = 0; j < n; j++) { deValue eq = sourceEq[j]; deValue v = source[j]; deValue c = curve->calcValue(eq); v = c; if (v < 0) { destination[j] = 0; } else if (v > 1) { destination[j] = 1; } else { destination[j] = v; } } getSourceImage().finishRead(i); mainLayerImage.finishWrite(i); if (i != channel) { getSourceImage().finishRead(channel); } return true; } bool deEqualizerLayer::isChannelNeutral(int index) { dePropertyCurves* p = getPropertyCurves(); if (!p) { return false; } deBaseCurve* curve = p->getCurve(index); return curve->isNeutral(); } dePropertyCurves* deEqualizerLayer::getPropertyCurves() { deProperty* p = getProperty("curves"); return dynamic_cast(p); } void deEqualizerLayer::executeOperation(const std::string& operation) { int n = getColorSpaceSize(colorSpace); dePropertyCurves* p = getPropertyCurves(); int i; for (i = 0; i < n; i++) { deBaseCurve* curve = p->getCurve(i); curve->clearPoints(); curve->addPoint(0, 0.5); curve->addPoint(1, 0.5); curve->build(); } } void deEqualizerLayer::setHorizontalChannel() { int channel = getPropertyChoice("channel")->getIndex(); getPropertyCurves()->setHorizontalChannel(channel); } void deEqualizerLayer::beforeSetUIFromLayer() { setHorizontalChannel(); } delaboratory-0.8/layers/equalizer_layer.h0000644000175100001440000000313311764477311017725 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_EQUALIZER_LAYER_H #define _DE_EQUALIZER_LAYER_H #include "layer_with_blending.h" #include "curve.h" class dePropertyCurves; class deEqualizerLayer:public deLayerWithBlending { private: dePropertyCurves* getPropertyCurves(); void setHorizontalChannel(); protected: virtual std::string getType() const {return "curves";}; public: deEqualizerLayer(deColorSpace _colorSpace, int _sourceLayer, deLayerStack& _layerStack, deChannelManager& _channelManager, deViewManager& _viewManager); virtual ~deEqualizerLayer(); virtual bool isChannelNeutral(int index); virtual bool updateMainImageSingleChannel(int i); virtual std::string getActionName() {return "curves";}; virtual void executeOperation(const std::string& operation); virtual void beforeSetUIFromLayer(); }; #endif delaboratory-0.8/layers/levels_layer.cc0000644000175100001440000001134512000457565017351 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "levels_layer.h" #include "copy_channel.h" #include "color_space_utils.h" #include "property_levels.h" #include "curve.h" #include "preset.h" #include "histogram.h" #include "logger.h" #include "str.h" deLevelsLayer::deLevelsLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); reset->addOperation("reset"); dePreset* autoLevels = createPreset("auto levels"); autoLevels->addOperation("auto levels"); dePreset* autoLevelsLight = createPreset("auto levels light"); autoLevelsLight->addOperation("auto levels light"); dePreset* autoLevelsHeavy = createPreset("auto levels heavy"); autoLevelsHeavy->addOperation("auto levels heavy"); int n = getColorSpaceSize(colorSpace); properties.push_back(new dePropertyLevels("levels", n)); } deLevelsLayer::~deLevelsLayer() { } bool deLevelsLayer::isChannelNeutral(int channel) { dePropertyLevels* propertyLevels = getPropertyLevels(); if (!propertyLevels) { return true; } const deLevels& levels = propertyLevels->getLevels(channel); return levels.isNeutral(); } bool deLevelsLayer::updateMainImageSingleChannel(int channel) { logInfo("processing levels channel " + str(channel)); dePropertyLevels* propertyLevels = getPropertyLevels(); if (!propertyLevels) { return false; } const deLevels& levels = propertyLevels->getLevels(channel); const deValue* source = getSourceImage().startRead(channel); deValue* target = mainLayerImage.startWrite(channel); int n = mainLayerImage.getChannelSize().getN(); deBaseCurve curve; curve.addPoint(0, 0); curve.addPoint(levels.getMin(), 0); curve.addPoint(levels.getMiddle(), 0.5); curve.addPoint(levels.getMax(), 1); curve.addPoint(1, 1); curve.build(); logInfo("levels curve build min: " + str(levels.getMin()) + " middle: " + str(levels.getMiddle()) + " max: " + str(levels.getMax())); curve.process(source, target, n); getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return true; } dePropertyLevels* deLevelsLayer::getPropertyLevels() { deProperty* p = getProperty("levels"); return dynamic_cast(p); } void deLevelsLayer::executeOperation(const std::string& operation) { logInfo("levels layer operation: " + operation); int n = getColorSpaceSize(colorSpace); dePropertyLevels* propertyLevels = getPropertyLevels(); if (!propertyLevels) { return; } int i; for (i = 0; i < n; i++) { deLevels& levels = propertyLevels->getLevels(i); deValue min = 0.0; deValue middle = 0.5; deValue max = 1.0; if (operation == "auto levels") { calcAutoLevels(i, min, middle, max, 0.0005, 0.4); } if (operation == "auto levels light") { calcAutoLevels(i, min, middle, max, 0.005, 0.4); } if (operation == "auto levels heavy") { calcAutoLevels(i, min, middle, max, 0.02, 0.4); } levels.setMin(min); levels.setMiddle(middle); levels.setMax(max); logInfo("set levels min: " + str(min) + " middle: " + str(middle) + " max: " + str(max)); if (!shouldUseAutoLevels(colorSpace, i)) { disableChannel(i); logInfo("levels - disabling channel " + str(i)); } } setOpacity(0.7); } void deLevelsLayer::calcAutoLevels(int channel, deValue& min, deValue& middle, deValue& max, deValue margin1, deValue margin2) { const deValue* c = getSourceImage().startRead(channel); int n = getSourceImage().getChannelSize().getN(); int s = 1024; deHistogram histogram(s); histogram.clear(); histogram.calc(c, n); getSourceImage().finishRead(channel); histogram.calcLevels(margin1, margin2, min, middle, max); } delaboratory-0.8/layers/saturation_layer.cc0000644000175100001440000000546311764477311020263 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "saturation_layer.h" #include "preset.h" #include "view_manager.h" #include "color_space_utils.h" #include "copy_channel.h" #include "logger.h" #include "str.h" #include "curve.h" deSaturationLayer::deSaturationLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack) { dePreset* reset = createPreset("reset"); createPropertyNumeric("saturation", -1, 1); reset->addNumericValue("saturation", 0.0); createPropertyNumeric("green / magenta", -1, 1); reset->addNumericValue("green / magenta", 0.0); createPropertyNumeric("blue / yellow", -1, 1); reset->addNumericValue("blue / yellow", 0.0); applyPreset("reset"); if (colorSpace != deColorSpaceLAB) { disableAll(); } else { disableChannel(0); } } deSaturationLayer::~deSaturationLayer() { } bool deSaturationLayer::updateMainImageSingleChannel(int channel) { deValue s = getNumericValue("saturation"); deValue s2 = 0.0; if (channel == 1) { s2 = getNumericValue("green / magenta"); } if (channel == 2) { s2 = getNumericValue("blue / yellow"); } s = s + s2; const deValue* source = getSourceImage().startRead(channel); deValue* target = mainLayerImage.startWrite(channel); int n = mainLayerImage.getChannelSize().getN(); deBaseCurve curve; if (s > 0) { if (s > 1) { s = 1.0; } s = 0.99 * s; curve.addPoint(0, 0); curve.addPoint(s / 2.0, 0); curve.addPoint(0.5, 0.5); curve.addPoint(1 - s/2.0, 1); curve.addPoint(1, 1); } else { if (s < -1) { s = -1; } s = -s; curve.addPoint(0, s / 2.0); curve.addPoint(0.5, 0.5); curve.addPoint(1, 1 - s / 2.0); } curve.build(); curve.process(source, target, n); getSourceImage().finishRead(channel); mainLayerImage.finishWrite(channel); return true; } delaboratory-0.8/layers/vignette_layer.cc0000644000175100001440000000607311774674304017717 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "vignette_layer.h" #include "vignette.h" #include "preset.h" #include "view_manager.h" #include "property_numeric.h" deVignetteLayer::deVignetteLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager) :deLayerWithBlending(_colorSpace, _channelManager, _sourceLayer, _layerStack), viewManager(_viewManager) { if (colorSpace == deColorSpaceCMYK) { setBlendMode(deBlendScreen); } else { setBlendMode(deBlendMultiply); } dePreset* reset = createPreset("reset"); createPropertyNumeric("radius", 0.3, 3.0); reset->addNumericValue("radius", 1.5); createPropertyNumeric("aspect", -0.9, 0.9); reset->addNumericValue("aspect", 0.0); createPropertyNumeric("center_x", -1, 1); reset->addNumericValue("center_x", 0.0); createPropertyNumeric("center_y", -1, 1); reset->addNumericValue("center_y", 0.0); applyPreset("reset"); disableNotLuminance(); } deVignetteLayer::~deVignetteLayer() { } bool deVignetteLayer::isChannelNeutral(int channel) { return false; } bool deVignetteLayer::updateMainImageSingleChannel(int channel) { if (!isChannelEnabled(channel)) { copySourceChannel(channel); return true; } deSize size = mainLayerImage.getChannelSize(); deValue* destination = mainLayerImage.startWrite(channel); deValue light = 1.0; deValue darkness = 0.0; deValue spot = 0.5; deValue x1; deValue y1; deValue x2; deValue y2; viewManager.getZoom(x1, y1, x2, y2); deValue r = getNumericValue("radius"); deValue a = getNumericValue("aspect"); deValue rx = r; if (a < 0.0) { rx *= (a + 1); } deValue ry = r; if (a > 0.0) { ry *= (1 - a); } deValue cx = getNumericValue("center_x"); deValue cy = getNumericValue("center_y"); deEllipse ellipse = calcEllipse(rx, ry, cx, cy, x1, y1, x2, y2); vignetteChannel(destination, size, ellipse, light, darkness, spot); mainLayerImage.finishWrite(channel); return true; } bool deVignetteLayer::onImageClick(deValue x, deValue y) { dePropertyNumeric* cx = getPropertyNumeric("center_x"); cx->set(2 * x - 1); dePropertyNumeric* cy = getPropertyNumeric("center_y"); cy->set(2 * y - 1); return true; } delaboratory-0.8/layers/gaussian_blur_layer.h0000644000175100001440000000255311764477311020567 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GAUSSIAN_BLUR_LAYER_H #define _DE_GAUSSIAN_BLUR_LAYER_H #include "layer_with_blending.h" class deGaussianBlurLayer:public deLayerWithBlending { private: virtual std::string getType() const {return "gaussian_blur";}; deViewManager& viewManager; public: deGaussianBlurLayer(deColorSpace _colorSpace, deChannelManager& _channelManager, int _sourceLayer, deLayerStack& _layerStack, deViewManager& _viewManager); virtual ~deGaussianBlurLayer(); virtual bool updateMainImageSingleChannel(int channel); virtual std::string getActionName() {return "gaussian blur";}; }; #endif delaboratory-0.8/gui_wx/0000755000175100001440000000000012005331266014345 5ustar jacekusersdelaboratory-0.8/gui_wx/color_matrix_frame.h0000644000175100001440000000304111764477311020405 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COLOR_MARTIX_FRAME6_H #define _DE_COLOR_MATRIX_FRAME6_H #include "help_frame.h" #include "palette.h" class deProject; class deColorMatrixFrame:public deHelpFrame { private: deProject& project; dePalette3* palette; dePalette3* palette2; dePalette3* paletteLAB; public: deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin); virtual ~deColorMatrixFrame(); }; class deColorMatrixFrame2:public deHelpFrame { private: public: deColorMatrixFrame2(wxWindow *parent, deProject& _project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette); virtual ~deColorMatrixFrame2(); }; #endif delaboratory-0.8/gui_wx/button.cc0000644000175100001440000000331011766762751016210 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "button.h" #include #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" class deButtonImpl:public dePanelWX { private: deButton& parent; wxButton* button; public: deButtonImpl(deButton& _parent, deWindow& _parentWindow, const std::string& _name) :dePanelWX(_parentWindow), parent(_parent) { button = new wxButton(this, wxID_ANY, wxString::FromAscii(_name.c_str())); Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deButtonImpl::click)); } virtual ~deButtonImpl() { } void click(wxCommandEvent &event) { parent.onClick(); } }; deButton::deButton(deWindow& window, const std::string& _name) { impl = new deButtonImpl(*this, window, _name); } deButton::~deButton() { if (impl) { delete impl; } } deWindow& deButton::getWindow() { return impl->getWindow(); } delaboratory-0.8/gui_wx/view_mode_panel.cc0000644000175100001440000000641411766762751020042 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "view_mode_panel.h" #include #include "color_space.h" #include "project.h" #include #include "logger.h" #include "color_space_utils.h" #include "gui.h" void deViewModePanel::select(wxCommandEvent &event) { int i = event.GetId(); deViewManager& viewManager = project.getViewManager(); if (buttons[0]->GetId() == i) { viewManager.setNormal(); return; } int j; for (j = 0; j < MAX_COLOR_SPACE_SIZE; j++) { if (buttons[j+1]->GetId() == i) { viewManager.setSingleChannel(j); } } } deViewModePanel::deViewModePanel(wxWindow* parent, deProject& _project, deGUI& gui) :wxPanel(parent), project(_project) { gui.setViewModePanel(this); wxSizer* sizerS = new wxStaticBoxSizer(wxVERTICAL, this, _T("view")); SetSizer(sizerS); wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); sizerS->Add(sizer); int i; for (i = 0; i < (MAX_COLOR_SPACE_SIZE + 1); i++) { int style = 0; if (i == 0) { style = wxRB_GROUP; } wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); sizer->Add(b); buttons.push_back(b); } updateNames(); updateMode(); Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deViewModePanel::select)); } deViewModePanel::~deViewModePanel() { } void deViewModePanel::updateNames() { deViewManager& viewManager = project.getViewManager(); deColorSpace colorSpace = viewManager.getColorSpace(); int i; int n = getColorSpaceSize(colorSpace); for (i = 0; i < ( MAX_COLOR_SPACE_SIZE + 1) ; i++) { wxRadioButton* b = buttons[i]; if (i == 0) { b->SetLabel(wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); b->Show(); } else { int c = i - 1; if (c < n) { std::string name = getChannelName(colorSpace, c); b->SetLabel(wxString::FromAscii(name.c_str())); b->Show(); } else { b->Hide(); } } } Layout(); Fit(); SetFocus(); } void deViewModePanel::updateMode() { deViewManager& viewManager = project.getViewManager(); if (viewManager.isSingleChannel()) { int c = viewManager.getChannel(); buttons[c+1]->SetValue(1); } else { buttons[0]->SetValue(1); } } delaboratory-0.8/gui_wx/zoom_panel.cc0000644000175100001440000000443211764477311017037 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "zoom_panel.h" #include "zoom_manager.h" #include "image_area_panel.h" deZoomPanel::deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager) :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), zoomManager(_zoomManager) { imageAreaPanel = NULL; wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("zoom")); SetSizer(sizerS); zoomIn = new wxButton(this, wxID_ANY, _T("select"), wxDefaultPosition, wxSize(60,25)); sizerS->Add(zoomIn); zoomOut = new wxButton(this, wxID_ANY, _T("full"), wxDefaultPosition, wxSize(60,25)); sizerS->Add(zoomOut); Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deZoomPanel::click)); updateButtons(); } void deZoomPanel::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) { imageAreaPanel = _imageAreaPanel; } deZoomPanel::~deZoomPanel() { } void deZoomPanel::click(wxCommandEvent &event) { int id = event.GetId(); if (zoomIn->GetId() == id) { zoomManager.enableSelectionMode(); } if (zoomOut->GetId() == id) { zoomManager.fullZoomOut(); if (imageAreaPanel) { imageAreaPanel->updateSize(false); } } updateButtons(); } void deZoomPanel::updateButtons() { if (zoomManager.isInSelectionMode()) { zoomIn->Disable(); zoomOut->Disable(); return; } if (zoomManager.isZoomed()) { zoomIn->Enable(); zoomOut->Enable(); } else { zoomIn->Enable(); zoomOut->Disable(); } } delaboratory-0.8/gui_wx/sampler_panel.h0000644000175100001440000000275111764477311017362 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SAMPLER_PANEL_H #define _DE_SAMPLER_PANEL_H #include "wx/wx.h" #include #include "color_space.h" #include "gradient_panel.h" class deSampler; class deProject; class deImage; class deSamplerPanel:public wxPanel { private: deSampler& sampler; deProject& project; wxChoice* colorSpaceChoice; deColorPanelOld* colorPanel; wxStaticText* v1; wxStaticText* v2; wxStaticText* v3; wxStaticText* v4; wxStaticBoxSizer* sizerS; std::vector colorSpaces; void choose(wxCommandEvent &event); void update(const deImage& image); public: deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project); virtual ~deSamplerPanel(); void update(); void setChoice(); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame.cc0000644000175100001440000000365211764477311021535 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame.h" #include "color_space.h" #include "gradient_panel.h" #include "color_space_utils.h" deHelpColorSpacesFrame::deHelpColorSpacesFrame(wxWindow *parent) :deHelpFrame(parent, "channels") { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); std::vector colorSpaces; getSupportedColorSpaces(colorSpaces); int width = 256; int barSize = 40; std::vector::iterator i; for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) { deColorSpace c = *i; wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); sizer->Add(sizerB); int n = getColorSpaceSize(c); int j; for (j = 0; j < n; j++) { wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getChannelName(c, j).c_str())); sizerB->Add(sizerBC); deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, -1, -1, -1, -1); sizerBC->Add(gradient, 0, wxCENTER); } } Fit(); } deHelpColorSpacesFrame::~deHelpColorSpacesFrame() { } delaboratory-0.8/gui_wx/slider.cc0000644000175100001440000001044012002551204016126 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "slider.h" #include #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" #include "logger.h" #include "str.h" class deSliderImpl:public dePanelWX { private: deSlider& parent; wxSlider* slider; wxStaticText* labelValue; deValue min; deValue max; deValue width; public: deSliderImpl(deSlider& _parent, deWindow& _parentWindow, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl) :dePanelWX(_parentWindow), parent(_parent), min(_min), max(_max), width(_width) { if (width == 0) { logError("slider with width 0 created"); } wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); SetSizer(sizer); if (_name.size() > 0) { wxStaticText* label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(_name.c_str()), wxDefaultPosition, wxSize(widthn, 30)); sizer->Add(label, 0, wxCENTER); } slider = new wxSlider(this, wxID_ANY, _width, 0, _width, wxDefaultPosition, wxSize(_width, -1), wxSL_HORIZONTAL); sizer->Add(slider, 0); labelValue = new wxStaticText(this, wxID_ANY, _T("inv"), wxDefaultPosition, wxSize(widthl, 30)); sizer->Add(labelValue, 0, wxCENTER); Connect(wxEVT_SCROLL_THUMBTRACK, wxCommandEventHandler(deSliderImpl::moveSlider)); Connect(wxEVT_SCROLL_CHANGED, wxCommandEventHandler(deSliderImpl::finishMoveSlider)); } virtual ~deSliderImpl() { #ifdef DEBUG_LOG logInfo("~deSliderImpl"); #endif } void moveSlider(wxCommandEvent &event) { updateValueFromSlider(false); } void finishMoveSlider(wxCommandEvent &event) { updateValueFromSlider(true); } void updateValueFromSlider(bool finished) { deValue v = min + slider->GetValue() * ((max - min) / width); setLabelValue(v); parent.onValueChange(v, finished); } void setLabelValue(deValue v) { std::ostringstream oss; oss.str(); oss << v; if (labelValue) { std::string s = oss.str(); labelValue->SetLabel(wxString::FromAscii(oss.str().c_str())); } } void setValue(deValue v) { setLabelValue(v); setSlider(v); } void setSlider(deValue v) { if (width == 0) { return; } if (max == min) { return; } deValue sl = (v - min) / ((max-min) / width); slider->SetValue(sl); } }; deSlider::deSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl) { #ifdef DEBUG_LOG logInfo("deSlider constructor"); #endif deWindowWX* w = dynamic_cast(&window); if (w) { impl = new deSliderImpl(*this, window, _name, _min, _max, _width, widthn, widthl); } else { impl = NULL; } } deSlider::~deSlider() { #ifdef DEBUG_LOG logInfo("deSlider destructor"); #endif if (impl) { delete impl; } } void deSlider::setValue(deValue v) { if (impl) { impl->setValue(v); } } deWindow& deSlider::getWindow() { return impl->getWindow(); } delaboratory-0.8/gui_wx/delaboratory.h0000644000175100001440000000166312005232453017211 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include std::string getApplicationName() { return "delaboratory"; } std::string getVersion() { return "0.8"; } std::string getCopyright() { return "(c) 2012 Jacek Poplawski"; } delaboratory-0.8/gui_wx/layer_grid_panel.cc0000644000175100001440000001072411766762751020204 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_grid_panel.h" #include "project.h" #include #include "base_layer_with_source.h" #include "switchable_layer.h" #include #include "layer_factory.h" #include "layer_processor.h" #include "frame.h" #include "str.h" #include "layer_stack.h" #include "window_wx.h" #include "gui.h" void deLayerGridPanel::buildRows() { logInfo("build rows"); deLayerStack& layerStack = project.getLayerStack(); int n = layerStack.getSize(); int idWidth = 24; int actionWidth = 200; int i; for (i = n-1; i >=0; i--) { const deBaseLayer* layer = layerStack.startReadLayer(i); layerRows.push_back(deLayerRow(i)); deLayerRow& row = layerRows.back(); std::ostringstream oss; oss << i; row.id = new wxStaticText(this, wxID_ANY, wxString::FromAscii(oss.str().c_str()), wxDefaultPosition, wxSize(idWidth, -1)); gridSizer->Add(row.id, 0, wxALIGN_CENTER); int style = 0; if (i == n-1) { style = wxRB_GROUP; } row.view = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); gridSizer->Add(row.view, 0, wxALIGN_CENTER); std::string action = layer->getType(); row.action = new wxButton(this, wxID_ANY, wxString::FromAscii(action.c_str()), wxDefaultPosition, wxSize(actionWidth,25)); if (action.size() > 0) { gridSizer->Add(row.action, 0); } else { gridSizer->Add(row.action, 0); row.action->Hide(); } layerStack.finishReadLayer(i); } } void deLayerGridPanel::clearRows() { logInfo("clear rows"); std::vector::iterator i; int index = 0; for (i = layerRows.begin(); i != layerRows.end(); i++) { index++; deLayerRow& row = *i; gridSizer->Detach(row.id); delete row.id; gridSizer->Detach(row.view); delete row.view; gridSizer->Detach(row.action); delete row.action; } gridSizer->Clear(); layerRows.clear(); } deLayerGridPanel::deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deChannelManager& _channelManager, deGUI& gui) :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(250, 400)), project(_project), layerProcessor(_processor), channelManager(_channelManager) { gui.setLayerGridPanel(this); gridSizer = new wxFlexGridSizer(3); gridSizer->SetFlexibleDirection(wxHORIZONTAL); SetSizer(gridSizer); buildRows(); SetMinSize(wxSize(300, 360)); Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deLayerGridPanel::select)); Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deLayerGridPanel::click)); } deLayerGridPanel::~deLayerGridPanel() { } void deLayerGridPanel::select(wxCommandEvent &event) { int id = event.GetId(); std::vector::const_iterator i; for (i = layerRows.begin(); i != layerRows.end(); i++) { const deLayerRow& row = *i; if (row.view->GetId() == id) { project.getViewManager().setView(row.index); layerProcessor.onChangeViewMode(); } } } void deLayerGridPanel::click(wxCommandEvent &event) { deLayerStack& layerStack = project.getLayerStack(); int id = event.GetId(); std::vector::const_iterator i; for (i = layerRows.begin(); i != layerRows.end(); i++) { const deLayerRow& row = *i; if (row.action->GetId() == id) { project.openLayerFrame(row.index); } } } void deLayerGridPanel::update() { clearRows(); buildRows(); Layout(); layerProcessor.onGUIUpdate(); } delaboratory-0.8/gui_wx/external_editor.cc0000644000175100001440000000306312003473454020052 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "external_editor.h" #include #include "str.h" #include "str_wx.h" #include #include #include "logger.h" #define WINDOWS_GIMP_EXE "gimp-2.8.exe" void executeExternalEditor(const std::string& fileName, const std::string& app) { const char* c = fileName.c_str(); wxString s(c, wxConvUTF8); std::string executable; #ifdef _WIN32 char * editor = getenv( "GR_EDITOR" ); if( editor != NULL ) { logInfo("using editor variable"); executable = editor; } else { logInfo("editor variable not found, using GIMP"); executable = WINDOWS_GIMP_EXE; } #else executable = app; #endif const wxString command = str2wx(executable) + _T(" ") + s; std::string command_s = str(command); logInfo("executing command: " + command_s); wxExecute(command); } delaboratory-0.8/gui_wx/histogram_mode_panel.h0000644000175100001440000000252611766762751020727 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HISTOGRAM_MODE_PANEL_H #define _DE_HISTOGRAM_MODE_PANEL_H #include #include class deProject; class deHistogramPanel; class deGUI; class deHistogramModePanel:public wxPanel { private: std::vector buttons; deProject& project; deHistogramPanel* histogramPanel; void select(wxCommandEvent &event); public: deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel, deGUI& gui); virtual ~deHistogramModePanel(); void updateNames(); void updateMode(int c); }; #endif delaboratory-0.8/gui_wx/color_matrix_frame.cc0000644000175100001440000002604611777136356020562 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "color_matrix_frame.h" #include "color_matrix.h" #include "gradient_panel.h" #include "project.h" #include "layer_stack.h" #include "base_layer.h" #include "channel_manager.h" #include "wx/notebook.h" #include "conversion_processor.h" #define LAB_TILE_SIZE 20 #define ALL_TILES_SIZE 800 deColorMatrixFrame2::deColorMatrixFrame2(wxWindow *parent, deProject& project, int channelHorizontal, int channelVertical, int channelAverage, int width, int height, dePalette3* palette) :deHelpFrame(parent, "color matrix") { const deViewManager& viewManager = project.getViewManager(); int view = viewManager.getView(); deLayerStack& layerStack = project.getLayerStack(); const deBaseLayer* layer = layerStack.startReadLayer(view); const deImage& originalImage = layer->getLayerImage(); deChannelManager& channelManager = project.getPreviewChannelManager(); deSize channelSize = originalImage.getChannelSize(); int n = channelSize.getN(); deImage LABImage(deColorSpaceLAB, channelManager); LABImage.allocateChannels(); deConversionProcessor p; deConversionCPU cpu(4); p.convertImage(originalImage, LABImage, cpu); int nn = width * height; int min = (n / 1.5) / nn; const deValue* valuesVertical = LABImage.startRead(channelVertical); const deValue* valuesHorizontal = LABImage.startRead(channelHorizontal); const deValue* valuesAverage = LABImage.startRead(channelAverage); if ((!valuesVertical) || (!valuesHorizontal) || (!valuesAverage)) { logError("LABImage broken in color matrix frame"); } int tilesW = width; int tilesH = height; deColorMatrix colorMatrix(tilesW , tilesH); colorMatrix.buildZoomed(valuesHorizontal, valuesVertical, valuesAverage, n, min); wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); SetSizer(mainSizer); int s = 0; wxSizer* LABMapSizer = new wxFlexGridSizer(tilesW, s, s); mainSizer->Add(LABMapSizer); deConversionProcessor cp; int x; int y; for (y = tilesH - 1; y >= 0; y--) { for (x = 0; x < tilesW; x++) { int style = 0; deValue vx = 0; deValue vy = 0; bool center; deValue a = colorMatrix.get(x, y, min, vx, vy, center); style = wxBORDER_NONE; if ((center) && (a < 0)) { style = wxBORDER_SIMPLE; } deColorPanelOld* colorPanel = new deColorPanelOld(this, wxSize(ALL_TILES_SIZE / width, ALL_TILES_SIZE / height), style); LABMapSizer->Add(colorPanel); if (a >= 0) { deValue v1 = 0; deValue v2 = 0; deValue v3 = 0; switch (channelHorizontal) { case 0: v1 = vx; break; case 1: { v2 = vx; break; } case 2: v3 = vx; break; default: break; } switch (channelVertical) { case 0: v1 = vy; break; case 1: v2 = vy; break; case 2: v3 = vy; break; default: break; } switch (channelAverage) { case 0: v1 = a; break; case 1: v2 = a; break; case 2: v3 = a; break; default: break; } deValue r; deValue g; deValue b; deValue z; cp.convert(deColorSpaceLAB, v1, v2, v3, 0, deColorSpaceRGB, r, g, b, z); colorPanel->setRGB(r, g, b); } else { } } } LABImage.finishRead(channelVertical); LABImage.finishRead(channelHorizontal); LABImage.finishRead(channelAverage); Fit(); layerStack.finishReadLayer(view); } deColorMatrixFrame2::~deColorMatrixFrame2() { } #define LAB_TILES 20 deColorMatrixFrame::deColorMatrixFrame(wxWindow *parent, deProject& _project, int tileRW, int tileRH, int tileW, int tileH, int palW, int palH, int palSize, deValue margin) :deHelpFrame(parent, "color matrix"), project(_project) { wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); SetSizer(mainSizer); wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); mainSizer->Add(notebook, 1, wxEXPAND); wxPanel* imagePanel = new wxPanel(notebook); notebook->AddPage(imagePanel, _T("image")); wxSizer* imageSizer = new wxBoxSizer(wxVERTICAL); imagePanel->SetSizer(imageSizer); wxPanel* LABPanel = new wxPanel(notebook); notebook->AddPage(LABPanel, _T("LAB")); wxSizer* LABSizer = new wxBoxSizer(wxVERTICAL); LABPanel->SetSizer(LABSizer); wxPanel* palettePanel = new wxPanel(notebook); notebook->AddPage(palettePanel, _T("palette")); wxSizer* paletteSizer = new wxBoxSizer(wxVERTICAL); palettePanel->SetSizer(paletteSizer); palette = NULL; palette2 = NULL; paletteLAB = NULL; const deViewManager& viewManager = project.getViewManager(); int view = viewManager.getView(); deLayerStack& layerStack = project.getLayerStack(); const deBaseLayer* layer = layerStack.startReadLayer(view); const deImage& image = layer->getLayerImage(); deColorSpace colorSpace = image.getColorSpace(); deConversionProcessor cp; palette = new dePalette3(colorSpace); paletteLAB = new dePalette3(deColorSpaceLAB); deSize channelSize = image.getChannelSize(); int cs = channelSize.getW(); int w = channelSize.getW() / tileW; int h = channelSize.getH() / tileH; int n = w * h; int s = 2; wxSizer* sizer = new wxFlexGridSizer(w, s, s); imageSizer->Add(sizer); int i; int y = 0; int x = 0; for (i = 0; i < n; i++) { deColorPanelOld* colorPanel = new deColorPanelOld(imagePanel, wxSize(tileRW, tileRH), 0); sizer->Add(colorPanel); int x1 = x * tileW; int x2 = (x + 1) * tileW; int y1 = y * tileH; int y2 = (y + 1) * tileH; deValue sum1 = 0; deValue sum2 = 0; deValue sum3 = 0; deValue v1; deValue v2; deValue v3; int xx; int yy; const deValue* values1 = image.startRead(0); const deValue* values2 = image.startRead(1); const deValue* values3 = image.startRead(2); for (yy = y1; yy < y2; yy++) { int p = cs * yy + x1; for (xx = x1; xx < x2; xx++) { v1 = values1[p]; v2 = values2[p]; v3 = values3[p]; sum1 += v1; sum2 += v2; sum3 += v3; p++; } } image.finishRead(0); image.finishRead(1); image.finishRead(2); int ts = tileW * tileH; sum1 /= ts; sum2 /= ts; sum3 /= ts; deValue sum4 = 0; palette->addColor(deColor4(sum1, sum2, sum3, sum4)); deValue r; deValue g; deValue b; deValue z; cp.convert(colorSpace, sum1, sum2, sum3, 0, deColorSpaceRGB, r, g, b, z); deValue L; deValue A; deValue B; cp.convert(colorSpace, sum1, sum2, sum3, 0, deColorSpaceLAB, L, A, B, z); paletteLAB->addColor(deColor4(L, A, B, 0)); colorPanel->setRGB(r, g, b); x++; if (x == w) { x = 0; y++; } } deValue minA; deValue maxA; paletteLAB->getMinMax(2, minA, maxA); deValue minB; deValue maxB; paletteLAB->getMinMax(3, minB, maxB); deValue deltaA = maxA - minA; deValue deltaB = maxB - minB; deValue delta = deltaA; if (deltaB > delta) { delta = deltaB; } deValue step = delta / LAB_TILES; int tiles = deltaA / step + 1; wxSizer* LABMapSizer = new wxFlexGridSizer(tiles, s, s); LABSizer->Add(LABMapSizer); deValue A; deValue B; deValue rB; for (rB = minB; rB < maxB; rB += step) { B = maxB + minB - rB; for (A = minA; A < maxA; A += step) { deColorPanelOld* colorPanel = new deColorPanelOld(LABPanel, wxSize(LAB_TILE_SIZE, LAB_TILE_SIZE), 0); LABMapSizer->Add(colorPanel); deValue L = 1.0; if (paletteLAB->find23(A, A + step, B, B + step, L)) { deValue r; deValue g; deValue b; deValue z; cp.convert(deColorSpaceLAB, L, A, B, 0, deColorSpaceRGB, r, g, b, z); colorPanel->setRGB(r, g, b); } } } palette2 = new dePalette3(colorSpace); palette2->optimize(*palette, palSize, margin); int s2 = 5; wxSizer* sizerS = new wxStaticBoxSizer(wxHORIZONTAL, palettePanel, _T("palette")); paletteSizer->Add(sizerS); wxSizer* palSizer = new wxFlexGridSizer(palSize / 2, s2, s2); sizerS->Add(palSizer); for (i = 0; i < palette2->getSize(); i++) { deColorPanelOld* colorPanel = new deColorPanelOld(palettePanel, wxSize(palW, palH), 0); palSizer->Add(colorPanel); deValue r; deValue g; deValue b; deColor4 c = palette2->getColor(i); deValue z; cp.convert(colorSpace, c.getV1(), c.getV2(), c.getV3(), 0, deColorSpaceRGB, r, g, b, z); colorPanel->setRGB(r, g, b); } Fit(); layerStack.finishReadLayer(view); } deColorMatrixFrame::~deColorMatrixFrame() { if (palette) { delete palette; } if (palette2) { delete palette2; } if (paletteLAB) { delete paletteLAB; } } delaboratory-0.8/gui_wx/raw_module.h0000644000175100001440000000270112004336607016657 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RAW_MODULE_H #define _DE_RAW_MODULE_H #include class deStaticImage; #include "color_space.h" #include "dcraw_support.h" #include "mutex.h" class deRawModule { private: mutable deMutex mutex; deRawLoader* loader; deRawModule(const deRawModule&); deRawModule& operator =(const deRawModule&); std::string dcraw_version; public: deRawModule(); virtual ~deRawModule(); void onInit(); std::string getVersion() const; bool loadRAW(const std::string& fileName, deStaticImage& image, bool half, bool srgb, bool brighten); bool updateRawLoading(bool& failure); bool isActive() const; }; #endif delaboratory-0.8/gui_wx/warning_panel.cc0000644000175100001440000000264611764477311017525 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "warning_panel.h" deWarningPanel::deWarningPanel(wxWindow* parent) :wxPanel(parent) { SetMinSize(wxSize(220,10)); wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("status")); SetSizer(sizerP); warning = new wxStaticText(this, wxID_ANY, _T(""), wxDefaultPosition); sizerP->Add(warning, 0, wxEXPAND); } deWarningPanel::~deWarningPanel() { } void deWarningPanel::setWarning(const std::string& w) { warning->SetLabel(wxString::FromAscii(w.c_str())); if (w == "OK") { unsigned char g = 128; warning->SetForegroundColour(wxColour(g, g, g)); } else { warning->SetForegroundColour(wxColour(255, 0, 0)); } } delaboratory-0.8/gui_wx/choice.cc0000644000175100001440000000525412004761246016120 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "choice.h" #include "window_wx.h" #include "panel_wx.h" class deChoiceImpl:public dePanelWX { private: deChoice& parent; wxChoice* choice; public: deChoiceImpl(deChoice& _parent, deWindow& _parentWindow, const std::string& _name, const std::vector& choices) :dePanelWX(_parentWindow), parent(_parent) { wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); SetSizer(sizer); if (_name.size() > 0) { int widthn = 100; wxStaticText* label = new wxStaticText(this, wxID_ANY, wxString::FromAscii(_name.c_str()), wxDefaultPosition, wxSize(widthn, 30)); sizer->Add(label, 0, wxCENTER); } wxString* ws = new wxString [choices.size()]; unsigned int i; for (i = 0; i < choices.size(); i++) { ws[i] = wxString::FromAscii(choices[i].c_str()); } choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(200, -1), choices.size(), ws); sizer->Add(choice); Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deChoiceImpl::choose)); } void choose(wxCommandEvent &event) { int i = event.GetInt(); parent.onChoose(i); } void set(int index) { choice->SetSelection(index); } }; deChoice::deChoice(deWindow& window, const std::string& _name, const std::vector& _choices) { deWindowWX* w = dynamic_cast(&window); if (w) { impl = new deChoiceImpl(*this, window, _name, _choices); } else { impl = NULL; } } deChoice::~deChoice() { if (impl) { delete impl; } } void deChoice::set(int index) { if (impl) { impl->set(index); } } deWindow& deChoice::getWindow() { return impl->getWindow(); } delaboratory-0.8/gui_wx/choice.h0000644000175100001440000000224211766762751015774 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CHOICE_H #define _DE_CHOICE_H #include #include #include "window.h" class deChoiceImpl; class deChoice { private: deChoiceImpl* impl; public: deChoice(deWindow& window, const std::string& _name, const std::vector& choices); virtual ~deChoice(); virtual void onChoose(int index) = 0; void set(int index); deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/canvas_wx.h0000644000175100001440000000252311764477311016526 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CANVAS_WX_H #define _DE_CANVAS_WX_H #include "canvas.h" #include class deCanvasWX:public deCanvas { private: wxDC& dc; public: deCanvasWX(wxDC& _dc); ~deCanvasWX(); virtual void clear(); virtual void setPen(int r, int g, int b); virtual void setBrush(int r, int g, int b); virtual void drawCircle(int x, int y, int r); virtual void drawLine(int x1, int y1, int x2, int y2); virtual void drawBitmap(deBitmap& bitmap); virtual void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3); }; #endif delaboratory-0.8/gui_wx/button.h0000644000175100001440000000216611766762751016062 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BUTTON_H #define _DE_BUTTON_H #include "value.h" #include class dePanel; class deWindow; class deLayerProcessor; class deButtonImpl; class deButton { private: deButtonImpl* impl; public: deButton(deWindow& window, const std::string& _name); virtual ~deButton(); virtual void onClick() = 0; deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/semaphore.h0000644000175100001440000000213211764477311016514 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SEMAPHORE_H #define _DE_SEMAPHORE_H class deSemaphoreImpl; class deSemaphore { private: deSemaphoreImpl* impl; deSemaphore(const deSemaphore& s); deSemaphore& operator =(const deSemaphore& s); public: deSemaphore(int a, int b); ~deSemaphore(); void wait(); void post(); }; #endif delaboratory-0.8/gui_wx/canvas_wx.cc0000644000175100001440000000342611764477311016667 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "canvas_wx.h" #include "bitmap_wx.h" deCanvasWX::deCanvasWX(wxDC& _dc) :dc(_dc) { } deCanvasWX::~deCanvasWX() { } void deCanvasWX::clear() { dc.Clear(); } void deCanvasWX::drawCircle(int x, int y, int r) { dc.DrawCircle(x, y, r); } void deCanvasWX::drawLine(int x1, int y1, int x2, int y2) { dc.DrawLine(x1, y1, x2, y2); } void deCanvasWX::setPen(int r, int g, int b) { wxPen pen(wxColour(r, g, b)); dc.SetPen(pen); } void deCanvasWX::setBrush(int r, int g, int b) { wxBrush brush(wxColour(r, g, b)); dc.SetBrush(brush); } void deCanvasWX::drawBitmap(deBitmap& bitmap) { deBitmapWX& bitmapWX = dynamic_cast(bitmap); wxBitmap* b = bitmapWX.getBitmap(); if (b) { dc.DrawBitmap(*b, 0, 0, false); } } void deCanvasWX::drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) { wxPoint points[3]; points[0] = wxPoint(x1, y1); points[1] = wxPoint(x2, y2); points[2] = wxPoint(x3, y3); dc.DrawPolygon(3, points); } delaboratory-0.8/gui_wx/window.cc0000644000175100001440000000146111764477311016202 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "window.h" deWindow::deWindow() { } deWindow::~deWindow() { } delaboratory-0.8/gui_wx/image_area_panel.h0000644000175100001440000000277211772646457020004 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CENTER_PANEL_H #define _DE_CENTER_PANEL_H #include class deProject; class deImagePanel; class deSamplerManager; class deZoomManager; class deZoomPanel; class deGUI; #include "mutex.h" class deImageAreaPanel:public wxPanel { private: void resize(wxSizeEvent &event); deProject& project; deImagePanel* imagePanel; deMutex sizeMutex; bool sizeLocked; public: deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel, deGUI& gui); virtual ~deImageAreaPanel(); void updateSize(bool canSkip); void lockSize(); void unlockSize(); deImagePanel* getImagePanel(); }; #endif delaboratory-0.8/gui_wx/control_panel.h0000644000175100001440000000366311764477311017402 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CONTROL_PANEL_H #define _DE_CONTROL_PANEL_H #include #include #include #include "color_space.h" class deProject; class deLayerProcessor; class deOperationProcessor; class deChannelManager; class deControlPanel:public wxPanel { private: deProject& project; deLayerProcessor& layerProcessor; deOperationProcessor& operationProcessor; wxSizer* mainSizer; wxButton* exportSingle; wxButton* exportAll; wxButton* externalEditor; std::map convertButtonsColorSpaces; std::vector convertButtons; std::map actionButtonsNames; std::vector actionButtons; deChannelManager& channelManager; wxButton* deleteLayer; void click(wxCommandEvent &event); //bool generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir); public: deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deOperationProcessor& _operationProcessor, deChannelManager& _channelManager); ~deControlPanel(); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame.h0000644000175100001440000000200011764477311021361 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME_H #define _DE_HELP_COLOR_SPACES_FRAME_H #include "help_frame.h" class deHelpColorSpacesFrame:public deHelpFrame { private: public: deHelpColorSpacesFrame(wxWindow *parent); virtual ~deHelpColorSpacesFrame(); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame3.cc0000644000175100001440000000451511764477311021617 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame3.h" #include "color_space.h" #include "gradient_panel.h" #include #include "color_space_utils.h" void add(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) { wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); sizer->Add(sizerB); int w = 160; int h = 160; deValue max = 1.0; int n = 6; deValue min = max - n * (0.25/2.0); deValue step = (max-min) / (n ); deValue light; for (light = min; light <= max; light+= step) { deValue l = light * 100; std::ostringstream oss; oss << l; wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); sizerB->Add(sizerBC); int c1; int c2; if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) { c1 = 1; c2 = 2; } else { c1 = 1; c2 = 0; } deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, light, -1, -1); sizerBC->Add(gradient, 0, wxCENTER); } } deHelpColorSpacesFrame3::deHelpColorSpacesFrame3(wxWindow *parent) :deHelpFrame(parent, "lightness / value") { wxSizer* sizer = new wxGridSizer(1); SetSizer(sizer); add(deColorSpaceLAB, this, sizer); add(deColorSpaceLCH, this, sizer); add(deColorSpaceHSL, this, sizer); add(deColorSpaceHSV, this, sizer); Fit(); } deHelpColorSpacesFrame3::~deHelpColorSpacesFrame3() { } delaboratory-0.8/gui_wx/property_choice_ui.h0000644000175100001440000000255411764477311020434 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_CHOICE_UI_H #define _DE_PROPERTY_CHOICE_UI_H #include "choice.h" class dePropertyChoice; class deLayerProcessor; class deLayerFrame; class dePropertyChoiceUI:public deChoice { private: dePropertyChoice& property; deLayerProcessor& layerProcessor; int layerIndex; deLayerFrame& parent; public: dePropertyChoiceUI(deWindow& window, dePropertyChoice& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _parent); virtual ~dePropertyChoiceUI(); virtual void onChoose(int index); void setFromProperty(); }; #endif delaboratory-0.8/gui_wx/dcraw_support.cc0000644000175100001440000002074412004336607017562 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "dcraw_support.h" #include #include #include #include "logger.h" #include "str.h" #include "str_wx.h" #include "size.h" #include "static_image.h" #define DCRAW_EXECUTABLE "dcraw" std::string getDcrawVersion() { const char* com = DCRAW_EXECUTABLE; wxString s(com, wxConvUTF8); wxProcess* process = wxProcess::Open(s); wxInputStream* input = process->GetInputStream(); std::string vs = ""; int counter = 0; char c = ' '; char c2 = ' '; do { c2 = c; c = input->GetC(); counter++; if (counter > 40) { return ""; } } while ((c2 != ' ') || (c != 'v')); do { c = input->GetC(); if (c != '\n') { vs += c; } } while (c != '\n'); return vs; } bool isRawValid(const std::string& f) { std::string command = std::string(DCRAW_EXECUTABLE) + " -i -v \"" + f + "\""; logInfo("calling: " + command); const char* c = command.c_str(); wxString s(c, wxConvUTF8); int result = wxExecute(s, wxEXEC_SYNC); logInfo("result: " + str(result)); return (result == 0); } std::string getRawInfo(const std::string& f) { std::string command = std::string(DCRAW_EXECUTABLE) + " -i -v \"" + f + "\""; logInfo("calling: " + command); const char* c = command.c_str(); wxString s(c, wxConvUTF8); wxProcess* process = wxProcess::Open(s); wxInputStream* input = process->GetInputStream(); std::string result; bool finished = false; logInfo("before input reading..."); while (!finished) { unsigned char c = input->GetC(); if (!input->Eof()) { result+= c; } else { finished = true; } } logInfo("after input reading..."); logInfo("raw info: " + result); return result; } deRawLoader::deRawLoader(const std::string& f, deStaticImage& _image, bool _half, bool srgb, bool brighten) :filename(f), image(_image), half(_half) { logInfo("deRawLoader constructor"); std::string options = "-w -c -6"; if (!srgb) { options += " -o 4"; colorSpace = deColorSpaceProPhoto; } else { colorSpace = deColorSpaceRGB; } if (!brighten) { options += " -W"; } if (half) { options += " -h"; } else { options += " -q 3"; } std::string command = std::string(DCRAW_EXECUTABLE) + " " + options + " \"" + f + "\" >abc "; logInfo("calling: " + command); const char* c = command.c_str(); wxString s(c, wxConvUTF8); process = wxProcess::Open(s); input = process->GetInputStream(); } deRawLoader::~deRawLoader() { logInfo("deRawLoader destructor"); } bool deRawLoader::load(bool& failure) { if (!input->CanRead()) { logInfo("deRawLoader load - can't read yet"); return false; } logInfo("deRawLoader::load() - CanRead"); char c1 = input->GetC(); char c2 = input->GetC(); if (c1 != 'P') { logError("first character not P"); failure = true; return false; } if (c2 != '6') { logError("second character not 6"); failure = true; return false; } logInfo("P6 loaded"); char c; std::string ws = ""; do { c = input->GetC(); if (c != ' ') ws += c; } while (c != ' '); int w = getInt(ws); if (w <= 0) { logError("width 0"); failure = true; return false; } std::string hs = ""; do { c = input->GetC(); if (c != '\n') hs += c; } while (c != '\n'); int h = getInt(hs); if (h <= 0) { logError("height 0"); failure = true; return false; } std::string ms = ""; do { c = input->GetC(); if (c != '\n') ms += c; } while (c != '\n'); int max = getInt(ms); if (max <= 256) { logError("max <= 256"); failure = true; return false; } logInfo("w: " + str(w) + " h: " + str(h) + " max: " + str(max)); if (half) { w *= 2; h *= 2; logInfo("after half w: " + str(w) + " h: " + str(h) + " max: " + str(max)); } image.lock(); deSize size(w, h); image.setSize(size); deValue* pixels0 = image.startWriteStatic(0); deValue* pixels1 = image.startWriteStatic(1); deValue* pixels2 = image.startWriteStatic(2); deValue scale = 1.0 / max; int pos = 0; unsigned char cc1; unsigned char cc2; char* buffer; int bufsize=500000; logInfo("allocating buffer of size " + str(bufsize)); buffer = new char[bufsize]; int n = w * h; if (half) { n /= 4; } int offset = 0; int steps = 0; int maxRead = 0; image.setColorSpace(colorSpace); int tx = 0; int ty = 0; logInfo("start loading PPM data"); while ((pos < n) && (!input->Eof())) { steps++; input->Read(buffer + offset, bufsize - offset); int r = input->LastRead(); if (r > maxRead) { maxRead = r; } r += offset; int p = 0; while (p + 6 <= r) { deValue r; deValue g; deValue b; c = buffer[p]; p++; cc1 = (unsigned char)(c); c = buffer[p]; p++; cc2 = (unsigned char)(c); r = (256 * cc1 + cc2) * scale; c = buffer[p]; p++; cc1 = (unsigned char)(c); c = buffer[p]; p++; cc2 = (unsigned char)(c); g = (256 * cc1 + cc2) * scale; c = buffer[p]; p++; cc1 = (unsigned char)(c); c = buffer[p]; p++; cc2 = (unsigned char)(c); b = (256 * cc1 + cc2) * scale; if (half) { pixels0[(2 * ty + 0) * w + 2 * tx + 0] = r; pixels0[(2 * ty + 1) * w + 2 * tx + 0] = r; pixels0[(2 * ty + 0) * w + 2 * tx + 1] = r; pixels0[(2 * ty + 1) * w + 2 * tx + 1] = r; pixels1[(2 * ty + 0) * w + 2 * tx + 0] = g; pixels1[(2 * ty + 1) * w + 2 * tx + 0] = g; pixels1[(2 * ty + 0) * w + 2 * tx + 1] = g; pixels1[(2 * ty + 1) * w + 2 * tx + 1] = g; pixels2[(2 * ty + 0) * w + 2 * tx + 0] = b; pixels2[(2 * ty + 1) * w + 2 * tx + 0] = b; pixels2[(2 * ty + 0) * w + 2 * tx + 1] = b; pixels2[(2 * ty + 1) * w + 2 * tx + 1] = b; tx++; if (tx >= w / 2) { tx = 0; ty++; } } else { pixels0[pos] = r; pixels1[pos] = g; pixels2[pos] = b; } pos++; } int left = r - p; int i; for (i = 0; i < left; i++) { buffer[i] = buffer[p + i]; } offset = left; } image.finishWriteStatic(0); image.finishWriteStatic(1); image.finishWriteStatic(2); logInfo("pos: " + str(pos) + " n: " + str(n) + " steps: " + str(steps) + " maxRead: " + str(maxRead)); if (input->Eof()) { logInfo("input stream EOF"); } logInfo("deallocating buffer"); delete [] buffer; image.unlock(); logInfo("loading ppm done"); return true; } bool deRawLoader::getStatus() { if (!process) { return false; } if (!input) { return false; } return true; } delaboratory-0.8/gui_wx/property_mixer_ui.h0000644000175100001440000000265211764477311020325 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_MIXER_UI_H #define _DE_PROPERTY_MIXER_UI_H class dePropertyMixer; class deLayerProcessor; class deWindow; class dePropertyMixerUIImpl; class deBaseLayerWithSource; class dePropertyMixerUI { private: dePropertyMixer& property; deLayerProcessor& layerProcessor; int layerIndex; deBaseLayerWithSource& layer; dePropertyMixerUIImpl* impl; public: dePropertyMixerUI(deWindow& window, dePropertyMixer& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); virtual ~dePropertyMixerUI(); deWindow& getWindow(); void setFromProperty(); }; #endif delaboratory-0.8/gui_wx/tmp.h0000644000175100001440000000147511766762751015351 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_TMP_H #define _DE_TMP_H #include std::string getTmp(); #endif delaboratory-0.8/gui_wx/str_wx.h0000644000175100001440000000167612005061147016054 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_STR_WX_H #define _DE_STR_WX_H #include #include "value.h" #include wxString str2wx(const std::string& s); std::string str(const wxString& ws); std::string getUserDataDir(); #endif delaboratory-0.8/gui_wx/help_color_spaces_frame3.h0000644000175100001440000000200511764477311021451 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME3_H #define _DE_HELP_COLOR_SPACES_FRAME3_H #include "help_frame.h" class deHelpColorSpacesFrame3:public deHelpFrame { private: public: deHelpColorSpacesFrame3(wxWindow *parent); virtual ~deHelpColorSpacesFrame3(); }; #endif delaboratory-0.8/gui_wx/canvas.h0000644000175100001440000000243711764477311016014 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CANVAS_H #define _DE_CANVAS_H class deBitmap; class deCanvas { private: public: deCanvas(); ~deCanvas(); virtual void clear() = 0; virtual void drawCircle(int x, int y, int r) = 0; virtual void drawLine(int x1, int y1, int x2, int y2) = 0; virtual void setPen(int r, int g, int b) = 0; virtual void setBrush(int r, int g, int b) = 0; virtual void drawBitmap(deBitmap& bitmap) = 0; virtual void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) = 0; }; #endif delaboratory-0.8/gui_wx/curves_panel.cc0000644000175100001440000002371712005233617017355 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "curves_panel.h" #include #include "curves_layer.h" #include "layer_processor.h" #include "logger.h" #include "channels.h" #include "color_space_utils.h" #include "channel_manager.h" #include "property_curves.h" #include "str.h" #include "str_wx.h" wxColour getChannelwxColour(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceRGB: case deColorSpaceProPhoto: { int g = 200; switch (channel) { case DE_CHANNEL_RED: return wxColour(g, 0, 0); case DE_CHANNEL_GREEN: return wxColour(0, g, 0); case DE_CHANNEL_BLUE: return wxColour(0, 0, g); } } case deColorSpaceCMYK: case deColorSpaceCMY: { int g = 240; int g2 = 100; switch (channel) { case DE_CHANNEL_CYAN: return wxColour(0, g, g); case DE_CHANNEL_MAGENTA: return wxColour(g, 0, g); case DE_CHANNEL_YELLOW: return wxColour(g, g, 0); case DE_CHANNEL_KEY: return wxColour(g2, g2, g2); } } default: { // in any other cases just use dark gray int g = 50; return wxColour(g, g, g); } } } BEGIN_EVENT_TABLE(deCurvesPanel, wxPanel) EVT_PAINT(deCurvesPanel::paintEvent) END_EVENT_TABLE() deCurvesPanel::deCurvesPanel(wxWindow* parent, deLayerProcessor& _layerProcessor, int _layerIndex, dePropertyCurves& _property, deColorSpace _colorSpace, wxStaticText* _infoEntry) :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(CURVES_PANEL_SIZE_X, CURVES_PANEL_SIZE_Y)), sizeX(CURVES_PANEL_SIZE_X), sizeY(CURVES_PANEL_SIZE_Y), layerProcessor(_layerProcessor), layerIndex(_layerIndex), property(_property), colorSpace(_colorSpace), infoEntry(_infoEntry) { SetFocus(); Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deCurvesPanel::click)); Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deCurvesPanel::release)); Connect(wxEVT_MOTION, wxMouseEventHandler(deCurvesPanel::move)); channel = 0; selectedPoint = -1; lastSelectedPoint = -1; marker = -1; backgroundBitmap = NULL; clickPosition = -1; bitmap.Create(CURVES_PANEL_SIZE_X, CURVES_PANEL_SIZE_Y); } deCurvesPanel::~deCurvesPanel() { delete backgroundBitmap; } void deCurvesPanel::generateBackground(const deValue* c, int n) { if (backgroundBitmap) { delete backgroundBitmap; } deHistogram histogram(CURVES_PANEL_SIZE_X); histogram.clear(); histogram.calc(c, n); wxImage* image = new wxImage(sizeX, sizeY); unsigned char* data = image->GetData(); unsigned char g1 = 255; unsigned char g2 = 200; wxColour colour = getChannelwxColour(colorSpace, channel); int margin = 0; histogram.render(data, sizeX, sizeY, g1, g2, margin); backgroundBitmap = new wxBitmap(*image); delete image; } void deCurvesPanel::render(wxDC& dc_orig) { wxBufferedDC dc(&dc_orig, bitmap, wxBUFFER_CLIENT_AREA); int g = 50; wxColour colourB(g, g, g); wxBrush brush(colourB); if (backgroundBitmap) { dc.DrawBitmap(*backgroundBitmap, 0, 0, false); } else { dc.Clear(); } drawLines(dc); wxColour colour = getChannelwxColour(colorSpace, channel); wxPen pen(colour); dc.SetPen(pen); drawCurve(dc); } void deCurvesPanel::drawPoint(wxDC& dc, deValue x, deValue y) { int xx = (sizeX - 1) * x; int yy = (sizeY - 1) * (1 - y); dc.DrawCircle(xx, yy, 5); } void deCurvesPanel::drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2) { int xx1 = (sizeX - 1) * x1; int xx2 = (sizeX - 1) * x2; int yy1 = (sizeY - 1) * (1 - y1); int yy2 = (sizeY - 1) * (1 - y2); dc.DrawLine(xx1, yy1, xx2, yy2); } void deCurvesPanel::drawLines(wxDC& dc) { int g1 = 180; int g2 = 80; wxPen pen1(wxColour(g1, g1, g1)); wxPen pen2(wxColour(g2, g2, g2)); dc.SetPen(pen1); float y; for (y = 0.0; y <= 1.0; y += (1/8.0)) { drawLine(dc, 0.0, y, 1.0, y); } float x; for (x = 0.0; x <= 1.0; x += (1/8.0)) { drawLine(dc, x, 0.0, x, 1.0); } dc.SetPen(pen2); if (marker >= 0) { drawLine(dc, 0.0, marker, 1.0, marker); drawLine(dc, marker, 0.0, marker, 1.0); } } void deCurvesPanel::drawCurve(wxDC& dc) { deBaseCurve* curve = property.getCurve(channel); if (!curve) { return; } int i; deValue lastY = 0.0; deValue lastX = 0.0; for (i = 0; i < sizeX; i++) { deValue x = (deValue) i / (sizeX - 1.0); deValue y = curve->calcValue(x); if (i > 0) { drawLine(dc, lastX, lastY, x, y); } lastY = y; lastX = x; } const deCurvePoints& controlPoints = curve->getControlPoints(); deCurvePoints::const_iterator j; int index = 0; for (j = controlPoints.begin(); j != controlPoints.end(); j++) { const deCurvePoint& point = *j; deValue x = point.getX(); deValue y = point.getY(); drawPoint(dc, x, y); index++; } } void deCurvesPanel::click(wxMouseEvent &event) { deBaseCurve* curve = property.getCurve(channel); if (!curve) { return; } selectedPoint = -1; deValue x; deValue y; getPosition(event, x, y); setInfo(x,y); int n = curve->findPoint(x, y); if (n >= 0) { selectedPoint = n; } else { selectedPoint = curve->addPoint(x, y); curve->build(); } lastSelectedPoint = selectedPoint; const deCurvePoint& point = curve->getPoint(selectedPoint); grabX = point.getX() - x; grabY = point.getY() - y; update(false); } void deCurvesPanel::update(bool finished) { paint(); layerProcessor.markUpdateSingleChannel(layerIndex, channel); } void deCurvesPanel::release(wxMouseEvent &event) { if (selectedPoint) { deValue x; deValue y; getPosition(event, x, y); if ((x < -0.1) || (y < -0.1) || (x>1.1) || (y>1.1)) { removeSelectedPoint(); return; } } selectedPoint = -1; update(true); } bool deCurvesPanel::removeSelectedPoint() { deBaseCurve* curve = property.getCurve(channel); if (!curve) { logError("no curve in remove selected point"); return false;; } if (selectedPoint < 0) { selectedPoint = lastSelectedPoint; } if (selectedPoint >= 0) { curve->deletePoint(selectedPoint); curve->build(); lastSelectedPoint = -1; selectedPoint = -1; update(true); return true; } return false; } void deCurvesPanel::move(wxMouseEvent &event) { if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT)) { selectedPoint = -1; return; } deBaseCurve* curve = property.getCurve(channel); if (!curve) { return; } if (selectedPoint >= 0) { deValue x; deValue y; getPosition(event, x, y); x+= grabX; y+= grabY; if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (x > 1) { x = 1; } if (y > 1) { y = 1; } curve->movePoint(selectedPoint, x, y); setInfo(x,y); curve->build(); update(false); } } void deCurvesPanel::getPosition(wxMouseEvent &event, deValue& x, deValue &y) { deValue dX = 1.0 / (sizeX - 1); deValue dY = 1.0 / (sizeY - 1); x = event.GetX() * dX; y = 1 - (event.GetY() * dY); } void deCurvesPanel::paint() { wxClientDC dc(this); render(dc); } void deCurvesPanel::paintEvent(wxPaintEvent & evt) { wxPaintDC dc(this); render(dc); } void deCurvesPanel::changeChannel(int _channel) { logInfo("curves panel change channel start"); layerProcessor.lockLayerProcessor(); channel = _channel; layerProcessor.unlockLayerProcessor(); layerProcessor.setHistogramChannel(channel); paint(); logInfo("curves panel change channel DONE"); } void deCurvesPanel::onImageClick(deValue x, deValue y, const deValue* c, const deSize& size) { if ((x < 0) || (y < 0) || (x >= 1) || (y >= 1)) { return; } clickPosition = (y * size.getH() ) * size.getW() + (x * size.getW()); setMarker(c, size.getN()); paint(); } void deCurvesPanel::setMarker(const deValue* c, int n) { if ((clickPosition < 0) || (clickPosition > n)) { marker = -1; } else { marker = c[clickPosition]; } paint(); } int deCurvesPanel::getClickPosition() const { return clickPosition; } void deCurvesPanel::setInfo(deValue x, deValue y) { if (infoEntry) { std::string s = str(getPresentationValue(colorSpace, channel, x)) + " " + str(getPresentationValue(colorSpace, channel, y)); infoEntry->SetLabel(str2wx(s)); } } delaboratory-0.8/gui_wx/curves_panel.h0000644000175100001440000000502212000472655017206 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CURVES_PANEL_H #define _DE_CURVES_PANEL_H #define CURVES_PANEL_SIZE_X 384 #define CURVES_PANEL_SIZE_Y 256 #include "wx/wx.h" class deCurvesLayer; class deLayerProcessor; class deChannelManager; class deCanvas; class dePropertyCurves; #include "value.h" #include "histogram.h" #include "color_space.h" #include "size.h" class deCurvesPanel:public wxPanel { private: wxBitmap bitmap; wxBitmap* backgroundBitmap; int sizeX; int sizeY; int channel; bool realtime; void drawPoint(wxDC& dc, deValue x, deValue y); void drawCurve(wxDC& dc); void click(wxMouseEvent &event); void release(wxMouseEvent &event); void move(wxMouseEvent &event); void update(bool finished); int selectedPoint; int lastSelectedPoint; deValue grabX; deValue grabY; void getPosition(wxMouseEvent &event, deValue& x, deValue &y); void setInfo(deValue x, deValue y); deValue marker; int clickPosition; deLayerProcessor& layerProcessor; int layerIndex; dePropertyCurves& property; deColorSpace colorSpace; wxStaticText* infoEntry; void drawLine(wxDC& dc, deValue x1, deValue y1, deValue x2, deValue y2); void drawLines(wxDC& dc); public: deCurvesPanel(wxWindow* parent, deLayerProcessor& _layerProcessor, int _layerIndex, dePropertyCurves& _property, deColorSpace _colorSpace, wxStaticText* _infoEntry); ~deCurvesPanel(); void paintEvent(wxPaintEvent & evt); void render(wxDC& dc); void paint(); void changeChannel(int _channel); void onImageClick(deValue x, deValue y, const deValue* c, const deSize& size); void setMarker(const deValue* c, int n); void generateBackground(const deValue* c, int n); int getClickPosition() const; bool removeSelectedPoint(); DECLARE_EVENT_TABLE() }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame4.cc0000644000175100001440000000440311764477311021614 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame4.h" #include "color_space.h" #include "gradient_panel.h" #include #include "color_space_utils.h" void add2(deColorSpace colorSpace, wxWindow* parent, wxSizer* sizer) { wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(getColorSpaceName(colorSpace).c_str())); sizer->Add(sizerB); wxSizer* sizerG = new wxGridSizer(6); sizerB->Add(sizerG); int w = 120; int h = 50; int n = 18; deValue step = 1.0 / n; deValue l = 0; int i; for (i = 0; i < n; i++) { std::ostringstream oss; int hue; hue = 360 * l; oss << hue; wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, parent, wxString::FromAscii(oss.str().c_str())); sizerG->Add(sizerBC); int c1; int c2; if (colorSpace == deColorSpaceLCH) { c1 = 0; c2 = 1; } else { c1 = 1; c2 = 2; } deGradientPanel1* gradient = new deGradientPanel1(parent, wxSize(w, h), colorSpace, c1, c2, -1, l, -1); sizerBC->Add(gradient, 0, wxCENTER); l += step; } } deHelpColorSpacesFrame4::deHelpColorSpacesFrame4(wxWindow *parent) :deHelpFrame(parent, "hue") { wxSizer* sizer = new wxGridSizer(1); SetSizer(sizer); add2(deColorSpaceLCH, this, sizer); add2(deColorSpaceHSL, this, sizer); add2(deColorSpaceHSV, this, sizer); Fit(); } deHelpColorSpacesFrame4::~deHelpColorSpacesFrame4() { } delaboratory-0.8/gui_wx/file_dialogs.cc0000644000175100001440000000565312005223531017301 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "file_dialogs.h" #include "str.h" #include "str_wx.h" #include "logger.h" wxString getFileType(const std::string& t) { if (t == "image") { return _T("TIFF / JPEG (*.tiff;*.tif;*.jpeg;*.jpg) | ;*.tiff;*.tif;*.jpeg;*.jpg"); } if (t == "raw") { return _T("RAW (*.*) | ;*.*;"); } if (t == "tiff") { return _T("TIFF (*.tiff;*.tif) | ;*.tiff;*.tif"); } if (t == "jpeg") { return _T("JPEG (*.jpeg;*.jpg) | ;*.jpeg;*.jpg"); } if (t == "delab") { return _T("delab (*.delab) | ;*.delab"); } return _T(""); } std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir) { logInfo("getSaveFile info: " + info + " t: " + t + " dir: " + dir); wxString type = getFileType(t); wxString directory = str2wx(dir); wxFileDialog saveFileDialog(parent, wxString::FromAscii(info.c_str()), directory, _T(""), type, wxFD_SAVE); if (saveFileDialog.ShowModal() == wxID_CANCEL) { return ""; } wxString path = saveFileDialog.GetPath(); std::string result = str(path); logInfo("getSaveFile result: " + result); return result; } std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir) { logInfo("getOpenFile info: " + info + " t: " + t + " dir: " + dir); wxString type = getFileType(t); wxString directory = str2wx(dir); wxFileDialog openFileDialog(parent, wxString::FromAscii(info.c_str()), directory, _T(""), type, wxFD_OPEN); if (openFileDialog.ShowModal() == wxID_CANCEL) { return ""; } wxString path = openFileDialog.GetPath(); std::string result = str(path); logInfo("getOpenFile result: " + result); return result; } std::string getDir(wxWindow* parent, const std::string& info) { wxDirDialog saveFileDialog(parent, wxString::FromAscii(info.c_str())); if (saveFileDialog.ShowModal() != wxID_OK) { logInfo("getDir hit cancel"); return ""; } wxString path = saveFileDialog.GetPath(); std::string result = str(path); logInfo("getDir result: " + result); return result; } delaboratory-0.8/gui_wx/layer_frame_manager.cc0000644000175100001440000000701311764477311020652 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_frame_manager.h" #include "layer_frame.h" #include "str.h" #include "logger.h" deLayerFrameManager::deLayerFrameManager() { } deLayerFrameManager::~deLayerFrameManager() { destroyAllFrames(); } void deLayerFrameManager::destroyAllFrames() { while (layerFrames.size() > 0) { std::map::iterator i = layerFrames.begin(); layerFrames.erase(i); delete i->second; } } bool deLayerFrameManager::addLayerFrame(int index, deLayerFrame* frame) { std::map::iterator i = layerFrames.find(index); if (i != layerFrames.end()) { return false; } layerFrames[index] = frame; return true; } bool deLayerFrameManager::removeLayerFrame(int index) { logInfo("remove layer frame " + str(index)); std::map::iterator i = layerFrames.find(index); if (i == layerFrames.end()) { return false; } layerFrames.erase(i); logInfo("remove layer frame " + str(index) + " DONE"); return true; } bool deLayerFrameManager::destroyLayerFrame(int index) { logInfo("destroy layer frame " + str(index)); std::map::iterator i = layerFrames.find(index); if (i == layerFrames.end()) { return false; } deLayerFrame* frame = i->second; logInfo("b destroy layer frame " + str(index)); if (frame) { delete frame; } else { logError("broken layer frame detected!"); } logInfo("c destroy layer frame " + str(index)); return true; } void deLayerFrameManager::onDestroyLayer(int index) { logInfo("c onDestroyLayer " + str(index)); destroyLayerFrame(index); logInfo("onDestroyLayer " + str(index) + " DONE"); } bool deLayerFrameManager::onImageClick(deValue x, deValue y) { { std::map::iterator i = layerFrames.begin(); for (i = layerFrames.begin(); i != layerFrames.end(); i++) { deLayerFrame* layerFrame = i->second; if (layerFrame) { bool result = layerFrame->onImageClick(x, y); if (result) { return result; } } } } return false; } void deLayerFrameManager::onKey(int key) { std::map::iterator i = layerFrames.begin(); for (i = layerFrames.begin(); i != layerFrames.end(); i++) { deLayerFrame* layerFrame = i->second; if (layerFrame) { layerFrame->onKey(key); } } } bool deLayerFrameManager::checkLayerFrame(int index) { std::map::iterator i = layerFrames.find(index); if (i != layerFrames.end()) { return true; } return false; } delaboratory-0.8/gui_wx/main_frame.h0000644000175100001440000001000412004336607016612 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MAIN_FRAME_H #define _DE_MAIN_FRAME_H #include "wx/wx.h" class deProject; class deImageAreaPanel; class deLayerGridPanel; class deControlPanel; class deHistogramPanel; class deLayerProcessor; class deSamplersPanel; class deSamplerManager; class deZoomManager; class deThreadsPanel; class deOperationProcessor; class deChannelManager; class deWarningPanel; #include "size.h" #include "main_frame_events.h" #include "gui.h" class deMainFrame: public wxFrame { private: deProject& project; wxPanel* hPanel; wxPanel* topPanel; deLayerGridPanel* layerGridPanel; deSamplersPanel* samplersPanel; deControlPanel* controlPanel; wxSizer* mainSizer; deImageAreaPanel* imageAreaPanel; deHistogramPanel* histogramPanel; deThreadsPanel* threadsPanel; deWarningPanel* warningPanel; deGUI& gui; std::string imageName; deLayerProcessor& layerProcessor; deSize imageSize; std::string openDirectory; std::string saveDirectory; bool full; void onTestImageSmall(wxCommandEvent& event); void onTestImageBig(wxCommandEvent& event); void onOpenImage(wxCommandEvent& event); void onOpenRawImageProPhoto(wxCommandEvent& event); void onOpenRawImageRGB(wxCommandEvent& event); void onOpenRawImageProPhotoAB(wxCommandEvent& event); void onOpenRawImageRGBAB(wxCommandEvent& event); void onQuit(wxCommandEvent& event); void onNewProject(wxCommandEvent& event); void onHelpColorSpaces(wxCommandEvent& event); void onHelpColorSpaces2(wxCommandEvent& event); void onHelpColorSpaces3(wxCommandEvent& event); void onHelpColorSpaces4(wxCommandEvent& event); void onHelpColorSpaces5(wxCommandEvent& event); void onLABColors1(wxCommandEvent& event); void onLABColors2(wxCommandEvent& event); void onLABColors5(wxCommandEvent& event); void onColorMatrix1(wxCommandEvent& event); void onColorMatrix2(wxCommandEvent& event); void onColorMatrix3(wxCommandEvent& event); void onColorMatrix4(wxCommandEvent& event); void onColorMatrix5(wxCommandEvent& event); void onRepaintEvent(wxCommandEvent& event); void onImageLoadEvent(wxCommandEvent& event); void onInfoEvent(wxCommandEvent& event); void onWarningEvent(wxCommandEvent& event); void onHistogramEvent(wxCommandEvent& event); void onTimerEvent(wxTimerEvent& event); void onExportGIMP(wxCommandEvent& event); void onExportTIFF(wxCommandEvent& event); void onExportJPG(wxCommandEvent& event); void onExportAll(wxCommandEvent& event); void onCloseEvent(wxCloseEvent& event); void repaintMainFrame(bool calcHistogram); void check(wxCommandEvent &event); void updateTitle(); void paintHistogram(); bool generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir); public: deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcrawVersion, deOperationProcessor& _operationProcessor, deChannelManager& channelManager, deGUI& _gui); ~deMainFrame(); void rebuild(); void onKey(int key); void generateHistogram(); void updateWarning(); void setImageName(const std::string& _imageName, const deSize& _size); void forceUpdateSize(); DECLARE_EVENT_TABLE() }; #endif delaboratory-0.8/gui_wx/property_curves_ui.h0000644000175100001440000000302611764477311020504 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_CURVES_UI_H #define _DE_PROPERTY_CURVES_UI_H class dePropertyCurves; class deLayerProcessor; class deWindow; class dePropertyCurvesUIImpl; class deBaseLayerWithSource; #include "value.h" class dePropertyCurvesUI { private: dePropertyCurves& property; deLayerProcessor& layerProcessor; int layerIndex; deBaseLayerWithSource& layer; dePropertyCurvesUIImpl* impl; public: dePropertyCurvesUI(deWindow& window, dePropertyCurves& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); virtual ~dePropertyCurvesUI(); deWindow& getWindow(); void setFromProperty(); bool onImageClick(deValue x, deValue y); bool onKey(int key); }; #endif delaboratory-0.8/gui_wx/view_mode_panel.h0000644000175100001440000000237211766762751017703 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_VIEW_MODE_PANEL_H #define _DE_VIEW_MODE_PANEL_H #include #include #include #include "color_space.h" class deProject; class deGUI; class deViewModePanel:public wxPanel { private: std::vector buttons; deProject& project; void select(wxCommandEvent &event); public: deViewModePanel(wxWindow* parent, deProject& _project, deGUI& gui); virtual ~deViewModePanel(); void updateNames(); void updateMode(); }; #endif delaboratory-0.8/gui_wx/rendered_image.h0000644000175100001440000000305611764477311017471 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RENDERED_IMAGE_H #define _DE_RENDERED_IMAGE_H #include "size.h" class deBitmap; class deCanvas; class deRenderedImage { private: deBitmap* renderedBitmap; unsigned char* internalData; deRenderedImage(const deRenderedImage& i); deRenderedImage& operator = (const deRenderedImage& i); deSize size; deSize requestedSize; deSize bitmapSize; bool error; public: deRenderedImage(); virtual ~deRenderedImage(); void setSize(const deSize& _size); unsigned char* getCurrentImageData(); unsigned char* getCurrentBitmapData(); bool render(deCanvas& canvas); void setError() {error = true;}; void clearError() {error = false;}; bool getError() const {return error;}; }; #endif delaboratory-0.8/gui_wx/sampler_panel.cc0000644000175100001440000001515111764477311017516 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "sampler_panel.h" #include "sampler.h" #include "project.h" #include "base_layer.h" #include "conversion_processor.h" #include "image.h" #include #include "channel_manager.h" #include "layer_stack.h" #include "color_space_utils.h" deSamplerPanel::deSamplerPanel(wxWindow* parent, deSampler& _sampler, deProject& _project) :wxPanel(parent, wxID_ANY, wxDefaultPosition), sampler(_sampler), project(_project) { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); int valueWidth = 70; getSupportedColorSpaces(colorSpaces); wxSizer* sizerT = new wxBoxSizer(wxHORIZONTAL); sizer->Add(sizerT); wxString* colorSpaceStrings = new wxString [colorSpaces.size()]; unsigned int i; for (i = 0; i < colorSpaces.size(); i++) { colorSpaceStrings[i] = wxString::FromAscii(getColorSpaceName(colorSpaces[i]).c_str()); } colorSpaceChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, colorSpaces.size(), colorSpaceStrings); sizerT->Add(colorSpaceChoice); colorPanel = new deColorPanelOld(this, wxSize(60, 25), 0); sizerT->Add(colorPanel, 0, wxALIGN_CENTER); sizerS = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("")); sizer->Add(sizerS); v1 = new wxStaticText(this, wxID_ANY, _T("v1"), wxDefaultPosition, wxSize(valueWidth, -1)); sizerS->Add(v1); v2 = new wxStaticText(this, wxID_ANY, _T("v2"), wxDefaultPosition, wxSize(valueWidth, -1)); sizerS->Add(v2); v3 = new wxStaticText(this, wxID_ANY, _T("v3"), wxDefaultPosition, wxSize(valueWidth, -1)); sizerS->Add(v3); v4 = new wxStaticText(this, wxID_ANY, _T("v4"), wxDefaultPosition, wxSize(valueWidth, -1)); sizerS->Add(v4); delete [] colorSpaceStrings; setChoice(); Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(deSamplerPanel::choose)); } deSamplerPanel::~deSamplerPanel() { } void deSamplerPanel::setChoice() { deColorSpace colorSpace = sampler.getColorSpace(); unsigned int i; for (i = 0; i != colorSpaces.size(); i++) { if (colorSpaces[i] == colorSpace) { colorSpaceChoice->SetSelection(i); } } } void deSamplerPanel::update() { if (sampler.isEnabled()) { colorSpaceChoice->Enable(); v1->Enable(); v2->Enable(); v3->Enable(); v4->Enable(); } else { v1->Disable(); v2->Disable(); v3->Disable(); v4->Disable(); colorSpaceChoice->Disable(); } int g = 240; if (sampler.isSelected()) { g = 200; } sizerS->GetStaticBox()->SetBackgroundColour(wxColour(g, g, g)); const deViewManager& viewManager = project.getViewManager(); int view = viewManager.getView(); deLayerStack& layerStack = project.getLayerStack(); const deBaseLayer* layer = layerStack.startReadLayer(view); if (layer) { const deImage& image = layer->getLayerImage(); update(image); } layerStack.finishReadLayer(view); } void deSamplerPanel::update(const deImage& image) { deSize channelSize = image.getChannelSize(); deValue x = sampler.getX(); deValue y = sampler.getY(); if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) { int xx = channelSize.getW() * x; int yy = channelSize.getH() * y; int p = channelSize.getW() * yy + xx; deColorSpace colorSpace = sampler.getColorSpace(); int n = getColorSpaceSize(colorSpace); switch (n) { case 1: { v1->Show(); v2->Hide(); v3->Hide(); v4->Hide(); break; } case 3: { v1->Show(); v2->Show(); v3->Show(); v4->Hide(); break; } case 4: { v1->Show(); v2->Show(); v3->Show(); v4->Show(); break; } } deValue orig[4]; deColorSpace oc = image.getColorSpace(); int on = getColorSpaceSize(oc); logInfo("reading values for sampler"); int i; for (i = 0; i < on; i++) { const deValue* values = image.startRead(i); if (values) { orig[i] = values[p]; } image.finishRead(i); } deValue vv1; deValue vv2; deValue vv3; deValue vv4; deValue rr; deValue gg; deValue bb; deConversionProcessor cp; cp.convert(oc, orig[0], orig[1], orig[2], orig[3], deColorSpaceRGB, rr, gg, bb, vv4); cp.convert(oc, orig[0], orig[1], orig[2], orig[3], colorSpace, vv1, vv2, vv3, vv4); colorPanel->setRGB(rr, gg, bb); std::ostringstream oss; oss.setf(std::ios_base::fixed); oss.precision(3); { oss.str(""); oss << getPresentationValue(colorSpace, 0, vv1); v1->SetLabel(wxString::FromAscii(oss.str().c_str())); } { oss.str(""); oss << getPresentationValue(colorSpace, 1, vv2); v2->SetLabel(wxString::FromAscii(oss.str().c_str())); } { oss.str(""); oss << getPresentationValue(colorSpace, 2, vv3); v3->SetLabel(wxString::FromAscii(oss.str().c_str())); } { oss.str(""); oss << getPresentationValue(colorSpace, 3, vv4); v4->SetLabel(wxString::FromAscii(oss.str().c_str())); } } } void deSamplerPanel::choose(wxCommandEvent &event) { int c = colorSpaceChoice->GetSelection(); deColorSpace colorSpace = colorSpaces[c]; sampler.setColorSpace(colorSpace); update(); } delaboratory-0.8/gui_wx/gradient_panel.h0000644000175100001440000000515311764477311017513 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GRADIENT_PANEL_H #define _DE_GRADIENT_PANEL_H #include #include "color_space.h" #include "value.h" class dePalette3; class deColorPanelOld:public wxPanel { private: deValue r; deValue g; deValue b; protected: void click(wxMouseEvent &event); void hover(wxMouseEvent &event); void enter(wxMouseEvent &event); void leave(wxMouseEvent &event); public: deColorPanelOld(wxWindow* parent, wxSize _size, int style); virtual ~deColorPanelOld(); void setRGB(deValue rr, deValue gg, deValue bb); void setColor(deColorSpace colorSpace, int channel, deValue value); }; class deGradientPanel:public wxPanel { protected: wxBitmap* bitmap; deColorSpace colorSpace; public: deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace); virtual ~deGradientPanel(); void paintEvent(wxPaintEvent & evt); }; class deGradientPanel0:public deGradientPanel { private: void generateBitmap(); int channel; int margin; public: deGradientPanel0(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel, int _margin); ~deGradientPanel0(); void changeChannel(int _channel); }; class deGradientPanel1:public deGradientPanel { private: void generateBitmap(); int channel1; int channel2; deValue c1; deValue c2; deValue c3; public: deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3); ~deGradientPanel1(); void changeChannel(int _channel); }; class deGradientPanel2:public deGradientPanel { private: void generateBitmap(); deValue c1; deValue c2; deValue c3; deValue c4; public: deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4); ~deGradientPanel2(); }; #endif delaboratory-0.8/gui_wx/xml.cc0000644000175100001440000000226211764477311015473 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "xml.h" void saveChild(xmlNodePtr node, std::string name, std::string value) { xmlChar* _name = BAD_CAST(name.c_str()); xmlChar* _value = BAD_CAST(value.c_str()); xmlNodePtr child = xmlNewChild(node, NULL, _name, NULL); xmlNodeSetContent(child, _value); } std::string getContent(xmlNodePtr node) { xmlChar* xs = xmlNodeGetContent(node); std::string s = (char*)(xs); xmlFree(xs); return s; } delaboratory-0.8/gui_wx/message_box.cc0000644000175100001440000000163011765506775017175 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include #include "str_wx.h" void showMessageBox(const std::string& s) { wxMessageBox(str2wx(s)); } void sleep(int ms) { wxThread::Sleep(200); } delaboratory-0.8/gui_wx/xml.h0000644000175100001440000000166111764477311015337 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_XML_H #define _DE_XML_H #include #include void saveChild(xmlNodePtr node, std::string name, std::string value); std::string getContent(xmlNodePtr node); #endif delaboratory-0.8/gui_wx/color_space_utils.cc0000644000175100001440000002552611764477311020414 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "color_space_utils.h" #include "channels.h" int getEqualizerChannel(deColorSpace colorSpace) { switch (colorSpace) { case deColorSpaceBW: return 0; case deColorSpaceRGB: return -1; case deColorSpaceProPhoto: return -1; case deColorSpaceHSL: return 0; case deColorSpaceHSV: return 0; case deColorSpaceLAB: return 0; case deColorSpaceLCH: return 2; case deColorSpaceCMY: return -1; case deColorSpaceCMYK: return 3; default: return 0; } } int getColorSpaceSize(const deColorSpace& colorSpace) { switch (colorSpace) { case deColorSpaceBW: return 1; case deColorSpaceRGB: return 3; case deColorSpaceProPhoto: return 3; case deColorSpaceHSL: return 3; case deColorSpaceHSV: return 3; case deColorSpaceLAB: return 3; case deColorSpaceLCH: return 3; case deColorSpaceXYZ: return 3; case deColorSpaceCMY: return 3; case deColorSpaceCMYK: return 4; default: return 0; } } void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max) { min = 0; max = 1; } std::string getColorSpaceName(deColorSpace colorSpace) { switch (colorSpace) { case deColorSpaceInvalid: return "invalid"; case deColorSpaceBW: return "BW"; case deColorSpaceRGB: return "sRGB"; case deColorSpaceProPhoto: return "ProPhoto"; case deColorSpaceHSL: return "HSL"; case deColorSpaceHSV: return "HSV"; case deColorSpaceLAB: return "LAB"; case deColorSpaceLCH: return "LCH"; case deColorSpaceXYZ: return "XYZ"; case deColorSpaceCMY: return "CMY"; case deColorSpaceCMYK: return "CMYK"; default: return "unknown"; } } deColorSpace colorSpaceFromString(const std::string& name) { if (name == "sRGB") { return deColorSpaceRGB; } if (name == "ProPhoto") { return deColorSpaceProPhoto; } if (name == "LAB") { return deColorSpaceLAB; } if (name == "LCH") { return deColorSpaceLCH; } if (name == "CMYK") { return deColorSpaceCMYK; } if (name == "HSL") { return deColorSpaceHSL; } if (name == "HSV") { return deColorSpaceHSV; } if (name == "BW") { return deColorSpaceBW; } if (name == "XYZ") { return deColorSpaceXYZ; } if (name == "CMY") { return deColorSpaceCMY; } return deColorSpaceInvalid; } std::string getChannelName(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceInvalid: return "invalid"; case deColorSpaceBW: return "BW"; case deColorSpaceRGB: case deColorSpaceProPhoto: { switch (channel) { case DE_CHANNEL_RED: return "red"; case DE_CHANNEL_GREEN: return "green"; case DE_CHANNEL_BLUE: return "blue"; } } case deColorSpaceLAB: switch (channel) { case DE_CHANNEL_L: return "L"; case DE_CHANNEL_A: return "A"; case DE_CHANNEL_B: return "B"; } case deColorSpaceLCH: switch (channel) { case DE_CHANNEL_L: return "lightness"; case DE_CHANNEL_C: return "chroma"; case DE_CHANNEL_H: return "hue"; } case deColorSpaceXYZ: switch (channel) { case DE_CHANNEL_X: return "X"; case DE_CHANNEL_Y: return "Y"; case DE_CHANNEL_Z: return "Z"; } case deColorSpaceHSL: switch (channel) { case DE_CHANNEL_HUE: return "hue"; case DE_CHANNEL_SATURATION: return "saturation"; case DE_CHANNEL_LIGHTNESS: return "lightness"; } case deColorSpaceHSV: switch (channel) { case DE_CHANNEL_HUE: return "hue"; case DE_CHANNEL_SATURATION: return "saturation"; case DE_CHANNEL_VALUE: return "value"; } case deColorSpaceCMY: case deColorSpaceCMYK: switch (channel) { case DE_CHANNEL_CYAN: return "cyan"; case DE_CHANNEL_MAGENTA: return "magenta"; case DE_CHANNEL_YELLOW: return "yellow"; case DE_CHANNEL_KEY: return "key"; } default: return "unknown"; } } void getSupportedColorSpaces(std::vector& result) { result.push_back(deColorSpaceRGB); result.push_back(deColorSpaceProPhoto); result.push_back(deColorSpaceBW); result.push_back(deColorSpaceLAB); result.push_back(deColorSpaceLCH); result.push_back(deColorSpaceHSL); result.push_back(deColorSpaceHSV); result.push_back(deColorSpaceCMYK); } deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v) { if (colorSpace == deColorSpaceLAB) { if (channel == DE_CHANNEL_L) { return 100 * v; } else { return 200 * v - 100.0; } } if (colorSpace == deColorSpaceRGB) { return 255 * v; } if (colorSpace == deColorSpaceProPhoto) { return 255 * v; } if ((colorSpace == deColorSpaceCMYK) || (colorSpace == deColorSpaceCMY)) { return 100 * v; } if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) { if (channel == DE_CHANNEL_HUE) { return 360 * v; } else { return 100 * v; } } if (colorSpace == deColorSpaceLCH) { if (channel == DE_CHANNEL_H) { return 360 * v; } else { return 100 * v; } } return v; } bool shouldUseAutoLevels(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceLCH: { if (channel == 2) { return false; } break; } case deColorSpaceHSV: case deColorSpaceHSL: { if (channel == 0) { return false; } break; } case deColorSpaceCMYK: { if (channel == 3) { return false; } break; } default: { break; } } return true; } bool shouldChannelBeSharpened(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceLAB: case deColorSpaceLCH: { if (channel == 0) { return true; } break; } case deColorSpaceHSV: case deColorSpaceHSL: { if (channel == 2) { return true; } break; } case deColorSpaceCMYK: { if (channel == 3) { return true; } break; } default: { return true; break; } } return false; } bool isChannelLuminance(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceLAB: case deColorSpaceLCH: { if (channel == 0) { return true; } break; } case deColorSpaceHSV: case deColorSpaceHSL: { if (channel == 2) { return true; } break; } default: { return true; break; } } return false; } bool isChannelWrapped(deColorSpace colorSpace, int channel) { switch (colorSpace) { case deColorSpaceLCH: { if (channel == 2) { return true; } break; } case deColorSpaceHSV: case deColorSpaceHSL: { if (channel == 0) { return true; } break; } default: break; } return false; } bool isActionSupported(const std::string& action, deColorSpace colorSpace) { if ((action == "equalizer8") || (action == "equalizer16")) { switch (colorSpace) { case deColorSpaceRGB: case deColorSpaceCMY: case deColorSpaceProPhoto: return false; default: return true; } } return true; } std::vector getChannelNames(deColorSpace colorSpace) { std::vector result; int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { std::string s = getChannelName(colorSpace, i); result.push_back(s); } return result; } delaboratory-0.8/gui_wx/tiff.h0000644000175100001440000000206311766762751015473 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LOAD_TIFF_H #define _DE_LOAD_TIFF_H class deStaticImage; #include #include "value.h" #include "size.h" bool loadTIFF(const std::string& fileName, deStaticImage& image); bool saveTIFF(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size); #endif delaboratory-0.8/gui_wx/progress_dialog.cc0000644000175100001440000000226711765506775020073 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "progress_dialog.h" #include deProgressDialog::deProgressDialog() { progressDialog = new wxProgressDialog(_T("generate final image"), _T("generate final image"), 100, NULL, wxPD_AUTO_HIDE | wxPD_ELAPSED_TIME); } deProgressDialog::~deProgressDialog() { delete progressDialog; } void deProgressDialog::update(int progress, const std::string& s) { progressDialog->Update(progress, wxString::FromAscii(s.c_str())); } delaboratory-0.8/gui_wx/main_window.h0000644000175100001440000000342511766762751017061 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MAIN_WINDOW_H #define _DE_MAIN_WINDOW_H class deMainWindowImpl; class deProject; class deLayerProcessor; class deSamplerManager; class deZoomManager; class deOperationProcessor; class deSize; class deChannelManager; class deGUI; #include class deMainWindow { private: deMainWindowImpl* impl; public: deMainWindow(); virtual ~deMainWindow(); void init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui); void show(); void setTopWindow(); void postEvent(int event, int arg); void generateHistogram(); void onKey(int key); void rebuild(); void setImageName(const std::string& _imageName, const deSize& _size); void startRawTimer(); void stopRawTimer(); void updateWarning(); void forceUpdateSize(); }; #endif delaboratory-0.8/gui_wx/progress_dialog.h0000644000175100001440000000206111765506775017725 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROGRESS_DIALOG_H #define _DE_PROGRESS_DIALOG_H class wxProgressDialog; #include class deProgressDialog { private: wxProgressDialog* progressDialog; public: deProgressDialog(); virtual ~deProgressDialog(); void update(int progress, const std::string& s); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame5.h0000644000175100001440000000200511764477311021453 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME5_H #define _DE_HELP_COLOR_SPACES_FRAME5_H #include "help_frame.h" class deHelpColorSpacesFrame5:public deHelpFrame { private: public: deHelpColorSpacesFrame5(wxWindow *parent); virtual ~deHelpColorSpacesFrame5(); }; #endif delaboratory-0.8/gui_wx/frame.cc0000644000175100001440000000633611764477311015773 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "frame.h" #include "window_wx.h" #include "panel_wx.h" #include #include "logger.h" #include "str.h" class deFrameImpl:public wxFrame { private: wxSizer* sizer; std::map sizers; deWindowWX window; deFrame* frame; public: deFrameImpl(deWindow& parent, const std::string& name, deFrame* _frame) :wxFrame((dynamic_cast(parent)).getWindow(), wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT), window(this), frame(_frame) { sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); } virtual ~deFrameImpl() { logInfo(" ~deFrameImpl"); if (frame->clearImpl()) { delete frame; } logInfo(" ~deFrameImpl DONE"); } void addWidget(wxWindow* widget) { sizer->Add(widget); } void addWidget(const std::string& _name, wxWindow* widget) { sizers[_name]->Add(widget); } void addSizer(const std::string& _name) { wxSizer* s = new wxBoxSizer(wxHORIZONTAL); sizer->Add(s); sizers[_name] = s; } deWindow& getWindow() { return window; } void fit() { Fit(); } }; deFrame::deFrame(deWindow& parent, const std::string& name) { impl = new deFrameImpl(parent, name, this); } deFrame::~deFrame() { logInfo(" ~deFrame"); if (impl) { deFrameImpl* i = impl; clearImpl(); delete i; } logInfo(" ~deFrame DONE"); } bool deFrame::clearImpl() { bool result = (impl != NULL); impl = NULL; return result; } void deFrame::show() { if (impl) { impl->Show(); } } void deFrame::addWidget(deWindow& window) { deWindowWX& w = dynamic_cast(window); if (impl) { impl->addWidget(w.getWindow()); } } void deFrame::addWidget(const std::string& _name, deWindow& window) { deWindowWX& w = dynamic_cast(window); if (impl) { impl->addWidget(_name, w.getWindow()); } } void deFrame::addSizer(const std::string& _name) { if (impl) { impl->addSizer(_name); } } deWindow& deFrame::getWindow() { return impl->getWindow(); } void deFrame::fit() { impl->fit(); } delaboratory-0.8/gui_wx/file_dialogs.h0000644000175100001440000000215711777136356017166 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_FILE_DIALOGS_H #define _DE_FILE_DIALOGS_H #include #include std::string getSaveFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir); std::string getOpenFile(wxWindow* parent, const std::string& info, const std::string& t, const std::string& dir); std::string getDir(wxWindow* parent, const std::string& info); #endif delaboratory-0.8/gui_wx/samplers_panel.cc0000644000175100001440000000475211777136356017713 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "samplers_panel.h" #include "sampler_panel.h" #include "project.h" #include "layer_processor.h" deSamplersPanel::deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager) :wxPanel(parent, wxID_ANY, wxDefaultPosition), project(_project), samplerManager(_samplerManager) { unsigned int n = samplerManager.getNumberOfSamplers(); unsigned int i; wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); sizer->Add(sizer2); show = new wxCheckBox(this, wxID_ANY, _T("show samplers")); show->SetValue(0); sizer2->Add(show); clearButton = new wxButton(this, wxID_ANY, _T("clear"), wxDefaultPosition, wxSize(60,25)); sizer2->Add(clearButton); for (i = 0; i < n; i++) { deSampler* sampler = samplerManager.getSampler(i); if (sampler) { deSamplerPanel* panel = new deSamplerPanel(this, *sampler, project); sizer->Add(panel); panels.push_back(panel); } } Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deSamplersPanel::check)); Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deSamplersPanel::click)); } deSamplersPanel::~deSamplersPanel() { } void deSamplersPanel::update() { std::list::iterator i; for (i = panels.begin(); i != panels.end(); i++) { (*i)->update(); } } void deSamplersPanel::check(wxCommandEvent &event) { bool checked = show->IsChecked(); samplerManager.setMoving(checked); project.getLayerProcessor().onGUIUpdate(); } void deSamplersPanel::click(wxCommandEvent &event) { samplerManager.clear(); project.getLayerProcessor().onGUIUpdate(); } delaboratory-0.8/gui_wx/property_mixer_ui.cc0000644000175100001440000001366611764477311020472 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_mixer_ui.h" #include "property_mixer.h" #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" #include "histogram.h" #include #include "canvas_wx.h" #include "gradient_panel.h" #include "color_space_utils.h" #include "slider.h" #include "logger.h" #include "channel_selector.h" #include "base_layer_with_source.h" class deMixerChannelSelector:public deChannelSelector { private: dePropertyMixerUIImpl& ui; public: deMixerChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyMixerUIImpl& _ui) :deChannelSelector(window, colorSpace), ui(_ui) { } virtual ~deMixerChannelSelector() { } virtual void onValueChange(int channel); }; class deMixerSlider:public deSlider { private: dePropertyMixerUIImpl& ui; int index; public: deMixerSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl, dePropertyMixerUIImpl& _ui, int _index) :deSlider(window, _name, _min, _max, _width, widthn, widthl), ui(_ui), index(_index) { logInfo("deMixerSlider constructor"); } virtual ~deMixerSlider() { logInfo("deMixerSlider destructor"); } virtual void onValueChange(deValue value, bool finished); }; class dePropertyMixerUIImpl:public dePanelWX { private: dePropertyMixerUI& parent; dePropertyMixer& property; deMixerChannelSelector *channelSelector; std::vector sliders; int channel; deLayerProcessor& layerProcessor; deGradientPanel0* gradient; int layerIndex; public: dePropertyMixerUIImpl(dePropertyMixerUI& _parent, deWindow& _parentWindow, dePropertyMixer& _property, deBaseLayerWithSource& layer, deLayerProcessor& _layerProcessor, int _layerIndex, int width) :dePanelWX(_parentWindow), parent(_parent), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex) { int margin = 10; wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); deColorSpace colorSpace = layer.getColorSpace(); { channelSelector = new deMixerChannelSelector(getWindow(), colorSpace, *this); deWindowWX& w = dynamic_cast(channelSelector->getWindow()); sizer->Add(w.getWindow()); } channel = 0; int n = getColorSpaceSize(layer.getColorSpace()); deValue min = -3; deValue max = 3; int w = 400; int wn = 80; int wl = 40; int i; for (i = 0; i < n; i++) { std::string c = getChannelName(layer.getColorSpace(), i); deMixerSlider* s = new deMixerSlider(getWindow(), c, min, max, w, wn, wl, *this, i); sliders.push_back(s); deWindowWX& w = dynamic_cast(s->getWindow()); sizer->Add(w.getWindow()); } gradient = new deGradientPanel0(this, wxSize(width, 8), layer.getColorSpace(), channel, margin); sizer->Add(gradient); setFromProperty(); Fit(); } virtual ~dePropertyMixerUIImpl() { delete channelSelector; } void setFromProperty() { deMixer* mixer = property.getMixer(channel); int n = sliders.size(); int i; for (i = 0; i < n; i++) { deValue w = mixer->getWeight(i); deMixerSlider* s = sliders[i]; s->setValue(w); } } void setFromSlider(int index, deValue v) { deMixer* mixer = property.getMixer(channel); mixer->setWeight(index, v); layerProcessor.markUpdateSingleChannel(layerIndex, channel); } void setChannel(int _channel) { channel = _channel; gradient->changeChannel(channel); setFromProperty(); layerProcessor.setHistogramChannel(channel); } }; dePropertyMixerUI::dePropertyMixerUI(deWindow& window, dePropertyMixer& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) :property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) { deWindowWX* w = dynamic_cast(&window); if (w) { impl = new dePropertyMixerUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); } else { impl = NULL; } } dePropertyMixerUI::~dePropertyMixerUI() { if (impl) { delete impl; } } deWindow& dePropertyMixerUI::getWindow() { return impl->getWindow(); } void dePropertyMixerUI::setFromProperty() { if (impl) { impl->setFromProperty(); } } void deMixerSlider::onValueChange(deValue value, bool finished) { ui.setFromSlider(index, value); } void deMixerChannelSelector::onValueChange(int channel) { ui.setChannel(channel); } delaboratory-0.8/gui_wx/warning_panel.h0000644000175100001440000000203411764477311017356 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_WARNING_PANEL_H #define _DE_WARNING_PANEL_H #include class deWarningPanel:public wxPanel { private: wxStaticText* warning; public: deWarningPanel(wxWindow* parent); virtual ~deWarningPanel(); void setWarning(const std::string& w); }; #endif delaboratory-0.8/gui_wx/layer_frame_manager.h0000644000175100001440000000300611764477311020512 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_FRAME_MANAGER_H #define _DE_LAYER_FRAME_MANAGER_H #include #include "value.h" class deLayerFrame; #include class deLayerFrameManager { private: std::map layerFrames; deLayerFrameManager(const deLayerFrameManager& ); deLayerFrameManager& operator =(const deLayerFrameManager& ); public: deLayerFrameManager(); virtual ~deLayerFrameManager(); void onDestroyLayer(int index); bool onImageClick(deValue x, deValue y); void onKey(int key); void destroyAllFrames(); bool addLayerFrame(int index, deLayerFrame* frame); bool removeLayerFrame(int index); bool destroyLayerFrame(int index); bool checkLayerFrame(int index); }; #endif delaboratory-0.8/gui_wx/update_blend.h0000644000175100001440000000157011765506775017174 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_UPDATE_BLEND_H #define _DE_UPDATE_BLEND_H class deLayerWithBlending; void updateBlendOnThread(deLayerWithBlending& layer); #endif delaboratory-0.8/gui_wx/help_frame.cc0000644000175100001440000000177511764477311017005 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_frame.h" deHelpFrame::deHelpFrame(wxWindow *parent, const std::string& name) :wxFrame(parent, wxID_ANY, wxString::FromAscii(name.c_str()), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxFRAME_FLOAT_ON_PARENT) { } deHelpFrame::~deHelpFrame() { } delaboratory-0.8/gui_wx/samplers_panel.h0000644000175100001440000000247411777136356017554 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SAMPLERS_PANEL_H #define _DE_SAMPLERS_PANEL_H #include "wx/wx.h" class deProject; class deSamplerPanel; class deSamplerManager; #include class deSamplersPanel:public wxPanel { private: deProject& project; std::list panels; wxCheckBox* show; wxButton* clearButton; deSamplerManager& samplerManager; void check(wxCommandEvent &event); void click(wxCommandEvent &event); public: deSamplersPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager); virtual ~deSamplersPanel(); void update(); }; #endif delaboratory-0.8/gui_wx/dcraw_support.h0000644000175100001440000000267212004336607017424 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_DCRAW_SUPPORT_H #define _DE_DCRAW_SUPPORT_H #include class deStaticImage; #include "color_space.h" std::string getDcrawVersion(); std::string getRawInfo(const std::string& f); bool isRawValid(const std::string& f); class wxProcess; class wxInputStream; class deRawLoader { private: wxProcess* process; wxInputStream* input; const std::string& filename; deStaticImage& image; deColorSpace colorSpace; bool half; public: deRawLoader(const std::string& f, deStaticImage& image, bool half, bool srgb, bool brighten); virtual ~deRawLoader(); bool load(bool& failure); bool getStatus(); }; #endif delaboratory-0.8/gui_wx/slider.h0000644000175100001440000000237211766762751016030 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SLIDER_H #define _DE_SLIDER_H #include "value.h" #include class dePanel; class deWindow; class deLayerProcessor; class deSliderImpl; class deSlider { private: deSliderImpl* impl; public: deSlider(deWindow& window, const std::string& _name, deValue _min, deValue _max, int _width, int widthn, int widthl); virtual ~deSlider(); void setValue(deValue v); virtual void onValueChange(deValue value, bool finished) = 0; deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/channel_selector.cc0000644000175100001440000000632511764477311020207 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "channel_selector.h" #include #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" #include "logger.h" #include "str.h" #include "color_space_utils.h" class deChannelSelectorImpl:public dePanelWX { private: deChannelSelector& parent; deColorSpace colorSpace; std::vector buttons; public: deChannelSelectorImpl(deChannelSelector& _parent, deWindow& _parentWindow, deColorSpace _colorSpace) :dePanelWX(_parentWindow), parent(_parent), colorSpace(_colorSpace) { wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); SetSizer(sizer); int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { int style = 0; if (i == 0) { style = wxRB_GROUP; } std::string s = getChannelName(colorSpace, i); wxRadioButton* b = new wxRadioButton(this, wxID_ANY, wxString::FromAscii(s.c_str()), wxDefaultPosition, wxDefaultSize, style); sizer->Add(b); buttons.push_back(b); } Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deChannelSelectorImpl::select)); } virtual ~deChannelSelectorImpl() { logInfo("~deChannelSelectorImpl"); } void setValue(int channel) { buttons[channel]->SetValue(1); } void select(wxCommandEvent &event) { int i = event.GetId(); unsigned int j; for (j = 0; j < buttons.size(); j++) { if (buttons[j]->GetId() == i) { parent.onValueChange(j); } } } }; deChannelSelector::deChannelSelector(deWindow& window, deColorSpace colorSpace) { logInfo("deChannelSelector constructor"); deWindowWX* w = dynamic_cast(&window); if (w) { impl = new deChannelSelectorImpl(*this, window, colorSpace); } else { impl = NULL; } } deChannelSelector::~deChannelSelector() { logInfo("deChannelSelector destructor"); if (impl) { delete impl; } } void deChannelSelector::setValue(int channel) { if (impl) { impl->setValue(channel); } } deWindow& deChannelSelector::getWindow() { return impl->getWindow(); } delaboratory-0.8/gui_wx/help_color_spaces_frame6.h0000644000175100001440000000202011764477311021451 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME6_H #define _DE_HELP_COLOR_SPACES_FRAME6_H #include "help_frame.h" class deHelpColorSpacesFrame6:public deHelpFrame { private: public: deHelpColorSpacesFrame6(wxWindow *parent, int scale); virtual ~deHelpColorSpacesFrame6(); }; #endif delaboratory-0.8/gui_wx/mutex.h0000644000175100001440000000206011767175713015677 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MUTEX_H #define _DE_MUTEX_H class deMutexImpl; class deMutex { private: deMutexImpl* impl; deMutex(const deMutex& m); deMutex& operator = (const deMutex& m); public: deMutex(bool recursive = true); ~deMutex(); void lock(); void unlock(); }; #endif delaboratory-0.8/gui_wx/image_io.cc0000644000175100001440000001263312004336607016435 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "image_io.h" #include #include #include "logger.h" #include "static_image.h" #include "str.h" #include "dcraw_support.h" #include "channel_manager.h" #include "image.h" #include "conversion_processor.h" #include "tiff.h" void saveJPEG(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size) { wxImage* image; int w = size.getW(); int h = size.getH(); image = new wxImage(w, h); image->SetOption(wxIMAGE_OPTION_QUALITY,98); int pos = 0; int y; for (y = 0; y < h; y++) { int x; for (x = 0; x < w; x++) { deValue r = 255 * channelR[pos]; deValue g = 255 * channelG[pos]; deValue b = 255 * channelB[pos]; image->SetRGB(x, y, r, g, b); pos++; } } const char* c = fileName.c_str(); wxString s(c, wxConvUTF8); image->SaveFile(s); delete image; } bool loadJPEG(const std::string& fileName, deStaticImage& image) { logInfo("loadJPEG " + fileName); const char* c = fileName.c_str(); wxString s(c, wxConvUTF8); wxImage fileImage; bool result = fileImage.LoadFile(s, wxBITMAP_TYPE_JPEG); if (!result) { return false; } int w = fileImage.GetWidth(); int h = fileImage.GetHeight(); image.lock(); deSize size(w, h); image.setSize(size); image.setColorSpace(deColorSpaceRGB); deValue* pixels0 = image.startWriteStatic(0); deValue* pixels1 = image.startWriteStatic(1); deValue* pixels2 = image.startWriteStatic(2); int pos = 0; unsigned char* data = fileImage.GetData(); int p = 0; int y; for (y =0; y < h; y++) { int x; for (x = 0; x < w; x++) { deValue r = data[p] / 255.0; p++; deValue g = data[p] / 255.0; p++; deValue b = data[p] / 255.0; p++; pixels0[pos] = r; pixels1[pos] = g; pixels2[pos] = b; pos++; } } logInfo("loadJPEG " + fileName + " done"); image.finishWriteStatic(0); image.finishWriteStatic(1); image.finishWriteStatic(2); image.unlock(); return true; } bool saveImage(const std::string& fileName, const deImage& image, const std::string& type, deChannelManager& previewChannelManager) { bool result = false; if (image.getColorSpace() == deColorSpaceRGB) { if (type == "tiff") { const deValue* vr = image.startRead(0); const deValue* vg = image.startRead(1); const deValue* vb = image.startRead(2); result = saveTIFF(fileName, vr, vg, vb, image.getChannelSize()); image.finishRead(0); image.finishRead(1); image.finishRead(2); } if (type == "jpg") { const deValue* vr = image.startRead(0); const deValue* vg = image.startRead(1); const deValue* vb = image.startRead(2); saveJPEG(fileName, vr, vg, vb, image.getChannelSize()); image.finishRead(0); image.finishRead(1); image.finishRead(2); result = true; } } else { logInfo("image is not in sRGB, conversion is needed before save..."); deImage finalImage(deColorSpaceRGB, previewChannelManager); finalImage.allocateChannels(); deConversionProcessor p; deConversionCPU cpu(4); p.convertImage(image, finalImage, cpu); if (type == "tiff") { const deValue* vr = finalImage.startRead(0); const deValue* vg = finalImage.startRead(1); const deValue* vb = finalImage.startRead(2); result = saveTIFF(fileName, vr, vg, vb, image.getChannelSize()); finalImage.finishRead(0); finalImage.finishRead(1); finalImage.finishRead(2); } if (type == "jpg") { const deValue* vr = finalImage.startRead(0); const deValue* vg = finalImage.startRead(1); const deValue* vb = finalImage.startRead(2); saveJPEG(fileName, vr, vg, vb, image.getChannelSize()); finalImage.finishRead(0); finalImage.finishRead(1); finalImage.finishRead(2); result = true; } } return result; } bool loadImage(const std::string& fileName, deStaticImage& image) { wxLogNull noerrormessages; if (loadTIFF(fileName, image)) { return true; } if (loadJPEG(fileName, image)) { return true; } return false; } delaboratory-0.8/gui_wx/external_editor.h0000644000175100001440000000162011764477311017722 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_EXTERNAL_EDITOR_H #define _DE_EXTERNAL_EDITOR_H #include void executeExternalEditor(const std::string& fileName, const std::string& app); #endif delaboratory-0.8/gui_wx/panel_wx.cc0000644000175100001440000000230211764477311016503 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "panel_wx.h" #include "window_wx.h" dePanelWX::dePanelWX() :wxPanel(), window(this) { } dePanelWX::dePanelWX(deWindow& _parent) :wxPanel(dynamic_cast(_parent).getWindow()), window(this) { } dePanelWX::dePanelWX(deWindow& _parent, int w, int h) :wxPanel(dynamic_cast(_parent).getWindow(), wxID_ANY, wxDefaultPosition, wxSize(w, h)), window(this) { } dePanelWX::~dePanelWX() { } deWindow& dePanelWX::getWindow() { return window; } delaboratory-0.8/gui_wx/zoom_panel.h0000644000175100001440000000243311764477311016700 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_ZOOM_PANEL_H #define _DE_ZOOM_PANEL_H #include class deZoomManager; class deImageAreaPanel; class deZoomPanel:public wxPanel { private: deZoomManager& zoomManager; deImageAreaPanel* imageAreaPanel; wxButton* zoomIn; wxButton* zoomOut; void click(wxCommandEvent &event); public: deZoomPanel(wxWindow* parent, deZoomManager& _zoomManager); virtual ~deZoomPanel(); void updateButtons(); void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); }; #endif delaboratory-0.8/gui_wx/threads_panel.cc0000644000175100001440000000620611764477311017506 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "threads_panel.h" #include "layer_processor.h" deThreadsPanel::deThreadsPanel(wxWindow* parent) :wxPanel(parent) { //wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("thread activity")); wxSizer* sizerP = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("threads")); SetSizer(sizerP); //processingInfo = new wxStaticText(this, wxID_ANY, _T("[processing]"), wxDefaultPosition); processingInfo = new wxStaticText(this, wxID_ANY, _T("[p]"), wxDefaultPosition); sizerP->Add(processingInfo, 0, wxEXPAND); //renderingInfo = new wxStaticText(this, wxID_ANY, _T("[rendering]"), wxDefaultPosition); renderingInfo = new wxStaticText(this, wxID_ANY, _T("[r]"), wxDefaultPosition); sizerP->Add(renderingInfo, 0, wxEXPAND); //histogramInfo = new wxStaticText(this, wxID_ANY, _T("[histogram]"), wxDefaultPosition); histogramInfo = new wxStaticText(this, wxID_ANY, _T("[h]"), wxDefaultPosition); sizerP->Add(histogramInfo, 0, wxEXPAND); //dcrawInfo = new wxStaticText(this, wxID_ANY, _T("[dcraw]"), wxDefaultPosition); dcrawInfo = new wxStaticText(this, wxID_ANY, _T("[d]"), wxDefaultPosition); sizerP->Add(dcrawInfo, 0, wxEXPAND); } deThreadsPanel::~deThreadsPanel() { } void deThreadsPanel::setInfoColor(int i) { int e = 100; int e2 = 50; int d = 150; switch (i) { case DE_PROCESSING_START: { processingInfo->SetForegroundColour(wxColour(e, e, e)); break; } case DE_PROCESSING_END: { processingInfo->SetForegroundColour(wxColour(d, d, d)); break; } case DE_RENDERING_START: { renderingInfo->SetForegroundColour(wxColour(e, e, e)); break; } case DE_RENDERING_END: { renderingInfo->SetForegroundColour(wxColour(d, d, d)); break; } case DE_HISTOGRAM_START: { histogramInfo->SetForegroundColour(wxColour(e, e, e)); break; } case DE_HISTOGRAM_END: { histogramInfo->SetForegroundColour(wxColour(d, d, d)); break; } case DE_DCRAW_START: { dcrawInfo->SetForegroundColour(wxColour(e2, e2, e2)); break; } case DE_DCRAW_END: { dcrawInfo->SetForegroundColour(wxColour(d, d, d)); break; } } } delaboratory-0.8/gui_wx/help_color_spaces_frame5.cc0000644000175100001440000000553211764477311021621 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame5.h" #include "color_space.h" #include "gradient_panel.h" #include #include "conversion_processor.h" #include #include #include "skin_color_chart.h" void generateFelixVonLuschan(wxWindow* window, wxSizer* sizer) { int w = 240; int h = 30; std::vector skins; getFelixVonLuschan(skins); std::vector ranges; getSkinRanges(ranges); std::vector::iterator r; for (r = ranges.begin(); r != ranges.end(); r++) { deSkinRange range = *r; std::ostringstream oss; oss << range.description; wxSizer* sizer_B = new wxStaticBoxSizer(wxVERTICAL, window, wxString::FromAscii(oss.str().c_str())); sizer->Add(sizer_B); int i; deConversionProcessor cp; for (i = range.first - 1; i <= range.last - 1; i++) { deSkinRGB& skin = skins[i]; deValue cc; deValue mm; deValue yy; deValue kk; // rgb2cmyk(skin.r / 255.0, skin.g / 255.0, skin.b / 255.0, cc, mm, yy, kk); cp.convert(deColorSpaceRGB, skin.r / 255.0, skin.g / 255.0, skin.b / 255.0, 0, deColorSpaceCMYK, cc, mm, yy, kk); int c = 100 * cc; int m = 100 * mm; int y = 100 * yy; int k = 100 * kk; std::ostringstream oss; oss << "C: " << c << " M: " << m << " Y: " << y << " K: " << k; wxSizer* sizer_S = new wxStaticBoxSizer(wxHORIZONTAL, window, wxString::FromAscii(oss.str().c_str())); sizer_B->Add(sizer_S); deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceCMYK, cc, mm, yy, kk); sizer_S->Add(gradient, 0, wxCENTER); } } } deHelpColorSpacesFrame5::deHelpColorSpacesFrame5(wxWindow *parent) :deHelpFrame(parent, "skin colors in CMYK (based on Felix Von Lunshan scale)") { wxSizer* sizer = new wxFlexGridSizer(3); SetSizer(sizer); generateFelixVonLuschan(this, sizer); Fit(); } deHelpColorSpacesFrame5::~deHelpColorSpacesFrame5() { } delaboratory-0.8/gui_wx/channel_selector.h0000644000175100001440000000240511764477311020044 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CHANNEL_SELECTOR_H #define _DE_CHANNEL_SELECTOR_H #include #include "value.h" #include "color_space.h" class dePanel; class deWindow; class deLayerProcessor; class deChannelSelectorImpl; class deChannelSelector { private: deChannelSelectorImpl* impl; public: deChannelSelector(deWindow& window, deColorSpace colorSpace); virtual ~deChannelSelector(); void setValue(int channel); virtual void onValueChange(int channel) = 0; deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/logger.cc0000644000175100001440000000605311772646457016164 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "logger.h" #include "str.h" #include #include #define LOCK_THRESHOLD 100 #define LOGGING 1 static bool loggerActive = false; class deLoggerHelp { private: public: wxThreadIdType main_id; wxStopWatch sw; deLoggerHelp() { } virtual ~deLoggerHelp() { } }; deLogger& deLogger::getLogger() { static deLogger logger; return logger; } deLogger::deLogger() { help = new deLoggerHelp(); f = NULL; started = false; loggerActive = true; } deLogger::~deLogger() { logInfo("closing logger..."); loggerActive = false; mutex.lock(); if (f) { f->close(); delete f; } delete help; mutex.unlock(); } void deLogger::setFile(const std::string& fileName) { #ifdef LOGGING mutex.lock(); if (f) { f->close(); delete f; } f = new std::ofstream(fileName.c_str()); if (!f) { logError("can't create logfile: " + fileName); } mutex.unlock(); #endif } std::string deLogger::getThreadName() { if (!started) { help->main_id = wxThread::GetCurrentId(); started = true; } wxThreadIdType c_id = wxThread::GetCurrentId(); std::string thr = "main"; if (help->main_id != c_id) { std::ostringstream oss; oss.str(""); oss << c_id; thr = oss.str(); } return thr; } void deLogger::log(const std::string& message) { mutex.lock(); if (f) { int t = help->sw.Time(); (*f) << t << ": [" << getThreadName() << "] " << message << std::endl; } mutex.unlock(); } void deLogger::logInfo(const std::string& message) { log("INFO " + message); } int deLogger::getTime() const { int t = help->sw.Time(); return t; } void logInfo(const std::string& message) { #ifdef LOGGING if (loggerActive) { deLogger::getLogger().logInfo(message); } #endif } static deMutex logErrorMutex; void logError(const std::string& message) { const std::string m = "ERROR " + message; logErrorMutex.lock(); std::cout << m << std::endl; logErrorMutex.unlock(); #ifdef LOGGING if (loggerActive) { deLogger::getLogger().log(m); } #endif } delaboratory-0.8/gui_wx/threads_panel.h0000644000175100001440000000224411764477311017346 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_THREADS_PANEL_H #define _DE_THREADS_PANEL_H #include class deThreadsPanel:public wxPanel { private: wxStaticText* processingInfo; wxStaticText* renderingInfo; wxStaticText* histogramInfo; //wxStaticText* debugInfo; wxStaticText* dcrawInfo; public: deThreadsPanel(wxWindow* parent); virtual ~deThreadsPanel(); void setInfoColor(int i); }; #endif delaboratory-0.8/gui_wx/rendered_image.cc0000644000175100001440000000574512004112446017615 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "rendered_image.h" #include "logger.h" #include "str.h" #include #include #include "bitmap_wx.h" #include "canvas_wx.h" void deRenderedImage::setSize(const deSize& _size) { requestedSize = _size; } unsigned char* deRenderedImage::getCurrentImageData() { if (requestedSize != size) { if (internalData) { delete [] internalData; } size = requestedSize; int w = size.getW(); int h = size.getH(); internalData = new unsigned char [ 3 * w * h ]; } return internalData; } deRenderedImage::deRenderedImage() :size(0,0), requestedSize(0,0), bitmapSize(0,0) { renderedBitmap = new deBitmapWX(); internalData = NULL; error = false; } deRenderedImage::~deRenderedImage() { if (renderedBitmap) { delete renderedBitmap; } if (internalData) { delete [] internalData; } } bool deRenderedImage::render(deCanvas& canvas) { if (error) { logError("can't render"); return false; } if (!internalData) { logInfo("can't render - no internal data"); return false; } int w = size.getW(); int h = size.getH(); if (bitmapSize != size) { renderedBitmap->resize(w, h); bitmapSize = size; } deBitmapWX* bitmapWX = dynamic_cast(renderedBitmap); wxNativePixelData bitmapData(*(bitmapWX->getBitmap())); if (!bitmapData) { logError("can't render - wxNativePixelData doesn't work"); return false; } wxNativePixelData::Iterator p(bitmapData); p.Offset(bitmapData, 0, 0); int x; int y; int pos = 0; for (y = 0; y < h; y++) { wxNativePixelData::Iterator rowStart = p; for (x = 0; x < w; x++) { unsigned char r = internalData[pos]; p.Red() = r; pos++; unsigned char g = internalData[pos]; p.Green() = g; pos++; unsigned char b = internalData[pos]; p.Blue() = b; pos++; p++; } p = rowStart; p.OffsetY(bitmapData, 1); } canvas.drawBitmap(*renderedBitmap); return true; } delaboratory-0.8/gui_wx/property_numeric_ui.cc0000644000175100001440000000315211764477311020775 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_numeric_ui.h" #include "property_numeric.h" #include "layer_processor.h" dePropertyNumericUI::dePropertyNumericUI(deWindow& window, dePropertyNumeric& _property, deLayerProcessor& _layerProcessor, int _layerIndex, int _width, int widthn, int widthl) :deSlider(window, _property.getName(), _property.getMin(), _property.getMax(), _width, widthn, widthl), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex) { setFromProperty(); } dePropertyNumericUI::~dePropertyNumericUI() { } void dePropertyNumericUI::onValueChange(deValue value, bool finished) { property.set(value); if (property.updateBlendOnly()) { layerProcessor.markUpdateBlendAllChannels(layerIndex); } else { layerProcessor.markUpdateAllChannels(layerIndex); } } void dePropertyNumericUI::setFromProperty() { setValue(property.get()); } delaboratory-0.8/gui_wx/histogram_mode_panel.cc0000644000175100001440000000557111766762751021070 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "histogram_mode_panel.h" #include #include "color_space.h" #include "project.h" #include #include "histogram_panel.h" #include "layer_processor.h" #include "color_space_utils.h" #include "gui.h" void deHistogramModePanel::select(wxCommandEvent &event) { int i = event.GetId(); int j; for (j = 0; j < MAX_COLOR_SPACE_SIZE; j++) { if (buttons[j]->GetId() == i) { histogramPanel->setChannel(j); project.getLayerProcessor().generateHistogram(); } } } deHistogramModePanel::deHistogramModePanel(wxWindow* parent, deProject& _project, deHistogramPanel* _histogramPanel, deGUI& gui) :wxPanel(parent), project(_project), histogramPanel(_histogramPanel) { gui.setHistogramModePanel(this); wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); SetSizer(sizer); int i; for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) { int style = 0; if (i == 0) { style = wxRB_GROUP; } wxRadioButton* b = new wxRadioButton(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, style); sizer->Add(b); buttons.push_back(b); } updateNames(); updateMode(0); Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(deHistogramModePanel::select)); } deHistogramModePanel::~deHistogramModePanel() { } void deHistogramModePanel::updateNames() { deViewManager& viewManager = project.getViewManager(); deColorSpace colorSpace = viewManager.getColorSpace(); int i; int n = getColorSpaceSize(colorSpace); for (i = 0; i < MAX_COLOR_SPACE_SIZE; i++) { wxRadioButton* b = buttons[i]; if (i < n) { std::string name = getChannelName(colorSpace, i); b->SetLabel(wxString::FromAscii(name.c_str())); b->Show(); } else { b->Hide(); } } Layout(); Fit(); SetFocus(); } void deHistogramModePanel::updateMode(int c) { if ((c < 0) || (c >= MAX_COLOR_SPACE_SIZE)) { return; } histogramPanel->setChannel(c); buttons[c]->SetValue(1); } delaboratory-0.8/gui_wx/help_frame.h0000644000175100001440000000172611764477311016643 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_FRAME_H #define _DE_HELP_FRAME_H #include class deHelpFrame:public wxFrame { private: public: deHelpFrame(wxWindow *parent, const std::string& _name); virtual ~deHelpFrame(); }; #endif delaboratory-0.8/gui_wx/layer_processor_threads.cc0000644000175100001440000001401512002551204021573 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "layer_processor_threads.h" #include "layer_processor.h" #include "main_window.h" #include "main_frame.h" #include "layer_frame_manager.h" #include "layer_stack.h" #include "view_manager.h" #include #include "base_layer.h" #include "channel_manager.h" #include "str.h" #include #include #include "logger.h" #include "renderer.h" #include "image_io.h" class deLayerProcessorWorkerThread:public wxThread { private: void performTasks() { while (true) { if (processor.isClosing()) { return; } #ifdef DEBUG_LOG logInfo("worker thread wait..."); #endif semaphore.wait(); Sleep(10); if (TestDestroy()) { return; } processor.tickWork(); if (TestDestroy()) { return; } } } virtual void *Entry() { performTasks(); logInfo("worker thread finished"); return NULL; } deLayerProcessor& processor; deSemaphore& semaphore; public: deLayerProcessorWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) :processor(_processor), semaphore(_semaphore) { logInfo("worker thread created"); } virtual ~deLayerProcessorWorkerThread() { } }; class deRenderWorkerThread:public wxThread { private: void performTasks() { while (true) { if (processor.isClosing()) { return; } #ifdef DEBUG_LOG logInfo("render thread wait..."); #endif semaphore.wait(); Sleep(10); if (TestDestroy()) { return; } if (processor.prepareImage()) { processor.sendRepaintEvent(); } if (TestDestroy()) { return; } } } virtual void *Entry() { performTasks(); logInfo("render thread finished"); return NULL; } deLayerProcessor& processor; deSemaphore& semaphore; public: deRenderWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) :processor(_processor), semaphore(_semaphore) { logInfo("render thread created"); } virtual ~deRenderWorkerThread() { } }; class deHistogramWorkerThread:public wxThread { private: void performTasks() { while (true) { if (processor.isClosing()) { return; } #ifdef DEBUG_LOG logInfo("histogram thread wait..."); #endif semaphore.wait(); Sleep(10); if (TestDestroy()) { return; } processor.onGenerateHistogram(); processor.sendHistogramEvent(); if (TestDestroy()) { return; } } } virtual void *Entry() { performTasks(); logInfo("histogram thread finished"); return NULL; } deLayerProcessor& processor; deSemaphore& semaphore; public: deHistogramWorkerThread(deLayerProcessor& _processor, deSemaphore& _semaphore) :processor(_processor), semaphore(_semaphore) { logInfo("histogram thread created"); } virtual ~deHistogramWorkerThread() { } }; void deLayerProcessorThreads::stopWorkerThread() { logInfo("stop worker, render and histogram threads"); workerSemaphore.post(); workerThread->Delete(); renderWorkerSemaphore.post(); renderWorkerThread->Delete(); histogramWorkerSemaphore.post(); histogramWorkerThread->Delete(); wxThread::Sleep(200); logInfo("stopped worker, render and histogram threads"); } void deLayerProcessorThreads::startWorkerThread() { logInfo("start worker, render and histogram threads"); workerThread = new deLayerProcessorWorkerThread(layerProcessor, workerSemaphore); if ( workerThread->Create() != wxTHREAD_NO_ERROR ) { } if ( workerThread->Run() != wxTHREAD_NO_ERROR ) { } renderWorkerThread = new deRenderWorkerThread(layerProcessor, renderWorkerSemaphore); if ( renderWorkerThread->Create() != wxTHREAD_NO_ERROR ) { } if ( renderWorkerThread->Run() != wxTHREAD_NO_ERROR ) { } histogramWorkerThread = new deHistogramWorkerThread(layerProcessor, histogramWorkerSemaphore); if ( histogramWorkerThread->Create() != wxTHREAD_NO_ERROR ) { } if ( histogramWorkerThread->Run() != wxTHREAD_NO_ERROR ) { } logInfo("started worker, render and histogram threads"); } delaboratory-0.8/gui_wx/property_levels_ui.cc0000644000175100001440000002556412005233755020627 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_levels_ui.h" #include "property_levels.h" #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" #include "histogram.h" #include #include "canvas_wx.h" #include "gradient_panel.h" #include "channel_selector.h" #include "base_layer_with_source.h" class deLevelsChannelSelector:public deChannelSelector { private: dePropertyLevelsUIImpl& ui; public: deLevelsChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyLevelsUIImpl& _ui) :deChannelSelector(window, colorSpace), ui(_ui) { } virtual ~deLevelsChannelSelector() { } virtual void onValueChange(int channel); }; class deLevelsControl:public dePanelWX { private: wxBitmap bitmap; dePropertyLevels& property; int width; int height; int margin; deLayerProcessor& layerProcessor; int layerIndex; int channel; enum { deModeNothing, deModeMin, deModeMiddle, deModeMax } mode; void click(wxMouseEvent &event) { deValue v = getValue(event.GetX()); const deLevels& levels = property.getLevels(channel); deValue min = levels.getMin(); deValue middle = levels.getMiddle(); deValue max = levels.getMax(); deValue dmin = fabs(v - min); deValue dmiddle = fabs(v - middle); deValue dmax = fabs(v - max); deValue d = 0.01; if (dmin < d) { mode = deModeMin; } else if (dmax < d) { mode = deModeMax; } else if (dmiddle < d) { mode = deModeMiddle; } } void release(wxMouseEvent &event) { mode = deModeNothing; } void move(wxMouseEvent &event) { deValue v = getValue(event.GetX()); if ((v < 0) || (v > 1.0)) { return; } deLevels& levels = property.getLevels(channel); switch (mode) { case deModeMin: { levels.setMin(v); break; } case deModeMiddle: { levels.setMiddle(v); break; } case deModeMax: { levels.setMax(v); break; } default: { return; break; } } paint(); layerProcessor.markUpdateSingleChannel(layerIndex, channel); } void drawArrow(deCanvas& canvas, deValue v) { int p = margin + v * (width - 2 * margin); int m = 3; int p1 = p - m; if (p1 < 0) { p1 = 0; } int p2 = p + m; if (p2 >= width) { p2 = width - 1; } int g = 50; canvas.setBrush(g, g, g); canvas.drawTriangle(p, 0, p1, height, p2, height); } deValue getValue(int p) { deValue a = p - margin; deValue b = width - 2 * margin; return a / b; } public: deLevelsControl(deWindow& _parentWindow, dePropertyLevels& _property, int _width, int _height, int _margin, deLayerProcessor& _layerProcessor, int _layerIndex) :dePanelWX(_parentWindow, _width, _height), property(_property), width(_width), height(_height), margin(_margin), layerProcessor(_layerProcessor), layerIndex(_layerIndex) { SetMinSize(wxSize(width, height)); channel = -1; mode = deModeNothing; bitmap.Create(_width, _height); Connect(wxEVT_PAINT, wxPaintEventHandler(deLevelsControl::paintEvent)); Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deLevelsControl::click)); Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deLevelsControl::release)); Connect(wxEVT_MOTION, wxMouseEventHandler(deLevelsControl::move)); } ~deLevelsControl() { } void setChannel(int _channel) { channel = _channel; paint(); } void paint() { wxClientDC dc(this); render(dc); } void paintEvent(wxPaintEvent & evt) { wxPaintDC dc(this); render(dc); } void render(wxDC& dc_orig) { wxBufferedDC dc(&dc_orig, bitmap, wxBUFFER_CLIENT_AREA); deCanvasWX canvas(dc); int h = height / 5; canvas.clear(); canvas.drawLine(0, h, width, h); const deLevels& levels = property.getLevels(channel); deValue min = levels.getMin(); deValue middle = levels.getMiddle(); deValue max = levels.getMax(); unsigned char g = 50; canvas.setPen(g, g, g); drawArrow(canvas, min); drawArrow(canvas, middle); drawArrow(canvas, max); } }; class deChannelHistogramPanel:public dePanelWX { private: wxBitmap* backgroundBitmap; int width; int height; int margin; public: deChannelHistogramPanel(deWindow& _parentWindow, const deValue* c, int n, int _width, int _height, int _margin) :dePanelWX(_parentWindow, _width, _height), width(_width), height(_height), margin(_margin) { backgroundBitmap = NULL; generate(c, n); Connect(wxEVT_PAINT, wxPaintEventHandler(deChannelHistogramPanel::paintEvent)); } virtual ~deChannelHistogramPanel() { } void paintEvent(wxPaintEvent & evt) { wxPaintDC dc(this); dc.DrawBitmap(*backgroundBitmap, 0, 0, false); } void paint() { wxClientDC dc(this); dc.DrawBitmap(*backgroundBitmap, 0, 0, false); } void generate(const deValue* c, int n) { if (backgroundBitmap) { delete backgroundBitmap; backgroundBitmap = NULL; } deHistogram histogram(width - 2 * margin); histogram.clear(); histogram.calc(c, n); wxImage* image = new wxImage(width, height); unsigned char* data = image->GetData(); unsigned char g1 = 255; unsigned char g2 = 200; histogram.render(data, width, height, g1, g2, margin); backgroundBitmap = new wxBitmap(*image); delete image; paint(); } }; class dePropertyLevelsUIImpl:public dePanelWX { private: deBaseLayerWithSource& layer; dePropertyLevelsUI& parent; dePropertyLevels& property; deLevelsChannelSelector *channelSelector; deChannelHistogramPanel* histogramPanel; deLevelsControl* levelsControl; deGradientPanel0* gradient; int channel; public: dePropertyLevelsUIImpl(dePropertyLevelsUI& _parent, deWindow& _parentWindow, dePropertyLevels& _property, deBaseLayerWithSource& _layer, deLayerProcessor& layerProcessor, int layerIndex, int width) :dePanelWX(_parentWindow), layer(_layer), parent(_parent), property(_property) { int margin = 10; wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); channel = -1; deColorSpace colorSpace = layer.getColorSpace(); { channelSelector = new deLevelsChannelSelector(getWindow(), colorSpace, *this); deWindowWX& w = dynamic_cast(channelSelector->getWindow()); sizer->Add(w.getWindow()); } int h = 80; histogramPanel = new deChannelHistogramPanel(getWindow(), NULL, 0, width, h, margin); sizer->Add(histogramPanel); gradient = new deGradientPanel0(this, wxSize(width, 8), layer.getColorSpace(), 0, margin); sizer->Add(gradient); levelsControl = new deLevelsControl(getWindow(), property, width, 10, margin, layerProcessor, layerIndex); sizer->Add(levelsControl); setChannel(0); Fit(); } virtual ~dePropertyLevelsUIImpl() { } void generate() { const deImage& sourceImage = layer.getSourceImage(); const deValue* c = sourceImage.startRead(channel); int n = sourceImage.getChannelSize().getN(); histogramPanel->generate(c, n); sourceImage.finishRead(channel); } void setFromProperty() { levelsControl->paint(); } void setChannel(int _channel) { channel = _channel; levelsControl->setChannel(channel); gradient->changeChannel(channel); generate(); } }; dePropertyLevelsUI::dePropertyLevelsUI(deWindow& window, dePropertyLevels& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) :property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) { deWindowWX* w = dynamic_cast(&window); if (w) { impl = new dePropertyLevelsUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); } else { impl = NULL; } } dePropertyLevelsUI::~dePropertyLevelsUI() { if (impl) { delete impl; } } deWindow& dePropertyLevelsUI::getWindow() { return impl->getWindow(); } void dePropertyLevelsUI::setFromProperty() { if (impl) { impl->setFromProperty(); } } void deLevelsChannelSelector::onValueChange(int channel) { ui.setChannel(channel); } delaboratory-0.8/gui_wx/main_frame.cc0000644000175100001440000004150012005134175016752 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "main_frame.h" #include "layer_grid_panel.h" #include "control_panel.h" #include "image_area_panel.h" #include "histogram_panel.h" #include "view_mode_panel.h" #include "histogram_mode_panel.h" #include "help_color_spaces_frame.h" #include "help_color_spaces_frame2.h" #include "help_color_spaces_frame3.h" #include "help_color_spaces_frame4.h" #include "help_color_spaces_frame5.h" #include "help_color_spaces_frame6.h" #include "color_matrix_frame.h" #include "project.h" #include "str.h" #include "str_wx.h" #include "file_dialogs.h" #include "delaboratory.h" #include "samplers_panel.h" #include "layer_processor.h" #include "zoom_panel.h" #include "threads_panel.h" #include "warning_panel.h" #include "layer_stack.h" #include "image_panel.h" #include "wx/thread.h" #include "wx/notebook.h" #include "progress_dialog.h" BEGIN_EVENT_TABLE(deMainFrame, wxFrame) #ifdef __WXOSX_MAC__ EVT_MENU(wxID_EXIT, deMainFrame::onQuit) #else EVT_MENU(ID_Quit, deMainFrame::onQuit) #endif EVT_MENU(ID_NewProject, deMainFrame::onNewProject) EVT_MENU(ID_TestImageSmall, deMainFrame::onTestImageSmall) EVT_MENU(ID_TestImageBig, deMainFrame::onTestImageBig) EVT_MENU(ID_OpenImage, deMainFrame::onOpenImage) EVT_MENU(ID_OpenRawImageProPhoto, deMainFrame::onOpenRawImageProPhoto) EVT_MENU(ID_OpenRawImageRGB, deMainFrame::onOpenRawImageRGB) EVT_MENU(ID_OpenRawImageProPhotoAB, deMainFrame::onOpenRawImageProPhotoAB) EVT_MENU(ID_OpenRawImageRGBAB, deMainFrame::onOpenRawImageRGBAB) EVT_MENU(ID_HelpColorSpaces, deMainFrame::onHelpColorSpaces) EVT_MENU(ID_HelpColorSpaces2, deMainFrame::onHelpColorSpaces2) EVT_MENU(ID_HelpColorSpaces3, deMainFrame::onHelpColorSpaces3) EVT_MENU(ID_HelpColorSpaces4, deMainFrame::onHelpColorSpaces4) EVT_MENU(ID_HelpColorSpaces5, deMainFrame::onHelpColorSpaces5) EVT_MENU(ID_LABColors1, deMainFrame::onLABColors1) EVT_MENU(ID_LABColors2, deMainFrame::onLABColors2) EVT_MENU(ID_LABColors5, deMainFrame::onLABColors5) EVT_MENU(ID_ColorMatrix1, deMainFrame::onColorMatrix1) EVT_MENU(ID_ColorMatrix2, deMainFrame::onColorMatrix2) EVT_MENU(ID_ColorMatrix3, deMainFrame::onColorMatrix3) EVT_MENU(ID_ColorMatrix4, deMainFrame::onColorMatrix4) EVT_MENU(ID_ColorMatrix5, deMainFrame::onColorMatrix5) EVT_MENU(DE_REPAINT_EVENT, deMainFrame::onRepaintEvent) EVT_MENU(DE_IMAGE_LOAD_EVENT, deMainFrame::onImageLoadEvent) EVT_MENU(DE_HISTOGRAM_EVENT, deMainFrame::onHistogramEvent) EVT_MENU(DE_INFO_EVENT, deMainFrame::onInfoEvent) EVT_MENU(DE_WARNING_EVENT, deMainFrame::onWarningEvent) EVT_MENU(ID_ExportGIMP, deMainFrame::onExportGIMP) EVT_MENU(ID_ExportTIFF, deMainFrame::onExportTIFF) EVT_MENU(ID_ExportJPG, deMainFrame::onExportJPG) EVT_MENU(ID_ExportAll, deMainFrame::onExportAll) END_EVENT_TABLE() deMainFrame::deMainFrame(const wxSize& size, deProject& _project, deLayerProcessor& _layerProcessor, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, const std::string& dcraw_version, deOperationProcessor& _operationProcessor, deChannelManager& channelManager, deGUI& _gui) : wxFrame() , project(_project), layerProcessor(_layerProcessor), imageSize(0,0), gui(_gui) { logInfo("main frame constructor"); imageName = ""; #ifdef __WXOSX_MAC__ Create((wxFrame *)NULL, wxID_ANY, _T("main frame")); #else Create((wxFrame *)NULL, wxID_ANY, _T("main frame"), wxDefaultPosition, size, wxDEFAULT_FRAME_STYLE | wxMAXIMIZE); #endif #ifdef _WIN32 SetIcon(wxICON(id)); #endif updateTitle(); mainSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* leftSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add(leftSizer, 1, wxEXPAND); topPanel = new wxPanel(this); leftSizer->Add(topPanel, 0, wxEXPAND); wxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL); topPanel->SetSizer(topSizer); wxPanel* viewModePanel = new deViewModePanel(topPanel, project, gui); topSizer->Add(viewModePanel); threadsPanel = new deThreadsPanel(topPanel); topSizer->Add(threadsPanel, 0, wxEXPAND); deZoomPanel* zoomPanel = new deZoomPanel(topPanel, _zoomManager); topSizer->Add(zoomPanel); warningPanel = new deWarningPanel(topPanel); topSizer->Add(warningPanel, 0, wxEXPAND); wxSizer* sizerI = new wxStaticBoxSizer(wxVERTICAL, this, _T("image")); leftSizer->Add(sizerI, 1, wxEXPAND); imageAreaPanel = new deImageAreaPanel(this, project, _samplerManager, _zoomManager, zoomPanel, gui); sizerI->Add(imageAreaPanel, 1, wxEXPAND); wxSizer* rightSizer = new wxBoxSizer(wxVERTICAL); hPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(280, 250)); wxSizer* sizerH = new wxStaticBoxSizer(wxVERTICAL, hPanel, _T("histogram")); hPanel->SetSizer(sizerH); histogramPanel = new deHistogramPanel(hPanel, &project, 260, 2); sizerH->Add(histogramPanel, 0, wxCENTER); deHistogramModePanel* histogramModePanel = new deHistogramModePanel(hPanel, project, histogramPanel, gui); sizerH->Add(histogramModePanel, 0, wxLEFT); rightSizer->Add(hPanel, 0, wxEXPAND); wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); rightSizer->Add(notebook, 1, wxEXPAND); layerGridPanel = new deLayerGridPanel(notebook, project, _layerProcessor, channelManager, gui); notebook->AddPage(layerGridPanel, _T("layers")); samplersPanel = new deSamplersPanel(notebook, project, _samplerManager); notebook->AddPage(samplersPanel, _T("samplers")); controlPanel = new deControlPanel(this, project, _layerProcessor, _operationProcessor, channelManager); rightSizer->Add(controlPanel, 0, wxEXPAND); mainSizer->Add(rightSizer, 0, wxEXPAND); SetSizer(mainSizer); full = false; wxMenu *menuFile = new wxMenu; menuFile->Append( ID_NewProject, _("New project") ); menuFile->AppendSeparator(); menuFile->Append( ID_OpenRawImageProPhoto, _("Open RAW image as ProPhoto RGB (default)") ); menuFile->Append( ID_OpenRawImageRGB, _("Open RAW image as sRGB") ); menuFile->Append( ID_OpenRawImageProPhotoAB, _("Open RAW image as ProPhoto RGB - auto brighten") ); menuFile->Append( ID_OpenRawImageRGBAB, _("Open RAW image as sRGB - auto brighten") ); menuFile->Append( ID_OpenImage, _("Open TIFF/JPG image") ); menuFile->AppendSeparator(); menuFile->Append( ID_TestImageSmall, _("Generate test image (small)") ); menuFile->Append( ID_TestImageBig, _("Generate test image (big, slow)") ); menuFile->AppendSeparator(); #ifdef __WXOSX_MAC__ menuFile->Append( wxID_EXIT, _("E&xit") ); #else menuFile->Append( ID_Quit, _("E&xit") ); #endif wxMenu *menuExport = new wxMenu; menuExport->Append( ID_ExportGIMP, _("Send to External Editor") ); menuExport->Append( ID_ExportTIFF, _("Export 16-bit TIFF") ); menuExport->Append( ID_ExportAll, _("Export all layers to 16-bit TIFFs") ); menuExport->Append( ID_ExportJPG, _("Export JPG") ); wxMenu *menuHelp = new wxMenu; menuHelp->Append( ID_HelpColorSpaces, _("channels") ); menuHelp->Append( ID_HelpColorSpaces2, _("mix of channels") ); menuHelp->Append( ID_HelpColorSpaces3, _("lightness/value in LAB/LCH/HSL/HSV") ); menuHelp->Append( ID_HelpColorSpaces4, _("hue in LCH/HSL/HSV") ); menuHelp->Append( ID_HelpColorSpaces5, _("CMYK skin colors") ); menuHelp->Append( ID_LABColors1, _("LAB colors 1") ); menuHelp->Append( ID_LABColors2, _("LAB colors 2") ); menuHelp->Append( ID_LABColors5, _("LAB colors 5") ); wxMenu *menuPalette = new wxMenu; menuPalette->Append( ID_ColorMatrix1, _("LAB color matrix 40x40") ); menuPalette->Append( ID_ColorMatrix2, _("LAB color matrix 20x20") ); menuPalette->Append( ID_ColorMatrix3, _("color tiles 20") ); menuPalette->Append( ID_ColorMatrix4, _("color tiles 40") ); menuPalette->Append( ID_ColorMatrix5, _("color tiles 80") ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, _("&File") ); menuBar->Append( menuExport, _("&Export") ); menuBar->Append( menuPalette, _("&Palette") ); menuBar->Append( menuHelp, _("&Channels") ); SetMenuBar( menuBar ); Layout(); imageAreaPanel->SetFocus(); Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deMainFrame::check)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(deMainFrame::onCloseEvent)); Connect(wxEVT_TIMER, wxTimerEventHandler(deMainFrame::onTimerEvent)); threadsPanel->setInfoColor(DE_DCRAW_END); } #define TILE1 20 #define TILE2 40 #define TILE3 60 #define TILER1 30 #define TILER2 50 #define TILER3 80 #define PALRW 60 #define PALRH 40 #define PAL1 16 #define PAL2 12 #define PAL3 10 #define MAR1 0.03 #define MAR2 0.06 deMainFrame::~deMainFrame() { logInfo("main frame destructor"); layerProcessor.stopWorkerThread(); layerProcessor.lockLayerProcessor(); layerProcessor.unlockLayerProcessor(); } void deMainFrame::rebuild() { topPanel->Layout(); topPanel->Update(); topPanel->Refresh(); } void deMainFrame::onKey(int key) { } void deMainFrame::onQuit(wxCommandEvent& WXUNUSED(event)) { logInfo("main frame onQuit"); Close(TRUE); } void deMainFrame::onNewProject(wxCommandEvent& WXUNUSED(event)) { project.newProject(); } void deMainFrame::onTestImageSmall(wxCommandEvent& WXUNUSED(event)) { project.setTestImage(900); } void deMainFrame::onTestImageBig(wxCommandEvent& WXUNUSED(event)) { project.setTestImage(1800); } void deMainFrame::onOpenImage(wxCommandEvent& WXUNUSED(event)) { std::string f = getOpenFile(this, "load source image", "image", openDirectory); if (!f.empty()) { openDirectory = getPath(f); project.openImage(f, false, false, false); } } void deMainFrame::onOpenRawImageProPhoto(wxCommandEvent& WXUNUSED(event)) { std::string f = getOpenFile(this, "load source image", "raw", openDirectory); if (!f.empty()) { openDirectory = getPath(f); project.openImage(f, true, false, false); } } void deMainFrame::onOpenRawImageRGB(wxCommandEvent& WXUNUSED(event)) { std::string f = getOpenFile(this, "load source image", "raw", openDirectory); if (!f.empty()) { openDirectory = getPath(f); project.openImage(f, true, true, false); } } void deMainFrame::onOpenRawImageProPhotoAB(wxCommandEvent& WXUNUSED(event)) { std::string f = getOpenFile(this, "load source image", "raw", openDirectory); if (!f.empty()) { openDirectory = getPath(f); project.openImage(f, true, false, true); } } void deMainFrame::onOpenRawImageRGBAB(wxCommandEvent& WXUNUSED(event)) { std::string f = getOpenFile(this, "load source image", "raw", openDirectory); if (!f.empty()) { openDirectory = getPath(f); project.openImage(f, true, true, true); } } void deMainFrame::onHelpColorSpaces(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame(this); help->Show(); } void deMainFrame::onHelpColorSpaces2(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame2(this); help->Show(); } void deMainFrame::onHelpColorSpaces3(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame3(this); help->Show(); } void deMainFrame::onHelpColorSpaces4(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame4(this); help->Show(); } void deMainFrame::onHelpColorSpaces5(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame5(this); help->Show(); } void deMainFrame::onLABColors1(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame6(this, 1); help->Show(); } void deMainFrame::onLABColors2(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame6(this, 2); help->Show(); } void deMainFrame::onLABColors5(wxCommandEvent& event) { wxFrame* help = new deHelpColorSpacesFrame6(this, 5); help->Show(); } void deMainFrame::onColorMatrix1(wxCommandEvent& event) { dePalette3* palette = NULL; wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 32, 32, palette); help->Show(); } void deMainFrame::onColorMatrix2(wxCommandEvent& event) { dePalette3* palette = NULL; wxFrame* help = new deColorMatrixFrame2(this, project, 1, 2, 0, 16, 16, palette); help->Show(); } void deMainFrame::onColorMatrix3(wxCommandEvent& event) { wxFrame* help = new deColorMatrixFrame(this, project, 20, 20, 20, 20, 40, 40, 12, 0.1); help->Show(); } void deMainFrame::onColorMatrix4(wxCommandEvent& event) { wxFrame* help = new deColorMatrixFrame(this, project, 40, 40, 40, 40, 40, 40, 12, 0.1); help->Show(); } void deMainFrame::onColorMatrix5(wxCommandEvent& event) { wxFrame* help = new deColorMatrixFrame(this, project, 80, 80, 80, 80, 40, 40, 12, 0.1); help->Show(); } void deMainFrame::onRepaintEvent(wxCommandEvent& event) { repaintMainFrame(true); } void deMainFrame::onImageLoadEvent(wxCommandEvent& event) { layerProcessor.onImageLoad(); } void deMainFrame::onInfoEvent(wxCommandEvent& event) { int i = event.GetInt(); threadsPanel->setInfoColor(i); } void deMainFrame::onWarningEvent(wxCommandEvent& event) { int view = project.getViewManager().getView(); deLayerStack& stack = project.getLayerStack(); const deBaseLayer* layer = stack.startReadLayer(view); if (layer) { std::string warning = layer->getWarning(); warningPanel->setWarning(warning); } stack.finishReadLayer(view); } void deMainFrame::repaintMainFrame(bool calcHistogram) { #ifdef DEBUG_LOG logInfo("repaint main frame"); #endif if (!project.isSourceValid()) { return; } imageAreaPanel->getImagePanel()->repaintImagePanel(); samplersPanel->update(); } void deMainFrame::check(wxCommandEvent &event) { } void deMainFrame::onCloseEvent(wxCloseEvent& event) { logInfo("deMainFrame::onCloseEvent"); this->Destroy(); } void deMainFrame::generateHistogram() { if (project.getSourceImageSize().getW() == 0) { return; } if (histogramPanel) { histogramPanel->generateHistogram(); } } void deMainFrame::onHistogramEvent(wxCommandEvent& event) { if (histogramPanel) { histogramPanel->paintHistogram(); } } void deMainFrame::updateTitle() { std::string s = imageName + " " + str(imageSize.getW()) + "x" + str(imageSize.getH()) + " - " + getApplicationName() + " " + getVersion() + " " + getCopyright(); SetTitle(str2wx(s)); } void deMainFrame::setImageName(const std::string& _imageName, const deSize& _size) { imageName = _imageName; imageSize = _size; updateTitle(); } void deMainFrame::onTimerEvent(wxTimerEvent& event) { project.onTimerUpdate(); } void deMainFrame::updateWarning() { } void deMainFrame::forceUpdateSize() { imageAreaPanel->updateSize(false); } void deMainFrame::onExportGIMP(wxCommandEvent& event) { #ifdef __WXOSX_MAC__ generateFinalImage("/Applications/Gimp.app/Contents/MacOS/Gimp", "tiff", "", false, ""); #else generateFinalImage("gimp", "tiff", "", false, ""); #endif } void deMainFrame::onExportAll(wxCommandEvent& event) { std::string f = getDir(this, "export all images"); if (!f.empty()) { logInfo("export all images to " + f); generateFinalImage("", "tiff", "", true, f); } } void deMainFrame::onExportTIFF(wxCommandEvent& event) { std::string f = getSaveFile(this, "export TIFF", "tiff", saveDirectory); if (!f.empty()) { saveDirectory = getPath(f); if (f.rfind(".tiff") != f.size() - 5) { f += ".tiff"; } generateFinalImage("", "tiff", f, false, ""); } } void deMainFrame::onExportJPG(wxCommandEvent& event) { std::string f = getSaveFile(this, "export JPG", "jpg", saveDirectory); if (!f.empty()) { saveDirectory = getPath(f); if (f.rfind(".jpg") != f.size() - 4) { f += ".jpg"; } generateFinalImage("", "jpg", f, false, ""); } } bool deMainFrame::generateFinalImage(const std::string& app, const std::string& type, const std::string& name, bool saveAll, const std::string& dir) { logInfo("generateFinalImage..."); deProgressDialog dialog; bool result = project.exportFinalImage(app, type, name, dialog, saveAll, dir); return result; } delaboratory-0.8/gui_wx/raw_module.cc0000644000175100001440000000374012004336607017021 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "raw_module.h" #include "dcraw_support.h" #include "image_io.h" #include "str.h" #include "logger.h" deRawModule::deRawModule() { dcraw_version = ""; loader = NULL; } deRawModule::~deRawModule() { } void deRawModule::onInit() { dcraw_version = getDcrawVersion(); } std::string deRawModule::getVersion() const { return dcraw_version; } bool deRawModule::loadRAW(const std::string& fileName, deStaticImage& image, bool half, bool srgb, bool brighten) { if (loader) { logError("can't load RAW - loader already active"); return false; } bool status = false; mutex.lock(); loader = new deRawLoader(fileName, image, half, srgb, brighten); status = loader->getStatus(); mutex.unlock(); return status; } bool deRawModule::updateRawLoading(bool& failure) { if (!loader) { return false; } if (failure) { logError("failure detected before load ?!"); } bool result = loader->load(failure); if (failure) { logError("failure detected in deRawModule"); } if ((result) || (failure)) { delete loader; loader = NULL; } return result; } bool deRawModule::isActive() const { return (loader); } delaboratory-0.8/gui_wx/property_boolean_ui.h0000644000175100001440000000245111764477311020615 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_BOOLEAN_UI_H #define _DE_PROPERTY_BOOLEAN_UI_H #include "check_box.h" class dePropertyBoolean; class deLayerProcessor; class dePropertyBooleanUI:public deCheckBox { private: dePropertyBoolean& property; deLayerProcessor& layerProcessor; int layerIndex; public: dePropertyBooleanUI(deWindow& window, dePropertyBoolean& _property, deLayerProcessor& _layerProcessor, int _layerIndex); virtual ~dePropertyBooleanUI(); virtual void onCheck(bool c); void setFromProperty(); }; #endif delaboratory-0.8/gui_wx/layer_processor_threads.h0000644000175100001440000000424611764477311021466 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_PROCESSOR_THREADS_H #define _DE_LAYER_PROCESSOR_THREADS_H class deMainWindow; class deLayerStack; class deViewManager; class deChannelManager; class wxProgressDialog; class deLayer; class deLogger; class deLayerFrameManager; class wxThread; #include #include "size.h" #include "renderer.h" #include "semaphore.h" #include "base_layer.h" class deLayerProcessorThreads { private: deLayerProcessor& layerProcessor; wxThread* workerThread; wxThread* renderWorkerThread; wxThread* histogramWorkerThread; deSemaphore workerSemaphore; deSemaphore renderWorkerSemaphore; deSemaphore histogramWorkerSemaphore; public: deLayerProcessorThreads(deLayerProcessor& _layerProcessor) :layerProcessor(_layerProcessor), workerSemaphore(1,1), renderWorkerSemaphore(1, 1), histogramWorkerSemaphore(1, 1) { histogramWorkerThread = NULL; workerThread = NULL; renderWorkerThread = NULL; }; virtual ~deLayerProcessorThreads() { }; void startWorkerThread(); void stopWorkerThread(); void renderPost() { renderWorkerSemaphore.post(); } void histogramPost() { histogramWorkerSemaphore.post(); } void workerPost() { workerSemaphore.post(); } }; #endif delaboratory-0.8/gui_wx/logger.h0000644000175100001440000000260011764477311016010 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LOGGER_H #define _DE_LOGGER_H #include #include #include "mutex.h" class deLoggerHelp; class deLogger { private: deLoggerHelp* help; std::ofstream* f; deMutex mutex; bool started; std::string getThreadName(); deLogger(); public: static deLogger& getLogger(); virtual ~deLogger(); void setFile(const std::string& fileName); void log(const std::string& message); void logInfo(const std::string& message); int getTime() const; }; void logInfo(const std::string& message); void logError(const std::string& message); #endif delaboratory-0.8/gui_wx/layer_grid_panel.h0000644000175100001440000000351511766762751020046 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_LAYER_GRID_PANEL_H #define _DE_LAYER_GRID_PANEL_H #include #include #include class deProject; class deLayerProcessor; class deChannelManager; class deGUI; class deLayerGridPanel:public wxPanel { class deLayerRow { public: deLayerRow(int _index) :index(_index) { }; int index; wxStaticText* id; wxRadioButton* view; wxButton* action; }; private: std::vector layerRows; deProject& project; deLayerProcessor& layerProcessor; wxSizer* mainSizer; wxFlexGridSizer* gridSizer; deChannelManager& channelManager; int maxRows; void select(wxCommandEvent &event); void click(wxCommandEvent &event); public: deLayerGridPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deChannelManager& _channelManager, deGUI& gui); ~deLayerGridPanel(); void buildRows(); void clearRows(); void update(); }; #endif delaboratory-0.8/gui_wx/update_main_layer_image.cc0000644000175100001440000000464212004112446021502 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "update_main_layer_image.h" #include #include "base_layer.h" #include "semaphore.h" #include "logger.h" #include "color_space_utils.h" #include "str.h" class deUpdateActionThread:public wxThread { private: virtual void *Entry() { bool result = layer.processMainImageSingleChannel(channel); if (!result) { logInfo("update action failed"); } semaphore.post(); return NULL; } deBaseLayer& layer; int channel; deSemaphore& semaphore; public: deUpdateActionThread(deBaseLayer& _layer, int _channel, deSemaphore& _semaphore) :layer(_layer), channel(_channel), semaphore(_semaphore) { } virtual ~deUpdateActionThread() { } }; void updateMainImageAllChannels(deBaseLayer& layer) { #ifdef DEBUG_LOG logInfo("update action all channels start"); #endif int n = getColorSpaceSize(layer.getColorSpace()); int i; deSemaphore semaphore(0, n); for (i = 0; i < n; i++) { #ifdef DEBUG_LOG logInfo("creating update action thread for channel " + str(i)); #endif deUpdateActionThread* thread = new deUpdateActionThread(layer, i, semaphore); if ( thread->Create() != wxTHREAD_NO_ERROR ) { } if ( thread->Run() != wxTHREAD_NO_ERROR ) { } } for (i = 0; i < n; i++) { #ifdef DEBUG_LOG logInfo("waiting for update action thread for channel " + str(i)); #endif semaphore.wait(); } #ifdef DEBUG_LOG logInfo("update action all channels DONE"); #endif } delaboratory-0.8/gui_wx/bitmap_wx.h0000644000175100001440000000206511764477311016530 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BITMAP_WX_H #define _DE_BITMAP_WX_H #include "bitmap.h" #include class deBitmapWX:public deBitmap { private: wxBitmap* bitmap; public: deBitmapWX(); virtual ~deBitmapWX(); virtual void resize(int w, int h); wxBitmap* getBitmap() {return bitmap;}; }; #endif delaboratory-0.8/gui_wx/frame.h0000644000175100001440000000242411766762751015636 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_FRAME_H #define _DE_FRAME_H #include class deWindow; class dePanel; class deFrameImpl; class deFrame { private: deFrameImpl* impl; protected: void addWidget(deWindow& window); void addWidget(const std::string& _name, deWindow& window); void addSizer(const std::string& _name); public: deFrame(deWindow& parent, const std::string& name); virtual ~deFrame(); void show(); deWindow& getWindow(); void fit(); bool clearImpl(); }; #endif delaboratory-0.8/gui_wx/tiff.cc0000644000175100001440000001327012000476242015606 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "tiff.h" #include #include "static_image.h" #include #include "logger.h" TIFF* openTIFF(const std::string fileName, bool write) { std::string mode = ""; if (write) { logInfo("opening TIFF " + fileName + " in write mode"); mode = "w"; } else { logInfo("opening TIFF " + fileName + " in read mode"); mode = "r"; } TIFF* tif = NULL; const char* c = fileName.c_str(); #ifdef _WIN32 wxString ws(c, wxConvUTF8); const wchar_t* wc = ws.wc_str(wxConvUTF8); tif = TIFFOpenW(wc, mode.c_str()); #else tif = TIFFOpen(c, mode.c_str()); #endif logInfo("DONE opening TIFF"); return tif; } bool loadTIFF(const std::string& fileName, deStaticImage& image) { TIFF* tif = openTIFF(fileName, false); if (!tif) { return false; } tdata_t buf; image.lock(); int w; int h; uint16 bps; uint16 spp; uint16 photometric; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); deSize size(w, h); image.setSize(size); image.setColorSpace(deColorSpaceRGB); if (photometric != PHOTOMETRIC_RGB) { logInfo("loading not RGB image, let's use LAB"); image.setColorSpace(deColorSpaceLAB); } deValue* pixelsR = image.startWriteStatic(0); deValue* pixelsG = image.startWriteStatic(1); deValue* pixelsB = image.startWriteStatic(2); int pos = 0; int y; int ssize = TIFFScanlineSize(tif); buf = _TIFFmalloc(ssize); deValue d = -1; if (bps == 16) { logInfo("bps 16"); d = (256 * 256) - 1; } else { logInfo("bps not 16"); d = 256 - 1; } for (y = 0; y < h; y++) { TIFFReadScanline(tif, buf, y); int x; for (x = 0; x < w; x++) { deValue r; deValue g; deValue b; if (bps == 16) { uint16* bb = (uint16*)(buf); uint16 u1 = bb[spp*x+0]; uint16 u2 = bb[spp*x+1]; uint16 u3 = bb[spp*x+2]; r = u1 / d; g = u2 / d; b = u3 / d; } else { uint8* bb = (uint8*)(buf); uint8 u1 = bb[spp*x+0]; uint8 u2 = bb[spp*x+1]; uint8 u3 = bb[spp*x+2]; r = u1 / d; g = u2 / d; b = u3 / d; } if (photometric == PHOTOMETRIC_RGB) { pixelsR[pos] = r; pixelsG[pos] = g; pixelsB[pos] = b; } else { // LAB pixelsR[pos] = r; g += 0.5; if (g > 1) { g -= 1.0; } b += 0.5; if (b > 1) { b -= 1.0; } pixelsG[pos] = g; pixelsB[pos] = b; } pos++; } } image.finishWriteStatic(0); image.finishWriteStatic(1); image.finishWriteStatic(2); image.unlock(); _TIFFfree(buf); TIFFClose(tif); return true; } bool saveTIFF(const std::string& fileName, const deValue* channelR, const deValue* channelG, const deValue* channelB, deSize size) { int w = size.getW(); int h = size.getH(); if ((!channelR) || (!channelG) || (!channelB)) { return false; } TIFF* tif = openTIFF(fileName, true); if (!tif) { return false; } TIFFSetField (tif, TIFFTAG_SOFTWARE, "delaboratory"); TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, w); TIFFSetField (tif, TIFFTAG_IMAGELENGTH, h); TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 16); TIFFSetField (tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, h); TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); tdata_t buf; int ssize = TIFFScanlineSize(tif); buf = _TIFFmalloc(ssize); uint16* bb = (uint16*)(buf); int pos = 0; int y; for (y = 0; y < h; y++) { int x; for (x = 0; x < w; x++) { deValue d = 256 * 256 - 1 ; deValue r = d * channelR[pos]; deValue g = d * channelG[pos]; deValue b = d * channelB[pos]; bb[3*x+0] = r; bb[3*x+1] = g; bb[3*x+2] = b;; pos++; } TIFFWriteScanline (tif, buf, y, 0); } TIFFClose(tif); return true; } delaboratory-0.8/gui_wx/gradient_panel.cc0000644000175100001440000002756211764477311017661 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gradient_panel.h" #include "conversion_processor.h" deColorPanelOld::deColorPanelOld(wxWindow* parent, wxSize _size, int style) :wxPanel(parent, wxID_ANY, wxDefaultPosition, _size, style) { Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deColorPanelOld::click)); Connect(wxEVT_MOTION, wxMouseEventHandler(deColorPanelOld::hover)); Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(deColorPanelOld::enter)); Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(deColorPanelOld::leave)); } deColorPanelOld::~deColorPanelOld() { } void deColorPanelOld::click(wxMouseEvent &event) { } void deColorPanelOld::hover(wxMouseEvent &event) { } void deColorPanelOld::enter(wxMouseEvent &event) { // SetBackgroundColour(wxColour(255 * r, 255 * g, 255 * b)); } void deColorPanelOld::leave(wxMouseEvent &event) { // SetBackgroundColour(wxColour(100 * r, 100 * g, 100 * b)); } void deColorPanelOld::setRGB(deValue rr, deValue gg, deValue bb) { r = rr; g = gg; b = bb; SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); } void deColorPanelOld::setColor(deColorSpace colorSpace, int channel, deValue value) { deValue rr = 0; deValue gg = 0; deValue bb = 0; deValue v1 = 0; deValue v2 = 0; deValue v3 = 0; deValue v4 = 0; if (colorSpace == deColorSpaceHSV) { v2 = 0.8; v3 = 1.0; } if (colorSpace == deColorSpaceHSL) { v2 = 0.8; v3 = 0.5; } if (colorSpace == deColorSpaceLCH) { v1 = 0.7; v2 = 0.9; } if (colorSpace == deColorSpaceLAB) { v2 = 0.5; v3 = 0.5; } switch (channel) { case 0: v1 = value; break; case 1: v2 = value; break; case 2: v3 = value; break; case 3: v4 = value; break; } deConversionProcessor p; deValue z; p.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); SetBackgroundColour(wxColour(255 * rr, 255 * gg, 255 * bb)); } deGradientPanel::deGradientPanel(wxWindow* parent, wxSize _size, deColorSpace _colorSpace) :wxPanel(parent, wxID_ANY, wxDefaultPosition, _size), colorSpace(_colorSpace) { bitmap = NULL; Connect(wxEVT_PAINT, wxPaintEventHandler(deGradientPanel::paintEvent)); } deGradientPanel::~deGradientPanel() { if (bitmap) { delete bitmap; } } void deGradientPanel::paintEvent(wxPaintEvent & evt) { wxPaintDC dc(this); dc.DrawBitmap(*bitmap, 0, 0, false); } deGradientPanel1::deGradientPanel1(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel1, int _channel2, deValue _c1, deValue _c2, deValue _c3) :deGradientPanel(parent, _size, _colorSpace), channel1(_channel1), channel2(_channel2), c1(_c1), c2(_c2), c3(_c3) { bitmap = NULL; generateBitmap(); } deGradientPanel1::~deGradientPanel1() { } void deGradientPanel1::changeChannel(int _channel) { channel1 = _channel; generateBitmap(); Update(); Refresh(); } void setValues(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, int channel1, int channel2, deValue u, deValue v, deValue c1, deValue c2, deValue c3) { v1 = 0; v2 = 0; v3 = 0; v4 = 0; if (colorSpace == deColorSpaceLAB) { v1 = 0.9; v2 = 0.5; v3 = 0.5; } if (colorSpace == deColorSpaceLCH) { v1 = 0.8; v2 = 0.7; v3 = 0.0; } if (colorSpace == deColorSpaceHSL) { v1 = 0.0; v2 = 0.8; v3 = 0.6; } if (colorSpace == deColorSpaceHSV) { v1 = 0.0; v2 = 0.8; v3 = 0.8; } if (colorSpace == deColorSpaceXYZ) { v1 = 0.1; v2 = 0.1; v3 = 0.1; } switch (channel2) { case 0: v1 = u; break; case 1: v2 = u; break; case 2: v3 = u; break; case 3: v4 = u; break; }; switch (channel1) { case 0: v1 = v; if ((colorSpace == deColorSpaceLCH) && (channel2 < 0)) { v2 = 0; } break; case 1: v2 = v; break; case 2: v3 = v; break; case 3: v4 = v; break; }; if (c1 >= 0) { if ((colorSpace == deColorSpaceLAB) || (colorSpace == deColorSpaceLCH)) { v1 = c1; } if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) { v3 = c1; } } if (c2 >= 0) { if (colorSpace == deColorSpaceLCH) { v3 = c2; } if ((colorSpace == deColorSpaceHSL) || (colorSpace == deColorSpaceHSV)) { v1 = c2; } } if (colorSpace == deColorSpaceCMYK) { if (c1 >= 0) { v1 = c1; } if (c2 >= 0) { v2 = c2; } if (c3 >= 0) { v3 = c3; } } } void deGradientPanel1::generateBitmap() { if (bitmap) { delete bitmap; } deConversionProcessor cp; int w = GetSize().GetWidth(); int h = GetSize().GetHeight(); wxImage* image = new wxImage(w, h); unsigned char* data = image->GetData(); int x; int y; for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { float v = 0; float u = 0; if (h > w) { v = 1.0 - (float) y / h; u = (float) x / w; } else { v = (float) x / w; u = 1.0 - (float) y / h; } deValue v1 = v; deValue v2 = v; deValue v3 = v; deValue v4 = v; setValues(v1, v2, v3, v4, colorSpace, channel1, channel2, u, v, c1, c2, c3); deValue rr = 0; deValue gg = 0; deValue bb = 0; deValue z; cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); unsigned char r = 255 * rr; unsigned char g = 255 * gg; unsigned char b = 255 * bb; data[3*(y*w+x) + 0] = r; data[3*(y*w+x) + 1] = g; data[3*(y*w+x) + 2] = b; } } bitmap = new wxBitmap(*image); delete image; } deGradientPanel2::deGradientPanel2(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, deValue _c1, deValue _c2, deValue _c3, deValue _c4) :deGradientPanel(parent, _size, _colorSpace), c1(_c1), c2(_c2), c3(_c3), c4(_c4) { bitmap = NULL; generateBitmap(); } deGradientPanel2::~deGradientPanel2() { } void setValues2(deValue& v1, deValue& v2, deValue& v3, deValue& v4, deColorSpace colorSpace, deValue c1, deValue c2, deValue c3, deValue c4, deValue u, deValue v) { if (colorSpace == deColorSpaceCMYK) { v1 = c1; v2 = c2; v3 = c3; v4 = c4 + v * 0.2; } if (colorSpace == deColorSpaceLAB) { deValue uu = u + 0.2; deValue vv = v + 0.2; deValue s = sqrt(vv * vv + uu * uu) - 0.2; if (s < 0) { s = 0; } v1 = 1.0 - 0.2 * s; v2 = c1; v3 = c2; v4 = 0; } } void deGradientPanel2::generateBitmap() { if (bitmap) { delete bitmap; } deConversionProcessor cp; int w = GetSize().GetWidth(); int h = GetSize().GetHeight(); wxImage* image = new wxImage(w, h); unsigned char* data = image->GetData(); int x; int y; for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { float v = 0; float u = 0; deValue d = 2; deValue xx = fabs(x - w / d) / (w / d); deValue yy = fabs(y - h / d) / (h / d); if (h > w) { v = yy; u = xx; } else { v = xx; u = yy; } deValue v1 = v; deValue v2 = v; deValue v3 = v; deValue v4 = v; setValues2(v1, v2, v3, v4, colorSpace, c1, c2, c3, c4, u, v); deValue rr = 0; deValue gg = 0; deValue bb = 0; deValue z; cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); unsigned char r = 255 * rr; unsigned char g = 255 * gg; unsigned char b = 255 * bb; data[3*(y*w+x) + 0] = r; data[3*(y*w+x) + 1] = g; data[3*(y*w+x) + 2] = b; } } bitmap = new wxBitmap(*image); delete image; } deGradientPanel0::deGradientPanel0(wxWindow* parent, wxSize _size, deColorSpace _colorSpace, int _channel, int _margin) :deGradientPanel(parent, _size, _colorSpace), channel(_channel), margin(_margin) { bitmap = NULL; generateBitmap(); } deGradientPanel0::~deGradientPanel0() { } void deGradientPanel0::changeChannel(int _channel) { channel = _channel; generateBitmap(); Update(); Refresh(); } void deGradientPanel0::generateBitmap() { if (bitmap) { delete bitmap; } deConversionProcessor cp; int w = GetSize().GetWidth(); int h = GetSize().GetHeight(); unsigned char gray = 128; int ww = w - 2 * margin; wxImage* image = new wxImage(w, h); unsigned char* data = image->GetData(); int xx; int y; for (xx = 0; xx < w; xx++) { int x = xx - margin; if (x < 0) { x = -1; } if (x >= ww) { x = -1; } for (y = 0; y < h; y++) { unsigned char r = gray; unsigned char g = gray; unsigned char b = gray; if (x >= 0) { float v = 0; float u = 0; if (h > ww) { v = 1.0 - (float) y / h; u = (float) x / ww; } else { v = (float) x / ww; u = 1.0 - (float) y / h; } deValue v1 = v; deValue v2 = v; deValue v3 = v; deValue v4 = v; setValues(v1, v2, v3, v4, colorSpace, channel, -1, u, v, -1, -1, -1); deValue rr = 0; deValue gg = 0; deValue bb = 0; deValue z; cp.convert(colorSpace, v1, v2, v3, v4, deColorSpaceRGB, rr, gg, bb, z); r = 255 * rr; g = 255 * gg; b = 255 * bb; } data[3*(y*w+xx) + 0] = r; data[3*(y*w+xx) + 1] = g; data[3*(y*w+xx) + 2] = b; } } bitmap = new wxBitmap(*image); delete image; } delaboratory-0.8/gui_wx/panel_wx.h0000644000175100001440000000215011764477311016346 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PANEL_WX_H #define _DE_PANEL_WX_H #include #include "window_wx.h" class dePanelWX:public wxPanel { private: deWindowWX window; dePanelWX(); protected: dePanelWX(deWindow& _parent); dePanelWX(deWindow& _parent, int w, int h); public: virtual ~dePanelWX(); deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/update_blend.cc0000644000175100001440000000362311765506775017333 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "update_blend.h" #include #include "color_space_utils.h" #include "layer_with_blending.h" #include "semaphore.h" class deUpdateBlendThread:public wxThread { private: virtual void *Entry() { layer.updateBlend(channel); semaphore.post(); return NULL; } deLayerWithBlending& layer; int channel; deSemaphore& semaphore; public: deUpdateBlendThread(deLayerWithBlending& _layer, int _channel, deSemaphore& _semaphore) :layer(_layer), channel(_channel), semaphore(_semaphore) { } virtual ~deUpdateBlendThread() { } }; void updateBlendOnThread(deLayerWithBlending& layer) { int n = getColorSpaceSize(layer.getColorSpace()); int i; deSemaphore semaphore(0, n); for (i = 0; i < n; i++) { deUpdateBlendThread* thread = new deUpdateBlendThread(layer, i, semaphore); if ( thread->Create() != wxTHREAD_NO_ERROR ) { } if ( thread->Run() != wxTHREAD_NO_ERROR ) { } } for (i = 0; i < n; i++) { semaphore.wait(); } } delaboratory-0.8/gui_wx/bitmap.h0000644000175100001440000000165211764477311016013 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BITMAP_H #define _DE_BITMAP_H class deBitmap { private: public: deBitmap(); virtual ~deBitmap(); virtual void resize(int w, int h) = 0; }; #endif delaboratory-0.8/gui_wx/delaboratory.cc0000644000175100001440000001121012005061147017334 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "wx/wx.h" #include "project.h" #include "str.h" #include "str_wx.h" #include "layer_processor.h" #include "logger.h" #include "channel_manager.h" #include "layer_stack.h" #include "layer_frame_manager.h" #include "static_image.h" #include "raw_module.h" #include "zoom_manager.h" #include "operation_processor.h" #include "main_window.h" #include "gui.h" #include "wx/stdpaths.h" const std::string LOG_FILE_NAME = "debug.log"; const std::string LOG_LOCKS_FILE_NAME = "locks.log"; class deInitLogger { private: wxString message; public: deInitLogger() { // std::string ucd = getUserConfigDir(); std::string ucd = getUserDataDir(); wxString ucd_wx = str2wx(ucd); if (wxDirExists(ucd_wx)) { message = _T(""); } else { if (wxMkdir(ucd_wx)) { message = _T("created user config dir ") + ucd_wx; } else { message = _T("unable to create user config dir ") + ucd_wx; } } deLogger::getLogger().setFile(ucd + "/" + LOG_FILE_NAME); } wxString getMessage() { return message; } }; class deLaboratory: public wxApp { public: deLaboratory() :wxApp(), sourceImage(), processor(previewChannelManager, layerStack, layerFrameManager, mainWindow), project(processor, previewChannelManager, layerStack, layerFrameManager, sourceImage, rawModule, zoomManager, mainWindow, gui), operationProcessor(processor, project) { logInfo("deLaboratory constructor"); } ~deLaboratory() { logInfo("deLaboratory destructor"); } private: virtual bool OnInit(); virtual int OnExit(); deInitLogger initLogger; deMainWindow mainWindow; deSamplerManager samplerManager; deLayerStack layerStack; deLayerFrameManager layerFrameManager; deChannelManager previewChannelManager; deStaticImage sourceImage; deLayerProcessor processor; deRawModule rawModule; deZoomManager zoomManager; deGUI gui; deProject project; deOperationProcessor operationProcessor; virtual int FilterEvent(wxEvent& event); }; IMPLEMENT_APP(deLaboratory) int deLaboratory::FilterEvent(wxEvent& event) { if (event.GetEventType()==wxEVT_KEY_DOWN ) { int key = ((wxKeyEvent&)event).GetKeyCode(); project.onKey(key); mainWindow.onKey(key); return true; } return -1; } int deLaboratory::OnExit() { logInfo("OnExit"); return 0; } bool deLaboratory::OnInit() { logInfo("deLaboratory::OnInit"); rawModule.onInit(); std::string dcraw_version = rawModule.getVersion(); if (dcraw_version == "") { dcraw_version = "dcraw not found"; } else { dcraw_version = "dcraw version " + dcraw_version; } wxInitAllImageHandlers(); int width = 1200; int height = 960; mainWindow.init( width, height, project, processor, samplerManager, zoomManager, dcraw_version, operationProcessor, previewChannelManager, gui); logInfo("show main frame"); mainWindow.show(); logInfo("set top level"); mainWindow.setTopWindow(); logInfo("startWorkerThread..."); wxString ws = initLogger.getMessage(); if (ws.size() > 0) { wxMessageBox(ws); } processor.startWorkerThread(); logInfo("process argc/argv..."); if (argc > 1) { wxString a = argv[1]; project.init(str(a)); if (argc > 2) { wxString a2 = argv[2]; operationProcessor.initProfile(str(a2)); } } logInfo("OnInit done"); return TRUE; } delaboratory-0.8/gui_wx/window_wx.h0000644000175100001440000000201111764477311016552 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_WINDOW_WX_H #define _DE_WINDOW_WX_H #include "window.h" #include class deWindowWX:public deWindow { private: wxWindow* window; public: deWindowWX(wxWindow* _window); virtual ~deWindowWX(); wxWindow* getWindow(); }; #endif delaboratory-0.8/gui_wx/property_boolean_ui.cc0000644000175100001440000000277311765775026020767 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_boolean_ui.h" #include "property_boolean.h" #include "base_layer.h" #include "layer_processor.h" dePropertyBooleanUI::dePropertyBooleanUI(deWindow& window, dePropertyBoolean& _property, deLayerProcessor& _layerProcessor, int _layerIndex) :deCheckBox(window, _property.getLabel()), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex) { setFromProperty(); } dePropertyBooleanUI::~dePropertyBooleanUI() { } void dePropertyBooleanUI::onCheck(bool c) { property.set(c); if (property.updateBlendOnly()) { layerProcessor.markUpdateBlendAllChannels(layerIndex); } else { layerProcessor.markUpdateAllChannels(layerIndex); } } void dePropertyBooleanUI::setFromProperty() { set(property.get()); } delaboratory-0.8/gui_wx/update_main_layer_image.h0000644000175100001440000000160511764477311021361 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_UPDATE_MAIN_LAYER_IMAGE_H #define _DE_UPDATE_MAIN_LAYER_IMAGE_H class deBaseLayer; void updateMainImageAllChannels(deBaseLayer& layer); #endif delaboratory-0.8/gui_wx/bitmap.cc0000644000175100001440000000146111764477311016147 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "bitmap.h" deBitmap::deBitmap() { } deBitmap::~deBitmap() { } delaboratory-0.8/gui_wx/window_wx.cc0000644000175100001440000000162711764477311016724 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "window_wx.h" deWindowWX::deWindowWX(wxWindow* _window) :window(_window) { } deWindowWX::~deWindowWX() { } wxWindow* deWindowWX::getWindow() { return window; } delaboratory-0.8/gui_wx/gui.h0000644000175100001440000000371111772646457015331 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GUI_H #define _DE_GUI_H class deViewModePanel; class deLayerGridPanel; class deLayerProcessor; class deLayerFrameManager; class deBaseLayer; class deHistogramModePanel; class deImageAreaPanel; class deGUI { private: deGUI(const deGUI& gui); deGUI& operator =(const deGUI& gui); deViewModePanel* viewModePanel; deLayerGridPanel* layerGridPanel; deHistogramModePanel* histogramModePanel; deImageAreaPanel* imageAreaPanel; public: deGUI(); virtual ~deGUI(); void setViewModePanel(deViewModePanel* _viewModePanel); void updateViewModePanelMode(); void updateViewModePanelNames(); void setLayerGridPanel(deLayerGridPanel* _panel); void updateLayerGrid(); void openLayerFrame(deBaseLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& layerFrameManager, int index); void setHistogramModePanel(deHistogramModePanel* _histogramModePanel); void updateHistogramMode(int channel); void updateHistogramNames(); void setImageAreaPanel(deImageAreaPanel* _imageAreaPanel); void updateImageAreaSize(); void lockSize(); void unlockSize(); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame4.h0000644000175100001440000000200511764477311021452 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME4_H #define _DE_HELP_COLOR_SPACES_FRAME4_H #include "help_frame.h" class deHelpColorSpacesFrame4:public deHelpFrame { private: public: deHelpColorSpacesFrame4(wxWindow *parent); virtual ~deHelpColorSpacesFrame4(); }; #endif delaboratory-0.8/gui_wx/tmp.cc0000644000175100001440000000200211766762751015472 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "tmp.h" #include #include "str_wx.h" std::string getTmp() { wxString temp; if (wxGetEnv(_T("TEMP"), &temp)) { // on Windows $TEMP should be set return str(temp); } else { return "/tmp"; } } delaboratory-0.8/gui_wx/histogram_panel.cc0000644000175100001440000000734512004112446020035 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "histogram_panel.h" #include "project.h" #include "color_space.h" #include #include "base_layer.h" #include "image.h" #include "layer_processor.h" #include #include "channel_manager.h" #include "layer_stack.h" #include "str.h" #include "canvas_wx.h" BEGIN_EVENT_TABLE(deHistogramPanel, wxPanel) EVT_PAINT(deHistogramPanel::paintEvent) END_EVENT_TABLE() deHistogramPanel::deHistogramPanel(wxWindow* parent, deProject* _project, int _width, int _margin) :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(_width, 200)), project(_project), histogram(_width - 2 * _margin), width(_width), margin(_margin) { channel = 0; generated = false; renderedImage.setSize(deSize(width, width)); } deHistogramPanel::~deHistogramPanel() { } void deHistogramPanel::paintEvent(wxPaintEvent & evt) { wxBufferedPaintDC dc(this); deCanvasWX canvas(dc); render(canvas); } void deHistogramPanel::paintHistogram() { wxClientDC dc(this); wxBufferedDC bufferedDC(&dc); deCanvasWX canvas(bufferedDC); render(canvas); } void deHistogramPanel::render(deCanvas& canvas) { mutex.lock(); if (generated) { renderedImage.render(canvas); } else { canvas.clear(); } mutex.unlock(); } void deHistogramPanel::generateHistogram() { mutex.lock(); #ifdef DEBUG_LOG logInfo("generate histogram..."); #endif generated = false; deLayerStack& layerStack = project->getLayerStack(); deViewManager& viewManager = project->getViewManager(); int viewV = viewManager.getView(); project->getLayerProcessor().lockLayerProcessor(); int view = project->getLayerProcessor().getLastValidLayer(); if (view > viewV) { view = viewV; } const deBaseLayer* layer = layerStack.startReadLayer(view); project->getLayerProcessor().unlockLayerProcessor(); if (layer) { const deImage& image = layer->getLayerImage(); int n = image.getChannelSize().getN(); const deValue* values = image.startRead(channel); if ((n > 0) && (values)) { histogram.clear(); histogram.calc(values, n); } else { if (!values) { logError("can't generate histogram - NULL channel"); } if (n <= 0) { logError("can't generate histogram - n: " + str(n)); } } image.finishRead(channel); } if (layer) { int sizeH = 200; unsigned char g1 = 50; unsigned char g2 = 120; generated = histogram.render(renderedImage.getCurrentImageData(), width, sizeH, g1, g2, margin); } layerStack.finishReadLayer(view); #ifdef DEBUG_LOG logInfo("generate histogram DONE"); #endif mutex.unlock(); } void deHistogramPanel::setChannel(int _channel) { mutex.lock(); channel = _channel; mutex.unlock(); } int deHistogramPanel::getChannel() const { return channel; } delaboratory-0.8/gui_wx/property_levels_ui.h0000644000175100001440000000266411764477311020476 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_LEVELS_UI_H #define _DE_PROPERTY_LEVELS_UI_H class dePropertyLevels; class deLayerProcessor; class deWindow; class dePropertyLevelsUIImpl; class deBaseLayerWithSource; class dePropertyLevelsUI { private: dePropertyLevels& property; deLayerProcessor& layerProcessor; int layerIndex; deBaseLayerWithSource& layer; dePropertyLevelsUIImpl* impl; public: dePropertyLevelsUI(deWindow& window, dePropertyLevels& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width); virtual ~dePropertyLevelsUI(); deWindow& getWindow(); void setFromProperty(); }; #endif delaboratory-0.8/gui_wx/check_box.h0000644000175100001440000000215711766762751016474 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_CHECK_BOX_H #define _DE_CHECK_BOX_H #include #include "window.h" class deCheckBoxImpl; class deCheckBox { private: deCheckBoxImpl* impl; public: deCheckBox(deWindow& window, const std::string& _name); virtual ~deCheckBox(); virtual void onCheck(bool c) = 0; void set(bool c); deWindow& getWindow(); }; #endif delaboratory-0.8/gui_wx/histogram_panel.h0000644000175100001440000000304711764477311017713 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HISTOGRAM_PANEL_H #define _DE_HISTOGRAM_PANEL_H #include #include "histogram.h" class deProject; #include "rendered_image.h" #include "mutex.h" class deHistogramPanel:public wxPanel { private: deProject* project; deHistogram histogram; deRenderedImage renderedImage; int channel; bool generated; int width; int margin; deMutex mutex; void paintEvent(wxPaintEvent & evt); void render(deCanvas& canvas); DECLARE_EVENT_TABLE() public: deHistogramPanel(wxWindow* parent, deProject* _project, int _width, int _margin); virtual ~deHistogramPanel(); void generateHistogram(); void paintHistogram(); void setChannel(int _channel); int getChannel() const; }; #endif delaboratory-0.8/gui_wx/gui.cc0000644000175100001440000000622311772725565015466 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gui.h" #include "view_mode_panel.h" #include "layer_grid_panel.h" #include "layer_frame_manager.h" #include "window_wx.h" #include "base_layer.h" #include "generic_layer_frame.h" #include "histogram_mode_panel.h" #include "image_area_panel.h" #include "logger.h" deGUI::deGUI() { viewModePanel = NULL; layerGridPanel = NULL; histogramModePanel = NULL; imageAreaPanel = NULL; } deGUI::~deGUI() { } void deGUI::setViewModePanel(deViewModePanel* _viewModePanel) { viewModePanel = _viewModePanel; } void deGUI::setLayerGridPanel(deLayerGridPanel* _panel) { layerGridPanel = _panel; } void deGUI::setHistogramModePanel(deHistogramModePanel* _histogramModePanel) { histogramModePanel = _histogramModePanel; } void deGUI::updateViewModePanelMode() { if (viewModePanel) { viewModePanel->updateMode(); } } void deGUI::updateViewModePanelNames() { if (viewModePanel) { viewModePanel->updateNames(); } } void deGUI::updateLayerGrid() { if (layerGridPanel) { layerGridPanel->update(); } } void deGUI::openLayerFrame(deBaseLayer& layer, deLayerProcessor& layerProcessor, deLayerFrameManager& layerFrameManager, int index) { if (!layerFrameManager.checkLayerFrame(index)) { deWindowWX window(layerGridPanel); const std::string name = layer.getType(); deFrame* frame = new deGenericLayerFrame(window, name, layer, layerProcessor, layerFrameManager, index); if (frame) { frame->show(); } } } void deGUI::updateHistogramMode(int channel) { if (histogramModePanel) { histogramModePanel->updateMode(channel); } } void deGUI::updateHistogramNames() { if (histogramModePanel) { histogramModePanel->updateNames(); } } void deGUI::setImageAreaPanel(deImageAreaPanel* _imageAreaPanel) { imageAreaPanel = _imageAreaPanel; } void deGUI::updateImageAreaSize() { if (imageAreaPanel) { imageAreaPanel->updateSize(false); } } void deGUI::lockSize() { if (imageAreaPanel) { imageAreaPanel->lockSize(); } else { logError("can't lockSize, no imageAreaPanel"); } } void deGUI::unlockSize() { if (imageAreaPanel) { imageAreaPanel->unlockSize(); } else { logError("can't unlockSize, no imageAreaPanel"); } } delaboratory-0.8/gui_wx/window.h0000644000175100001440000000157111764477311016046 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_WINDOW_H #define _DE_WINDOW_H class deWindow { private: public: deWindow(); virtual ~deWindow(); }; #endif delaboratory-0.8/gui_wx/help_color_spaces_frame6.cc0000644000175100001440000000462411764477311021623 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame6.h" #include "color_space.h" #include "gradient_panel.h" #include #include #include const int LAB_COLORS_COUNT=10; const int LAB_COLORS_ELEMENTS = (2 * LAB_COLORS_COUNT + 1); void generateAB(wxWindow* window, wxSizer* sizer, int scale) { int w = 40; int h = 40; int b; int a; sizer->Add(-1, 0, wxCENTER); for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) { int sa = scale * a; std::ostringstream oss; oss << sa; wxStaticText* la = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); sizer->Add(la, 1, wxCENTER); } for (b = LAB_COLORS_COUNT; b >= -LAB_COLORS_COUNT; b--) { int sb = scale * b; std::ostringstream oss; oss << sb; wxStaticText* lb = new wxStaticText(window, wxID_ANY, wxString::FromAscii(oss.str().c_str())); sizer->Add(lb, 0, wxCENTER); deValue bb = (sb + 100.0) / 200.0; for (a = -LAB_COLORS_COUNT; a <= LAB_COLORS_COUNT; a++) { int sa = scale * a; deValue aa = (sa + 100.0) / 200.0; deGradientPanel2* gradient = new deGradientPanel2(window, wxSize(w, h), deColorSpaceLAB, aa, bb, -1, -1); sizer->Add(gradient, 0, wxCENTER); } } sizer->Layout(); } deHelpColorSpacesFrame6::deHelpColorSpacesFrame6(wxWindow *parent, int scale) :deHelpFrame(parent, "LAB") { wxSizer* sizer = new wxFlexGridSizer(1 + LAB_COLORS_ELEMENTS, 0, 0); SetSizer(sizer); generateAB(this, sizer, scale); Fit(); } deHelpColorSpacesFrame6::~deHelpColorSpacesFrame6() { } delaboratory-0.8/gui_wx/help_color_spaces_frame2.h0000644000175100001440000000200511764477311021450 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_HELP_COLOR_SPACES_FRAME2_H #define _DE_HELP_COLOR_SPACES_FRAME2_H #include "help_frame.h" class deHelpColorSpacesFrame2:public deHelpFrame { private: public: deHelpColorSpacesFrame2(wxWindow *parent); virtual ~deHelpColorSpacesFrame2(); }; #endif delaboratory-0.8/gui_wx/property_numeric_ui.h0000644000175100001440000000257011764477311020642 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_PROPERTY_VALUE_SLIDER_H #define _DE_PROPERTY_VALUE_SLIDER_H class dePropertyNumeric; class deLayerProcessor; class deWindow; #include "slider.h" class dePropertyNumericUI:public deSlider { private: dePropertyNumeric& property; deLayerProcessor& layerProcessor; int layerIndex; public: dePropertyNumericUI(deWindow& window, dePropertyNumeric& _property, deLayerProcessor& _layerProcessor, int _layerIndex, int _width, int width, int widthl); virtual ~dePropertyNumericUI(); virtual void onValueChange(deValue value, bool finished); void setFromProperty(); }; #endif delaboratory-0.8/gui_wx/mutex_read_write.h0000644000175100001440000000242311764477311020103 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MUTEX_READ_WRITE_H #define _DE_MUTEX_READ_WRITE_H #include "mutex.h" #include "semaphore.h" class deMutexReadWrite { private: int maxReaders; deSemaphore readSemaphore; deMutex writeMutex; deMutexReadWrite(const deMutexReadWrite& m); deMutexReadWrite& operator = (const deMutexReadWrite& m); public: deMutexReadWrite(int _maxReaders); ~deMutexReadWrite(); void lockRead(); void unlockRead(); void lockWrite(); void unlockWrite(); }; #endif delaboratory-0.8/gui_wx/image_panel.h0000644000175100001440000000342611765506775017011 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_IMAGE_PANEL_H #define _DE_IMAGE_PANEL_H #include "wx/wx.h" #include "renderer.h" #include "value.h" class deProject; class deSamplerManager; class deZoomManager; class deZoomPanel; class deImageAreaPanel; class deCanvas; class deImagePanel:public wxPanel { private: deImageAreaPanel* area; deProject& project; bool clicked; deSamplerManager& samplerManager; deZoomManager& zoomManager; deZoomPanel* zoomPanel; void click(wxMouseEvent &event); void release(wxMouseEvent &event); void move(wxMouseEvent &event); void wheel(wxMouseEvent &event); bool onClick(deValue x, deValue y); bool onMove(deValue x, deValue y); bool onRelease(); void drawSamplers(deCanvas& canvas); void drawSelection(deCanvas& canvas); void render(deCanvas& canvas); public: deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel); virtual ~deImagePanel(); void paintEvent(wxPaintEvent & evt); void repaintImagePanel(); }; #endif delaboratory-0.8/gui_wx/image_area_panel.cc0000644000175100001440000000513011772646457020131 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "image_area_panel.h" #include "size.h" #include "project.h" #include "image_panel.h" #include "channel_manager.h" #include "layer_processor.h" #include "zoom_panel.h" #include "str.h" #include "gui.h" void deImageAreaPanel::resize(wxSizeEvent& event) { logInfo("SIZE event in image area panel"); updateSize(true); Refresh(); } void deImageAreaPanel::updateSize(bool canSkip) { if (sizeLocked) { logError("updateSize called when sizeLocked, skipped"); return; } wxSize s = GetSize(); logInfo("image area panel update size " + str(s.GetWidth()) + "x" + str(s.GetHeight())); const deSize ps(s.GetWidth(), s.GetHeight()); deSize fit = project.onImageAreaChangeSize(ps, canSkip); logInfo("set image panel size " + str(fit.getW()) + "x" + str(fit.getH())); imagePanel->SetMinSize(wxSize(fit.getW(), fit.getH())); Layout(); } deImageAreaPanel::deImageAreaPanel(wxWindow* parent, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* zoomPanel, deGUI& gui) :wxPanel(parent), project(_project) { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); imagePanel = new deImagePanel(this, project, _samplerManager, _zoomManager, zoomPanel); sizer->Add(imagePanel, 0, wxCENTER); gui.setImageAreaPanel(this); zoomPanel->setImageAreaPanel(this); sizeLocked = false; Connect(wxEVT_SIZE, wxSizeEventHandler(deImageAreaPanel::resize)); } deImageAreaPanel::~deImageAreaPanel() { } deImagePanel* deImageAreaPanel::getImagePanel() { return imagePanel; } void deImageAreaPanel::lockSize() { logInfo("sizeLocked = true"); sizeMutex.lock(); sizeLocked = true; sizeMutex.unlock(); } void deImageAreaPanel::unlockSize() { logInfo("sizeLocked = false"); sizeMutex.lock(); sizeLocked = false; sizeMutex.unlock(); } delaboratory-0.8/gui_wx/image_io.h0000644000175100001440000000227412004336607016277 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_IMAGE_IO_H #define _DE_IMAGE_IO_H #include #include "size.h" #include "color_space.h" class deStaticImage; class deImage; class deChannelManager; bool loadImage(const std::string& fileName, deStaticImage& image); bool loadPPM(const std::string& fileName, deStaticImage& image, deColorSpace colorSpace); bool saveImage(const std::string& fileName, const deImage& image, const std::string& type, deChannelManager& previewChannelManager); #endif delaboratory-0.8/gui_wx/check_box.cc0000644000175100001440000000450611764477311016623 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "check_box.h" #include "window_wx.h" #include "panel_wx.h" class deCheckBoxImpl:public dePanelWX { private: deCheckBox& parent; wxCheckBox* checkBox; public: deCheckBoxImpl(deCheckBox& _parent, deWindow& _parentWindow, const std::string& _name) :dePanelWX(_parentWindow), parent(_parent) { wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); SetSizer(sizer); checkBox = new wxCheckBox(this, wxID_ANY, wxString::FromAscii(_name.c_str())); sizer->Add(checkBox); Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(deCheckBoxImpl::check)); } void check(wxCommandEvent &event) { if (checkBox->IsChecked()) { parent.onCheck(true); } else { parent.onCheck(false); } } void set(bool b) { if (b) { checkBox->SetValue(1); } else { checkBox->SetValue(0); } } }; deCheckBox::deCheckBox(deWindow& window, const std::string& _name) { deWindowWX* w = dynamic_cast(&window); if (w) { impl = new deCheckBoxImpl(*this, window, _name); } else { impl = NULL; } } deCheckBox::~deCheckBox() { if (impl) { delete impl; } } void deCheckBox::set(bool c) { if (impl) { impl->set(c); } } deWindow& deCheckBox::getWindow() { return impl->getWindow(); } delaboratory-0.8/gui_wx/mutex.cc0000644000175100001440000000324612002551204016014 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "mutex.h" #include #include "logger.h" class deMutexImpl { private: wxMutex mutex; public: deMutexImpl(wxMutexType flags) :mutex(flags) { } ~deMutexImpl() { } void lock() { mutex.Lock(); } void unlock() { mutex.Unlock(); } }; deMutex::deMutex(bool recursive) { wxMutexType flags = wxMUTEX_DEFAULT; if (recursive) { #ifdef DEBUG_LOG logInfo("create recursive mutex"); #endif flags = wxMUTEX_RECURSIVE; } else { #ifdef DEBUG_LOG logInfo("create normal mutex"); #endif } impl = new deMutexImpl(flags); } deMutex::~deMutex() { #ifdef DEBUG_LOG logInfo("destroy mutex"); #endif delete impl; } void deMutex::lock() { impl->lock(); } void deMutex::unlock() { impl->unlock(); } delaboratory-0.8/gui_wx/bitmap_wx.cc0000644000175100001440000000203511764477311016663 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "bitmap_wx.h" deBitmapWX::deBitmapWX() { bitmap = NULL; } deBitmapWX::~deBitmapWX() { if (bitmap) { delete bitmap; } } void deBitmapWX::resize(int w, int h) { if (bitmap) { delete bitmap; bitmap = NULL; } bitmap = new wxBitmap(w, h, 24); } delaboratory-0.8/gui_wx/property_curves_ui.cc0000644000175100001440000001721212000472655020632 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_curves_ui.h" #include "property_curves.h" #include "layer_processor.h" #include "panel_wx.h" #include "window_wx.h" #include #include "canvas_wx.h" #include "gradient_panel.h" #include "channel_selector.h" #include "curves_panel.h" #include "base_layer_with_source.h" #include "logger.h" #include "color_space_utils.h" class deCurvesChannelSelector:public deChannelSelector { private: dePropertyCurvesUIImpl& ui; public: deCurvesChannelSelector(deWindow& window, deColorSpace colorSpace, dePropertyCurvesUIImpl& _ui) :deChannelSelector(window, colorSpace), ui(_ui) { } virtual ~deCurvesChannelSelector() { } virtual void onValueChange(int channel); }; class dePropertyCurvesUIImpl:public dePanelWX { private: deBaseLayerWithSource& layer; dePropertyCurvesUI& parent; dePropertyCurves& property; deCurvesChannelSelector *channelSelector; deCurvesPanel* curvesPanel; deGradientPanel1* leftBar; deGradientPanel1* bottomBar; wxStaticText* infoEntry; int channel; public: dePropertyCurvesUIImpl(dePropertyCurvesUI& _parent, deWindow& _parentWindow, dePropertyCurves& _property, deBaseLayerWithSource& _layer, deLayerProcessor& layerProcessor, int layerIndex, int width) :dePanelWX(_parentWindow), layer(_layer), parent(_parent), property(_property) { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); channel = -1; deColorSpace colorSpace = layer.getColorSpace(); wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); sizer->Add(sizer2); { channelSelector = new deCurvesChannelSelector(getWindow(), colorSpace, *this); deWindowWX& w = dynamic_cast(channelSelector->getWindow()); sizer2->Add(w.getWindow(), 0); } sizer2->AddSpacer(20); infoEntry = new wxStaticText(this, wxID_ANY, _T("info")); sizer2->Add(infoEntry, 0, wxRIGHT); curvesPanel = new deCurvesPanel(this, layerProcessor, layerIndex, property, colorSpace, infoEntry); int barSize = 16; leftBar = new deGradientPanel1(this, wxSize(barSize, CURVES_PANEL_SIZE_Y), colorSpace, 0, -1, -1, -1, -1); bottomBar = new deGradientPanel1(this, wxSize(CURVES_PANEL_SIZE_X, barSize), colorSpace, 0, -1, -1, -1, -1); wxSizer* sizerC = new wxFlexGridSizer(2, 8, 8); sizer->Add(sizerC); sizerC->Add(leftBar, 0, wxCENTER); sizerC->Add(curvesPanel, 0, wxCENTER); sizerC->Add(-1, 0, wxCENTER); sizerC->Add(bottomBar, 0, wxCENTER); setChannel(0); Fit(); } virtual ~dePropertyCurvesUIImpl() { } void generate() { const deImage& sourceImage = layer.getSourceImage(); int chan = channel; int hc = property.getHorizontalChannel(); if (hc >=0 ) { chan = hc; } const deValue* c = sourceImage.startRead(chan); int n = sourceImage.getChannelSize().getN(); curvesPanel->generateBackground(c, n); sourceImage.finishRead(chan); } void setMarker() { const deImage& sourceImage = layer.getSourceImage(); const deValue* c = sourceImage.startRead(channel); int n = sourceImage.getChannelSize().getN(); curvesPanel->setMarker(c, n); sourceImage.finishRead(channel); } void setFromProperty() { generate(); updateBars(); curvesPanel->paint(); } void setChannel(int _channel) { channel = _channel; generate(); curvesPanel->changeChannel(channel); setMarker(); updateBars(); } void updateBars() { leftBar->changeChannel(channel); int hc = property.getHorizontalChannel(); if (hc < 0) { bottomBar->changeChannel(channel); } else { bottomBar->changeChannel(hc); } } bool onImageClick(deValue x, deValue y) { const deImage& sourceImage = layer.getSourceImage(); const deValue* c = sourceImage.startRead(channel); curvesPanel->onImageClick(x, y, c, sourceImage.getChannelSize()); sourceImage.finishRead(channel); return true; } bool onKey(int key) { if (key == 'X') { return curvesPanel->removeSelectedPoint(); } int p = curvesPanel->getClickPosition(); if (p >= 0) { const deImage& sourceImage = layer.getSourceImage(); if (p >= sourceImage.getChannelSize().getN()) { logError("click position outside channel"); return false; } deColorSpace colorSpace = layer.getColorSpace(); int n = getColorSpaceSize(colorSpace); int i; for (i = 0; i < n; i++) { const deValue* c = sourceImage.startRead(i); if (c) { deValue v = c[p]; property.onKey(key, i, v); } sourceImage.finishRead(i); } return true; } return false; } }; dePropertyCurvesUI::dePropertyCurvesUI(deWindow& window, dePropertyCurves& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deBaseLayerWithSource& _layer, int width) :property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), layer(_layer) { deWindowWX* w = dynamic_cast(&window); if (w) { impl = new dePropertyCurvesUIImpl(*this, window, property, layer, layerProcessor, layerIndex, width); } else { impl = NULL; } } dePropertyCurvesUI::~dePropertyCurvesUI() { if (impl) { delete impl; } } deWindow& dePropertyCurvesUI::getWindow() { return impl->getWindow(); } void dePropertyCurvesUI::setFromProperty() { if (impl) { impl->setFromProperty(); } } bool dePropertyCurvesUI::onImageClick(deValue x, deValue y) { if (impl) { return impl->onImageClick(x,y); } return false; } bool dePropertyCurvesUI::onKey(int key) { if (impl) { return impl->onKey(key); } return false; } void deCurvesChannelSelector::onValueChange(int channel) { ui.setChannel(channel); } delaboratory-0.8/gui_wx/canvas.cc0000644000175100001440000000146111764477311016146 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "canvas.h" deCanvas::deCanvas() { } deCanvas::~deCanvas() { } delaboratory-0.8/gui_wx/help_color_spaces_frame2.cc0000644000175100001440000000647711764477311021627 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "help_color_spaces_frame2.h" #include "color_space.h" #include "gradient_panel.h" #include "color_space_utils.h" deHelpColorSpacesFrame2::deHelpColorSpacesFrame2(wxWindow *parent) :deHelpFrame(parent, "mix of channels") { wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); SetSizer(mainSizer); wxSizer* sizer1 = new wxGridSizer(2); mainSizer->Add(sizer1); std::vector colorSpaces; getSupportedColorSpaces(colorSpaces); int width = 140; int barSize = 140; std::vector::iterator i; for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) { deColorSpace c = *i; int n = getColorSpaceSize(c); if (n == 3) { wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); sizer1->Add(sizerB); int j; for (j = 0; j < n; j++) { int k = j + 1; if (k >= n) { k = 0; } std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); sizerB->Add(sizerBC); deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); sizerBC->Add(gradient, 0, wxCENTER); } } } wxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL); mainSizer->Add(sizer2); for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) { deColorSpace c = *i; int n = getColorSpaceSize(c); if (n == 4) { wxSizer* sizerB = new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(getColorSpaceName(c).c_str())); sizer2->Add(sizerB); int j; for (j = 0; j < n; j++) { int k; for (k = j + 1; k < n; k++) { std::string s = getChannelName(c, j) + " / " + getChannelName(c, k); wxSizer* sizerBC= new wxStaticBoxSizer(wxHORIZONTAL, this, wxString::FromAscii(s.c_str())); sizerB->Add(sizerBC); deGradientPanel1* gradient = new deGradientPanel1(this, wxSize(width, barSize), c, j, k, -1, -1, -1); sizerBC->Add(gradient, 0, wxCENTER); } } } } Fit(); } deHelpColorSpacesFrame2::~deHelpColorSpacesFrame2() { } delaboratory-0.8/gui_wx/main_frame_events.h0000644000175100001440000000274112004336607020207 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MAIN_FRAME_EVENTS_H #define _DE_MAIN_FRAME_EVENTS_H enum { ID_Quit = 1, ID_NewProject, ID_TestImageSmall, ID_TestImageBig, ID_OpenImage, ID_OpenRawImageProPhoto, ID_OpenRawImageRGB, ID_OpenRawImageProPhotoAB, ID_OpenRawImageRGBAB, ID_HelpColorSpaces, ID_HelpColorSpaces2, ID_HelpColorSpaces3, ID_HelpColorSpaces4, ID_HelpColorSpaces5, ID_LABColors1, ID_LABColors2, ID_LABColors5, ID_ColorMatrix1, ID_ColorMatrix2, ID_ColorMatrix3, ID_ColorMatrix4, ID_ColorMatrix5, ID_ExportGIMP, ID_ExportTIFF, ID_ExportJPG, ID_ExportAll, DE_REPAINT_EVENT, DE_IMAGE_LOAD_EVENT, DE_HISTOGRAM_EVENT, DE_WARNING_EVENT, DE_INFO_EVENT }; #endif delaboratory-0.8/gui_wx/mutex_read_write.cc0000644000175100001440000000257211764477311020246 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "mutex_read_write.h" #include "logger.h" deMutexReadWrite::deMutexReadWrite(int _maxReaders) :maxReaders(_maxReaders), readSemaphore(_maxReaders, _maxReaders) { } deMutexReadWrite::~deMutexReadWrite() { } void deMutexReadWrite::lockRead() { readSemaphore.wait(); } void deMutexReadWrite::unlockRead() { readSemaphore.post(); } void deMutexReadWrite::lockWrite() { int i; for (i = 0; i < maxReaders; i++) { readSemaphore.wait(); } writeMutex.lock(); } void deMutexReadWrite::unlockWrite() { writeMutex.unlock(); int i; for (i = 0; i < maxReaders; i++) { readSemaphore.post(); } } delaboratory-0.8/gui_wx/image_panel.cc0000644000175100001440000001367311771712213017133 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "image_panel.h" #include #include "project.h" #include "base_layer.h" #include "layer_processor.h" #include #include "str.h" #include "layer_frame_manager.h" #include "zoom_manager.h" #include "zoom_panel.h" #include "image_area_panel.h" #include "canvas_wx.h" void deImagePanel::click(wxMouseEvent &event) { int ex = event.GetX(); int ey = event.GetY(); int xx; int yy; GetSize(&xx, &yy); float x = (float) ex / xx; float y = (float) ey / yy; clicked = true; onClick(x,y); } void deImagePanel::release(wxMouseEvent &event) { clicked = false; onRelease(); project.getLayerProcessor().onGUIUpdate(); } void deImagePanel::move(wxMouseEvent &event) { int ex = event.GetX(); int ey = event.GetY(); int xx; int yy; GetSize(&xx, &yy); float x = (float) ex / xx; float y = (float) ey / yy; if (clicked) { if (onMove(x,y)) { project.getLayerProcessor().onGUIUpdate(); } } } void deImagePanel::wheel(wxMouseEvent &event) { } bool deImagePanel::onClick(deValue x, deValue y) { if (zoomManager.isInSelectionMode()) { bool result = zoomManager.onClick(x, y); zoomPanel->updateButtons(); return result; } bool used = project.getLayerFrameManager().onImageClick(x, y); if (!used) { used = samplerManager.onClick(x, y); if (used) { project.getLayerProcessor().onGUIUpdate(); } } return used; } bool deImagePanel::onMove(deValue x, deValue y) { if (zoomManager.isInSelectionMode()) { bool result = zoomManager.onMove(x, y); zoomPanel->updateButtons(); return result; } bool used = project.getLayerFrameManager().onImageClick(x, y); if (!used) { used = samplerManager.onMove(x, y); } return used; } bool deImagePanel::onRelease() { if (zoomManager.isInSelectionMode()) { bool result = zoomManager.onRelease(); zoomPanel->updateButtons(); area->updateSize(false); return result; } samplerManager.onRelease(); return false; } deImagePanel::deImagePanel(deImageAreaPanel* _area, deProject& _project, deSamplerManager& _samplerManager, deZoomManager& _zoomManager, deZoomPanel* _zoomPanel) :wxPanel(_area, wxID_ANY, wxDefaultPosition, wxDefaultSize), area(_area), project(_project), samplerManager(_samplerManager), zoomManager(_zoomManager), zoomPanel(_zoomPanel) { clicked = false; Connect(wxEVT_PAINT, wxPaintEventHandler(deImagePanel::paintEvent)); Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(deImagePanel::click)); Connect(wxEVT_LEFT_UP, wxMouseEventHandler(deImagePanel::release)); Connect(wxEVT_MOTION, wxMouseEventHandler(deImagePanel::move)); Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(deImagePanel::wheel)); } deImagePanel::~deImagePanel() { } void deImagePanel::paintEvent(wxPaintEvent & evt) { logInfo("paint event start"); project.getLayerProcessor().lockLayerProcessor(); int view = project.getLayerProcessor().getLastValidLayer(); if (view >= 0) { wxBufferedPaintDC dc(this); deCanvasWX canvas(dc); canvas.clear(); render(canvas); } else { } project.getLayerProcessor().unlockLayerProcessor(); logInfo("paint event DONE"); } void deImagePanel::repaintImagePanel() { int view = project.getLayerProcessor().getLastValidLayer(); if (view >= 0) { wxClientDC dc(this); wxBufferedDC bufferedDC(&dc); deCanvasWX canvas(bufferedDC); canvas.clear(); render(canvas); } else { } } void deImagePanel::render(deCanvas& canvas) { project.getLayerProcessor().render(canvas); if (samplerManager.getMoving()) { drawSamplers(canvas); } if (zoomManager.isInSelectionMode()) { drawSelection(canvas); } } void deImagePanel::drawSamplers(deCanvas& canvas) { int w; int h; GetSize(&w, &h); int n = samplerManager.getNumberOfSamplers(); int selected = samplerManager.getSelected(); int i; for (i = 0; i < n; i++) { deSampler* sampler = samplerManager.getSampler(i); if (sampler->isEnabled()) { if (i == selected) { canvas.setPen(200, 200, 200); } else { canvas.setPen(0, 0, 0); } float x = sampler->getX(); float y = sampler->getY(); if ((x >= 0) && (y >= 0) && (x <= 1) && (y<= 1)) { canvas.drawCircle(w * x, h * y, 5); } } } } void deImagePanel::drawSelection(deCanvas& canvas) { int w; int h; GetSize(&w, &h); deValue x1; deValue y1; deValue x2; deValue y2; zoomManager.getSelection(x1, y1, x2, y2); int xx1 = w * x1; int yy1 = h * y1; int xx2 = w * x2; int yy2 = h * y2; canvas.setPen(220, 220, 220); canvas.drawLine(xx1, yy1, xx2, yy1); canvas.drawLine(xx1, yy2, xx2, yy2); canvas.drawLine(xx1, yy1, xx1, yy2); canvas.drawLine(xx2, yy1, xx2, yy2); } delaboratory-0.8/gui_wx/message_box.h0000644000175100001440000000156611765506775017047 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_MESSAGE_BOX_H #define _DE_MESSAGE_BOX_H #include void showMessageBox(const std::string& s); void sleep(int ms); #endif delaboratory-0.8/gui_wx/main_window.cc0000644000175100001440000001104211766762751017211 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "main_window.h" #include "main_frame.h" #include class deMainWindowImpl { private: deMainFrame* frame; wxTimer* rawTimer; public: deMainWindowImpl() { frame = NULL; } ~deMainWindowImpl() { } void init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui) { frame = new deMainFrame( wxSize(width,height), project, layerProcessor, samplerManager, zoomManager, dcrawVersion, operationProcessor, channelManager, gui); rawTimer = new wxTimer(frame, wxID_ANY); } void show() { if (frame) { frame->Show(TRUE); } } void setTopWindow() { if (frame) { //SetTopWindow(frame); } } void postEvent(int e, int arg) { if (frame) { wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, e ); event.SetInt(arg); wxPostEvent( frame, event ); } } void generateHistogram() { if (frame) { frame->generateHistogram(); } } void onKey(int key) { if (frame) { frame->onKey(key); } } void rebuild() { if (frame) { frame->rebuild(); } } void setImageName(const std::string& _imageName, const deSize& _size) { if (frame) { frame->setImageName(_imageName, _size); } } void startRawTimer() { rawTimer->Start(500); } void stopRawTimer() { rawTimer->Stop(); } void updateWarning() { if (frame) { frame->updateWarning(); } } void forceUpdateSize() { if (frame) { frame->forceUpdateSize(); } } }; deMainWindow::deMainWindow() { impl = new deMainWindowImpl(); } deMainWindow::~deMainWindow() { delete impl; } void deMainWindow::init(int width, int height, deProject& project, deLayerProcessor& layerProcessor, deSamplerManager& samplerManager, deZoomManager& zoomManager, const std::string& dcrawVersion, deOperationProcessor& operationProcessor, deChannelManager& channelManager, deGUI& gui) { impl->init( width, height, project, layerProcessor, samplerManager, zoomManager, dcrawVersion, operationProcessor, channelManager, gui); } void deMainWindow::show() { impl->show(); } void deMainWindow::setTopWindow() { impl->setTopWindow(); } void deMainWindow::postEvent(int event, int arg) { impl->postEvent(event, arg); } void deMainWindow::generateHistogram() { impl->generateHistogram(); } void deMainWindow::onKey(int key) { impl->onKey(key); } void deMainWindow::rebuild() { impl->rebuild(); } void deMainWindow::setImageName(const std::string& _imageName, const deSize& _size) { impl->setImageName(_imageName, _size); } void deMainWindow::startRawTimer() { impl->startRawTimer(); } void deMainWindow::stopRawTimer() { impl->stopRawTimer(); } void deMainWindow::updateWarning() { impl->updateWarning(); } void deMainWindow::forceUpdateSize() { impl->forceUpdateSize(); } delaboratory-0.8/gui_wx/semaphore.cc0000644000175100001440000000253311764477311016657 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "semaphore.h" #include class deSemaphoreImpl { private: wxSemaphore semaphore; public: deSemaphoreImpl(int a, int b) :semaphore(a, b) { } ~deSemaphoreImpl() { } void wait() { semaphore.Wait(); } void post() { semaphore.Post(); } }; deSemaphore::deSemaphore(int a, int b) { impl = new deSemaphoreImpl(a, b); } deSemaphore::~deSemaphore() { delete impl; } void deSemaphore::wait() { impl->wait(); } void deSemaphore::post() { impl->post(); } delaboratory-0.8/gui_wx/str_wx.cc0000644000175100001440000000265012005061147016203 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "str_wx.h" #include std::string str(const wxString& ws) { char cstring[1024]; strncpy(cstring, (const char*)ws.mb_str(wxConvUTF8), 1023); return cstring; } wxString str2wx(const std::string& s) { const char* c = s.c_str(); wxString result(c, wxConvUTF8); return result; } std::string getUserDataDir() { wxStandardPathsBase& paths = wxStandardPaths::Get(); wxString ucd = paths.GetUserDataDir(); std::string userDataDir = str(ucd); #ifdef _WIN32 userDataDir += "\\delaboratory"; #else #ifdef __WXOSX_MAC__ userDataDir += "/delaboratory"; #else userDataDir += "/.delaboratory"; #endif #endif return userDataDir; } delaboratory-0.8/gui_wx/control_panel.cc0000644000175100001440000001357512004107537017527 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "control_panel.h" #include "project.h" #include "base_layer.h" #include "layer_factory.h" #include "file_dialogs.h" #include "layer_processor.h" #include "wx/notebook.h" #include "layer_stack.h" #include "layer_frame_manager.h" #include "color_space_utils.h" #include "operation_processor.h" const int g_txt = 220; deControlPanel::deControlPanel(wxWindow* parent, deProject& _project, deLayerProcessor& _processor, deOperationProcessor& _operationProcessor, deChannelManager& _channelManager) :wxPanel(parent), project(_project), layerProcessor(_processor), operationProcessor(_operationProcessor), channelManager(_channelManager) { mainSizer = new wxBoxSizer(wxVERTICAL); SetSizer(mainSizer); int bw2 = 140; int bw3 = 90; int bh = 32; wxNotebook* notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("notebook")); mainSizer->Add(notebook, 1, wxEXPAND); { wxPanel* basicPanel = new wxPanel(notebook); notebook->AddPage(basicPanel, _T("colors")); std::vector operations; getSupportedColorsOperations(operations); wxSizer* gridSizer = new wxGridSizer(2); basicPanel->SetSizer(gridSizer); std::vector::iterator j; for (j = operations.begin(); j != operations.end(); j++) { std::string d = *j; wxButton* b = new wxButton(basicPanel, wxID_ANY, wxString::FromAscii(d.c_str()), wxDefaultPosition, wxSize(bw2,bh)); gridSizer->Add(b); actionButtons.push_back(b); actionButtonsNames[b->GetId()] = *j; } } { wxPanel* basicPanel = new wxPanel(notebook); notebook->AddPage(basicPanel, _T("other")); std::vector operations; getSupportedOtherOperations(operations); wxSizer* gridSizer = new wxGridSizer(2); basicPanel->SetSizer(gridSizer); std::vector::iterator j; for (j = operations.begin(); j != operations.end(); j++) { std::string d = *j; wxButton* b = new wxButton(basicPanel, wxID_ANY, wxString::FromAscii(d.c_str()), wxDefaultPosition, wxSize(bw2,bh)); gridSizer->Add(b); actionButtons.push_back(b); actionButtonsNames[b->GetId()] = *j; } } { std::vector actions; getSupportedActions(actions); wxPanel* actionsPanel = new wxPanel(notebook); notebook->AddPage(actionsPanel, _T("expert")); wxSizer* gridSizer = new wxGridSizer(3); actionsPanel->SetSizer(gridSizer); std::vector::iterator j; for (j = actions.begin(); j != actions.end(); j++) { std::string actionDescription = getActionDescription(*j); wxButton* b = new wxButton(actionsPanel, wxID_ANY, wxString::FromAscii(actionDescription.c_str()), wxDefaultPosition, wxSize(bw3,bh)); gridSizer->Add(b); actionButtons.push_back(b); actionButtonsNames[b->GetId()] = *j; } } { wxPanel* conversionsPanel = new wxPanel(notebook); notebook->AddPage(conversionsPanel, _T("colorspace")); std::vector colorSpaces; getSupportedColorSpaces(colorSpaces); wxSizer* gridSizer = new wxGridSizer(3); conversionsPanel->SetSizer(gridSizer); std::vector::iterator i; for (i = colorSpaces.begin(); i != colorSpaces.end(); i++) { std::string n = getColorSpaceName(*i); wxButton* b = new wxButton(conversionsPanel, wxID_ANY, wxString::FromAscii(n.c_str()), wxDefaultPosition, wxSize(bw3,bh)); gridSizer->Add(b); convertButtons.push_back(b); convertButtonsColorSpaces[b->GetId()] = *i; } } wxSizer* hSizer = new wxBoxSizer(wxHORIZONTAL); mainSizer->Add(hSizer, 0, wxCENTER); wxSizer* sizerD = new wxStaticBoxSizer(wxVERTICAL, this, _T("delete")); hSizer->Add(sizerD, 1, wxCENTER); { deleteLayer = new wxButton(this, wxID_ANY, _T("delete top layer")); sizerD->Add(deleteLayer, 0, wxCENTER); } Layout(); Fit(); Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(deControlPanel::click)); } deControlPanel::~deControlPanel() { } void deControlPanel::click(wxCommandEvent &event) { int id = event.GetId(); if (deleteLayer->GetId() == id) { logInfo("delete layer clicked"); deLayerStack& layerStack = project.getLayerStack(); int index = layerStack.getSize() - 1; project.getLayerFrameManager().onDestroyLayer(index); operationProcessor.execute("remove"); } std::map::iterator c = convertButtonsColorSpaces.find(id); if (c != convertButtonsColorSpaces.end()) { deColorSpace colorSpace = c->second; operationProcessor.execute(getColorSpaceName(colorSpace)); } std::map::iterator a = actionButtonsNames.find(id); if (a != actionButtonsNames.end()) { std::string action = a->second; operationProcessor.execute(action); } } delaboratory-0.8/gui_wx/property_choice_ui.cc0000644000175100001440000000342611764477311020571 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "property_choice_ui.h" #include "property_choice.h" #include "base_layer.h" #include "layer_processor.h" #include "layer_frame.h" dePropertyChoiceUI::dePropertyChoiceUI(deWindow& window, dePropertyChoice& _property, deLayerProcessor& _layerProcessor, int _layerIndex, deLayerFrame& _parent) :deChoice(window, _property.getName(), _property.getChoices()), property(_property), layerProcessor(_layerProcessor), layerIndex(_layerIndex), parent(_parent) { setFromProperty(); } dePropertyChoiceUI::~dePropertyChoiceUI() { } void dePropertyChoiceUI::onChoose(int index) { property.setIndex(index); if (property.affectOthers()) { parent.setUIFromLayer(); } if (property.affectSize()) { layerProcessor.forceUpdateSize(); } if (property.updateBlendOnly()) { layerProcessor.markUpdateBlendAllChannels(layerIndex); } else { layerProcessor.markUpdateAllChannels(layerIndex); } } void dePropertyChoiceUI::setFromProperty() { int index = property.getIndex(); set(index); } delaboratory-0.8/gui_wx/color_space_utils.h0000644000175100001440000000362011764477311020245 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COLOR_SPACE_UTILS_H #define _DE_COLOR_SPACE_UTILS_H #include "color_space.h" #include "value.h" #include #include int getColorSpaceSize(const deColorSpace& colorSpace); void getColorSpaceChannelRanges(const deColorSpace& colorSpace, int index, deValue& min, deValue& max); std::string getColorSpaceName(deColorSpace colorSpace); std::string getChannelName(deColorSpace colorSpace, int channel); deColorSpace colorSpaceFromString(const std::string& name); void getSupportedColorSpaces(std::vector& result); void getSupportedConversions(const deColorSpace& colorSpace, std::vector& result); deValue getPresentationValue(deColorSpace colorSpace, int channel, deValue v); bool isChannelLuminance(deColorSpace colorSpace, int channel); bool shouldChannelBeSharpened(deColorSpace colorSpace, int channel); int getEqualizerChannel(deColorSpace colorSpace); bool isChannelWrapped(deColorSpace colorSpace, int channel); bool isActionSupported(const std::string& action, deColorSpace colorSpace); bool shouldUseAutoLevels(deColorSpace colorSpace, int channel); std::vector getChannelNames(deColorSpace colorSpace); #endif delaboratory-0.8/algorithms/0000755000175100001440000000000012005331267015215 5ustar jacekusersdelaboratory-0.8/algorithms/gradient.cc0000644000175100001440000000417511774100224017327 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "gradient.h" #include #include #include "logger.h" #include "str.h" void gradientChannel(deValue* destination, deSize size, deValue cx, deValue cy, deValue r, deValue a, deValue sinus) { int w = size.getW(); int h = size.getH(); if (w == 0) { return; } if (h == 0) { return; } deValue ww = w / 2.0; deValue hh = h / 2.0; int i; int j; int p = 0; deValue angle = 2 * M_PI * (a / 360.0); deValue vx = sin (angle); deValue vy = cos (angle); deValue div; if (r > 0) { div = 1.0 / (r + 0.1); } else { div = 1.0 / (r - 0.1); } for (i = 0; i < h; i++) { deValue y = (i - hh) / hh; deValue yy = y - cy; for (j = 0; j < w; j++) { deValue x = (j - ww) / ww; deValue xx = x - cx; deValue rr = (yy * vy + xx * vx) * div; rr = 1.0 - rr; if (sinus > 0) { rr = 1.0 - sin (sinus * rr * M_PI); } else if (sinus < 0) { rr = sin (sinus * rr * M_PI); } if (rr < 0) { rr = -rr; } if (rr > 1) { rr = 1; } destination[p] = rr; p++; } } } delaboratory-0.8/algorithms/blur.h0000644000175100001440000000174111764477311016351 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BLUR_H #define _DE_BLUR_H #include "value.h" #include "blur_type.h" #include "size.h" bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t); #endif delaboratory-0.8/algorithms/c2g.cc0000644000175100001440000000747511764477311016230 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "c2g.h" #include #include #include "radial_lut.h" #include "logger.h" #include "str.h" void c2g(const deValue* source0, const deValue* source1, const deValue* source2, deValue* mask, const deSize& size, deValue r, int samples) { int w = size.getW(); int h = size.getH(); int lutsize = 10 * 1024; deRadialLUT lut(lutsize, r); int* offsets = new int [samples]; int x; for (x = 0; x < w; x++) { int y; for (y = 0; y < h; y++) { int p = w * y + x; deValue v0 = source0[p]; deValue v1 = source1[p]; deValue v2 = source2[p]; deValue min0 = 1.0; deValue max0 = 0.0; deValue min1 = 1.0; deValue max1 = 0.0; deValue min2 = 1.0; deValue max2 = 0.0; int offset = lut.getStart(samples); int i = 0; while (i < samples) { int xx; int yy; lut.get(offset, xx, yy); xx += x; yy += y; if ((xx >= 0) && (xx < w) && (yy >= 0) && (yy < h)) { int pp = w * yy + xx; offsets[i] = pp; i++; } offset++; if (offset >= lutsize) { offset = 0; } } for (i = 0; i < samples; i++) { int pp = offsets[i]; deValue vv0 = source0[pp]; deValue vv1 = source1[pp]; deValue vv2 = source2[pp]; if (vv0 < min0) { min0 = vv0; } if (vv0 > max0) { max0 = vv0; } if (vv1 < min1) { min1 = vv1; } if (vv1 > max1) { max1 = vv1; } if (vv2 < min2) { min2 = vv2; } if (vv2 > max2) { max2 = vv2; } } deValue n0 = v0 - min0; deValue d0 = v0 - max0; deValue n1 = v1 - min1; deValue d1 = v1 - max1; deValue n2 = v2 - min2; deValue d2 = v2 - max2; deValue n = sqrt(n0 * n0 + n1 * n1 + n2 * n2); deValue d = sqrt(d0 * d0 + d1 * d1 + d2 * d2); d = d + n; deValue result; if (d != 0) { result = n / d; if (result < 0) { result = 0; } else if (result > 1) { result = 1; } } else { result = (v0 + v1 + v2) / 3.0; } mask[p] = result; } } delete [] offsets; } delaboratory-0.8/algorithms/radial_lut.cc0000644000175100001440000000306711764477311017666 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "radial_lut.h" #include #include "value.h" #include deRadialLUT::deRadialLUT(int _size, int r) :size(_size) { lut = new int [2 * size]; srand(0); int i; for (i = 0; i < size; i++) { deValue angle = (rand () % 1024) / 1024.0 * 2 * M_PI; deValue radius_1 = ((rand () % 1024) / 1024.0 * r + 1.0); deValue radius_2 = ((rand () % 1024) / 1024.0 * radius_1 + 1.0); int xx = sin(angle) * radius_2; int yy = cos(angle) * radius_2; lut[2*i+0] = xx; lut[2*i+1] = yy; } } deRadialLUT::~deRadialLUT() { delete [] lut; } void deRadialLUT::get(int i, int& x, int& y) const { if ((i >= 0) && (i < size)) { x = lut[2*i+0]; y = lut[2*i+1]; } } int deRadialLUT::getStart(int s) const { return rand() % (size - s); } delaboratory-0.8/algorithms/c2g.h0000644000175100001440000000171311764477311016057 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_C2G_H #define _DE_C2G_H #include "value.h" #include "size.h" void c2g(const deValue* source0, const deValue* source1, const deValue* source2, deValue* mask, const deSize& size, deValue r, int samples); #endif delaboratory-0.8/algorithms/vignette.cc0000644000175100001440000000645511767140432017371 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "vignette.h" #include #include #include "logger.h" #include "str.h" deEllipse::deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY) :centerX(_centerX), centerY(_centerY), radiusX(_radiusX), radiusY(_radiusY) { } deEllipse::~deEllipse() { } deValue deEllipse::processX(deValue x) const { x = x - centerX; x /= radiusX; return x; } deValue deEllipse::processY(deValue y) const { y = y - centerY; y /= radiusY; return y; } bool deEllipse::isValid() const { if (radiusX <= 0.0) { return false; } if (radiusY <= 0.0) { return false; } return true; } void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot) { logInfo("vignette start"); if (!destination) { logError("NULL channel in vignette"); return; } if (!ellipse.isValid()) { logError("invalid ellipce in ignette"); return; } int w = size.getW(); int h = size.getH(); if (w == 0) { return; } if (h == 0) { return; } deValue ww = w / 2.0; deValue hh = h / 2.0; int i; int j; int p = 0; for (i = 0; i < h; i++) { deValue y = (i - hh) / hh; y = ellipse.processY(y); for (j = 0; j < w; j++) { deValue x = (j - ww) / ww; x = ellipse.processX(x); deValue r = 1.0; deValue rr = x * x + y * y; // if (rr <= 1.0) { r = sqrt(rr); } deValue v = 1.0 - r; if (v > 0) { v = sin(v * M_PI / 2); } deValue vv = darkness + (light - darkness) * v; if (vv < 0) { vv = 0; } if (vv > 1) { vv = 1; } destination[p] = vv; p++; } } logInfo("vignette DONE"); } deEllipse calcEllipse(deValue radX, deValue radY, deValue cenX, deValue cenY, deValue x1, deValue y1, deValue x2, deValue y2) { deValue w = x2 - x1; deValue h = y2 - y1; deValue rx = radX / w; deValue ry = radY / h; // 0..1 deValue ccx = (cenX + 1.0) / 2.0; deValue ccy = (cenY + 1.0) / 2.0; deValue cccx = (ccx - x1) / w; deValue cccy = (ccy - y1) / h; // -1..1 deValue cx = cccx * 2.0 - 1.0; deValue cy = cccy * 2.0 - 1.0; return deEllipse(cx, cy, rx, ry); } delaboratory-0.8/algorithms/blend_mode.cc0000644000175100001440000001776711764477311017652 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "blend_mode.h" #include std::string getBlendModeName(deBlendMode mode) { switch (mode) { case deBlendNormal: return "normal"; case deBlendNone: return "none"; case deBlendMultiply: return "multiply"; case deBlendScreen: return "screen"; case deBlendOverlay: return "overlay"; case deBlendOverlayInvert: return "overlay invert"; case deBlendAdd: return "add"; case deBlendGrainExtract: return "graint extract"; case deBlendGrainMerge: return "graint merge"; case deBlendSub: return "sub"; case deBlendDifference: return "difference"; case deBlendDarken: return "darken"; case deBlendLighten: return "lighten"; case deBlendDodge: return "dodge"; case deBlendBurn: return "burn"; case deBlendColor: return "color"; case deBlendLuminosity: return "luminosity"; default: return "unknown"; } } deBlendMode blendModeFromString(const std::string& s) { if (s == "normal") { return deBlendNormal; } if (s == "none") { return deBlendNone; } if (s == "multiply") { return deBlendMultiply; } if (s == "screen") { return deBlendScreen; } if (s == "overlay") { return deBlendOverlay; } if (s == "overlay invert") { return deBlendOverlayInvert; } if (s == "add") { return deBlendAdd; } if (s == "grain extract") { return deBlendGrainExtract; } if (s == "grain merge") { return deBlendGrainMerge; } if (s == "sub") { return deBlendSub; } if (s == "difference") { return deBlendDifference; } if (s == "darken") { return deBlendDarken; } if (s == "lighten") { return deBlendLighten; } if (s == "dodge") { return deBlendDodge; } if (s == "burn") { return deBlendBurn; } if (s == "color") { return deBlendColor; } if (s == "luminosity") { return deBlendLuminosity; } return deBlendInvalid; } std::vector getSupportedBlendModes(deColorSpace colorSpace) { std::vector result; result.push_back(deBlendNormal); result.push_back(deBlendNone); result.push_back(deBlendMultiply); result.push_back(deBlendScreen); result.push_back(deBlendOverlay); result.push_back(deBlendOverlayInvert); result.push_back(deBlendAdd); result.push_back(deBlendGrainExtract); result.push_back(deBlendGrainMerge); result.push_back(deBlendSub); result.push_back(deBlendDifference); result.push_back(deBlendDarken); result.push_back(deBlendLighten); result.push_back(deBlendDodge); result.push_back(deBlendBurn); if ((colorSpace == deColorSpaceRGB) || (colorSpace == deColorSpaceProPhoto) || (colorSpace == deColorSpaceCMYK)) { result.push_back(deBlendColor); result.push_back(deBlendLuminosity); } return result; } std::vector getSupportedBlendModeNames(deColorSpace colorSpace) { std::vector modes = getSupportedBlendModes(colorSpace); std::vector result; std::vector::const_iterator i; for (i = modes.begin(); i != modes.end(); i++) { result.push_back(getBlendModeName(*i)); } return result; } deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode) { switch (mode) { case deBlendNormal: return v2; break; case deBlendNone: return src; break; case deBlendMultiply: return src*v2; break; case deBlendScreen: return 1 - (1-src)*(1-v2); break; case deBlendOverlay: if (src > 0.5) { return 1 - (1 - 2 * ( src - 0.5)) * (1 - v2); } else { return 2 * src * v2; } break; case deBlendOverlayInvert: if (src > 0.5) { return 1 - (1 - 2 * ( src - 0.5)) * v2; } else { return 2 * src * (1 - v2); } break; case deBlendAdd: { deValue v = src + v2; if (v < 0) { return 0; } if (v > 1) { return 1; } return v; break; } case deBlendGrainExtract: { deValue v = 0.5 + src - v2; if (v < 0) { return 0; } if (v > 1) { return 1; } return v; break; } case deBlendGrainMerge: { deValue v = src + v2 - 0.5; if (v < 0) { return 0; } if (v > 1) { return 1; } return v; break; } case deBlendSub: { deValue v = src - v2; if (v < 0) { return 0; } if (v > 1) { return 1; } return v; break; } case deBlendDifference: return fabs(src - v2); break; case deBlendDarken: if (src < v2) { return src; } else { return v2; } break; case deBlendLighten: if (src > v2) { return src; } else { return v2; } break; case deBlendDodge: { deValue d = 1 - v2; if (d == 0) { return 1.0; } else { deValue r = src / d; if ( r > 1) { return 1; } else { return r; } } break; } case deBlendBurn: { if (v2 == 0) { return 0.0; } else { deValue v = (1 - src) / v2; if (v > 1) { v = 1; } deValue r = 1 - v; return r; } break; } default: return 0; } } delaboratory-0.8/algorithms/vignette.h0000644000175100001440000000270611764477311017234 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_VIGNETTE_H #define _DE_VIGNETTE_H #include "value.h" #include "size.h" class deEllipse { private: deValue centerX; deValue centerY; deValue radiusX; deValue radiusY; public: deEllipse(deValue _centerX, deValue _centerY, deValue _radiusX, deValue _radiusY); virtual ~deEllipse(); deValue processX(deValue x) const; deValue processY(deValue y) const; bool isValid() const; }; void vignetteChannel(deValue* destination, deSize size, deEllipse ellipse, deValue light, deValue darkness, deValue spot); deEllipse calcEllipse(deValue radX, deValue radY, deValue cenX, deValue cenY, deValue x1, deValue y1, deValue x2, deValue y2); #endif delaboratory-0.8/algorithms/scale_channel.h0000644000175100001440000000200111777136356020157 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SCALE_CHANNEL_H #define _DE_SCALE_CHANNEL_H #include "value.h" void scaleChannel(const deValue* src, deValue* dst, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, int w, int h, bool mirrorX, bool mirrorY, int rotate, int ws, int hs, deValue contrast); #endif delaboratory-0.8/algorithms/blend_channel.h0000644000175100001440000000200711764477311020155 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BLEND_CHANNEL_H #define _DE_BLEND_CHANNEL_H #include "value.h" #include "blend_mode.h" void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize); #endif delaboratory-0.8/algorithms/blur.cc0000644000175100001440000001675311764477311016520 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "blur.h" #include #include #include "logger.h" void boxBlur(deValue* source, deValue* destination, int n, int s) { int i; for (i = 0; i < n; i++) { deValue result = 0.0; int n1 = i - s + 1; int n2 = i + s - 1; if (n1 < 0) { n1 = 0; } if (n2 >= n) { n2 = n - 1; } int j; for (j = n1; j <= n2; j++) { result += source[j]; } destination[i] = result / (n2 - n1 + 1.0); } } void gaussianBlur(deValue* source, deValue* destination, int n, int s, deValue* weights) { int i; for (i = 0; i < n; i++) { deValue result = 0.0; deValue sum = 0.0; int n1 = i - s + 1; int n2 = i + s - 1; if (n1 < 0) { n1 = 0; } if (n2 >= n) { n2 = n - 1; } int j; int p; j = n1; p = i - n1; while (p >= 0) { deValue v = source[j]; deValue w = weights[p]; result += w * v; sum += w; p--; j++; } p = 1; while (j <= n2) { deValue v = source[j]; deValue w = weights[p]; result += w * v; sum += w; p++; j++; } destination[i] = result / sum; } } void surfaceBlur(deValue* source, deValue* destination, int n, int s, deValue* weights, deValue t) { deValue tt = 1.0 - t; int i; for (i = 0; i < n; i++) { deValue result = 0.0; deValue sum = 0.0; deValue reference = source[i]; int n1 = i - s + 1; int n2 = i + s - 1; if (n1 < 0) { n1 = 0; } if (n2 >= n) { n2 = n - 1; } int j; int p; j = n1; p = i - n1; while (p >= 0) { deValue v = source[j]; if (fabs(v - reference) <= tt) { deValue w = weights[p]; result += w * v; sum += w; } p--; j++; } p = 1; while (j <= n2) { deValue v = source[j]; if (fabs(v - reference) <= tt) { deValue w = weights[p]; result += w * v; sum += w; } p++; j++; } destination[i] = result / sum; } } void fillWeightsFlat(deValue* weights, int blurSize) { int i; for (i = 0 ; i < blurSize; i++) { weights[i] = 1.0; } } void fillWeightsGaussian(deValue* weights, int blurSize) { int i; deValue radius = blurSize / 3.0; deValue rr2 = 2.0 * radius * radius; for (i = 0 ; i < blurSize; i++) { deValue ii = i * i; deValue ee = exp( - ii / rr2 ); weights[i] = 1.0 / sqrt(rr2 * M_PI) * ee; } } bool blurChannel(const deValue* source, deValue* destination, deSize size, deValue radiusX, deValue radiusY, deBlurType type, deValue t) { assert(source); assert(destination); int w = size.getW(); int h = size.getH(); if (w == 0) { return false; } if (h == 0) { return false; } if ((radiusX <= 0) || (radiusY <= 0)) { return false; } assert(w > 0); assert(h > 0); int min = 1; int blurSizeW = radiusX; if (blurSizeW < min) { blurSizeW = min; } int blurSizeH = radiusY; if (blurSizeH < min) { blurSizeH = min; } int maxSize = blurSizeW; if (blurSizeH > maxSize) { maxSize = blurSizeH; } int max = w; if (h > max) { max = h; } deValue* tmp = NULL; try { tmp = new deValue[size.getN()]; } catch (std::bad_alloc) { logError("allocating memory in blur"); if (tmp) { delete [] tmp; } return false; } deValue* sourceBuffer = new deValue[max]; deValue* destinationBuffer = new deValue[max]; deValue* weights = NULL; if (type != deBoxBlur) { weights = new deValue[maxSize]; } int i; int j; { if (type != deBoxBlur) { fillWeightsGaussian(weights, blurSizeW); } for (i = 0; i < h; i++) { int p = i * w; for (j = 0; j < w; j++) { sourceBuffer[j] = source[p + j]; } switch (type) { case deBoxBlur: { boxBlur(sourceBuffer, destinationBuffer, w, blurSizeW); break; } case deGaussianBlur: { gaussianBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights); break; } case deSurfaceBlur: { surfaceBlur(sourceBuffer, destinationBuffer, w, blurSizeW, weights, t); break; } default: break; } for (j = 0; j < w; j++) { tmp[p + j] = destinationBuffer[j]; } } } { if (type != deBoxBlur) { fillWeightsGaussian(weights, blurSizeH); } for (i = 0; i < w; i++) { for (j = 0; j < h; j++) { sourceBuffer[j] = tmp[j * w + i]; } switch (type) { case deBoxBlur: { boxBlur(sourceBuffer, destinationBuffer, h, blurSizeH); break; } case deGaussianBlur: { gaussianBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights); break; } case deSurfaceBlur: { surfaceBlur(sourceBuffer, destinationBuffer, h, blurSizeH, weights, t); break; } default: break; } for (j = 0; j < h; j++) { destination[j * w + i] = destinationBuffer[j]; } } } delete [] tmp; if (type != deBoxBlur) { delete [] weights; } delete [] destinationBuffer; delete [] sourceBuffer; return true; } delaboratory-0.8/algorithms/blend_channel.cc0000644000175100001440000000401611766762751020324 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "blend_channel.h" #include #include "logger.h" void blendChannel(const deValue* sourcePixels, const deValue* overlayPixels, deValue* resultPixels, deValue* maskPixels, deBlendMode blendMode, deValue opacity, int channelSize) { if (!sourcePixels) { logError("no source pixels in blend channel"); return; } if (!overlayPixels) { logError("no overlay pixels in blend channel"); return; } if (!resultPixels) { logError("no result pixels in blend channel"); return; } int j; if (maskPixels) { for (j = 0; j < channelSize; j++) { deValue src = sourcePixels[j]; deValue ov = overlayPixels[j]; deValue dst = calcBlendResult(src, ov, blendMode); deValue m = maskPixels[j] * opacity; deValue result = (1 - m) * src + m * dst; resultPixels[j] = result; } } else { for (j = 0; j < channelSize; j++) { deValue src = sourcePixels[j]; deValue ov = overlayPixels[j]; deValue dst = calcBlendResult(src, ov, blendMode); deValue result = (1 - opacity) * src + opacity * dst; resultPixels[j] = result; } } } delaboratory-0.8/algorithms/scale_channel.cc0000644000175100001440000000507311777136356020331 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "scale_channel.h" #include "sample_pixel.h" void scaleChannel(const deValue* src, deValue* dst, deValue z_x1, deValue z_y1, deValue z_x2, deValue z_y2, int w, int h, bool mirrorX, bool mirrorY, int rotate, int ws, int hs, deValue contrast) { int x1; int y1; int x2; int y2; x1 = ws * z_x1; y1 = hs * z_y1; x2 = ws * z_x2; y2 = hs * z_y2; if ((rotate == 90) || (rotate == 270)) { x1 = hs * z_x1; y1 = ws * z_y1; x2 = hs * z_x2; y2 = ws * z_y2; } deValue scaleW; deValue scaleH; deValue dx = x2 - x1; deValue dy = y2 - y1; scaleW = dx / w; scaleH = dy / h; if (scaleW <= 0) { } if (scaleH <= 0) { } int yy1; int yy2; int xx1; int xx2; int x; for (x = 0; x < w; x++) { xx1 = scaleW * x; xx2 = scaleW * (x + 1); int y; for (y = 0; y < h; y++) { yy1 = scaleH * y; yy2 = scaleH * (y + 1); deValue v = 1; if (rotate == 0) { v = samplePixel(src, x1 + xx1, x1 + xx2, y1 + yy1, y1 + yy2, mirrorX, mirrorY, ws, hs); } if (rotate == 90) { v = samplePixel(src, ws - 1 - yy2 - y1, ws - 1 - yy1 - y1, xx1 + x1, xx2 + x1, mirrorX, mirrorY, ws, hs); } if (rotate == 180) { v = samplePixel(src, ws - 1 - xx2 - x1, ws - 1 - xx1 - x1, hs - 1 - yy2 - y1, hs - 1 - yy1 - y1, mirrorX, mirrorY, ws, hs); } if (rotate == 270) { v = samplePixel(src, y1 + yy1, y1 + yy2, hs - 1 - xx2 - x1, hs - 1 - xx1 - x1, mirrorX, mirrorY, ws, hs); } dst[y * w + x] = contrast * v + 0.5 - 0.5 * contrast; } } } delaboratory-0.8/algorithms/sample_pixel.cc0000644000175100001440000000463511764477311020232 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "sample_pixel.h" deValue samplePixel(const deValue* src, int xx1, int xx2, int yy1, int yy2, bool mirrorX, bool mirrorY, int ws, int hs) { if (xx1 < 0) { xx1 = 0; } else if (xx1 >= ws) { xx1 = ws - 1; } if (xx2 < 0) { xx2 = 0; } else if (xx2 >= ws) { xx2 = ws - 1; } if (yy1 < 0) { yy1 = 0; } else if (yy1 >= hs) { yy1 = hs - 1; } if (yy2 < 0) { yy2 = 0; } else if (yy2 >= hs) { yy2 = hs - 1; } int n = 0; int x0; int y0; deValue value = 0.0; if ((!mirrorX) && (!mirrorY)) { for (x0 = xx1; x0 <= xx2; x0++) { for (y0 = yy1; y0 <= yy2; y0++) { value += src[x0 + y0 * ws]; n++; } } } if ((mirrorX) && (!mirrorY)) { for (x0 = xx1; x0 <= xx2; x0++) { for (y0 = yy1; y0 <= yy2; y0++) { value += src[(ws - 1 - x0) + y0 * ws]; n++; } } } if ((!mirrorX) && (mirrorY)) { for (x0 = xx1; x0 <= xx2; x0++) { for (y0 = yy1; y0 <= yy2; y0++) { value += src[x0 + (hs - 1 - y0) * ws]; n++; } } } if ((mirrorX) && (mirrorY)) { for (x0 = xx1; x0 <= xx2; x0++) { for (y0 = yy1; y0 <= yy2; y0++) { value += src[(ws - 1 - x0) + (hs - 1 - y0) * ws]; n++; } } } if (n == 0) { return 0.0; } return value / n; } delaboratory-0.8/algorithms/blur_type.cc0000644000175100001440000000326411764477311017552 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "blur_type.h" std::string getBlurTypeName(deBlurType type) { switch (type) { case deBoxBlur: return "box"; case deGaussianBlur: return "gaussian"; case deSurfaceBlur: return "surface"; default: return "unknown"; } } deBlurType blurTypeFromString(const std::string& s) { if (s == "box") { return deBoxBlur; } if (s == "gaussian") { return deGaussianBlur; } if (s == "surface") { return deSurfaceBlur; } return deBlurInvalid; } void getSupportedBlurTypes(std::vector& result) { result.push_back(deBoxBlur); result.push_back(deGaussianBlur); result.push_back(deSurfaceBlur); } std::vector getSupportedBlurTypes() { std::vector result; result.push_back("box"); result.push_back("gaussian"); result.push_back("surface"); return result; } delaboratory-0.8/algorithms/fill_channel.h0000644000175100001440000000155411764477311020025 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_COPY_CHANNEL_H #define _DE_COPY_CHANNEL_H #include "value.h" void fillChannel(deValue* dst, int n, deValue v); #endif delaboratory-0.8/algorithms/gradient.h0000644000175100001440000000167711774047603017210 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_GRADIENT_H #define _DE_GRADIENT_H #include "value.h" #include "size.h" void gradientChannel(deValue* destination, deSize size, deValue cx, deValue cy, deValue r, deValue a, deValue sinus); #endif delaboratory-0.8/algorithms/sample_pixel.h0000644000175100001440000000166311764477311020072 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_SAMPLE_PIXEL_H #define _DE_SAMPLE_PIXEL_H #include "value.h" deValue samplePixel(const deValue* src, int xx1, int xx2, int yy1, int yy2, bool mirrorX, bool mirrorY, int ws, int hs); #endif delaboratory-0.8/algorithms/blur_type.h0000644000175100001440000000216511764477311017413 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BLUR_TYPE_H #define _DE_BLUR_TYPE_H #include #include enum deBlurType { deBlurInvalid, deBoxBlur, deGaussianBlur, deSurfaceBlur }; std::string getBlurTypeName(deBlurType type); deBlurType blurTypeFromString(const std::string& s); void getSupportedBlurTypes(std::vector& result); std::vector getSupportedBlurTypes(); #endif delaboratory-0.8/algorithms/fill_channel.cc0000644000175100001440000000157711764477311020170 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "fill_channel.h" void fillChannel(deValue* dst, int n, deValue v) { int i; for (i = 0; i < n; i++) { dst[i] = v; } } delaboratory-0.8/algorithms/blend_mode.h0000644000175100001440000000275411764477311017502 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BLEND_MODES_H #define _DE_BLEND_MODES_H #include #include #include "value.h" #include "color_space.h" enum deBlendMode { deBlendInvalid, deBlendNormal, deBlendNone, deBlendMultiply, deBlendScreen, deBlendOverlay, deBlendOverlayInvert, deBlendDodge, deBlendBurn, deBlendAdd, deBlendGrainExtract, deBlendGrainMerge, deBlendSub, deBlendDifference, deBlendDarken, deBlendLighten, deBlendColor, deBlendLuminosity }; std::string getBlendModeName(deBlendMode mode); deValue calcBlendResult(deValue src, deValue v2, deBlendMode mode); deBlendMode blendModeFromString(const std::string& s); std::vector getSupportedBlendModeNames(deColorSpace colorSpace); #endif delaboratory-0.8/algorithms/usm.cc0000644000175100001440000001426011767142664016352 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "usm.h" #include "logger.h" #include "blur.h" #include "blend_channel.h" #include #include "image.h" #include "color_space_utils.h" void unsharpMask(const deValue* source, const deValue* mask, deValue* destination, int n, deValue a) { int i; for (i = 0; i < n; i++) { deValue src = source[i]; deValue u = src - mask[i]; deValue d = src + a * u; if (d < 0) { destination[i] = 0; } else if (d > 1) { destination[i] = 1; } else { destination[i] = d; } } } void unsharpMask(const deValue* source, const deValue* mask, deValue* destination, int n, deValue a, deValue t) { int i; for (i = 0; i < n; i++) { deValue src = source[i]; deValue u = src - mask[i]; if (fabs(2 * u) >= t) { deValue d = src + a * u; if (d < 0) { destination[i] = 0; } else if (d > 1) { destination[i] = 1; } else { destination[i] = d; } } else { destination[i] = src; } } } bool unsharpMask(const deValue* source, deValue* destination, deSize& size, deValue a, deValue r, deValue t, deBlurType type) { logInfo("unsharp mask start"); int n = size.getN(); deValue* mask = NULL; try { mask = new deValue [n]; } catch (std::bad_alloc) { logError("allocating memory in USM"); if (mask) { delete [] mask; } return false; } if (mask) { logInfo("mask allocated"); } else { logError("unable to allocate mask"); } deValue b_t = 0.0; if (blurChannel(source, mask, size, r, r, type, b_t)) { if (t > 0) { unsharpMask(source, mask, destination, n, a, t); } else { unsharpMask(source, mask, destination, n, a); } } delete [] mask; logInfo("unsharp mask DONE"); return true; } bool autoDodgeBurn(const deValue* source, deValue* destination, deSize& size, deValue r1, deValue r2, deValue t, bool burn) { int n = size.getN(); deValue* mask1 = NULL; try { mask1 = new deValue [n]; } catch (std::bad_alloc) { logError("allocating memory"); if (mask1) { delete [] mask1; } return false; } blurChannel(source, mask1, size, r1, r1, deBoxBlur, 0.0); int i; t = 1 - t; if (burn) { deValue d = 1.0 - t; deValue s = 1.0 / d; for (i = 0; i < n; i++) { deValue v = 1.0 - mask1[i]; if (v < t) { v = 0.0; } else { v = s * (v - t); if (v < 0) { v = 0; } } mask1[i] = v; } } else { deValue d = 1.0 - t; deValue s = 1.0 / d; for (i = 0; i < n; i++) { deValue v = mask1[i]; if (v < t) { v = 0.0; } else { v = s * (v - t); if (v > 1) { v = 1; } } mask1[i] = v; } } blurChannel(mask1, mask1, size, r2, r2, deBoxBlur, 0.0); deBlendMode mode = deBlendDodge; if (burn) { mode = deBlendBurn; } blendChannel(source, source, destination, mask1, mode, 1.0, n); delete [] mask1; return true; } bool shadowsHighlights(deValue r, int channel, const deImage& sourceImage, deImage& mainLayerImage, bool shadows) { deSize size = mainLayerImage.getChannelSize(); int n = size.getN(); deValue* mask = NULL; try { mask = new deValue [n]; } catch (std::bad_alloc) { logError("allocating memory"); if (mask) { delete [] mask; } return false; } const deValue* source = sourceImage.startRead(channel); blurChannel(source, mask, size, r, r, deBoxBlur, 0.0); sourceImage.finishRead(channel); int i; int nc = getColorSpaceSize(sourceImage.getColorSpace()); for (i = 0; i < nc; i++) { deValue* d = mainLayerImage.startWrite(i); const deValue* s = sourceImage.startRead(i); int j; if (shadows) { for (j = 0; j < n; j++) { deValue v = s[j]; deValue m = mask[j]; deValue r = calcBlendResult(v, m, deBlendOverlayInvert); if (r > v) { v = r; } d[j] = v; } } else { for (j = 0; j < n; j++) { deValue v = s[j]; deValue m = mask[j]; deValue r = calcBlendResult(v, m, deBlendOverlayInvert); if (r < v) { v = r; } d[j] = v; } } sourceImage.finishRead(i); mainLayerImage.finishWrite(i); } delete [] mask; return true; } delaboratory-0.8/algorithms/blend_color_luminosity.cc0000644000175100001440000002074411764477311022325 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #include "blend_color_luminosity.h" #include "conversion_cpu.h" void blendColorRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) { deConversionCPU cpu(3); int i; for (i = 0; i < n; i++) { deValue rs = source0[i]; deValue gs = source1[i]; deValue bs = source2[i]; cpu.input[0] = rs; cpu.input[1] = gs; cpu.input[2] = bs; rgb2lab(cpu); deValue L = cpu.output[0]; deValue ro = overlay0[i]; deValue go = overlay1[i]; deValue bo = overlay2[i]; cpu.input[0] = ro; cpu.input[1] = go; cpu.input[2] = bo; rgb2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2rgb(cpu); deValue r = cpu.output[0]; deValue g = cpu.output[1]; deValue b = cpu.output[2]; destination0[i] = (1 - o) * rs + o * r; destination1[i] = (1 - o) * gs + o * g; destination2[i] = (1 - o) * bs + o * b; } } void blendLuminosityRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) { deConversionCPU cpu(3); int i; for (i = 0; i < n; i++) { deValue rs = source0[i]; deValue gs = source1[i]; deValue bs = source2[i]; cpu.input[0] = rs; cpu.input[1] = gs; cpu.input[2] = bs; rgb2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; deValue ro = overlay0[i]; deValue go = overlay1[i]; deValue bo = overlay2[i]; cpu.input[0] = ro; cpu.input[1] = go; cpu.input[2] = bo; rgb2lab(cpu); deValue L = cpu.output[0]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2rgb(cpu); deValue r = cpu.output[0]; deValue g = cpu.output[1]; deValue b = cpu.output[2]; destination0[i] = (1 - o) * rs + o * r; destination1[i] = (1 - o) * gs + o * g; destination2[i] = (1 - o) * bs + o * b; } } void blendColorProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) { deConversionCPU cpu(3); int i; for (i = 0; i < n; i++) { deValue rs = source0[i]; deValue gs = source1[i]; deValue bs = source2[i]; cpu.input[0] = rs; cpu.input[1] = gs; cpu.input[2] = bs; prophoto2lab(cpu); deValue L = cpu.output[0]; deValue ro = overlay0[i]; deValue go = overlay1[i]; deValue bo = overlay2[i]; cpu.input[0] = ro; cpu.input[1] = go; cpu.input[2] = bo; prophoto2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2prophoto(cpu); deValue r = cpu.output[0]; deValue g = cpu.output[1]; deValue b = cpu.output[2]; destination0[i] = (1 - o) * rs + o * r; destination1[i] = (1 - o) * gs + o * g; destination2[i] = (1 - o) * bs + o * b; } } void blendLuminosityProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o) { deConversionCPU cpu(3); int i; for (i = 0; i < n; i++) { deValue rs = source0[i]; deValue gs = source1[i]; deValue bs = source2[i]; cpu.input[0] = rs; cpu.input[1] = gs; cpu.input[2] = bs; prophoto2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; deValue ro = overlay0[i]; deValue go = overlay1[i]; deValue bo = overlay2[i]; cpu.input[0] = ro; cpu.input[1] = go; cpu.input[2] = bo; prophoto2lab(cpu); deValue L = cpu.output[0]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2prophoto(cpu); deValue r = cpu.output[0]; deValue g = cpu.output[1]; deValue b = cpu.output[2]; destination0[i] = (1 - o) * rs + o * r; destination1[i] = (1 - o) * gs + o * g; destination2[i] = (1 - o) * bs + o * b; } } void blendColorCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o) { deConversionCPU cpu(4); int i; for (i = 0; i < n; i++) { deValue cs = source0[i]; deValue ms = source1[i]; deValue ys = source2[i]; deValue ks = source3[i]; cpu.input[0] = cs; cpu.input[1] = ms; cpu.input[2] = ys; cpu.input[3] = ks; cmyk2lab(cpu); deValue L = cpu.output[0]; deValue co = overlay0[i]; deValue mo = overlay1[i]; deValue yo = overlay2[i]; deValue ko = overlay3[i]; cpu.input[0] = co; cpu.input[1] = mo; cpu.input[2] = yo; cpu.input[3] = ko; cmyk2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2cmyk(cpu); deValue c = cpu.output[0]; deValue m = cpu.output[1]; deValue y = cpu.output[2]; deValue k = cpu.output[3]; destination0[i] = (1 - o) * cs + o * c; destination1[i] = (1 - o) * ms + o * m; destination2[i] = (1 - o) * ys + o * y; destination3[i] = (1 - o) * ks + o * k; } } void blendLuminosityCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o) { deConversionCPU cpu(4); int i; for (i = 0; i < n; i++) { deValue cs = source0[i]; deValue ms = source1[i]; deValue ys = source2[i]; deValue ks = source3[i]; cpu.input[0] = cs; cpu.input[1] = ms; cpu.input[2] = ys; cpu.input[3] = ks; cmyk2lab(cpu); deValue A = cpu.output[1]; deValue B = cpu.output[2]; deValue co = overlay0[i]; deValue mo = overlay1[i]; deValue yo = overlay2[i]; deValue ko = overlay3[i]; cpu.input[0] = co; cpu.input[1] = mo; cpu.input[2] = yo; cpu.input[3] = ko; cmyk2lab(cpu); deValue L = cpu.output[0]; cpu.input[0] = L; cpu.input[1] = A; cpu.input[2] = B; lab2cmyk(cpu); deValue c = cpu.output[0]; deValue m = cpu.output[1]; deValue y = cpu.output[2]; deValue k = cpu.output[3]; destination0[i] = (1 - o) * cs + o * c; destination1[i] = (1 - o) * ms + o * m; destination2[i] = (1 - o) * ys + o * y; destination3[i] = (1 - o) * ks + o * k; } } delaboratory-0.8/algorithms/radial_lut.h0000644000175100001440000000202511764477311017521 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_RADIAL_LUT_H #define _DE_RADIAL_LUT_H class deRadialLUT { private: int size; int* lut; public: deRadialLUT(int _size, int r); virtual ~deRadialLUT(); void get(int i, int& x, int& y) const; int getStart(int s) const; }; #endif delaboratory-0.8/algorithms/blend_color_luminosity.h0000644000175100001440000000475511764477311022173 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_BLEND_COLOR_LUMINOSITY_H #define _DE_BLEND_COLOR_LUMINOSITY_H #include "value.h" void blendColorRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); void blendLuminosityRGB(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); void blendColorProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); void blendLuminosityProPhoto(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, deValue* destination0, deValue* destination1, deValue* destination2, int n, deValue o); void blendColorCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o); void blendLuminosityCMYK(const deValue* source0, const deValue* source1, const deValue* source2, const deValue* source3, const deValue* overlay0, const deValue* overlay1, const deValue* overlay2, const deValue* overlay3, deValue* destination0, deValue* destination1, deValue* destination2, deValue* destination3, int n, deValue o); #endif delaboratory-0.8/algorithms/usm.h0000644000175100001440000000231611764477311016210 0ustar jacekusers/* delaboratory - color correction utility Copyright (C) 2011 Jacek Poplawski 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 3 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, see . */ #ifndef _DE_USM_H #define _DE_USM_H #include "value.h" #include "size.h" #include "blur.h" class deImage; bool unsharpMask(const deValue* source, deValue* destination, deSize& size, deValue a, deValue r, deValue t, deBlurType type); bool autoDodgeBurn(const deValue* source, deValue* destination, deSize& size, deValue r1, deValue r2, deValue t, bool burn); bool shadowsHighlights(deValue r, int channel, const deImage& sourceImage, deImage& mainLayerImage, bool shadows); #endif delaboratory-0.8/README0000644000175100001440000000033311713052054013722 0ustar jacekusersdelaboratory - color correction utility Copyright (C) 2012 Jacek Poplawski please see project website for more info: http://code.google.com/p/delaboratory/ delaboratory is a Free Software, read GNU GPL v3 for details