pax_global_header 0000666 0000000 0000000 00000000064 12141230411 0014477 g ustar 00root root 0000000 0000000 52 comment=80a53f0d2c54f9d5ba603ddc9ac797cf5217a50e
GIMP-Lensfun-0.2.3/ 0000775 0000000 0000000 00000000000 12141230411 0013645 5 ustar 00root root 0000000 0000000 GIMP-Lensfun-0.2.3/CHANGES.txt 0000664 0000000 0000000 00000002270 12141230411 0015457 0 ustar 00root root 0000000 0000000 Changes:
0.2.3
#######################################
- mostly cleanups and small fixes
- TCA correction had no effect in previous releases,
should work now
0.2.2
#######################################
- Lanczos interpolation is now used instead of bilinear
interpolation for sharper results
- crash on unknown exif is fixed
- settings are stored an reloaded if no exif data is
present
0.2.1
########################################
- some minor changes and fixes for windows compatibility.
- a complete windows package including Lensfun library,
database and all necessary dependencies is now available
- processing is parallelized on multi core processors
using OpenMP
0.2
########################################
- A LOT of code cleanups and stability improvements
- Bilinear interpolation is now used instead of nearest
neighbor interpolation
- Added possibility to correct vignetting and CA (but
currently no lens in database has correction data for
these)
0.1.1
########################################
- Fixed crash on unknown cameras in exif
- Added option to scale corrected image
without black borders
0.1
########################################
Initial release
GIMP-Lensfun-0.2.3/LICENSE.txt 0000664 0000000 0000000 00000104512 12141230411 0015473 0 ustar 00root root 0000000 0000000 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
. GIMP-Lensfun-0.2.3/Makefile 0000664 0000000 0000000 00000002566 12141230411 0015316 0 ustar 00root root 0000000 0000000
# enable/disable debug mode
DEBUG ?= 0
ifeq ($(DEBUG), 1)
CXXFLAGS += -DDEBUG=1
else
CXXFLAGS += -DDEBUG=0
endif
# set standard values, if not set by default
CXX ?= g++
CXXFLAGS += -O3 -Wall
# project-specific flags
EXTRA_CXXFLAGS += $(shell gimptool-2.0 --cflags && pkg-config --cflags lensfun exiv2)
LDFLAGS += $(shell gimptool-2.0 --libs && pkg-config --libs lensfun exiv2) -lstdc++
# set some system dependent options
SYS := $(shell gcc -dumpmachine)
ifneq (, $(findstring mingw, $(SYS)))
ifeq ($(DEBUG), 0)
LDFLAGS += -Wl,-subsystem,windows
endif
else
# comment to disable OpenMP
CXXFLAGS += -fopenmp
LDFLAGS += -fopenmp
endif
# project data
PLUGIN = gimp-lensfun
SOURCES = src/gimplensfun.cpp
HEADERS = src/LUT.hpp
# END CONFIG ##################################################################
.PHONY: all install userinstall clean uninstall useruninstall
all: $(PLUGIN)
OBJECTS = $(subst .cpp,.o,$(SOURCES))
$(PLUGIN): $(OBJECTS)
$(CXX) -o $@ $^ $(LDFLAGS)
%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) $(EXTRA_CXXFLAGS) -c -o $@ $*.cpp
install: $(PLUGIN)
@gimptool-2.0 --install-admin-bin $^
userinstall: $(PLUGIN)
@gimptool-2.0 --install-bin $^
uninstall:
@gimptool-2.0 --uninstall-admin-bin $(PLUGIN)
useruninstall:
@gimptool-2.0 --uninstall-bin $(PLUGIN)
clean:
rm -f src/*.o $(PLUGIN)
debug:
$(MAKE) $(MAKEFILE) DEBUG="-g -g3 -gdwarf-2 -D DEBUG"
GIMP-Lensfun-0.2.3/README.txt 0000664 0000000 0000000 00000000140 12141230411 0015336 0 ustar 00root root 0000000 0000000
See http://seebk.github.io/GIMP-Lensfun/ for detailed install
instructions and documentation.
GIMP-Lensfun-0.2.3/src/ 0000775 0000000 0000000 00000000000 12141230411 0014434 5 ustar 00root root 0000000 0000000 GIMP-Lensfun-0.2.3/src/LUT.hpp 0000664 0000000 0000000 00000012402 12141230411 0015610 0 ustar 00root root 0000000 0000000 /*
* This file is part of GimpLensfun.
*
* The sourcecode for the lookup table has been taken from Rawtherapee.
* Copyright (c) 2011 Jan Rinze Peterzon (janrinze@gmail.com)
*
* GimpLensfun is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GimpLensfun is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GimpLensfun. If not, see .
*/
/*
* Declaration of flexible Lookup Tables
*
* Usage:
*
* LUT name (size);
* LUT name (size, flags);
*
* creates an array which is valid within the normal C/C++ scope "{ ... }"
*
* access to elements is a simple as:
*
* LUT my_lut (10);
* float value = my_lut[3];
* float value = my_lut[2.5]; // this will interpolate
*
* when using a float type index it will interpolate the lookup values
*
* extra setting in flags: (clipping is set by default)
* LUT_CLIP_ABOVE
* LUT_CLIP_BELOW
*
* example:
* LUT my_lut (10,LUT_CLIP_BELOW);
* float value = my_lut[22.5]; // this will extrapolate
* float value = my_lut[-22.5]; // this will not extrapolate
*
* LUT my_lut (10,0); // this will extrapolate on either side
*
* shotcuts:
*
* LUTf stands for LUT
* LUTi stands for LUT
* LUTu stands for LUT
*/
#ifndef LUT_H_
#define LUT_H_
// bit representations of flags
#define LUT_CLIP_BELOW 1
#define LUT_CLIP_ABOVE 2
#define LUTf LUT
#define LUTi LUT
#define LUTu LUT
#include
template
class LUT {
private:
// list of variables ordered to improve cache speed
unsigned int maxs;
T * data;
unsigned int clip, size, owner;
public:
LUT(int s, int flags = 0xfffffff) {
clip = flags;
data = new T[s];
owner = 1;
size = s;
maxs=size-2;
}
void operator ()(int s, int flags = 0xfffffff) {
if (owner&&data)
delete[] data;
clip = flags;
data = new T[s];
owner = 1;
size = s;
maxs=size-2;
}
LUT(int s, T * source) {
data = new T[s];
owner = 1;
size = s;
maxs=size-2;
for (int i = 0; i < s; i++) {
data[i] = source[i];
}
}
LUT(void) {
data = NULL;
owner = 1;
size = 0;
maxs=0;
}
~LUT() {
if (owner)
delete[] data;
}
LUT & operator=(const LUT &rhs) {
if (this != &rhs) {
if (rhs.size>this->size)
{
delete [] this->data;
this->data=NULL;
}
if (this->data==NULL) this->data=new T[rhs.size];
this->clip=rhs.clip;
this->owner=1;
memcpy(this->data,rhs.data,rhs.size*sizeof(T));
this->size=rhs.size;
this->maxs=this->size-2;
}
return *this;
}
// use with integer indices
T& operator[](int index) {
if (((unsigned int)index) maxs) {
if (idx<0)
{
if (clip & LUT_CLIP_BELOW)
return data[0];
idx=0;
}
else
{
if (clip & LUT_CLIP_ABOVE)
return data[size - 1];
idx =maxs;
}
}
float diff = index - (float) idx;
T p1 = data[idx];
T p2 = data[idx + 1]-p1;
return (p1 + p2*diff);
}
operator bool (void)
{
return size>0;
}
void clear(void) {
memset(data, 0, size * sizeof(T));
}
};
#endif /* LUT_H_ */
GIMP-Lensfun-0.2.3/src/gimplensfun.cpp 0000664 0000000 0000000 00000122765 12141230411 0017504 0 ustar 00root root 0000000 0000000 /*
*
*
Copyright 2010-2011 Sebastian Kraft
This file is part of GimpLensfun.
GimpLensfun is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
GimpLensfun is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with GimpLensfun. If not, see
http://www.gnu.org/licenses/.
###################################################################
CHANGES:
22.10.2011 - OpenMP parallelization
20.10.2011 - Windows compatibility
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define VERSIONSTR "0.2.3"
#ifndef DEBUG
#define DEBUG 0
#endif
#include "LUT.hpp"
using namespace std;
//####################################################################
// Function declarations
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gboolean create_dialog_window (GimpDrawable *drawable);
//--------------------------------------------------------------------
//####################################################################
// Global variables
GtkWidget *camera_combo, *maker_combo, *lens_combo;
GtkWidget *CorrVignetting, *CorrTCA, *CorrDistortion;
lfDatabase *ldb;
bool bComboBoxLock = false;
//--------------------------------------------------------------------
//####################################################################
// interpolation parameters
const int cLanczosWidth = 2;
const int cLanczosTableRes = 256;
LUT LanczosLUT (cLanczosWidth * 2 * cLanczosTableRes + 1);
typedef enum GL_INTERPOL {
GL_INTERPOL_NN, // Nearest Neighbour
GL_INTERPOL_BL, // Bilinear
GL_INTERPOL_LZ // Lanczos
} glInterpolationType;
//####################################################################
// List of camera makers
const string CameraMakers[] = {
"Canon",
"Casio",
"Fujifilm",
"Kodak",
"Konica",
"Leica",
"Nikon",
"Olympus",
"Panasonic",
"Pentax",
"Ricoh",
"Samsung",
"Sigma",
"Sony",
"NULL"
};
//--------------------------------------------------------------------
//####################################################################
// struct for holding camera/lens info and parameters
typedef struct
{
int ModifyFlags;
bool Inverse;
std::string Camera;
std::string CamMaker;
std::string Lens;
float Scale;
float Crop;
float Focal;
float Aperture;
float Distance;
lfLensType TargetGeom;
} MyLensfunOpts;
//--------------------------------------------------------------------
static MyLensfunOpts sLensfunParameters =
{
LF_MODIFY_DISTORTION,
false,
"",
"",
"",
0.0,
0,
0,
0,
1.0,
LF_RECTILINEAR
};
//--------------------------------------------------------------------
//####################################################################
// struct for storing camera/lens info and parameters
typedef struct
{
int ModifyFlags;
bool Inverse;
char Camera[255];
char CamMaker[255];
char Lens[255];
float Scale;
float Crop;
float Focal;
float Aperture;
float Distance;
lfLensType TargetGeom;
} MyLensfunOptStorage;
//--------------------------------------------------------------------
static MyLensfunOptStorage sLensfunParameterStorage =
{
LF_MODIFY_DISTORTION,
false,
"",
"",
"",
0.0,
0,
0,
0,
1.0,
LF_RECTILINEAR
};
// GIMP Plugin
GimpPlugInInfo PLUG_IN_INFO =
{
NULL,
NULL,
query,
run
};
MAIN()
//####################################################################
// query() function
static void query (void)
{
static GimpParamDef args[] =
{
{
GIMP_PDB_INT32,
"run-mode",
"Run mode"
},
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Input drawable"
}
};
gimp_install_procedure (
"plug-in-lensfun",
"Correct lens distortion with lensfun",
"Correct lens distortion with lensfun",
"Sebastian Kraft",
"Copyright Sebastian Kraft",
"2010",
"_GimpLensfun...",
"RGB",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register ("plug-in-lensfun",
"/Filters/Enhance");
}
//--------------------------------------------------------------------
//####################################################################
// Some helper functions
// Round float to integer value
int roundfloat2int(float d)
{
return d<0?d-.5:d+.5;
}
//--------------------------------------------------------------------
void StrReplace(std::string& str, const std::string& old, const std::string& newstr)
{
size_t pos = 0;
while ((pos = str.find(old, pos)) != std::string::npos)
{
str.replace(pos, old.length(), newstr);
pos += newstr.length();
}
}
//--------------------------------------------------------------------
int StrCompare(const std::string& str1, const std::string& str2, bool CaseSensitive = false)
{
string s1 = str1;
string s2 = str2;
if (!CaseSensitive)
{
transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
transform(s2.begin(), s2.end(), s2.begin(), ::tolower);
}
return s1.compare(s2);
}
//--------------------------------------------------------------------
#ifdef POSIX
unsigned long long int timespec2llu(struct timespec *ts) {
return (unsigned long long int) ( ((unsigned long long int)ts->tv_sec * 1000000000) + ts->tv_nsec);
}
#endif
//--------------------------------------------------------------------
//####################################################################
// Helper functions for printing debug output
static void PrintMount (const lfMount *mount)
{
g_print ("Mount: %s\n", lf_mlstr_get (mount->Name));
if (mount->Compat)
for (int j = 0; mount->Compat [j]; j++)
g_print ("\tCompat: %s\n", mount->Compat [j]);
}
//--------------------------------------------------------------------
static void PrintCamera (const lfCamera *camera)
{
g_print ("Camera: %s / %s %s%s%s\n",
lf_mlstr_get (camera->Maker),
lf_mlstr_get (camera->Model),
camera->Variant ? "(" : "",
camera->Variant ? lf_mlstr_get (camera->Variant) : "",
camera->Variant ? ")" : "");
g_print ("\tMount: %s\n", lf_db_mount_name (ldb, camera->Mount));
g_print ("\tCrop factor: %g\n", camera->CropFactor);
}
//--------------------------------------------------------------------
static void PrintLens (const lfLens *lens)
{
g_print ("Lens: %s / %s\n",
lf_mlstr_get (lens->Maker),
lf_mlstr_get (lens->Model));
g_print ("\tCrop factor: %g\n", lens->CropFactor);
g_print ("\tFocal: %g-%g\n", lens->MinFocal, lens->MaxFocal);
g_print ("\tAperture: %g-%g\n", lens->MinAperture, lens->MaxAperture);
g_print ("\tCenter: %g,%g\n", lens->CenterX, lens->CenterY);
g_print ("\tCCI: %g/%g/%g\n", lens->RedCCI, lens->GreenCCI, lens->BlueCCI);
if (lens->Mounts)
for (int j = 0; lens->Mounts [j]; j++)
g_print ("\tMount: %s\n", lf_db_mount_name (ldb, lens->Mounts [j]));
}
//--------------------------------------------------------------------
static void PrintCameras (const lfCamera **cameras)
{
if (cameras)
for (int i = 0; cameras [i]; i++)
{
g_print ("--- camera %d: ---\n", i + 1);
PrintCamera (cameras [i]);
}
else
g_print ("\t- failed\n");
}
//--------------------------------------------------------------------
static void PrintLenses (const lfLens **lenses)
{
if (lenses)
for (int i = 0; lenses [i]; i++)
{
g_print ("--- lens %d, score %d: ---\n", i + 1, lenses [i]->Score);
PrintLens (lenses [i]);
}
else
g_print ("\t- failed\n");
}
//--------------------------------------------------------------------
//####################################################################
// set dialog combo boxes to values
static void dialog_set_cboxes( string sNewMake, string sNewCamera, string sNewLens) {
vector vCameraList;
vector vLensList;
const lfCamera** cameras = NULL;
const lfLens** lenses = NULL;
GtkTreeModel* store = NULL;
int iCurrMakerID = -1;
int iCurrCameraID = -1;
int iCurrLensId = -1;
sLensfunParameters.CamMaker.clear();
sLensfunParameters.Camera.clear();
sLensfunParameters.Lens.clear();
if (sNewMake.empty()==true)
return;
// try to match maker with predefined list
for (int i = 0; CameraMakers[i].compare("NULL")!=0; i++)
{
if (StrCompare(CameraMakers[i], sNewMake)==0) {
gtk_combo_box_set_active(GTK_COMBO_BOX(maker_combo), i);
iCurrMakerID = i;
}
}
// return if no maker has been identified
if (iCurrMakerID==-1)
return;
// store cam maker
sLensfunParameters.CamMaker = CameraMakers[iCurrMakerID];
// clear camera/lens combobox
store = gtk_combo_box_get_model( GTK_COMBO_BOX(camera_combo) );
gtk_list_store_clear( GTK_LIST_STORE( store ) );
store = gtk_combo_box_get_model( GTK_COMBO_BOX(lens_combo) );
gtk_list_store_clear( GTK_LIST_STORE( store ) );
// get all cameras from maker out of database
cameras = ldb->FindCamerasExt (CameraMakers[iCurrMakerID].c_str(), NULL, LF_SEARCH_LOOSE );
if (cameras) {
for (int i=0; cameras [i]; i++){
vCameraList.push_back(string(lf_mlstr_get(cameras[i]->Model)));
}
sort(vCameraList.begin(), vCameraList.end());
} else {
return;
}
for (unsigned int i=0; iModel)), sNewCamera)==0)
iCurrCameraID = i;
}
// return if camera is unidentified
if (iCurrCameraID == -1)
{
lf_free(cameras);
return;
}
// find lenses for camera model
lenses = ldb->FindLenses (cameras[iCurrCameraID], NULL, NULL);
if (lenses) {
vLensList.clear();
for (int i = 0; lenses [i]; i++)
vLensList.push_back(string(lf_mlstr_get(lenses[i]->Model)));
sort(vLensList.begin(), vLensList.end());
} else {
lf_free(cameras);
return;
}
for (unsigned int i = 0; iModel)), sNewLens)==0)
iCurrLensId = i;
}
gtk_widget_set_sensitive(CorrTCA, false);
gtk_widget_set_sensitive(CorrVignetting, false);
if (iCurrLensId >= 0)
{
if (lenses[iCurrLensId]->CalibTCA != NULL)
gtk_widget_set_sensitive(CorrTCA, true);
if (lenses[iCurrLensId]->CalibVignetting != NULL)
gtk_widget_set_sensitive(CorrVignetting, true);
}
lf_free(lenses);
lf_free(cameras);
}
//--------------------------------------------------------------------
//####################################################################
// dialog callback functions
static void
maker_cb_changed( GtkComboBox *combo,
gpointer data )
{
if (!bComboBoxLock) {
bComboBoxLock = true;
dialog_set_cboxes(gtk_combo_box_get_active_text(GTK_COMBO_BOX(maker_combo)),
"",
"");
bComboBoxLock = false;
}
}
//--------------------------------------------------------------------
static void
camera_cb_changed( GtkComboBox *combo,
gpointer data )
{
if (!bComboBoxLock) {
bComboBoxLock = true;
dialog_set_cboxes(string(gtk_combo_box_get_active_text(GTK_COMBO_BOX(maker_combo))),
string(gtk_combo_box_get_active_text(GTK_COMBO_BOX(camera_combo))),
"");
bComboBoxLock = false;
}
}
//--------------------------------------------------------------------
static void
lens_cb_changed( GtkComboBox *combo,
gpointer data )
{
if (!bComboBoxLock) {
bComboBoxLock = true;
dialog_set_cboxes(string(gtk_combo_box_get_active_text(GTK_COMBO_BOX(maker_combo))),
string(gtk_combo_box_get_active_text(GTK_COMBO_BOX(camera_combo))),
string(gtk_combo_box_get_active_text(GTK_COMBO_BOX(lens_combo))));
bComboBoxLock = false;
}
}
//--------------------------------------------------------------------
static void
focal_changed( GtkComboBox *combo,
gpointer data )
{
sLensfunParameters.Focal = (float) gtk_adjustment_get_value(GTK_ADJUSTMENT(data));
}
//--------------------------------------------------------------------
static void
aperture_changed( GtkComboBox *combo,
gpointer data )
{
sLensfunParameters.Aperture = (float) gtk_adjustment_get_value(GTK_ADJUSTMENT(data));
}
//--------------------------------------------------------------------
static void
scalecheck_changed( GtkCheckButton *togglebutn,
gpointer data )
{
sLensfunParameters.Scale = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutn));
}
//--------------------------------------------------------------------
static void
modify_changed( GtkCheckButton *togglebutn,
gpointer data )
{
sLensfunParameters.ModifyFlags = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CorrDistortion))
&& GTK_WIDGET_SENSITIVE(CorrDistortion))
sLensfunParameters.ModifyFlags |= LF_MODIFY_DISTORTION;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CorrTCA))
&& GTK_WIDGET_SENSITIVE(CorrTCA))
sLensfunParameters.ModifyFlags |= LF_MODIFY_TCA;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(CorrVignetting))
&& GTK_WIDGET_SENSITIVE(CorrVignetting))
sLensfunParameters.ModifyFlags |= LF_MODIFY_VIGNETTING;
}//--------------------------------------------------------------------
//####################################################################
// Create gtk dialog window
static gboolean create_dialog_window (GimpDrawable *drawable)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *frame, *frame2;
GtkWidget *camera_label, *lens_label, *maker_label;
GtkWidget *focal_label, *aperture_label;
GtkWidget *scalecheck;
GtkWidget *spinbutton;
GtkObject *spinbutton_adj;
GtkWidget *spinbutton_aperture;
GtkObject *spinbutton_aperture_adj;
GtkWidget *frame_label, *frame_label2;
GtkWidget *table, *table2;
gboolean run;
gint iTableRow = 0;
gimp_ui_init ("mylensfun", FALSE);
dialog = gimp_dialog_new ("GIMP-Lensfun (v" VERSIONSTR ")", "mylensfun",
NULL, GTK_DIALOG_MODAL ,
gimp_standard_help_func, "plug-in-lensfun",
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
main_vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
gtk_widget_show (main_vbox);
frame = gtk_frame_new (NULL);
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
frame_label = gtk_label_new ("Camera/Lens Parameters");
gtk_widget_show (frame_label);
gtk_frame_set_label_widget (GTK_FRAME (frame), frame_label);
gtk_label_set_use_markup (GTK_LABEL (frame_label), TRUE);
table = gtk_table_new(6, 2, TRUE);
gtk_table_set_homogeneous(GTK_TABLE(table), false);
gtk_table_set_row_spacings(GTK_TABLE(table), 2);
gtk_table_set_col_spacings(GTK_TABLE(table), 2);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);
// camera maker
maker_label = gtk_label_new ("Maker:");
gtk_misc_set_alignment(GTK_MISC(maker_label),0.0,0.5);
gtk_widget_show (maker_label);
gtk_table_attach(GTK_TABLE(table), maker_label, 0, 1, iTableRow, iTableRow+1, GTK_FILL, GTK_FILL, 0,0 );
maker_combo = gtk_combo_box_new_text();
gtk_widget_show (maker_combo);
for (int i = 0; StrCompare(CameraMakers[i], "NULL")!=0; i++)
{
gtk_combo_box_append_text( GTK_COMBO_BOX( maker_combo ), CameraMakers[i].c_str());
}
gtk_table_attach_defaults(GTK_TABLE(table), maker_combo, 1, 2, iTableRow, iTableRow+1 );
iTableRow++;
// camera
camera_label = gtk_label_new ("Camera:");
gtk_misc_set_alignment(GTK_MISC(camera_label),0.0,0.5);
gtk_widget_show (camera_label);
gtk_table_attach(GTK_TABLE(table), camera_label, 0, 1, iTableRow, iTableRow+1, GTK_FILL, GTK_FILL, 0,0 );
camera_combo = gtk_combo_box_new_text();
gtk_widget_show (camera_combo);
gtk_table_attach_defaults(GTK_TABLE(table), camera_combo, 1,2, iTableRow, iTableRow+1 );
iTableRow++;
// lens
lens_label = gtk_label_new ("Lens:");
gtk_misc_set_alignment(GTK_MISC(lens_label),0.0,0.5);
gtk_widget_show (lens_label);
gtk_table_attach_defaults(GTK_TABLE(table), lens_label, 0,1,iTableRow, iTableRow+1 );
lens_combo = gtk_combo_box_new_text();
gtk_widget_show (lens_combo);
gtk_table_attach_defaults(GTK_TABLE(table), lens_combo, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
// focal length
focal_label = gtk_label_new("Focal length (mm):");
gtk_misc_set_alignment(GTK_MISC(focal_label),0.0,0.5);
gtk_widget_show (focal_label);
gtk_table_attach_defaults(GTK_TABLE(table), focal_label, 0,1,iTableRow, iTableRow+1 );
spinbutton_adj = gtk_adjustment_new (sLensfunParameters.Focal, 0, 5000, 0.1, 0, 0);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_adj), 2, 1);
gtk_widget_show (spinbutton);
gtk_table_attach_defaults(GTK_TABLE(table), spinbutton, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
// aperture
aperture_label = gtk_label_new("Aperture:");
gtk_misc_set_alignment(GTK_MISC(aperture_label),0.0,0.5);
gtk_widget_show (focal_label);
gtk_table_attach_defaults(GTK_TABLE(table), aperture_label, 0,1,iTableRow, iTableRow+1 );
spinbutton_aperture_adj = gtk_adjustment_new (sLensfunParameters.Aperture, 0, 128, 0.1, 0, 0);
spinbutton_aperture = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_aperture_adj), 2, 1);
gtk_widget_show (spinbutton_aperture);
gtk_table_attach_defaults(GTK_TABLE(table), spinbutton_aperture, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_aperture), TRUE);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show_all(table);
frame2 = gtk_frame_new (NULL);
gtk_widget_show (frame2);
gtk_box_pack_start (GTK_BOX (main_vbox), frame2, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (frame2), 6);
frame_label2 = gtk_label_new ("Processing Parameters");
gtk_widget_show (frame_label2);
gtk_frame_set_label_widget (GTK_FRAME (frame2), frame_label2);
gtk_label_set_use_markup (GTK_LABEL (frame_label2), TRUE);
table2 = gtk_table_new(6, 2, TRUE);
gtk_table_set_homogeneous(GTK_TABLE(table2), false);
gtk_table_set_row_spacings(GTK_TABLE(table2), 2);
gtk_table_set_col_spacings(GTK_TABLE(table2), 2);
gtk_container_set_border_width(GTK_CONTAINER(table2), 10);
iTableRow = 0;
// scale to fit checkbox
scalecheck = gtk_check_button_new_with_label("Scale to fit");
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE);
gtk_widget_show (scalecheck);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(scalecheck), !sLensfunParameters.Scale);
gtk_table_attach_defaults(GTK_TABLE(table2), scalecheck, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
// enable distortion correction
CorrDistortion = gtk_check_button_new_with_label("Distortion");
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE);
gtk_widget_show (CorrDistortion);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CorrDistortion), true);
gtk_table_attach_defaults(GTK_TABLE(table2), CorrDistortion, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
// enable vignetting correction
CorrVignetting = gtk_check_button_new_with_label("Vignetting");
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE);
gtk_widget_show (CorrVignetting);
gtk_widget_set_sensitive(CorrVignetting, false);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CorrVignetting), false);
gtk_table_attach_defaults(GTK_TABLE(table2), CorrVignetting, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
// enable TCA correction
CorrTCA = gtk_check_button_new_with_label("Chromatic Aberration");
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), FALSE);
gtk_widget_show (CorrTCA);
gtk_widget_set_sensitive(CorrTCA, false);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(CorrTCA), false);
gtk_table_attach_defaults(GTK_TABLE(table2), CorrTCA, 1,2,iTableRow, iTableRow+1 );
iTableRow++;
gtk_container_add (GTK_CONTAINER (frame2), table2);
gtk_widget_show_all(table2);
// try to set combo boxes to exif
dialog_set_cboxes(sLensfunParameters.CamMaker,
sLensfunParameters.Camera,
sLensfunParameters.Lens);
// connect signals
g_signal_connect( G_OBJECT( maker_combo ), "changed",
G_CALLBACK( maker_cb_changed ), NULL );
g_signal_connect( G_OBJECT( camera_combo ), "changed",
G_CALLBACK( camera_cb_changed ), NULL );
g_signal_connect( G_OBJECT( lens_combo ), "changed",
G_CALLBACK( lens_cb_changed ), NULL );
g_signal_connect (spinbutton_adj, "value_changed",
G_CALLBACK (focal_changed), spinbutton_adj);
g_signal_connect (spinbutton_aperture_adj, "value_changed",
G_CALLBACK (aperture_changed), spinbutton_aperture_adj);
g_signal_connect( G_OBJECT( scalecheck ), "toggled",
G_CALLBACK( scalecheck_changed ), NULL );
g_signal_connect( G_OBJECT( CorrDistortion ), "toggled",
G_CALLBACK( modify_changed ), NULL );
g_signal_connect( G_OBJECT( CorrTCA ), "toggled",
G_CALLBACK( modify_changed ), NULL );
g_signal_connect( G_OBJECT( CorrVignetting ), "toggled",
G_CALLBACK( modify_changed ), NULL );
// show and run
gtk_widget_show (dialog);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
return run;
}
//--------------------------------------------------------------------
//####################################################################
// Interpolation functions
inline float Lanczos(float x)
{
if ( (x-FLT_MIN) )
return 1.0f;
if ( (x >= cLanczosWidth) && (x <= (-1)*cLanczosWidth) )
return 0.0f;
float xpi = x * static_cast(M_PI);
return ( cLanczosWidth * sin(xpi) * sin(xpi/cLanczosWidth) ) / ( xpi*xpi );
}
//--------------------------------------------------------------------
void InitInterpolation(glInterpolationType intType)
{
switch(intType) {
case GL_INTERPOL_NN: break;
case GL_INTERPOL_BL: break;
case GL_INTERPOL_LZ:
for (int i = -cLanczosWidth*cLanczosTableRes; i < cLanczosWidth*cLanczosTableRes; i++) {
LanczosLUT[i + cLanczosWidth*cLanczosTableRes] = Lanczos(static_cast(i)/static_cast(cLanczosTableRes));
}
break;
}
}
//--------------------------------------------------------------------
inline int InterpolateLanczos(guchar *ImgBuffer, gint w, gint h, gint channels, float xpos, float ypos, int chan)
{
int xl = int(xpos);
int yl = int(ypos);
float y = 0.0f;
float norm = 0.0f;
float L = 0.0f;
// border checking
if ((xl-cLanczosWidth+1 < 0) ||
(xl+cLanczosWidth >= w) ||
(yl-cLanczosWidth+1 < 0) ||
(yl+cLanczosWidth >= h))
{
return 0;
}
// convolve with lanczos kernel
for (int i = xl-cLanczosWidth+1; i < xl+cLanczosWidth; i++) {
for (int j = yl-cLanczosWidth+1; j < yl+cLanczosWidth; j++) {
L = LanczosLUT[ (xpos - static_cast(i))*static_cast(cLanczosTableRes) + static_cast(cLanczosWidth*cLanczosTableRes) ]
* LanczosLUT[ (ypos - static_cast(j))*static_cast(cLanczosTableRes) + static_cast(cLanczosWidth*cLanczosTableRes) ];
// L = Lanczos(xpos - static_cast(i))
// * Lanczos(ypos - static_cast(j));
y += static_cast(ImgBuffer[ (channels*w*j) + (i*channels) + chan ]) * L;
norm += L;
}
}
// normalize
y = y / norm;
// clip
if (y>255)
y = 255;
if (y<0)
y = 0;
// round to integer and return
return roundfloat2int(y);
}
//--------------------------------------------------------------------
inline int InterpolateLinear(guchar *ImgBuffer, gint w, gint h, gint channels, float xpos, float ypos, int chan)
{
// interpolated values in x and y direction
float x1, x2, y;
// surrounding integer rounded coordinates
int xl, xr, yu, yl;
xl = floor(xpos);
xr = ceil (xpos + 1e-10);
yu = floor(ypos);
yl = ceil (ypos + 1e-10);
// border checking
if ((xl < 0) ||
(xr >= w) ||
(yu < 0) ||
(yl >= h))
{
return 0;
}
float px1y1 = (float) ImgBuffer[ (channels*w*yu) + (xl*channels) + chan ];
float px1y2 = (float) ImgBuffer[ (channels*w*yl) + (xl*channels) + chan ];
float px2y1 = (float) ImgBuffer[ (channels*w*yu) + (xr*channels) + chan ];
float px2y2 = (float) ImgBuffer[ (channels*w*yl) + (xr*channels) + chan ];
x1 = (static_cast(xr) - xpos)*px1y1 + (xpos - static_cast(xl))*px2y1;
x2 = (static_cast(xr) - xpos)*px1y2 + (xpos - static_cast(xl))*px2y2;
y = (ypos - static_cast(yu))*x2 + (static_cast(yl) - ypos)*x1;
return roundfloat2int(y);
}
//--------------------------------------------------------------------
inline int InterpolateNearest(guchar *ImgBuffer, gint w, gint h, gint channels, float xpos, float ypos, int chan)
{
int x = roundfloat2int(xpos);
int y = roundfloat2int(ypos);
// border checking
if ((x < 0) ||
(x >= w) ||
(y < 0) ||
(y >= h))
{
return 0;
}
return ImgBuffer[ (channels*w*y) + (x*channels) + chan ];
}
//--------------------------------------------------------------------
//####################################################################
// Processing
static void process_image (GimpDrawable *drawable) {
gint channels;
gint x1, y1, x2, y2, imgwidth, imgheight;
GimpPixelRgn rgn_in, rgn_out;
guchar *ImgBuffer;
guchar *ImgBufferOut;
#ifdef POSIX
struct timespec profiling_start, profiling_stop;
#endif
// get image size
gimp_drawable_mask_bounds (drawable->drawable_id,
&x1, &y1,
&x2, &y2);
imgwidth = x2-x1;
imgheight = y2-y1;
// get number of channels
channels = gimp_drawable_bpp (drawable->drawable_id);
gimp_pixel_rgn_init (&rgn_in,
drawable,
x1, y1,
imgwidth, imgheight,
FALSE, FALSE);
gimp_pixel_rgn_init (&rgn_out,
drawable,
x1, y1,
imgwidth, imgheight,
TRUE, TRUE);
//Init input and output buffer
ImgBuffer = g_new (guchar, channels * (imgwidth+1) * (imgheight+1));
ImgBufferOut = g_new (guchar, channels * (imgwidth+1) * (imgheight+1));
InitInterpolation(GL_INTERPOL_LZ);
// Copy pixel data from GIMP to internal buffer
gimp_pixel_rgn_get_rect (&rgn_in, ImgBuffer, x1, y1, imgwidth, imgheight);
if (sLensfunParameters.Scale<1) {
sLensfunParameters.ModifyFlags |= LF_MODIFY_SCALE;
}
const lfCamera **cameras = ldb->FindCamerasExt (sLensfunParameters.CamMaker.c_str(), sLensfunParameters.Camera.c_str());
sLensfunParameters.Crop = cameras[0]->CropFactor;
const lfLens **lenses = ldb->FindLenses (cameras[0], NULL, sLensfunParameters.Lens.c_str());
if (DEBUG) {
g_print("\nApplied settings:\n");
g_print("\tCamera: %s, %s\n", cameras[0]->Maker, cameras[0]->Model);
g_print("\tLens: %s\n", lenses[0]->Model);
g_print("\tFocal Length: %f\n", sLensfunParameters.Focal);
g_print("\tF-Stop: %f\n", sLensfunParameters.Aperture);
g_print("\tCrop Factor: %f\n", sLensfunParameters.Crop);
g_print("\tScale: %f\n", sLensfunParameters.Scale);
#ifdef POSIX
clock_gettime(CLOCK_REALTIME, &profiling_start);
#endif
}
//init lensfun modifier
lfModifier *mod = lfModifier::Create (lenses[0], sLensfunParameters.Crop, imgwidth, imgheight);
mod->Initialize ( lenses[0], LF_PF_U8, sLensfunParameters.Focal,
sLensfunParameters.Aperture, sLensfunParameters.Distance, sLensfunParameters.Scale, sLensfunParameters.TargetGeom,
sLensfunParameters.ModifyFlags, sLensfunParameters.Inverse);
int iRowCount = 0;
#pragma omp parallel
{
// buffer containing undistorted coordinates for one row
float *UndistCoord = g_new (float, imgwidth*2*channels);
//main loop for processing, iterate through rows
#pragma omp for
for (int i = 0; i < imgheight; i++)
{
mod->ApplyColorModification( &ImgBuffer[(channels*imgwidth*i)],
0, i, imgwidth, 1,
LF_CR_3(RED, GREEN, BLUE),
channels*imgwidth);
mod->ApplySubpixelGeometryDistortion (0, i, imgwidth, 1, UndistCoord);
float* UndistIter = UndistCoord;
guchar *OutputBuffer = &ImgBufferOut[channels*imgwidth*i];
//iterate through subpixels in one row
for (int j = 0; j < imgwidth*channels; j += channels)
{
*OutputBuffer = InterpolateLanczos(ImgBuffer, imgwidth, imgheight, channels, UndistIter [0], UndistIter [1], 0);
OutputBuffer++;
*OutputBuffer = InterpolateLanczos(ImgBuffer, imgwidth, imgheight, channels, UndistIter [2], UndistIter [3], 1);
OutputBuffer++;
*OutputBuffer = InterpolateLanczos(ImgBuffer, imgwidth, imgheight, channels, UndistIter [4], UndistIter [5], 2);
OutputBuffer++;
// move pointer to next pixel
UndistIter += 2 * 3;
}
#pragma omp atomic
iRowCount++;
//update progress bar only every N rows
if (iRowCount % 200 == 0) {
#pragma omp critical
{
gimp_progress_update ((gdouble) (iRowCount - y1) / (gdouble) (imgheight));
}
}
}
g_free(UndistCoord);
}
lf_free(mod);
#ifdef POSIX
if (DEBUG) {
clock_gettime(CLOCK_REALTIME, &profiling_stop);
unsigned long long int time_diff = timespec2llu(&profiling_stop) - timespec2llu(&profiling_start);
g_print("\nPerformance: %12llu ns, %d pixel -> %llu ns/pixel\n", time_diff, imgwidth*imgheight, time_diff / (imgwidth*imgheight));
}
#endif
//write data back to gimp
gimp_pixel_rgn_set_rect (&rgn_out, ImgBufferOut, x1, y1, imgwidth, imgheight);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id,
x1, y1,
imgwidth, imgheight);
gimp_displays_flush ();
gimp_drawable_detach (drawable);
// free memory
g_free(ImgBufferOut);
g_free(ImgBuffer);
lf_free(lenses);
lf_free(cameras);
}
//--------------------------------------------------------------------
//####################################################################
// Read camera and lens info from exif and try to find in database
//
static int read_opts_from_exif(const char *filename) {
Exiv2::Image::AutoPtr Exiv2image;
Exiv2::ExifData exifData;
const lfCamera **cameras = 0;
const lfCamera *camera = 0;
const lfLens **lenses = 0;
const lfLens *lens = 0;
std::string LensNameMN;
if (DEBUG) {
g_print ("Reading exif data...");
}
try {
// read exif from file
Exiv2image = Exiv2::ImageFactory::open(string(filename));
Exiv2image.get();
Exiv2image->readMetadata();
exifData = Exiv2image->exifData();
if (exifData.empty()) {
if (DEBUG) {
g_print ("no exif data found. \n");
}
return -1;
}
}
catch (Exiv2::AnyError& e) {
if (DEBUG) {
g_print ("exception on reading data. \n");
}
return -1;
}
// search database for camera
cameras = ldb->FindCameras (exifData["Exif.Image.Make"].toString().c_str(), exifData["Exif.Image.Model"].toString().c_str());
if (cameras) {
camera = cameras [0];
sLensfunParameters.Crop = camera->CropFactor;
sLensfunParameters.Camera = string(lf_mlstr_get(camera->Model));
sLensfunParameters.CamMaker = string(lf_mlstr_get(camera->Maker));
} else {
sLensfunParameters.CamMaker = exifData["Exif.Image.Make"].toString();
}
//PrintCameras(cameras, ldb);
//Get lensID
string CamMaker = exifData["Exif.Image.Make"].toString();
transform(CamMaker.begin(), CamMaker.end(),CamMaker.begin(), ::tolower);
string MakerNoteKey;
//Select special MakerNote Tag for lens depending on Maker
if ((CamMaker.find("pentax"))!=string::npos) {
MakerNoteKey = "Exif.Pentax.LensType";
}
if ((CamMaker.find("canon"))!=string::npos) {
MakerNoteKey = "Exif.CanonCs.LensType";
}
if ((CamMaker.find("minolta"))!=string::npos) {
MakerNoteKey = "Exif.Minolta.LensID";
}
if ((CamMaker.find("nikon"))!=string::npos) {
MakerNoteKey = "Exif.NikonLd3.LensIDNumber";
if (exifData[MakerNoteKey].toString().size()==0) {
MakerNoteKey = "Exif.NikonLd2.LensIDNumber";
}
if (exifData[MakerNoteKey].toString().size()==0) {
MakerNoteKey = "Exif.NikonLd1.LensIDNumber";
}
}
if ((CamMaker.find("olympus"))!=string::npos) {
MakerNoteKey = "Exif.OlympusEq.LensType";
}
if ((CamMaker.find("sony"))!=string::npos) {
//MakerNoteKey = "Exif.Sony1.LensID";
}
//Decode Lens ID
if ((MakerNoteKey.size()>0) && (exifData[MakerNoteKey].toString().size()>0)) {
Exiv2::ExifKey ek(MakerNoteKey);
Exiv2::ExifData::const_iterator md = exifData.findKey(ek);
if (md != exifData.end()) {
LensNameMN = md->print(&exifData);
//Modify some lens names for better searching in lfDatabase
if ((CamMaker.find("nikon"))!=std::string::npos) {
StrReplace(LensNameMN, "Nikon", "");
StrReplace(LensNameMN, "Zoom-Nikkor", "");
}
}
}
if (camera) {
if (LensNameMN.size()>8) { // only take lens names with significant length
lenses = ldb->FindLenses (camera, NULL, LensNameMN.c_str());
} else {
lenses = ldb->FindLenses (camera, NULL, NULL);
}
if (lenses) {
lens = lenses[0];
sLensfunParameters.Lens = string(lf_mlstr_get(lens->Model));
}
lf_free (lenses);
}
lf_free (cameras);
sLensfunParameters.Focal = exifData["Exif.Photo.FocalLength"].toFloat();
sLensfunParameters.Aperture = exifData["Exif.Photo.FNumber"].toFloat();
if (DEBUG) {
g_print("\nExif Data:\n");
g_print("\tCamera: %s, %s\n", sLensfunParameters.CamMaker.c_str(), sLensfunParameters.Camera.c_str());
g_print("\tLens: %s\n", sLensfunParameters.Lens.c_str());
g_print("\tFocal Length: %f\n", sLensfunParameters.Focal);
g_print("\tF-Stop: %f\n", sLensfunParameters.Aperture);
g_print("\tCrop Factor: %f\n", sLensfunParameters.Crop);
g_print("\tScale: %f\n", sLensfunParameters.Scale);
}
return 0;
}
//--------------------------------------------------------------------
//####################################################################
// store and load parameters and settings to/from gimp_data_storage
static void loadSettings() {
gimp_get_data ("plug-in-gimplensfun", &sLensfunParameterStorage);
sLensfunParameters.ModifyFlags = sLensfunParameterStorage.ModifyFlags;
sLensfunParameters.Inverse = sLensfunParameterStorage.Inverse;
if (strlen(sLensfunParameterStorage.Camera)>0)
sLensfunParameters.Camera = std::string(sLensfunParameterStorage.Camera);
if (strlen(sLensfunParameterStorage.CamMaker)>0)
sLensfunParameters.CamMaker = std::string(sLensfunParameterStorage.CamMaker);
if (strlen(sLensfunParameterStorage.Lens)>0)
sLensfunParameters.Lens = std::string(sLensfunParameterStorage.Lens);
sLensfunParameters.Scale = sLensfunParameterStorage.Scale;
sLensfunParameters.Crop = sLensfunParameterStorage.Crop;
sLensfunParameters.Focal = sLensfunParameterStorage.Focal;
sLensfunParameters.Aperture = sLensfunParameterStorage.Aperture;
sLensfunParameters.Distance = sLensfunParameterStorage.Distance;
sLensfunParameters.TargetGeom = sLensfunParameterStorage.TargetGeom;
}
//--------------------------------------------------------------------
static void storeSettings() {
sLensfunParameterStorage.ModifyFlags = sLensfunParameters.ModifyFlags;
sLensfunParameterStorage.Inverse = sLensfunParameters.Inverse;
strcpy( sLensfunParameterStorage.Camera, sLensfunParameters.Camera.c_str() );
strcpy( sLensfunParameterStorage.CamMaker, sLensfunParameters.CamMaker.c_str() );
strcpy( sLensfunParameterStorage.Lens, sLensfunParameters.Lens.c_str() );
sLensfunParameterStorage.Scale = sLensfunParameters.Scale;
sLensfunParameterStorage.Crop = sLensfunParameters.Crop;
sLensfunParameterStorage.Focal = sLensfunParameters.Focal;
sLensfunParameterStorage.Aperture = sLensfunParameters.Aperture;
sLensfunParameterStorage.Distance = sLensfunParameters.Distance;
sLensfunParameterStorage.TargetGeom = sLensfunParameters.TargetGeom;
gimp_set_data ("plug-in-gimplensfun", &sLensfunParameterStorage, sizeof (sLensfunParameterStorage));
}
//--------------------------------------------------------------------
//####################################################################
// Run()
static void
run (const gchar* name,
gint nparams,
const GimpParam* param,
gint* nreturn_vals,
GimpParam** return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 imageID;
GimpRunMode run_mode;
GimpDrawable *drawable;
/* Setting mandatory output values */
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
drawable = gimp_drawable_get (param[2].data.d_drawable);
gimp_progress_init ("Lensfun correction...");
imageID = param[1].data.d_drawable;
run_mode = GimpRunMode(param[0].data.d_int32);
if (run_mode == GIMP_RUN_INTERACTIVE)
{
if (DEBUG) g_print ("Loading database...");
//Load lensfun database
ldb = lf_db_new ();
ldb->Load ();
// read exif data
const gchar *filename = gimp_image_get_filename(imageID);
if (DEBUG) g_print ("Image file path: %s\n", filename);
if ((filename == NULL) || (read_opts_from_exif(filename) != 0)) {
loadSettings();
}
if (DEBUG) g_print ("Creating dialog...\n");
/* Display the dialog */
if (create_dialog_window (drawable)) {
process_image(drawable);
}
storeSettings();
lf_db_destroy(ldb);
}
}
GIMP-Lensfun-0.2.3/tools/ 0000775 0000000 0000000 00000000000 12141230411 0015005 5 ustar 00root root 0000000 0000000 GIMP-Lensfun-0.2.3/tools/gimp-plugin-installer.iss 0000664 0000000 0000000 00000030314 12141230411 0021751 0 ustar 00root root 0000000 0000000 ;Installer for additional Gimp plugins
;
;supports both old-style (GIMP 2.6.x and older) and new-style (combined 32 and 64-bit) GIMP installations
;
;TODO: 64-bit GIMP can be installed without 32-bit plugin support - add code to detect this
;
;.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
; ;
;Copyright (c) 2002-2010 Jernej SimonŸiŸ ;
; ;
;This software is provided 'as-is', without any express or implied ;
;warranty. In no event will the authors be held liable for any damages ;
;arising from the use of this software. ;
; ;
;Permission is granted to anyone to use this software for any purpose, ;
;including commercial applications, and to alter it and redistribute it ;
;freely, subject to the following restrictions: ;
; ;
; 1. The origin of this software must not be misrepresented; you must ;
; not claim that you wrote the original software. If you use this ;
; software in a product, an acknowledgment in the product ;
; documentation would be appreciated but is not required. ;
; ;
; 2. Altered source versions must be plainly marked as such, and must ;
; not be misrepresented as being the original software. ;
; ;
; 3. This notice may not be removed or altered from any source ;
; distribution. ;
;.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.;
;for testing
;#define dontcompress
;AppId - only used with new-style installs; should be unique
#define APP_ID="GIMP-Lensfun-Plugin"
#define VERSION="0.2.3"
[Setup]
AppName=Lensfun plug-in for GIMP
AppVerName=GimpLensfun plugin 0.2.3
AppPublisherURL=http://seebk.github.io/GIMP-Lensfun/
AppSupportURL=http://seebk.github.io/GIMP-Lensfun/
AppUpdatesURL=http://seebk.github.io/GIMP-Lensfun/
DefaultDirName={code:GetGimpDir|{pf}\GIMP 2}
;WizardImageFile=big.bmp
;WizardImageBackColor=$ffffff
;WizardSmallImageFile=small.bmp
;WizardImageStretch=no
FlatComponentsList=yes
;don't change these
DirExistsWarning=no
DisableProgramGroupPage=yes
DisableDirPage=no
CreateUninstallRegKey=no
UpdateUninstallLogAppName=no
AppID={code:GetAppId}
UninstallFilesDir={code:GetUninstallDir}
UsePreviousLanguage=no
#if defined(dontcompress)
UseSetupLdr=no
OutputDir=_Output\47z
Compression=none
InternalCompressLevel=0
#else
OutputDir=_Output
Compression=lzma/ultra
InternalCompressLevel=ultra
SolidCompression=yes
OutputBaseFilename=gimplensfun-{#VERSION}-setup
#endif
;SignedUninstaller=yes
;SignedUninstallerDir=_Uninst
;[Languages]
;Name: "en"; MessagesFile: "compiler:Default.isl,help.en.isl"
[Files]
; The plugin
Source: "../gimp-lensfun.exe"; DestDir: "{app}\lib\gimp\2.0\plug-ins"; Flags: ignoreversion
; Several libraries not already part of GIMP installation
Source: "C:\MinGW\bin\libexiv2-12.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
Source: "C:\MinGW\bin\liblensfun.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
Source: "C:\MinGW\bin\libiconv-2.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
;Source: "C:\MinGW\bin\libstdc++-6.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
; For OpenMP
;Source: "C:\MinGW\bin\libgomp-1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
;Source: "C:\MinGW\bin\libpthread-2.dll"; DestDir: "{app}\bin"; Flags: ignoreversion
; The lensfun database xml files
Source: "C:\MinGW\share\lensfun\*"; DestDir: "{app}\share\lensfun\"; Flags: ignoreversion
[Code]
function SHAutoComplete(hWnd: Integer; dwFlags: DWORD): Integer; external 'SHAutoComplete@shlwapi.dll stdcall delayload';
function WideCharToMultiByte(CodePage: Cardinal; dwFlags: DWORD; lpWideCharStr: String; cchWideCharStr: Integer;
lpMultiByteStr: PAnsiChar; cbMultiByte: Integer; lpDefaultChar: Integer;
lpUsedDefaultChar: Integer): Integer; external 'WideCharToMultiByte@Kernel32 stdcall';
function MultiByteToWideChar(CodePage: Cardinal; dwFlags: DWORD; lpMultiByteStr: PAnsiChar; cbMultiByte: Integer;
lpWideCharStr: String; cchWideChar: Integer): Integer;
external 'MultiByteToWideChar@Kernel32 stdcall';
function GetLastError(): DWORD; external 'GetLastError@Kernel32 stdcall';
const
SHACF_FILESYSTEM = $1;
CP_UTF8 = 65001;
RegPath = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1';
RegPathNew = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GIMP-2_is1';
RegKey = 'Inno Setup: App Path';
VerKey = 'DisplayName';
var
GimpPath: String;
GimpVer: String;
InstallType: (itOld, itNew, itNew64);
function Count(What, Where: String): Integer;
begin
Result := 0;
if Length(What) = 0 then //nothing to count - should this throw an error?
exit;
while Pos(What,Where)>0 do
begin
Where := Copy(Where,Pos(What,Where)+Length(What),Length(Where));
Result := Result + 1;
end;
end;
//split text to array
procedure Explode(var ADest: TArrayOfString; aText, aSeparator: String);
var tmp: Integer;
begin
if aSeparator='' then
exit;
SetArrayLength(ADest,Count(aSeparator,aText)+1)
tmp := 0;
repeat
if Pos(aSeparator,aText)>0 then
begin
ADest[tmp] := Copy(aText,1,Pos(aSeparator,aText)-1);
aText := Copy(aText,Pos(aSeparator,aText)+Length(aSeparator),Length(aText));
tmp := tmp + 1;
end else
begin
ADest[tmp] := aText;
aText := '';
end;
until Length(aText)=0;
end;
//compares two version numbers, returns -1 if vA is newer, 0 if both are identical, 1 if vB is newer
function CompareVersion(vA,vB: String): Integer;
var tmp: TArrayOfString;
verA,verB: Array of Integer;
i,len: Integer;
begin
StringChange(vA,'-','.');
StringChange(vB,'-','.');
Explode(tmp,vA,'.');
SetArrayLength(verA,GetArrayLength(tmp));
for i := 0 to GetArrayLength(tmp) - 1 do
verA[i] := StrToIntDef(tmp[i],0);
Explode(tmp,vB,'.');
SetArrayLength(verB,GetArrayLength(tmp));
for i := 0 to GetArrayLength(tmp) - 1 do
verB[i] := StrToIntDef(tmp[i],0);
len := GetArrayLength(verA);
if GetArrayLength(verB) < len then
len := GetArrayLength(verB);
for i := 0 to len - 1 do
if verA[i] < verB[i] then
begin
Result := 1;
exit;
end else
if verA[i] > verB[i] then
begin
Result := -1;
exit
end;
if GetArrayLength(verA) < GetArrayLength(verB) then
begin
Result := 1;
exit;
end else
if GetArrayLength(verA) > GetArrayLength(verB) then
begin
Result := -1;
exit;
end;
Result := 0;
end;
function Utf82String(const pInput: AnsiString): String;
#ifndef UNICODE
#error "Unicode Inno Setup required"
#endif
var Output: String;
ret, outLen, nulPos: Integer;
begin
outLen := MultiByteToWideChar(CP_UTF8, 0, pInput, -1, Output, 0);
Output := StringOfChar(#0,outLen);
ret := MultiByteToWideChar(CP_UTF8, 0, pInput, -1, Output, outLen);
if ret = 0 then
RaiseException('MultiByteToWideChar failed: ' + IntToStr(GetLastError));
nulPos := Pos(#0,Output) - 1;
if nulPos = -1 then
nulPos := Length(Output);
Result := Copy(Output,1,nulPos);
end;
function LoadStringFromUTF8File(const pFileName: String; var oS: String): Boolean;
var Utf8String: AnsiString;
begin
Result := LoadStringFromFile(pFileName, Utf8String);
oS := Utf82String(Utf8String);
end;
function String2Utf8(const pInput: String): AnsiString;
var Output: AnsiString;
ret, outLen, nulPos: Integer;
begin
outLen := WideCharToMultiByte(CP_UTF8, 0, pInput, -1, Output, 0, 0, 0);
Output := StringOfChar(#0,outLen);
ret := WideCharToMultiByte(CP_UTF8, 0, pInput, -1, Output, outLen, 0, 0);
if ret = 0 then
RaiseException('WideCharToMultiByte failed: ' + IntToStr(GetLastError));
nulPos := Pos(#0,Output) - 1;
if nulPos = -1 then
nulPos := Length(Output);
Result := Copy(Output,1,nulPos);
end;
function SaveStringToUTF8File(const pFileName, pS: String; const pAppend: Boolean): Boolean;
begin
Result := SaveStringToFile(pFileName, String2Utf8(pS), pAppend);
end;
procedure SaveToUninstInf(const pText: AnsiString);
var sUnInf: String;
sOldContent: String;
begin
sUnInf := ExpandConstant('{app}\uninst\uninst.inf');
if not FileExists(sUnInf) then //save small header
SaveStringToUTF8File(sUnInf,#$feff+'#Additional uninstall tasks'#13#10+ //#$feff BOM is required for LoadStringsFromFile
'#This file uses UTF-8 encoding'#13#10+
'#'#13#10+
'#Empty lines and lines beginning with # are ignored'#13#10+
'#'#13#10+
'#Add uninstallers for GIMP add-ons that should be removed together with GIMP like this:'#13#10+
'#Run://'#13#10+
'#'#13#10+
'#The file is parsed in reverse order' + #13#10 +
'' + #13#10 //needs '' in front, otherwise preprocessor complains
,False)
else
begin
if LoadStringFromUTF8File(sUnInf,sOldContent) then
if Pos(#13#10+pText+#13#10,sOldContent) > 0 then //don't write duplicate lines
exit;
end;
SaveStringToUTF8File(sUnInf,pText+#13#10,True);
end;
procedure GetGimpInfo(const pRootKey: Integer; const pRegPath: String);
var p: Integer;
begin
If not RegQueryStringValue(pRootKey, pRegPath, RegKey, GimpPath) then //find Gimp install dir
begin
GimpPath := ExpandConstant('{pf}\GIMP 2');
end;
If not RegQueryStringValue(pRootKey, pRegPath, VerKey, GimpVer) then //find Gimp version
begin
GimpVer := '0';
end;
if GimpVer <> '' then //GimpVer at this point contains 'GIMP x.y.z' - strip the first part
begin
p := Pos('gimp ',LowerCase(GimpVer));
if p > 0 then
GimpVer := Copy(GimpVer,p+5,Length(GimpVer))
else
GimpVer := '0';
end;
end;
procedure WriteUninstallInfo();
begin
if InstallType <> itOld then //new installer expects components to be listed in the uninst.inf file
SaveToUninstInf('Run:GIMP Help/'+ExpandConstant('{uninstallexe}')+'//SILENT /NORESTART');
end;
function InitializeSetup(): Boolean;
begin
Result := True;
if IsWin64 and RegValueExists(HKLM64, RegPathNew, RegKey) then //check for 64bit GIMP with new installer first
begin
GetGimpInfo(HKLM64, RegPathNew);
InstallType := itNew64;
end else
if RegValueExists(HKLM, RegPathNew, RegKey) then //then for 32bit GIMP with new installer
begin
GetGimpInfo(HKLM, RegPathNew);
InstallType := itNew;
end else
if RegValueExists(HKLM, RegPath, RegKey) then //and finally for old installer
begin
GetGimpInfo(HKLM, RegPath);
InstallType := itOld;
end else
begin
GimpPath := ExpandConstant('{pf}\GIMP 2'); //provide some defaults
GimpVer := '0';
end;
end;
procedure CurStepChanged(pCurStep: TSetupStep);
begin
case pCurStep of
ssPostInstall:
begin
WriteUninstallInfo();
end;
end;
end;
procedure InitializeWizard();
var r: Integer;
begin
r := SHAutoComplete(WizardForm.DirEdit.Handle,SHACF_FILESYSTEM);
end;
function GetGimpDir(S: String): String;
begin
Result := GimpPath;
end;
function GetUninstallDir(default: String): String;
begin
if CompareVersion(GimpVer,'2.4.0') >= 0 then
Result := ExpandConstant('{app}')
else
begin
if InstallType = itOld then
Result := ExpandConstant('{app}\setup')
else
Result := ExpandConstant('{app}\uninst');
end;
end;
function GetAppId(default: String): String;
begin
if InstallType = itOld then
Result := 'WinGimp-2.0'
else
Result := '{#APP_ID}';
end;
(*
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
case CurPageID of
wpSelectDir:
begin
//you can do checks here
if not FileExists(AddBackslash(WizardDirValue) + 'bin\gimp-2.6.exe') then
begin
if SuppressibleMsgBox(CustomMessage('DirNotGimp'),mbConfirmation,MB_YESNO,IDYES) = IDNO then
Result := False;
end;
end;
end;
end;
*)
//#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")
GIMP-Lensfun-0.2.3/tools/gimplensfun.spec.in 0000664 0000000 0000000 00000002306 12141230411 0020616 0 ustar 00root root 0000000 0000000 # gimplensfun RPM specification file template
# based on the Fedora packaging guidelines
# replace the following:
# __VERSION__ with the version number
# __CHANGES__ with the change log info
Name: gimplensfun
Version: __VERSION__
Release: 1%{?dist}
Summary: Gimp plugin to correct lens distortion
Group: Applications/Multimedia
License: GPLv3
URL: http://lensfun.sebastiankraft.net/
Source0: http://lensfun.sebastiankraft.net/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gimp-devel >= 2.0
BuildRequires: exiv2-devel
BuildRequires: lensfun-devel
Requires: gimp >= 2.0
Requires: lensfun
Requires: exiv2
%description
GimpLensfun is a Gimp plugin to correct lens distortion using the lensfun
library and database.
%prep
%setup -q
%build
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_libdir}/gimp/2.0/plug-ins
install -m 755 %{name} $RPM_BUILD_ROOT%{_libdir}/gimp/2.0/plug-ins
%clean
rm -rf $RPM_BUILD_ROOT
%files
%doc LICENSE.txt CHANGES.txt README.txt
%{_libdir}/gimp/2.0/plug-ins/%{name}
%changelog
__CHANGES__