generic: import libkdcraw and libkexiv2, minor cleanup

This commit is contained in:
Ivailo Monev 2015-06-15 21:15:22 +03:00
parent 224a6ff3e8
commit d63f62ef99
108 changed files with 40747 additions and 22 deletions

View file

@ -244,7 +244,8 @@ add_subdirectory( plasma )
add_subdirectory( kunitconversion )
add_subdirectory( kdewebkit )
add_subdirectory( includes )
add_subdirectory( libkdcraw )
add_subdirectory( libkexiv2 )
add_subdirectory( experimental )
################# write dependency file which will be installed #################

View file

@ -0,0 +1,79 @@
# - Find LibRaw
# Find the LibRaw library <http://www.libraw.org>
# This module defines
# LibRaw_VERSION_STRING, the version string of LibRaw
# LibRaw_INCLUDE_DIR, where to find libraw.h
# LibRaw_LIBRARIES, the libraries needed to use LibRaw (non-thread-safe)
# LibRaw_r_LIBRARIES, the libraries needed to use LibRaw (thread-safe)
# LibRaw_DEFINITIONS, the definitions needed to use LibRaw (non-thread-safe)
# LibRaw_r_DEFINITIONS, the definitions needed to use LibRaw (thread-safe)
#
# Copyright (c) 2013, Pino Toscano <pino at kde dot org>
# Copyright (c) 2013, Gilles Caulier <caulier dot gilles at gmail dot com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
FIND_PACKAGE(PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(PC_LIBRAW libraw)
SET(LibRaw_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER})
PKG_CHECK_MODULES(PC_LIBRAW_R libraw_r)
SET(LibRaw_r_DEFINITIONS ${PC_LIBRAW_R_CFLAGS_OTHER})
ENDIF()
FIND_PATH(LibRaw_INCLUDE_DIR libraw.h
HINTS
${PC_LIBRAW_INCLUDEDIR}
${PC_LibRaw_INCLUDE_DIRS}
PATH_SUFFIXES libraw
)
FIND_LIBRARY(LibRaw_LIBRARIES NAMES raw
HINTS
${PC_LIBRAW_LIBDIR}
${PC_LIBRAW_LIBRARY_DIRS}
)
FIND_LIBRARY(LibRaw_r_LIBRARIES NAMES raw_r
HINTS
${PC_LIBRAW_R_LIBDIR}
${PC_LIBRAW_R_LIBRARY_DIRS}
)
IF(LibRaw_INCLUDE_DIR)
FILE(READ ${LibRaw_INCLUDE_DIR}/libraw_version.h _libraw_version_content)
STRING(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content})
SET(_libraw_version_major "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content})
SET(_libraw_version_minor "${CMAKE_MATCH_1}")
STRING(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content})
SET(_libraw_version_patch "${CMAKE_MATCH_1}")
IF(_version_major_match AND _version_minor_match AND _version_patch_match)
SET(LibRaw_VERSION_STRING "${_libraw_version_major}.${_libraw_version_minor}.${_libraw_version_patch}")
ELSE()
IF(NOT LibRaw_FIND_QUIETLY)
MESSAGE(STATUS "Failed to get version information from ${LibRaw_INCLUDE_DIR}/libraw_version.h")
ENDIF()
ENDIF()
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibRaw
REQUIRED_VARS LibRaw_LIBRARIES LibRaw_INCLUDE_DIR
VERSION_VAR LibRaw_VERSION_STRING
)
MARK_AS_ADVANCED(LibRaw_VERSION_STRING
LibRaw_INCLUDE_DIR
LibRaw_LIBRARIES
LibRaw_r_LIBRARIES
LibRaw_DEFINITIONS
LibRaw_r_DEFINITIONS
)

View file

@ -1,17 +0,0 @@
Begin3
Title: kwebkitpart
Version: 1.2.0
Entered-date: 06APR2011
Description: A WebKit browser component for KDE (KPart)
Keywords: webkit, webkitpart
Author: Trolltech ASA
Urs Wolfer <uwolfer @ kde.org>
Laurent Montel <montel@kde.org>
Dawit Alemayehu <adawit@kde.org>
Maintained-by: Dawit Alemayehu <adawit@kde.org>
Primary-site: ftp://ftp.kde.org/pub/kde/stable/kwebkitpart/1.2/
Home-Page: https://projects.kde.org/projects/extragear/base/kwebkitpart
Original-site: None
Platforms: KDE 4.4 and higher
Copying-policy: LGPL
End

2
libkdcraw/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.kate-swp
tests/databases/*/*.db

2
libkdcraw/.krazy Normal file
View file

@ -0,0 +1,2 @@
SKIP /libraw/

15
libkdcraw/AUTHORS Normal file
View file

@ -0,0 +1,15 @@
AUTHORS AND MAINTAINERS :
Caulier Gilles <caulier dot gilles at gmail dot com>
Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
CONTRIBUTORS:
Angelo Naselli <anaselli at linux dot it>
Gerhard Kulzer <gerhard at kulzer dot net>
Achim Bohnet <ach at mpe dot mpg dot de>
Guillaume Castagnino <casta at xwing dot info>
THANKS:
Alex Tutubalin <lexa at lexa dot ru> from LibRaw project (http://www.libraw.org)

102
libkdcraw/CMakeLists.txt Normal file
View file

@ -0,0 +1,102 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-12-09
# @brief a tread-safe libraw C++ program interface for KDE
#
# @author Copyright (C) 2006-2014 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
PROJECT(libkdcraw)
MESSAGE(STATUS "----------------------------------------------------------------------------------")
MESSAGE(STATUS "Starting CMake configuration for: libkdcraw")
FIND_PACKAGE(KDE4 REQUIRED 4.14.3)
INCLUDE(KDE4Defaults)
INCLUDE(MacroLibrary)
INCLUDE(MacroOptionalAddSubdirectory)
INCLUDE(FindPackageHandleStandardArgs)
INCLUDE(CMakePackageConfigHelpers)
# NOTE: Libraw 0.16.x is prefered version to use because it's ported to Cmake with full features supported.
# Until libraw 0.16.0 is release (ends of 2013), we will support previous version (with limited support)
FIND_PACKAGE(LibRaw 0.15)
SET_PACKAGE_PROPERTIES(LibRaw PROPERTIES DESCRIPTION "library that provides image Raw file demosaicing" URL "http://www.libraw.org" TYPE REQUIRED PURPOSE "Required to build libkdcraw")
IF(NOT LIBRAW_FOUND)
FEATURE_SUMMARY(
WHAT ALL
INCLUDE_QUIET_PACKAGES
FATAL_ON_MISSING_REQUIRED_PACKAGES
)
RETURN()
ENDIF()
# Check LibRaw config header.
MESSAGE(STATUS "LibRaw version: ${LibRaw_VERSION_STRING}")
IF(EXISTS "${LibRaw_INCLUDE_DIR}/libraw_config.h")
ADD_DEFINITIONS(-DLIBRAW_HAS_CONFIG)
MESSAGE(STATUS "LibRaw config file exists: yes")
ELSE()
MESSAGE(STATUS "LibRaw config file exists: no")
ENDIF()
ADD_DEFINITIONS(${QT_DEFINITIONS}
${QT_QTDBUS_DEFINITIONS}
${KDE4_DEFINITIONS}
${LibRaw_r_DEFINITIONS}
)
INCLUDE_DIRECTORIES(${QDBUS_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_SOURCE_DIR}/threadweaver
${LibRaw_INCLUDE_DIR}
)
SET(LIBKDCRAW_AREA_CODE_GENERAL 51002)
ADD_DEFINITIONS(-DKDE_DEFAULT_DEBUG_AREA=${LIBKDCRAW_AREA_CODE_GENERAL})
# ==================================================================================================
# Set env. variables accordinly.
SET(DCRAW_LIB_VERSION_STRING "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_RELEASE}")
SET(DCRAW_LIB_VERSION_ID "0x0${KDE_VERSION_MAJOR}0${KDE_VERSION_MINOR}0${KDE_VERSION_RELEASE}")
SET(DCRAW_LIB_SO_VERSION_STRING "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_RELEASE}")
# ==================================================================================================
ADD_SUBDIRECTORY(libkdcraw)
ADD_SUBDIRECTORY(icons)
ADD_SUBDIRECTORY(profiles)
IF(KDE4_BUILD_TESTS)
MACRO_OPTIONAL_ADD_SUBDIRECTORY(tests)
ENDIF(KDE4_BUILD_TESTS)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libkdcraw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkdcraw.pc)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libkdcraw.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
FEATURE_SUMMARY(
WHAT ALL
INCLUDE_QUIET_PACKAGES
FATAL_ON_MISSING_REQUIRED_PACKAGES
)

340
libkdcraw/COPYING Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. 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.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE 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.
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
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This 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 Library General
Public License instead of this License.

View file

@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

481
libkdcraw/COPYING.LIB Normal file
View file

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library 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 Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

1661
libkdcraw/ChangeLog Normal file

File diff suppressed because it is too large Load diff

2
libkdcraw/Messages.sh Normal file
View file

@ -0,0 +1,2 @@
#! /bin/sh
$XGETTEXT libkdcraw/*.cpp -o $podir/libkdcraw.pot

190
libkdcraw/NEWS Normal file
View file

@ -0,0 +1,190 @@
1.1.0 - Released with KDE 4.5.0
------------------------------------------------------------------------
*dcraw 9.03 (1.437) imported:
+ New cameras: Canon SX20, Nikon D3s, Olympus E-P2, Panasoni DMC-GF1, Samsung EX1, Sony A450.
+ Color data changed for some cameras.
* dcraw 9.01 (1.434) imported:
+ Separate black levels for each color channel.
+ New cameras: Canon 550D, Casio EX-Z1050, Fuji HS10/HS11,
Kodak Z981, Panasonic G2 and G10, Phase One P65,
Samsung NX-10 and WB550, Sony NEX-3 and NEX-5.
+ Fixed file descriptor leak in dark frame subtraction processing
* Fixed dcraw 9.01's bug in DNG black level processing
* Preliminary support for Sony A450 camera.
* New command-line switch -h in mem_image sample (half_size support)
* Some patches by Johannes Hanika (darktable author):
+ OpenMP speedup for PPG-interpolation
+ green_matching - suppress of 'color maze' on cameras with
different green channel sensitivity. This option is turns on
by filed with same name in imgdata.params
* LibRaw::free() is now public instead of private.
1.0.0 - Released with KDE 4.4.0
------------------------------------------------------------------------
- Updated to LibRaw 0.8.4:
# Fixed a bug in Phase One uncompressed files processing
- Updated to LibRaw 0.8.3:
# New cameras : Canon 7D, Panasonic GF1, Sony A850 and A380, Casio Z850, Nikon D300s
- Updated to LibRaw 0.8.2:
# Fixed bug in Hasselblad .3FR unpacking code
# Imported dcraw 8.97/1.428: Nikon D3000 image width fix
# Enum LibRaw_thumbnail_formats (LIBRAW_IMAGE_*) values changed to match values in enum LibRaw_image_formats (LIBRAW_THUMBNAIL_*).
- Updated to LibRaw 0.8.1:
# Imported dcraw 8.97/1.427: new cameras: Canon A470, Canon G11 (without color data), Nikon D3000, Olympus E-P1, Panasonic DMC-FZ35/FZ38
# Fixes for Microsoft Visual C++ 6.0 compatibility
# C-API libraw_dcraw_make_mem_thumb() call finally exported in API
- Updated to LibRaw 0.8.0:
# Support of RAW files larger than 2Gb
# dcraw 8.86/1.426 imported:
* many new cameras supported:
Casio EX-S20, EX-Z60, EX-Z75
Kodak Z980, Z1015
Nikon D5000
Olympus X200, D560Z, C350Z, E30, E620
Canon SX1, 500D/Rebel T1i, A570, A590, SX110
Motorola PIXL, Panasonic DMC-GH1, Pentax K7, Sony A330
AGFAPHOTO DC-833m,Phase One P65, Samsung S850.
* New color data for many cameras.
* Generalized unpacking code for many formats.
* Removed hardcoded white-balance data for many P&S cameras. It is recommended to set params.use_camera_wb to 1 for safe WB.
* Canon cameras: black level is not subtracted if params.document_mode =2
# API changes: params.gamma_16bit field removed. Gamma curve is set via params.gamm[0]/gamm[1] values (see documentation and samples for details)
# Many cosmetic changes to support more platforms/compilers.
# Samples: dcraw_emu and mem_image samples supports new dcraw 16bit/gamma semantics:
* -6: set 16 bit output
* -4: set 16 bit output and linear gamma curve and no auto brightness
# C-API: added missed (but documented) calls libraw_dcraw_make_mem_image() and libraw_dcraw_ make_mem_thumb()
- API changed : remove RawDecodingSetting::gamma16bit settings. Obsolete with LibRaw 0.8.0.
remove KDcraw depreciated methods.
- New widget to host settings : RExpanderBox.
0.5.0 - Released with KDE 4.3.0
------------------------------------------------------------------------
- Updated to LibRaw 0.7.2 : More accurate types conversion in libraw_datastream.h to make compilers happy.
New postprocessing parameter auto_bright_thr: set portion of clipped pixels for
auto brightening code (instead of dcraw-derived hardcoded 1%).
-U option for dcraw_emu sample sets auto_bright_thr parameter.
- Updated to LibRaw 0.7.1 : Fixed broken OpenMP support.
- Updated to LibRaw 0.7.0 : Black (masked) pixels data extracted from RAW and avaliable in application.
Application can turn off RAW data filtering (black level subtraction,
zero pixels removal and raw tone curve).
New 'input framework' released. Reading raw data from file and memory buffer supported from scratch.
LibRaw-using application can implement own data reading functions (e.g. reading from network stream).
Fuji SuperCCD: raw data extracted without 45-degree rotation.
New sample applications: 4channels and unprocessed_raw
Imported (subsequentally) new dcraw versions from 8.89 to 8.93 (up to date)
- New option to switch on/off auto brightness adjsutements.
- Add support of Leica Raw files (RWL).
- New method to see if Libraw use OpenMP shared library to perform parallel demosaicing.
- OpenMP support auto detection based on FindOpenMP Cmake script.
0.4.0 - Released with KDE 4.2.0
------------------------------------------------------------------------
- Updated to LibRaw 0.6.5 : Fixed file descriptor and buffer memory leak when thumbnail extractor is called,
but library object is not properly initialized.
Fixes in Imacon files unpacking.
Fixes in Hasselblad .fff files unpacking.
- Updated to LibRaw 0.6.3 : NEF processing code changed (some overflow control added).
- Updated to LibRaw 0.6.2.
- New cameras: Canon G10 & 5D Mk2, Leaf AFi 7, Leica D-LUX4,
Panasonic FX150 & G 1, Fujifilm IS Pro.
- Updated to LibRaw 0.6.1.
- New cameras: Canon 50D, Sony A900, Nikon D90 & P6000, Panasonic LX3 FZ28.
- Ported to LibRaw Api 0.6.0. Removed dcraw.c and DcrawBinary class.
- Use kDebug(51002) instead qDebug().
0.3.0 - Released with KDE 4.1.2
------------------------------------------------------------------------
- Sync with KDE3 branch 0.1.5 API changes.
0.2.0 - Released with KDE 4.1.0
------------------------------------------------------------------------
- Port to CMake/KDE4/QT4
- Moved from extragear/libs to kdegraphics/libs
0.1.5
------------------------------------------------------------------------
- API changed: add white point settings support (dcraw -S option)
- Updated dcraw to 8.86
New camera : Sony A300.
Fixed camera WB on the A200.
Set model-specific saturation levels in adobe_coeff().
No new options introduced.
- Updated dcraw to 8.85
New camera : Olympus E-420.
No new options introduced.
- Updated dcraw to 8.84
New cameras: Canon EOS 450D, Nikon D60, and Fuji S100FS.
Copied new matrices from Adobe DNG Converter 4.4.
sRAW support in 1.393 broke Fuji DNG files, now fixed.
No new options introduced.
0.1.4
------------------------------------------------------------------------
- updated dcraw to 8.83
new cameras: Apple QuickTake 200, Fuji IS-1, Sony DSLR-A350, Pentax K20D,
Nokia N95, Canon PowerShots A460, Canon PowerShots A530,
Canon PowerShots A650.
no new options introduced.
- updated dcraw to 8.82
new cameras: Sony DSLR-A200, Sony DSLR-A700, Sony XCD-SX910CR, STV680 VGA
no new options introduced.
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 142055 : Which whitebalance is used.
0.1.3
------------------------------------------------------------------------
- updated dcraw to 8.81
- New cameras: Canon G7, Fuji FinePix S9100/S9600, Olympus SP560UZ, Panasonic DMC-L10
- updated dcraw to 8.80
- new cameras: Hasselblad H3D, Olympus E-3, Canon EOS 40D, Canon PowerShot G9,
Canon EOS-1Ds Mark III, AVT F-080C, Nikon D3, Nikon D300,
Nikon Coolpix S6, Panasonic DMC-FZ18, Sony DSLR-A700
-m number_of_passes
After interpolation, clean up color artifacts by repeatedly
applying a 3x3 median filter to the R-G and B-G channels.
- dcraw.c licence : is GPL compatible again == less wories)
0.1.2
------------------------------------------------------------------------
New features
- updated internal dcraw from 8.60 to 8.77. API changed.
- add new chromatic aberration reduction options (patch from Guillaume Castagnino).
0.1.1
------------------------------------------------------------------------
New features
- API changed: * KDcraw destructor is now virtual.
* Added DcrawSettingsContainer destructor.
* Separate embedded JPEG preview extraction and half decoding methods
to get a preview of RAW pictures.
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 145482 : libkdraw compile fails on Cygwin.
0.1.0
------------------------------------------------------------------------
First implementation
For details and info about previous versions, see ChangeLog.

76
libkdcraw/README Normal file
View file

@ -0,0 +1,76 @@
LibRaw C++ interface for KDE
This library is a part of digiKam project (http://www.digikam.org)
-- AUTHORS -----------------------------------------------------------
See AUTHORS file for details.
-- ABOUT -------------------------------------------------------------
Libkdcraw is a C++ interface around LibRaw library used to decode RAW
picture files. More information about LibRaw can be found at http://www.libraw.org.
This library is used by kipi-plugins, digiKam and others kipi host programs.
The library documentation is available on header files.
-- DEPENDENCIES -------------------------------------------------------
CMake >= 2.4.3 http://www.cmake.org
libqt >= 4.2.x http://www.qtsoftware.com
libkde >= 4.0.x http://www.kde.org
libraw >= 0.16.x http://www.libraw.org
Note: all library dependencies require development and binary packages installed on your
computer to compile digiKam.
-- INSTALL ------------------------------------------------------------
In order to compile, especially when QT3/Qt4 are installed at the same time,
just use something like that:
# export VERBOSE=1
# export QTDIR=/usr/lib/qt4/
# export PATH=$QTDIR/bin:$PATH
# cmake .
# make
Usual CMake options :
-DCMAKE_INSTALL_PREFIX : decide where the program will be install on your computer.
-DCMAKE_BUILD_TYPE : decide which type of build you want. You can chose between "debugfull", "debug", "profile", "relwithdebinfo" and "release". The default is "relwithdebinfo" (-O2 -g).
Compared to old KDE3 autoconf options:
"cmake . -DCMAKE_BUILD_TYPE=debugfull" is equivalent to "./configure --enable-debug=full"
"cmake . -DCMAKE_INSTALL_PREFIX=/usr" is equivalent to "./configure --prefix=/usr"
More details can be found ata this url: http://techbase.kde.org/Development/Tutorials/CMake#Environment_Variables
Note: To know KDE install path on your computer, use 'kde-config --prefix' command line like this (with full debug object enabled):
"cmake . -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`"
-- CONTACT ------------------------------------------------------------
If you have questions, comments, suggestions to make do email at :
kde-imaging@kde.org
IRC channel from freenode.net server:
#kde-imaging
-- BUGS ---------------------------------------------------------------
IMPORTANT : the bugreports and wishlist are hosted by the KDE bugs report
system who can be contacted by the standard Kde help menu of plugins dialog.
A mail will be automatically sent to the Kipi mailing list.
There is no need to contact directly the Kipi mailing list for a bug report
or a devel wish.
The current Kipi bugs and devel wish reported to the Kde bugs report can be see
at this url :
http://bugs.kde.org/buglist.cgi?product=digikam&component=libkdcraw&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED

14
libkdcraw/TODO Normal file
View file

@ -0,0 +1,14 @@
- Add DNG writting mode support using Adobe DNG sdk
- Libraw 0.13.0 features to support :
1) Green channel local averaging. All interpolation methods, but may conflict with green_matching option, so it is safer to use only one green averaging.
int cfa_green; Boolean, default is 0 (off)
float green_threshold; - Sensitivity of method (green is averaged if difference less than this value in percent). Usable range between 0.01 and 0.1, commonly 0.03
This filtering is applied *before* demosaic.
The problem is simple: on some cameras (for example, Olympus E-xxx) two green channels are different (in sensitivity and, may be, in spectral response).
As a result, it produces 'maze artifacts' on flat surfaces (like sky).
The solution is simple: if two channels are *slightly* different in some local area, it is better to equalize it.

View file

@ -0,0 +1,25 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-12-09
# @brief a tread-safe libraw C++ program interface for KDE
#
# @author Copyright (C) 2006-2012 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
kde4_install_icons ( ${ICON_INSTALL_DIR} )

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -0,0 +1,12 @@
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${BIN_INSTALL_DIR}
libdir=${LIB_INSTALL_DIR}
includedir=${INCLUDE_INSTALL_DIR}
Name: libkdcraw
Description: A C++ wrapper around LibRaw library to decode RAW pictures. This library is used by digiKam and kipi-plugins.
URL: http://www.digikam.org/sharedlibs
Requires:
Version: ${DCRAW_LIB_VERSION_STRING}
Libs: -L${LIB_INSTALL_DIR} -lkdcraw
Cflags: -I${INCLUDE_INSTALL_DIR}

View file

@ -0,0 +1,68 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-12-09
# @brief a tread-safe libraw C++ program interface for KDE
#
# @author Copyright (C) 2006-2013 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
add_definitions(${KDE4_ENABLE_EXCEPTIONS})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
SET(kdcraw_LIB_SRCS kdcraw.cpp
kdcraw_p.cpp
dcrawsettingswidget.cpp
dcrawinfocontainer.cpp
rawdecodingsettings.cpp
rcombobox.cpp
rnuminput.cpp
rexpanderbox.cpp
ractionthreadbase.cpp
ractionthreadbase_p.cpp
squeezedcombobox.cpp
)
KDE4_ADD_LIBRARY(kdcraw SHARED ${kdcraw_LIB_SRCS})
TARGET_LINK_LIBRARIES(kdcraw
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${KDE4_SOLID_LIBS}
${KDE4_THREADWEAVER_LIBS}
${LibRaw_r_LIBRARIES}
)
SET_TARGET_PROPERTIES(kdcraw PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION})
INSTALL(TARGETS kdcraw ${INSTALL_TARGETS_DEFAULT_ARGS})
INSTALL(FILES rawdecodingsettings.h
kdcraw.h
dcrawsettingswidget.h
rnuminput.h
rcombobox.h
rexpanderbox.h
ractionthreadbase.h
squeezedcombobox.h
dcrawinfocontainer.h
rawfiles.h
libkdcraw_export.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION ${INCLUDE_INSTALL_DIR}/libkdcraw COMPONENT Devel)

1067
libkdcraw/libkdcraw/Doxyfile Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
/** @mainpage libKDcraw
libKDcraw is a thread-safe wrapper around <a href="http://www.libraw.org">libraw</a>. Have a look at KDcrawIface::KDcraw to get started.
@see KDcrawIface::KDcraw
*/

View file

@ -0,0 +1,173 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-05-02
* @brief RAW file identification information container
*
* @author Copyright (C) 2007-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Local includes
#include "dcrawinfocontainer.h"
namespace KDcrawIface
{
DcrawInfoContainer::DcrawInfoContainer()
{
sensitivity = -1.0;
exposureTime = -1.0;
aperture = -1.0;
focalLength = -1.0;
pixelAspectRatio = 1.0; // Default value. This can be unavailable (depending of camera model).
rawColors = -1;
rawImages = -1;
hasIccProfile = false;
isDecodable = false;
daylightMult[0] = 0.0;
daylightMult[1] = 0.0;
daylightMult[2] = 0.0;
cameraMult[0] = 0.0;
cameraMult[1] = 0.0;
cameraMult[2] = 0.0;
cameraMult[3] = 0.0;
blackPoint = 0;
for (int ch=0; ch<4; ch++)
{
blackPointCh[ch] = 0;
}
whitePoint = 0;
topMargin = 0;
leftMargin = 0;
orientation = ORIENTATION_NONE;
for (int x=0 ; x<3 ; x++)
{
for (int y=0 ; y<4 ; y++)
{
cameraColorMatrix1[x][y] = 0.0;
cameraColorMatrix2[x][y] = 0.0;
cameraXYZMatrix[y][x] = 0.0; // NOTE: see B.K.O # 253911 : [y][x] not [x][y]
}
}
}
DcrawInfoContainer::~DcrawInfoContainer()
{
}
bool DcrawInfoContainer::isEmpty()
{
if (make.isEmpty() &&
model.isEmpty() &&
filterPattern.isEmpty() &&
colorKeys.isEmpty() &&
DNGVersion.isEmpty() &&
exposureTime == -1.0 &&
aperture == -1.0 &&
focalLength == -1.0 &&
pixelAspectRatio == 1.0 &&
sensitivity == -1.0 &&
rawColors == -1 &&
rawImages == -1 &&
blackPoint == 0 &&
blackPointCh[0] == 0 &&
blackPointCh[1] == 0 &&
blackPointCh[2] == 0 &&
blackPointCh[3] == 0 &&
whitePoint == 0 &&
topMargin == 0 &&
leftMargin == 0 &&
!dateTime.isValid() &&
!imageSize.isValid() &&
!fullSize.isValid() &&
!outputSize.isValid() &&
!thumbSize.isValid() &&
cameraColorMatrix1[0][0] == 0.0 &&
cameraColorMatrix1[0][1] == 0.0 &&
cameraColorMatrix1[0][2] == 0.0 &&
cameraColorMatrix1[0][3] == 0.0 &&
cameraColorMatrix1[1][0] == 0.0 &&
cameraColorMatrix1[1][1] == 0.0 &&
cameraColorMatrix1[1][2] == 0.0 &&
cameraColorMatrix1[1][3] == 0.0 &&
cameraColorMatrix1[2][0] == 0.0 &&
cameraColorMatrix1[2][1] == 0.0 &&
cameraColorMatrix1[2][2] == 0.0 &&
cameraColorMatrix1[2][3] == 0.0 &&
cameraColorMatrix2[0][0] == 0.0 &&
cameraColorMatrix2[0][1] == 0.0 &&
cameraColorMatrix2[0][2] == 0.0 &&
cameraColorMatrix2[0][3] == 0.0 &&
cameraColorMatrix2[1][0] == 0.0 &&
cameraColorMatrix2[1][1] == 0.0 &&
cameraColorMatrix2[1][2] == 0.0 &&
cameraColorMatrix2[1][3] == 0.0 &&
cameraColorMatrix2[2][0] == 0.0 &&
cameraColorMatrix2[2][1] == 0.0 &&
cameraColorMatrix2[2][2] == 0.0 &&
cameraColorMatrix2[2][3] == 0.0 &&
cameraXYZMatrix[0][0] == 0.0 &&
cameraXYZMatrix[0][1] == 0.0 &&
cameraXYZMatrix[0][2] == 0.0 &&
cameraXYZMatrix[1][0] == 0.0 &&
cameraXYZMatrix[1][1] == 0.0 &&
cameraXYZMatrix[1][2] == 0.0 &&
cameraXYZMatrix[2][0] == 0.0 &&
cameraXYZMatrix[2][1] == 0.0 &&
cameraXYZMatrix[2][2] == 0.0 &&
cameraXYZMatrix[3][0] == 0.0 &&
cameraXYZMatrix[3][1] == 0.0 &&
cameraXYZMatrix[3][2] == 0.0 &&
orientation == ORIENTATION_NONE
)
{
return true;
}
else
{
return false;
}
}
QDebug operator<<(QDebug dbg, const DcrawInfoContainer& c)
{
dbg.nospace() << "DcrawInfoContainer::sensitivity: " << c.sensitivity << ", ";
dbg.nospace() << "DcrawInfoContainer::exposureTime: " << c.exposureTime << ", ";
dbg.nospace() << "DcrawInfoContainer::aperture: " << c.aperture << ", ";
dbg.nospace() << "DcrawInfoContainer::focalLength: " << c.focalLength << ", ";
dbg.nospace() << "DcrawInfoContainer::pixelAspectRatio: " << c.pixelAspectRatio << ", ";
dbg.nospace() << "DcrawInfoContainer::rawColors: " << c.rawColors << ", ";
dbg.nospace() << "DcrawInfoContainer::rawImages: " << c.rawImages << ", ";
dbg.nospace() << "DcrawInfoContainer::hasIccProfile: " << c.hasIccProfile << ", ";
dbg.nospace() << "DcrawInfoContainer::isDecodable: " << c.isDecodable << ", ";
dbg.nospace() << "DcrawInfoContainer::daylightMult: " << c.daylightMult << ", ";
dbg.nospace() << "DcrawInfoContainer::cameraMult: " << c.cameraMult << ", ";
dbg.nospace() << "DcrawInfoContainer::blackPoint: " << c.blackPoint << ", ";
dbg.nospace() << "DcrawInfoContainer::whitePoint: " << c.whitePoint << ", ";
dbg.nospace() << "DcrawInfoContainer::topMargin: " << c.topMargin << ", ";
dbg.nospace() << "DcrawInfoContainer::leftMargin: " << c.leftMargin << ", ";
dbg.nospace() << "DcrawInfoContainer::orientation: " << c.orientation;
return dbg.space();
}
} // namespace KDcrawIface

View file

@ -0,0 +1,158 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-05-02
* @brief RAW file identification information container
*
* @author Copyright (C) 2007-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef DCRAW_INFO_CONTAINER_H
#define DCRAW_INFO_CONTAINER_H
// Qt includes
#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtCore/QSize>
#include <QtCore/QDebug>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT DcrawInfoContainer
{
public:
/** The RAW image orientation values
*/
enum ImageOrientation
{
ORIENTATION_NONE = 0,
ORIENTATION_180 = 3,
ORIENTATION_Mirror90CCW = 4,
ORIENTATION_90CCW = 5,
ORIENTATION_90CW = 6
};
public:
/** Standard constructor */
DcrawInfoContainer();
/** Standard destructor */
virtual ~DcrawInfoContainer();
/** Return 'true' if container is empty, else 'false' */
bool isEmpty();
public:
/** True if RAW file include an ICC color profile. */
bool hasIccProfile;
/** True is RAW file is decodable by dcraw. */
bool isDecodable;
/** The number of RAW colors. */
int rawColors;
/** The number of RAW images. */
int rawImages;
/** Black level from Raw histogram. */
unsigned int blackPoint;
/** Channel black levels from Raw histogram. */
unsigned int blackPointCh[4];
/** White level from Raw histogram. */
unsigned int whitePoint;
/** Top margin of raw image. */
unsigned int topMargin;
/** Left margin of raw image. */
unsigned int leftMargin;
/** The raw image orientation */
ImageOrientation orientation;
/** The sensitivity in ISO used by camera to take the picture. */
float sensitivity;
/** ==> 1/exposureTime = exposure time in seconds. */
float exposureTime;
/** ==> Aperture value in APEX. */
float aperture;
/** ==> Focal Length value in mm. */
float focalLength;
/** The pixel Aspect Ratio if != 1.0. NOTE: if == 1.0, dcraw do not show this value. */
float pixelAspectRatio;
/** White color balance settings. */
double daylightMult[3];
/** Camera multipliers used for White Balance adjustments */
double cameraMult[4];
/** Camera Color Matrix */
float cameraColorMatrix1[3][4];
float cameraColorMatrix2[3][4];
float cameraXYZMatrix[4][3];
/** The used Color Keys */
QString colorKeys;
/** The camera maker. */
QString make;
/** The camera model. */
QString model;
/** The artist name who have picture owner. */
QString owner;
/** The demosaising filter pattern. */
QString filterPattern;
/** The DNG version. NOTE: it is only shown with DNG RAW files. */
QString DNGVersion;
/** Date & time when the picture has been taken. */
QDateTime dateTime;
/** The image dimensions in pixels. */
QSize imageSize;
/** The thumb dimensions in pixels. */
QSize thumbSize;
/** The full RAW image dimensions in pixels. */
QSize fullSize;
/** The output dimensions in pixels. */
QSize outputSize;
};
//! kDebug() stream operator. Writes container @a c to the debug output in a nicely formatted way.
LIBKDCRAW_EXPORT QDebug operator<<(QDebug dbg, const DcrawInfoContainer& c);
} // namespace KDcrawIface
#endif /* DCRAW_INFO_CONTAINER_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,127 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-13
* @brief LibRaw settings widgets
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2011 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2007-2008 by Guillaume Castagnino
* <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef DCRAW_SETTINGS_WIDGET_H
#define DCRAW_SETTINGS_WIDGET_H
// Qt includes
#include <QtCore/QString>
// KDE includes
#include <kurlrequester.h>
#include <kconfig.h>
// Local includes
#include "libkdcraw_export.h"
#include "rawdecodingsettings.h"
#include "rexpanderbox.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT DcrawSettingsWidget : public RExpanderBox
{
Q_OBJECT
public:
enum AdvancedSettingsOptions
{
SIXTEENBITS = 0x00000001,
COLORSPACE = 0x00000002,
POSTPROCESSING = 0x00000004,
BLACKWHITEPOINTS = 0x00000008
};
enum SettingsTabs
{
DEMOSAICING = 0,
WHITEBALANCE,
CORRECTIONS,
COLORMANAGEMENT
};
public:
/**
* @param advSettings the default value is COLORSPACE
*/
explicit DcrawSettingsWidget(QWidget* const parent, int advSettings = COLORSPACE);
virtual ~DcrawSettingsWidget();
KUrlRequester* inputProfileUrlEdit() const;
KUrlRequester* outputProfileUrlEdit() const;
void setup(int advSettings);
void setEnabledBrightnessSettings(bool b);
bool brightnessSettingsIsEnabled() const;
void updateMinimumWidth();
void resetToDefault();
void setSettings(const RawDecodingSettings& settings);
RawDecodingSettings settings() const;
void readSettings(KConfigGroup& group);
void writeSettings(KConfigGroup& group);
Q_SIGNALS:
void signalSixteenBitsImageToggled(bool);
void signalSettingsChanged();
private Q_SLOTS:
void slotWhiteBalanceToggled(int);
void slotsixteenBitsImageToggled(bool);
void slotUnclipColorActivated(int);
void slotNoiseReductionChanged(int);
void slotCACorrectionToggled(bool);
void slotExposureCorrectionToggled(bool);
void slotAutoCAToggled(bool);
void processDcrawUrl(const QString&);
void slotInputColorSpaceChanged(int);
void slotOutputColorSpaceChanged(int);
void slotRAWQualityChanged(int);
void slotExpoCorrectionShiftChanged(double);
private:
class Private;
Private* const d;
};
} // NameSpace KDcrawIface
#endif /* DCRAW_SETTINGS_WIDGET_H */

View file

@ -0,0 +1,582 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-12-09
* @brief a tread-safe libraw C++ program interface
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2007-2008 by Guillaume Castagnino
* <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_kdcraw.cpp"
#include "kdcraw_p.h"
// Qt includes
#include <QFile>
#include <QFileInfo>
#include <QStringList>
// KDE includes
#include <klibrary.h>
// LibRaw includes
#include <libraw_version.h>
#ifdef LIBRAW_HAS_CONFIG
#include <libraw_config.h>
#endif
// Local includes
#include "version.h"
#include "rawfiles.h"
static const KCatalogLoader loader("libkdcraw");
namespace KDcrawIface
{
KDcraw::KDcraw()
: d(new Private(this))
{
m_cancel = false;
}
KDcraw::~KDcraw()
{
cancel();
delete d;
}
QString KDcraw::version()
{
return QString(kdcraw_version);
}
void KDcraw::cancel()
{
m_cancel = true;
}
bool KDcraw::loadRawPreview(QImage& image, const QString& path)
{
// In first, try to extract the embedded JPEG preview. Very fast.
bool ret = loadEmbeddedPreview(image, path);
if (ret)
return true;
// In second, decode and half size of RAW picture. More slow.
return (loadHalfPreview(image, path));
}
bool KDcraw::loadEmbeddedPreview(QImage& image, const QString& path)
{
QByteArray imgData;
if ( loadEmbeddedPreview(imgData, path) )
{
kDebug() << "Preview data size:" << imgData.size();
if (image.loadFromData( imgData ))
{
kDebug() << "Using embedded RAW preview extraction";
return true;
}
}
kDebug() << "Failed to load embedded RAW preview";
return false;
}
bool KDcraw::loadEmbeddedPreview(QByteArray& imgData, const QString& path)
{
QFileInfo fileInfo(path);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
LibRaw raw;
int ret = raw.open_file(QFile::encodeName(path));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
return (Private::loadEmbeddedPreview(imgData, raw));
}
bool KDcraw::loadEmbeddedPreview(QByteArray& imgData, const QBuffer& buffer)
{
QString rawFilesExt(KDcrawIface::KDcraw::rawFiles());
LibRaw raw;
QByteArray inData = buffer.data();
int ret = raw.open_buffer((void*) inData.data(), (size_t) inData.size());
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_buffer: " << libraw_strerror(ret);
raw.recycle();
return false;
}
return (Private::loadEmbeddedPreview(imgData, raw));
}
bool KDcraw::loadHalfPreview(QImage& image, const QString& path)
{
QFileInfo fileInfo(path);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
kDebug() << "Try to use reduced RAW picture extraction";
LibRaw raw;
raw.imgdata.params.use_auto_wb = 1; // Use automatic white balance.
raw.imgdata.params.use_camera_wb = 1; // Use camera white balance, if possible.
raw.imgdata.params.half_size = 1; // Half-size color image (3x faster than -q).
int ret = raw.open_file(QFile::encodeName(path));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if(!Private::loadHalfPreview(image, raw))
{
kDebug() << "Failed to get half preview from LibRaw!";
return false;
}
kDebug() << "Using reduced RAW picture extraction";
return true;
}
bool KDcraw::loadHalfPreview(QByteArray& imgData, const QString& path)
{
QFileInfo fileInfo(path);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
kDebug() << "Try to use reduced RAW picture extraction";
LibRaw raw;
int ret = raw.open_file(QFile::encodeName(path));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run dcraw_process: " << libraw_strerror(ret);
raw.recycle();
return false;
}
QImage image;
if (!Private::loadHalfPreview(image, raw))
{
kDebug() << "KDcraw: failed to get half preview: " << libraw_strerror(ret);
return false;
}
QBuffer buffer(&imgData);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "JPEG");
return true;
}
bool KDcraw::loadHalfPreview(QByteArray& imgData, const QBuffer& inBuffer)
{
QString rawFilesExt(KDcrawIface::KDcraw::rawFiles());
LibRaw raw;
QByteArray inData = inBuffer.data();
int ret = raw.open_buffer((void*) inData.data(), (size_t) inData.size());
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run dcraw_make_mem_image: " << libraw_strerror(ret);
raw.recycle();
return false;
}
QImage image;
if (!Private::loadHalfPreview(image, raw))
{
kDebug() << "KDcraw: failed to get half preview: " << libraw_strerror(ret);
return false;
}
QBuffer buffer(&imgData);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "JPG");
return true;
}
bool KDcraw::loadFullImage(QImage& image, const QString& path, const RawDecodingSettings& settings)
{
QFileInfo fileInfo(path);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
kDebug() << "Try to load full RAW picture...";
RawDecodingSettings prm = settings;
prm.sixteenBitsImage = false;
QByteArray imgData;
int width, height, rgbmax;
KDcraw decoder;
bool ret = decoder.decodeRAWImage(path, prm, imgData, width, height, rgbmax);
if (!ret)
{
kDebug() << "Failled to load full RAW picture";
return false;
}
uchar* sptr = (uchar*)imgData.data();
uchar tmp8[2];
// Set RGB color components.
for (int i = 0 ; i < width * height ; ++i)
{
// Swap Red and Blue
tmp8[0] = sptr[2];
tmp8[1] = sptr[0];
sptr[0] = tmp8[0];
sptr[2] = tmp8[1];
sptr += 3;
}
image = QImage(width, height, QImage::Format_ARGB32);
uint* dptr = reinterpret_cast<uint*>(image.bits());
sptr = (uchar*)imgData.data();
for (int i = 0 ; i < width * height ; ++i)
{
*dptr++ = qRgba(sptr[2], sptr[1], sptr[0], 0xFF);
sptr += 3;
}
kDebug() << "Load full RAW picture done";
return true;
}
bool KDcraw::rawFileIdentify(DcrawInfoContainer& identify, const QString& path)
{
QFileInfo fileInfo(path);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
identify.isDecodable = false;
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
LibRaw raw;
int ret = raw.open_file(QFile::encodeName(path));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
ret = raw.adjust_sizes_info_only();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run adjust_sizes_info_only: " << libraw_strerror(ret);
raw.recycle();
return false;
}
Private::fillIndentifyInfo(&raw, identify);
raw.recycle();
return true;
}
// ----------------------------------------------------------------------------------
bool KDcraw::extractRAWData(const QString& filePath, QByteArray& rawData, DcrawInfoContainer& identify, unsigned int shotSelect)
{
QFileInfo fileInfo(filePath);
QString rawFilesExt(rawFiles());
QString ext = fileInfo.suffix().toUpper();
identify.isDecodable = false;
if (!fileInfo.exists() || ext.isEmpty() || !rawFilesExt.toUpper().contains(ext))
return false;
if (m_cancel)
return false;
d->setProgress(0.1);
LibRaw raw;
// Set progress call back function.
raw.set_progress_handler(callbackForLibRaw, d);
int ret = raw.open_file(QFile::encodeName(filePath));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.3);
raw.imgdata.params.output_bps = 16;
raw.imgdata.params.shot_select = shotSelect;
ret = raw.unpack();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run unpack: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.4);
ret = raw.raw2image();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run raw2image: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.6);
Private::fillIndentifyInfo(&raw, identify);
if (m_cancel)
{
raw.recycle();
return false;
}
d->setProgress(0.8);
rawData = QByteArray();
if (raw.imgdata.idata.filters == 0)
{
rawData.resize((int)(raw.imgdata.sizes.iwidth * raw.imgdata.sizes.iheight * raw.imgdata.idata.colors * sizeof(unsigned short)));
unsigned short* output = reinterpret_cast<unsigned short*>(rawData.data());
for (unsigned int row = 0; row < raw.imgdata.sizes.iheight; row++)
{
for (unsigned int col = 0; col < raw.imgdata.sizes.iwidth; col++)
{
for (int color = 0; color < raw.imgdata.idata.colors; color++)
{
*output = raw.imgdata.image[raw.imgdata.sizes.iwidth*row + col][color];
output++;
}
}
}
}
else
{
rawData.resize((int)(raw.imgdata.sizes.iwidth * raw.imgdata.sizes.iheight * sizeof(unsigned short)));
unsigned short* output = reinterpret_cast<unsigned short*>(rawData.data());
for (uint row = 0; row < raw.imgdata.sizes.iheight; row++)
{
for (uint col = 0; col < raw.imgdata.sizes.iwidth; col++)
{
*output = raw.imgdata.image[raw.imgdata.sizes.iwidth*row + col][raw.COLOR(row, col)];
output++;
}
}
}
raw.recycle();
d->setProgress(1.0);
return true;
}
bool KDcraw::decodeHalfRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
QByteArray& imageData, int& width, int& height, int& rgbmax)
{
m_rawDecodingSettings = rawDecodingSettings;
m_rawDecodingSettings.halfSizeColorImage = true;
return (d->loadFromLibraw(filePath, imageData, width, height, rgbmax));
}
bool KDcraw::decodeRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
QByteArray& imageData, int& width, int& height, int& rgbmax)
{
m_rawDecodingSettings = rawDecodingSettings;
return (d->loadFromLibraw(filePath, imageData, width, height, rgbmax));
}
bool KDcraw::checkToCancelWaitingData()
{
return m_cancel;
}
void KDcraw::setWaitingDataProgress(double)
{
}
const char* KDcraw::rawFiles()
{
return raw_file_extentions;
}
QStringList KDcraw::rawFilesList()
{
QString string = QString::fromLatin1(rawFiles());
return string.remove("*.").split(' ');
}
int KDcraw::rawFilesVersion()
{
return raw_file_extensions_version;
}
QStringList KDcraw::supportedCamera()
{
QStringList camera;
const char** const list = LibRaw::cameraList();
for (int i = 0; i < LibRaw::cameraCount(); i++)
camera.append(list[i]);
return camera;
}
QString KDcraw::librawVersion()
{
return QString(LIBRAW_VERSION_STR).remove("-Release");
}
int KDcraw::librawUseGomp()
{
#ifdef LIBRAW_HAS_CONFIG
# ifdef LIBRAW_USE_OPENMP
return true;
# else
return false;
# endif
#else
return -1;
#endif
}
int KDcraw::librawUseRawSpeed()
{
#ifdef LIBRAW_HAS_CONFIG
# ifdef LIBRAW_USE_RAWSPEED
return true;
# else
return false;
# endif
#else
return -1;
#endif
}
int KDcraw::librawUseGPL2DemosaicPack()
{
#ifdef LIBRAW_HAS_CONFIG
# ifdef LIBRAW_USE_DEMOSAIC_PACK_GPL2
return true;
# else
return false;
# endif
#else
return -1;
#endif
}
int KDcraw::librawUseGPL3DemosaicPack()
{
#ifdef LIBRAW_HAS_CONFIG
# ifdef LIBRAW_USE_DEMOSAIC_PACK_GPL3
return true;
# else
return false;
# endif
#else
return -1;
#endif
}
} // namespace KDcrawIface

View file

@ -0,0 +1,267 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-12-09
* @brief a tread-safe libraw C++ program interface
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2007-2008 by Guillaume Castagnino
* <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KDCRAW_H
#define KDCRAW_H
// C++ includes
#include <cmath>
// Qt includes
#include <QtCore/QBuffer>
#include <QtCore/QString>
#include <QtCore/QObject>
#include <QtGui/QImage>
// Local includes
#include "libkdcraw_export.h"
#include "rawdecodingsettings.h"
#include "dcrawinfocontainer.h"
/** @brief Main namespace of libKDcraw
*/
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT KDcraw : public QObject
{
Q_OBJECT
public:
/** Standard constructor.
*/
KDcraw();
/** Standard destructor.
*/
virtual ~KDcraw();
public:
/** Return a string version of libkdcraw release
*/
static QString version();
/** Get the preview of RAW picture as a QImage.
It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
*/
static bool loadRawPreview(QImage& image, const QString& path);
/** Get the preview of RAW picture as a QByteArray holding JPEG data.
It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
*/
static bool loadRawPreview(QByteArray& imgData, const QString& path);
/** Get the preview of RAW picture passed in QBuffer as a QByteArray holding JPEG data.
It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
*/
static bool loadRawPreview(QByteArray& imgData, const QBuffer& inBuffer);
/** Get the embedded JPEG preview image from RAW picture as a QByteArray which will include Exif Data.
This is fast and non cancelable. This method does not require a class instance to run.
*/
static bool loadEmbeddedPreview(QByteArray& imgData, const QString& path);
/** Get the embedded JPEG preview image from RAW picture as a QImage. This is fast and non cancelable
This method does not require a class instance to run.
*/
static bool loadEmbeddedPreview(QImage& image, const QString& path);
/** Get the embedded JPEG preview image from RAW image passed in QBuffer as a QByteArray which will include Exif Data.
This is fast and non cancelable. This method does not require a class instance to run.
*/
static bool loadEmbeddedPreview(QByteArray& imgData, const QBuffer& inBuffer);
/** Get the half decoded RAW picture. This is slower than loadEmbeddedPreview() method
and non cancelable. This method does not require a class instance to run.
*/
static bool loadHalfPreview(QImage& image, const QString& path);
/** Get the half decoded RAW picture as JPEG data in QByteArray. This is slower than loadEmbeddedPreview()
method and non cancelable. This method does not require a class instance to run.
*/
static bool loadHalfPreview(QByteArray& imgData, const QString& path);
/** Get the half decoded RAW picture passed in QBuffer as JPEG data in QByteArray. This is slower than loadEmbeddedPreview()
method and non cancelable. This method does not require a class instance to run.
*/
static bool loadHalfPreview(QByteArray& imgData, const QBuffer& inBuffer);
/** Get the full decoded RAW picture. This is a more slower than loadHalfPreview() method
and non cancelable. This method does not require a class instance to run.
*/
static bool loadFullImage(QImage& image, const QString& path, const RawDecodingSettings& settings = RawDecodingSettings());
/** Get the camera settings witch have taken RAW file. Look into dcrawinfocontainer.h
for more details. This is a fast and non cancelable method witch do not require
a class instance to run.
*/
static bool rawFileIdentify(DcrawInfoContainer& identify, const QString& path);
/** Return the string of all RAW file type mime supported.
*/
static const char* rawFiles();
/** Return the list of all RAW file type mime supported,
as a QStringList, without wildcard and suffix dot.
*/
static QStringList rawFilesList();
/** Returns a version number for the list of supported RAW file types.
This version is incremented if the list of supported formats has changed
between library releases.
*/
static int rawFilesVersion();
/** Provide a list of supported RAW Camera name.
*/
static QStringList supportedCamera();
/** Return LibRaw version string.
*/
static QString librawVersion();
/** Return true or false if LibRaw use parallel demosaicing or not (libgomp support).
* Return -1 if undefined.
*/
static int librawUseGomp();
/** Return true or false if LibRaw use RawSpeed codec or not.
* Return -1 if undefined.
*/
static int librawUseRawSpeed();
/** Return true or false if LibRaw use Demosaic Pack GPL2 or not.
* Return -1 if undefined.
*/
static int librawUseGPL2DemosaicPack();
/** Return true or false if LibRaw use Demosaic Pack GPL3 or not.
* Return -1 if undefined.
*/
static int librawUseGPL3DemosaicPack();
public:
/** Extract Raw image data undemosaiced and without post processing from 'filePath' picture file.
This is a cancelable method which require a class instance to run because RAW pictures loading
can take a while.
This method return:
- A byte array container 'rawData' with raw data.
- All info about Raw image into 'identify' container.
- 'false' is returned if loadding failed, else 'true'.
*/
bool extractRAWData(const QString& filePath, QByteArray& rawData, DcrawInfoContainer& identify, unsigned int shotSelect=0);
/** Extract a small size of decode RAW data from 'filePath' picture file using
'rawDecodingSettings' settings. This is a cancelable method which require
a class instance to run because RAW pictures decoding can take a while.
This method return:
- A byte array container 'imageData' with picture data. Pixels order is RGB.
Color depth can be 8 or 16. In 8 bits you can access to color component
using (uchar*), in 16 bits using (ushort*).
- Size size of image in number of pixels ('width' and 'height').
- The max average of RGB components from decoded picture.
- 'false' is returned if decoding failed, else 'true'.
*/
bool decodeHalfRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
QByteArray& imageData, int& width, int& height, int& rgbmax);
/** Extract a full size of RAW data from 'filePath' picture file using
'rawDecodingSettings' settings. This is a cancelable method which require
a class instance to run because RAW pictures decoding can take a while.
This method return:
- A byte array container 'imageData' with picture data. Pixels order is RGB.
Color depth can be 8 or 16. In 8 bits you can access to color component
using (uchar*), in 16 bits using (ushort*).
- Size size of image in number of pixels ('width' and 'height').
- The max average of RGB components from decoded picture.
- 'false' is returned if decoding failed, else 'true'.
*/
bool decodeRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
QByteArray& imageData, int& width, int& height, int& rgbmax);
/** To cancel 'decodeHalfRAWImage' and 'decodeRAWImage' methods running
in a separate thread.
*/
void cancel();
protected:
/** Used internally to cancel RAW decoding operation. Normally, you don't need to use it
directly, excepted if you derivated this class. Usual way is to use cancel() method
*/
bool m_cancel;
/** The settings container used to perform RAW pictures decoding. See 'rawdecodingsetting.h'
for details.
*/
RawDecodingSettings m_rawDecodingSettings;
protected:
/** Re-implement this method to control the cancelisation of loop witch wait data
from RAW decoding process with your propers envirronement.
By default, this method check if m_cancel is true.
*/
virtual bool checkToCancelWaitingData();
/** Re-implement this method to control the pseudo progress value during RAW decoding (when dcraw run with an
internal loop without feedback) with your proper environment. By default, this method does nothing.
Progress value average for this stage is 0%-n%, with 'n' == 40% max (see setWaitingDataProgress() method).
*/
virtual void setWaitingDataProgress(double value);
public:
// Declared public to be called externally by callbackForLibRaw() static method.
class Private;
private:
Private* const d;
friend class Private;
};
} // namespace KDcrawIface
#endif /* KDCRAW_H */

View file

@ -0,0 +1,686 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-10-09
* @brief internal private container for KDcraw
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kdcraw.h"
#include "kdcraw_p.h"
// Qt includes
#include <QString>
#include <QFile>
namespace KDcrawIface
{
int callbackForLibRaw(void* data, enum LibRaw_progress p, int iteration, int expected)
{
if (data)
{
KDcraw::Private* const d = static_cast<KDcraw::Private*>(data);
if (d)
{
return d->progressCallback(p, iteration, expected);
}
}
return 0;
}
// --------------------------------------------------------------------------------------------------
KDcraw::Private::Private(KDcraw* const p)
{
m_progress = 0.0;
m_parent = p;
}
KDcraw::Private::~Private()
{
}
void KDcraw::Private::createPPMHeader(QByteArray& imgData, libraw_processed_image_t* const img)
{
QString header = QString("P%1\n%2 %3\n%4\n").arg(img->colors == 3 ? "6" : "5")
.arg(img->width)
.arg(img->height)
.arg((1 << img->bits)-1);
imgData.append(header.toAscii());
imgData.append(QByteArray((const char*)img->data, (int)img->data_size));
}
int KDcraw::Private::progressCallback(enum LibRaw_progress p, int iteration, int expected)
{
kDebug() << "LibRaw progress: " << libraw_strprogress(p) << " pass "
<< iteration << " of " << expected;
// post a little change in progress indicator to show raw processor activity.
setProgress(progressValue()+0.01);
// Clean processing termination by user...
if (m_parent->checkToCancelWaitingData())
{
kDebug() << "LibRaw process terminaison invoked...";
m_parent->m_cancel = true;
m_progress = 0.0;
return 1;
}
// Return 0 to continue processing...
return 0;
}
void KDcraw::Private::setProgress(double value)
{
m_progress = value;
m_parent->setWaitingDataProgress(m_progress);
}
double KDcraw::Private::progressValue() const
{
return m_progress;
}
void KDcraw::Private::fillIndentifyInfo(LibRaw* const raw, DcrawInfoContainer& identify)
{
identify.dateTime.setTime_t(raw->imgdata.other.timestamp);
identify.make = QString(raw->imgdata.idata.make);
identify.model = QString(raw->imgdata.idata.model);
identify.owner = QString(raw->imgdata.other.artist);
identify.DNGVersion = QString::number(raw->imgdata.idata.dng_version);
identify.sensitivity = raw->imgdata.other.iso_speed;
identify.exposureTime = raw->imgdata.other.shutter;
identify.aperture = raw->imgdata.other.aperture;
identify.focalLength = raw->imgdata.other.focal_len;
identify.imageSize = QSize(raw->imgdata.sizes.width, raw->imgdata.sizes.height);
identify.fullSize = QSize(raw->imgdata.sizes.raw_width, raw->imgdata.sizes.raw_height);
identify.outputSize = QSize(raw->imgdata.sizes.iwidth, raw->imgdata.sizes.iheight);
identify.thumbSize = QSize(raw->imgdata.thumbnail.twidth, raw->imgdata.thumbnail.theight);
identify.topMargin = raw->imgdata.sizes.top_margin;
identify.leftMargin = raw->imgdata.sizes.left_margin;
identify.hasIccProfile = raw->imgdata.color.profile ? true : false;
identify.isDecodable = true;
identify.pixelAspectRatio = raw->imgdata.sizes.pixel_aspect;
identify.rawColors = raw->imgdata.idata.colors;
identify.rawImages = raw->imgdata.idata.raw_count;
identify.blackPoint = raw->imgdata.color.black;
for (int ch = 0; ch < 4; ch++)
{
identify.blackPointCh[ch] = raw->imgdata.color.cblack[ch];
}
identify.whitePoint = raw->imgdata.color.maximum;
identify.orientation = (DcrawInfoContainer::ImageOrientation)raw->imgdata.sizes.flip;
memcpy(&identify.cameraColorMatrix1, &raw->imgdata.color.cmatrix, sizeof(raw->imgdata.color.cmatrix));
memcpy(&identify.cameraColorMatrix2, &raw->imgdata.color.rgb_cam, sizeof(raw->imgdata.color.rgb_cam));
memcpy(&identify.cameraXYZMatrix, &raw->imgdata.color.cam_xyz, sizeof(raw->imgdata.color.cam_xyz));
if (raw->imgdata.idata.filters)
{
if (!raw->imgdata.idata.cdesc[3])
{
raw->imgdata.idata.cdesc[3] = 'G';
}
for (int i=0; i < 16; i++)
{
identify.filterPattern.append(raw->imgdata.idata.cdesc[raw->COLOR(i >> 1,i & 1)]);
}
identify.colorKeys = raw->imgdata.idata.cdesc;
}
for(int c = 0 ; c < raw->imgdata.idata.colors ; c++)
{
identify.daylightMult[c] = raw->imgdata.color.pre_mul[c];
}
if (raw->imgdata.color.cam_mul[0] > 0)
{
for(int c = 0 ; c < 4 ; c++)
{
identify.cameraMult[c] = raw->imgdata.color.cam_mul[c];
}
}
}
bool KDcraw::Private::loadFromLibraw(const QString& filePath, QByteArray& imageData,
int& width, int& height, int& rgbmax)
{
m_parent->m_cancel = false;
LibRaw raw;
// Set progress call back function.
raw.set_progress_handler(callbackForLibRaw, this);
QByteArray deadpixelPath = QFile::encodeName(m_parent->m_rawDecodingSettings.deadPixelMap);
QByteArray cameraProfile = QFile::encodeName(m_parent->m_rawDecodingSettings.inputProfile);
QByteArray outputProfile = QFile::encodeName(m_parent->m_rawDecodingSettings.outputProfile);
if (!m_parent->m_rawDecodingSettings.autoBrightness)
{
// Use a fixed white level, ignoring the image histogram.
raw.imgdata.params.no_auto_bright = 1;
}
if (m_parent->m_rawDecodingSettings.sixteenBitsImage)
{
// (-4) 16bit ppm output
raw.imgdata.params.output_bps = 16;
}
if (m_parent->m_rawDecodingSettings.halfSizeColorImage)
{
// (-h) Half-size color image (3x faster than -q).
raw.imgdata.params.half_size = 1;
}
if (m_parent->m_rawDecodingSettings.RGBInterpolate4Colors)
{
// (-f) Interpolate RGB as four colors.
raw.imgdata.params.four_color_rgb = 1;
}
if (m_parent->m_rawDecodingSettings.DontStretchPixels)
{
// (-j) Do not stretch the image to its correct aspect ratio.
raw.imgdata.params.use_fuji_rotate = 1;
}
// (-H) Unclip highlight color.
raw.imgdata.params.highlight = m_parent->m_rawDecodingSettings.unclipColors;
if (m_parent->m_rawDecodingSettings.brightness != 1.0)
{
// (-b) Set Brightness value.
raw.imgdata.params.bright = m_parent->m_rawDecodingSettings.brightness;
}
if (m_parent->m_rawDecodingSettings.enableBlackPoint)
{
// (-k) Set Black Point value.
raw.imgdata.params.user_black = m_parent->m_rawDecodingSettings.blackPoint;
}
if (m_parent->m_rawDecodingSettings.enableWhitePoint)
{
// (-S) Set White Point value (saturation).
raw.imgdata.params.user_sat = m_parent->m_rawDecodingSettings.whitePoint;
}
if (m_parent->m_rawDecodingSettings.medianFilterPasses > 0)
{
// (-m) After interpolation, clean up color artifacts by repeatedly applying a 3x3 median filter to the R-G and B-G channels.
raw.imgdata.params.med_passes = m_parent->m_rawDecodingSettings.medianFilterPasses;
}
if (!m_parent->m_rawDecodingSettings.deadPixelMap.isEmpty())
{
// (-P) Read the dead pixel list from this file.
raw.imgdata.params.bad_pixels = deadpixelPath.data();
}
switch (m_parent->m_rawDecodingSettings.whiteBalance)
{
case RawDecodingSettings::NONE:
{
break;
}
case RawDecodingSettings::CAMERA:
{
// (-w) Use camera white balance, if possible.
raw.imgdata.params.use_camera_wb = 1;
break;
}
case RawDecodingSettings::AUTO:
{
// (-a) Use automatic white balance.
raw.imgdata.params.use_auto_wb = 1;
break;
}
case RawDecodingSettings::CUSTOM:
{
/* Convert between Temperature and RGB.
*/
double T;
double RGB[3];
double xD, yD, X, Y, Z;
DcrawInfoContainer identify;
T = m_parent->m_rawDecodingSettings.customWhiteBalance;
/* Here starts the code picked and adapted from ufraw (0.12.1)
to convert Temperature + green multiplier to RGB multipliers
*/
/* Convert between Temperature and RGB.
* Base on information from http://www.brucelindbloom.com/
* The fit for D-illuminant between 4000K and 12000K are from CIE
* The generalization to 2000K < T < 4000K and the blackbody fits
* are my own and should be taken with a grain of salt.
*/
const double XYZ_to_RGB[3][3] = {
{ 3.24071, -0.969258, 0.0556352 },
{-1.53726, 1.87599, -0.203996 },
{-0.498571, 0.0415557, 1.05707 }
};
// Fit for CIE Daylight illuminant
if (T <= 4000)
{
xD = 0.27475e9/(T*T*T) - 0.98598e6/(T*T) + 1.17444e3/T + 0.145986;
}
else if (T <= 7000)
{
xD = -4.6070e9/(T*T*T) + 2.9678e6/(T*T) + 0.09911e3/T + 0.244063;
}
else
{
xD = -2.0064e9/(T*T*T) + 1.9018e6/(T*T) + 0.24748e3/T + 0.237040;
}
yD = -3*xD*xD + 2.87*xD - 0.275;
X = xD/yD;
Y = 1;
Z = (1-xD-yD)/yD;
RGB[0] = X*XYZ_to_RGB[0][0] + Y*XYZ_to_RGB[1][0] + Z*XYZ_to_RGB[2][0];
RGB[1] = X*XYZ_to_RGB[0][1] + Y*XYZ_to_RGB[1][1] + Z*XYZ_to_RGB[2][1];
RGB[2] = X*XYZ_to_RGB[0][2] + Y*XYZ_to_RGB[1][2] + Z*XYZ_to_RGB[2][2];
/* End of the code picked to ufraw
*/
RGB[1] = RGB[1] / m_parent->m_rawDecodingSettings.customWhiteBalanceGreen;
/* By default, decraw override his default D65 WB
We need to keep it as a basis : if not, colors with some
DSLR will have a high dominant of color that will lead to
a completely wrong WB
*/
if (rawFileIdentify(identify, filePath))
{
RGB[0] = identify.daylightMult[0] / RGB[0];
RGB[1] = identify.daylightMult[1] / RGB[1];
RGB[2] = identify.daylightMult[2] / RGB[2];
}
else
{
RGB[0] = 1.0 / RGB[0];
RGB[1] = 1.0 / RGB[1];
RGB[2] = 1.0 / RGB[2];
kDebug() << "Warning: cannot get daylight multipliers";
}
// (-r) set Raw Color Balance Multipliers.
raw.imgdata.params.user_mul[0] = RGB[0];
raw.imgdata.params.user_mul[1] = RGB[1];
raw.imgdata.params.user_mul[2] = RGB[2];
raw.imgdata.params.user_mul[3] = RGB[1];
break;
}
case RawDecodingSettings::AERA:
{
// (-A) Calculate the white balance by averaging a rectangular area from image.
raw.imgdata.params.greybox[0] = m_parent->m_rawDecodingSettings.whiteBalanceArea.left();
raw.imgdata.params.greybox[1] = m_parent->m_rawDecodingSettings.whiteBalanceArea.top();
raw.imgdata.params.greybox[2] = m_parent->m_rawDecodingSettings.whiteBalanceArea.width();
raw.imgdata.params.greybox[3] = m_parent->m_rawDecodingSettings.whiteBalanceArea.height();
break;
}
}
// (-q) Use an interpolation method.
raw.imgdata.params.user_qual = m_parent->m_rawDecodingSettings.RAWQuality;
switch (m_parent->m_rawDecodingSettings.NRType)
{
case RawDecodingSettings::WAVELETSNR:
{
// (-n) Use wavelets to erase noise while preserving real detail.
raw.imgdata.params.threshold = m_parent->m_rawDecodingSettings.NRThreshold;
break;
}
case RawDecodingSettings::FBDDNR:
{
// (100 - 1000) => (1 - 10) conversion
raw.imgdata.params.fbdd_noiserd = lround(m_parent->m_rawDecodingSettings.NRThreshold / 100.0);
break;
}
case RawDecodingSettings::LINENR:
{
// (100 - 1000) => (0.001 - 0.02) conversion.
raw.imgdata.params.linenoise = m_parent->m_rawDecodingSettings.NRThreshold * 2.11E-5 + 0.00111111;
raw.imgdata.params.cfaline = true;
break;
}
case RawDecodingSettings::IMPULSENR:
{
// (100 - 1000) => (0.005 - 0.05) conversion.
raw.imgdata.params.lclean = m_parent->m_rawDecodingSettings.NRThreshold * 5E-5;
raw.imgdata.params.cclean = m_parent->m_rawDecodingSettings.NRChroThreshold * 5E-5;
raw.imgdata.params.cfa_clean = true;
break;
}
default: // No Noise Reduction
{
raw.imgdata.params.threshold = 0;
raw.imgdata.params.fbdd_noiserd = 0;
raw.imgdata.params.linenoise = 0;
raw.imgdata.params.cfaline = false;
raw.imgdata.params.lclean = 0;
raw.imgdata.params.cclean = 0;
raw.imgdata.params.cfa_clean = false;
break;
}
}
// Chromatic aberration correction.
raw.imgdata.params.ca_correc = m_parent->m_rawDecodingSettings.enableCACorrection;
raw.imgdata.params.cared = m_parent->m_rawDecodingSettings.caMultiplier[0];
raw.imgdata.params.cablue = m_parent->m_rawDecodingSettings.caMultiplier[1];
// Exposure Correction before interpolation.
raw.imgdata.params.exp_correc = m_parent->m_rawDecodingSettings.expoCorrection;
raw.imgdata.params.exp_shift = m_parent->m_rawDecodingSettings.expoCorrectionShift;
raw.imgdata.params.exp_preser = m_parent->m_rawDecodingSettings.expoCorrectionHighlight;
switch (m_parent->m_rawDecodingSettings.inputColorSpace)
{
case RawDecodingSettings::EMBEDDED:
{
// (-p embed) Use input profile from RAW file to define the camera's raw colorspace.
raw.imgdata.params.camera_profile = (char*)"embed";
break;
}
case RawDecodingSettings::CUSTOMINPUTCS:
{
if (!m_parent->m_rawDecodingSettings.inputProfile.isEmpty())
{
// (-p) Use input profile file to define the camera's raw colorspace.
raw.imgdata.params.camera_profile = cameraProfile.data();
}
break;
}
default:
{
// No input profile
break;
}
}
switch (m_parent->m_rawDecodingSettings.outputColorSpace)
{
case RawDecodingSettings::CUSTOMOUTPUTCS:
{
if (!m_parent->m_rawDecodingSettings.outputProfile.isEmpty())
{
// (-o) Use ICC profile file to define the output colorspace.
raw.imgdata.params.output_profile = outputProfile.data();
}
break;
}
default:
{
// (-o) Define the output colorspace.
raw.imgdata.params.output_color = m_parent->m_rawDecodingSettings.outputColorSpace;
break;
}
}
//-- Extended demosaicing settings ----------------------------------------------------------
raw.imgdata.params.dcb_iterations = m_parent->m_rawDecodingSettings.dcbIterations;
raw.imgdata.params.dcb_enhance_fl = m_parent->m_rawDecodingSettings.dcbEnhanceFl;
raw.imgdata.params.eeci_refine = m_parent->m_rawDecodingSettings.eeciRefine;
raw.imgdata.params.es_med_passes = m_parent->m_rawDecodingSettings.esMedPasses;
//-------------------------------------------------------------------------------------------
setProgress(0.1);
kDebug() << filePath;
kDebug() << m_parent->m_rawDecodingSettings;
int ret = raw.open_file(QFile::encodeName(filePath));
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run open_file: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_parent->m_cancel)
{
raw.recycle();
return false;
}
setProgress(0.2);
ret = raw.unpack();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run unpack: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_parent->m_cancel)
{
raw.recycle();
return false;
}
setProgress(0.25);
if (m_parent->m_rawDecodingSettings.fixColorsHighlights)
{
kDebug() << "Applying LibRaw highlights adjustments";
// 1.0 is fallback to default value
raw.imgdata.params.adjust_maximum_thr = 1.0;
}
else
{
kDebug() << "Disabling LibRaw highlights adjustments";
// 0.0 disables this feature
raw.imgdata.params.adjust_maximum_thr = 0.0;
}
ret = raw.dcraw_process();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run dcraw_process: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_parent->m_cancel)
{
raw.recycle();
return false;
}
setProgress(0.3);
libraw_processed_image_t* img = raw.dcraw_make_mem_image(&ret);
if(!img)
{
kDebug() << "LibRaw: failed to run dcraw_make_mem_image: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if (m_parent->m_cancel)
{
// Clear memory allocation. Introduced with LibRaw 0.11.0
raw.dcraw_clear_mem(img);
raw.recycle();
return false;
}
setProgress(0.35);
width = img->width;
height = img->height;
rgbmax = (1 << img->bits)-1;
if (img->colors == 3)
{
imageData = QByteArray((const char*)img->data, (int)img->data_size);
}
else
{
// img->colors == 1 (Grayscale) : convert to RGB
imageData = QByteArray();
for (int i = 0 ; i < (int)img->data_size ; ++i)
{
for (int j = 0 ; j < 3 ; ++j)
{
imageData.append(img->data[i]);
}
}
}
// Clear memory allocation. Introduced with LibRaw 0.11.0
raw.dcraw_clear_mem(img);
raw.recycle();
if (m_parent->m_cancel)
{
return false;
}
setProgress(0.4);
kDebug() << "LibRaw: data info: width=" << width
<< " height=" << height
<< " rgbmax=" << rgbmax;
return true;
}
bool KDcraw::Private::loadEmbeddedPreview(QByteArray& imgData, LibRaw& raw)
{
int ret = raw.unpack_thumb();
if (ret != LIBRAW_SUCCESS)
{
raw.recycle();
kDebug() << "LibRaw: failed to run unpack_thumb: " << libraw_strerror(ret);
raw.recycle();
return false;
}
libraw_processed_image_t* const thumb = raw.dcraw_make_mem_thumb(&ret);
if(!thumb)
{
kDebug() << "LibRaw: failed to run dcraw_make_mem_thumb: " << libraw_strerror(ret);
raw.recycle();
return false;
}
if(thumb->type == LIBRAW_IMAGE_BITMAP)
{
createPPMHeader(imgData, thumb);
}
else
{
imgData = QByteArray((const char*)thumb->data, (int)thumb->data_size);
}
// Clear memory allocation. Introduced with LibRaw 0.11.0
raw.dcraw_clear_mem(thumb);
raw.recycle();
if ( imgData.isEmpty() )
{
kDebug() << "Failed to load JPEG thumb from LibRaw!";
return false;
}
return true;
}
bool KDcraw::Private::loadHalfPreview(QImage& image, LibRaw& raw)
{
raw.imgdata.params.use_auto_wb = 1; // Use automatic white balance.
raw.imgdata.params.use_camera_wb = 1; // Use camera white balance, if possible.
raw.imgdata.params.half_size = 1; // Half-size color image (3x faster than -q).
QByteArray imgData;
int ret = raw.unpack();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run unpack: " << libraw_strerror(ret);
raw.recycle();
return false;
}
ret = raw.dcraw_process();
if (ret != LIBRAW_SUCCESS)
{
kDebug() << "LibRaw: failed to run dcraw_process: " << libraw_strerror(ret);
raw.recycle();
return false;
}
libraw_processed_image_t* halfImg = raw.dcraw_make_mem_image(&ret);
if(!halfImg)
{
kDebug() << "LibRaw: failed to run dcraw_make_mem_image: " << libraw_strerror(ret);
raw.recycle();
return false;
}
Private::createPPMHeader(imgData, halfImg);
// Clear memory allocation. Introduced with LibRaw 0.11.0
raw.dcraw_clear_mem(halfImg);
raw.recycle();
if ( imgData.isEmpty() )
{
kDebug() << "Failed to load half preview from LibRaw!";
return false;
}
if (!image.loadFromData(imgData))
{
kDebug() << "Failed to load PPM data from LibRaw!";
return false;
}
return true;
}
} // namespace KDcrawIface

View file

@ -0,0 +1,94 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-10-09
* @brief internal private container for KDcraw
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KDCRAWPRIVATE_H
#define KDCRAWPRIVATE_H
// Qt includes
#include <QByteArray>
// KDE includes
#include <kdebug.h>
// LibRaw includes
#include <libraw.h>
// Local includes
#include "dcrawinfocontainer.h"
namespace KDcrawIface
{
class KDcraw;
extern "C"
{
int callbackForLibRaw(void* data, enum LibRaw_progress p, int iteration, int expected);
}
class KDcraw::Private
{
public:
Private(KDcraw* const p);
~Private();
public:
int progressCallback(enum LibRaw_progress p, int iteration, int expected);
void setProgress(double value);
double progressValue() const;
bool loadFromLibraw(const QString& filePath, QByteArray& imageData,
int& width, int& height, int& rgbmax);
public:
static void createPPMHeader(QByteArray& imgData, libraw_processed_image_t* const img);
static void fillIndentifyInfo(LibRaw* const raw, DcrawInfoContainer& identify);
static bool loadEmbeddedPreview(QByteArray&, LibRaw&);
static bool loadHalfPreview(QImage&, LibRaw&);
private:
double m_progress;
KDcraw* m_parent;
friend class KDcraw;
};
} // namespace KDcrawIface
#endif /* KDCRAWPRIVATE_H */

View file

@ -0,0 +1,47 @@
/** ===========================================================
* @file
*
* This file is part of the KDE project
*
* @brief Helper for exporting functions/classes from the shared library
*
* @author Copyright (C) 2007 David Faure <faure@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* ============================================================ */
#ifndef LIBKDCRAW_EXPORT_H
#define LIBKDCRAW_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <kdemacros.h>
#ifndef LIBKDCRAW_EXPORT
# if defined(MAKE_KDCRAW_LIB)
/* We are building this library */
# define LIBKDCRAW_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define LIBKDCRAW_EXPORT KDE_IMPORT
# endif
#endif
# ifndef LIBKDCRAW_EXPORT_DEPRECATED
# define LIBKDCRAW_EXPORT_DEPRECATED KDE_DEPRECATED LIBKDCRAW_EXPORT
# endif
#endif

View file

@ -0,0 +1,158 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2011-12-28
* @brief re-implementation of action thread using threadweaver
*
* @author Copyright (C) 2011-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2011-2012 by A Janardhan Reddy
* <a href="annapareddyjanardhanreddy at gmail dot com">annapareddyjanardhanreddy at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_ractionthreadbase.cpp"
// Qt includes
#include <QMutexLocker>
// KDE includes
#include <kurl.h>
#include <kdebug.h>
#include <Weaver/JobCollection.h>
#include <Weaver/ThreadWeaver.h>
#include <Weaver/Job.h>
#include <Weaver/DebuggingAids.h>
#include <solid/device.h>
// Local includes
#include "ractionthreadbase_p.h"
using namespace Solid;
namespace KDcrawIface
{
RActionThreadBase::RActionThreadBase(QObject* const parent)
: QThread(parent), d(new Private)
{
const int maximumNumberOfThreads = qMax(Device::listFromType(DeviceInterface::Processor).count(), 1);
d->log = new RWeaverObserver(this);
d->weaver = new Weaver(this);
d->weaver->registerObserver(d->log);
d->weaver->setMaximumNumberOfThreads(maximumNumberOfThreads);
kDebug() << "Starting Main Thread";
}
RActionThreadBase::~RActionThreadBase()
{
kDebug() << "calling action thread destructor";
// cancel the thread
cancel();
// wait for the thread to finish
wait();
delete d->log;
delete d->weaver;
delete d;
}
void RActionThreadBase::setMaximumNumberOfThreads(int n)
{
d->weaver->setMaximumNumberOfThreads(n);
}
void RActionThreadBase::slotFinished()
{
kDebug() << "Finish Main Thread";
d->weaverRunning = false;
d->condVarJobs.wakeAll();
emit QThread::finished();
}
void RActionThreadBase::cancel()
{
kDebug() << "Cancel Main Thread";
QMutexLocker lock(&d->mutex);
d->todo.clear();
d->running = false;
d->weaverRunning = true;
d->weaver->requestAbort();
d->weaver->dequeue();
d->condVarJobs.wakeAll();
}
void RActionThreadBase::finish()
{
d->weaver->finish();
}
bool RActionThreadBase::isEmpty() const
{
return d->todo.isEmpty();
}
void RActionThreadBase::appendJob(JobCollection* const job)
{
QMutexLocker lock(&d->mutex);
d->todo << job;
d->condVarJobs.wakeAll();
}
void RActionThreadBase::run()
{
d->running = true;
d->weaverRunning = false;
kDebug() << "In action thread Run";
while (d->running)
{
JobCollection* t = 0;
{
QMutexLocker lock(&d->mutex);
if (!isEmpty() && !d->weaverRunning)
{
t = d->todo.takeFirst();
}
else
{
d->condVarJobs.wait(&d->mutex);
}
}
if (t)
{
connect(t, SIGNAL(done(ThreadWeaver::Job*)),
this, SLOT(slotFinished()));
connect(t, SIGNAL(done(ThreadWeaver::Job*)),
t, SLOT(deleteLater()));
d->weaverRunning = true;
d->weaver->enqueue(t);
}
}
d->weaver->finish();
kDebug() << "Exiting Action Thread";
}
} // namespace KDcrawIface

View file

@ -0,0 +1,91 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2011-12-28
* @brief re-implementation of action thread using threadweaver
*
* @author Copyright (C) 2011-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2011-2012 by A Janardhan Reddy
* <a href="annapareddyjanardhanreddy at gmail dot com">annapareddyjanardhanreddy at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RACTION_THREAD_BASE_H
#define RACTION_THREAD_BASE_H
// Qt includes
#include <QtCore/QThread>
// Local includes
#include "libkdcraw_export.h"
namespace ThreadWeaver
{
class JobCollection;
}
using namespace ThreadWeaver;
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT RActionThreadBase : public QThread
{
Q_OBJECT
public:
RActionThreadBase(QObject* const parent=0);
~RActionThreadBase();
/** Adjust maximum number of thread used to parallelize collection of job processing.
* By default in constructor, KDE::Solid API is used to determine the number of CPU available and adjust
* this value automatically.
*/
void setMaximumNumberOfThreads(int n);
void cancel();
void finish();
protected:
void run();
/** Append a collection of jobs to process in pending list.
*/
void appendJob(JobCollection* const job);
/** Return true if list of pending jobs to process is empty.
*/
bool isEmpty() const;
protected Q_SLOTS:
void slotFinished();
private:
class Private;
Private* const d;
};
} // namespace KDcrawIface
#endif // RACTION_THREAD_BASE_H

View file

@ -0,0 +1,85 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2011-12-28
* @brief internal RActionThreadBase classes
*
* @author Copyright (C) 2011-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2011-2012 by A Janardhan Reddy
* <a href="annapareddyjanardhanreddy at gmail dot com">annapareddyjanardhanreddy at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_ractionthreadbase_p.cpp"
// KDE includes
#include <kdebug.h>
namespace KDcrawIface
{
RWeaverObserver::RWeaverObserver(QObject* const parent)
: WeaverObserver(parent)
{
connect(this, SIGNAL(weaverStateChanged(ThreadWeaver::State*)),
this, SLOT(slotWeaverStateChanged(ThreadWeaver::State*)));
connect(this, SIGNAL(threadStarted(ThreadWeaver::Thread*)),
this, SLOT(slotThreadStarted(ThreadWeaver::Thread*)));
connect(this, SIGNAL(threadBusy(ThreadWeaver::Thread*,ThreadWeaver::Job*)),
this, SLOT(slotThreadBusy(ThreadWeaver::Thread*,ThreadWeaver::Job*)));
connect(this, SIGNAL(threadSuspended(ThreadWeaver::Thread*)),
this, SLOT(slotThreadSuspended(ThreadWeaver::Thread*)));
connect(this, SIGNAL(threadExited(ThreadWeaver::Thread*)),
this, SLOT(slotThreadExited(ThreadWeaver::Thread*)));
}
RWeaverObserver::~RWeaverObserver()
{
}
void RWeaverObserver::slotWeaverStateChanged(State* state)
{
kDebug() << "RWeaverObserver: thread state changed to " << state->stateName();
}
void RWeaverObserver::slotThreadStarted(Thread* th)
{
kDebug() << "RWeaverObserver: thread " << th->id() <<" started";
}
void RWeaverObserver::slotThreadBusy(Thread* th, Job*)
{
kDebug() << "RWeaverObserver: thread " << th->id() << " busy";
}
void RWeaverObserver::slotThreadSuspended(Thread* th )
{
kDebug() << "RWeaverObserver: thread " << th->id() << " suspended";
}
void RWeaverObserver::slotThreadExited(Thread* th)
{
kDebug() << "RWeaverObserver: thread " << th->id() << " exited";
}
} // namespace KDcrawIface

View file

@ -0,0 +1,106 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2011-12-28
* @brief internal RActionThreadBase classes
*
* @author Copyright (C) 2011-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2011-2012 by A Janardhan Reddy
* <a href="annapareddyjanardhanreddy at gmail dot com">annapareddyjanardhanreddy at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RACTION_THREAD_BASE_P_H
#define RACTION_THREAD_BASE_P_H
// Qt includes
#include <QWaitCondition>
#include <QMutex>
#include <QList>
// KDE includes
#include <threadweaver/Job.h>
#include <threadweaver/WeaverObserver.h>
#include <threadweaver/State.h>
#include <threadweaver/Thread.h>
// Local includes
#include "ractionthreadbase.h"
namespace ThreadWeaver
{
class Weaver;
}
using namespace ThreadWeaver;
namespace KDcrawIface
{
/** RWeaverObserver is a simple wrapper to plug on the ActionThread class to
prints debug messages when signals are received.
*/
class RWeaverObserver : public WeaverObserver
{
Q_OBJECT
public:
RWeaverObserver(QObject* const parent=0);
~RWeaverObserver();
protected Q_SLOTS:
void slotWeaverStateChanged(ThreadWeaver::State*);
void slotThreadStarted(ThreadWeaver::Thread*);
void slotThreadBusy(ThreadWeaver::Thread*, ThreadWeaver::Job*);
void slotThreadSuspended(ThreadWeaver::Thread*);
void slotThreadExited(ThreadWeaver::Thread*);
};
// ----------------------------------------------------------------------------------
class RActionThreadBase::Private
{
public:
Private()
{
running = false;
weaverRunning = false;
weaver = 0;
log = 0;
}
volatile bool running;
volatile bool weaverRunning;
QWaitCondition condVarJobs;
QMutex mutex;
QList<JobCollection*> todo;
Weaver* weaver;
RWeaverObserver* log;
};
} // namespace KDcrawIface
#endif // RACTION_THREAD_BASE_P_H

View file

@ -0,0 +1,396 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-12-09
* @brief Raw decoding settings
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2007-2008 by Guillaume Castagnino
* <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#define OPTIONFIXCOLORSHIGHLIGHTSENTRY "FixColorsHighlights"
#define OPTIONDECODESIXTEENBITENTRY "SixteenBitsImage"
#define OPTIONWHITEBALANCEENTRY "White Balance"
#define OPTIONCUSTOMWHITEBALANCEENTRY "Custom White Balance"
#define OPTIONCUSTOMWBGREENENTRY "Custom White Balance Green"
#define OPTIONFOURCOLORRGBENTRY "Four Color RGB"
#define OPTIONUNCLIPCOLORSENTRY "Unclip Color"
// Wrong spelling, but do not fix it since it is a configuration key
// krazy:cond=spelling
#define OPTIONDONTSTRETCHPIXELSENTRY "Dont Stretch Pixels"
// krazy:endcond=spelling
#define OPTIONMEDIANFILTERPASSESENTRY "Median Filter Passes"
#define OPTIONNOISEREDUCTIONTYPEENTRY "Noise Reduction Type"
#define OPTIONNOISEREDUCTIONTHRESHOLDENTRY "Noise Reduction Threshold"
#define OPTIONUSECACORRECTIONENTRY "EnableCACorrection"
#define OPTIONCAREDMULTIPLIERENTRY "caRedMultiplier"
#define OPTIONCABLUEMULTIPLIERENTRY "caBlueMultiplier"
#define OPTIONAUTOBRIGHTNESSENTRY "AutoBrightness"
#define OPTIONDECODINGQUALITYENTRY "Decoding Quality"
#define OPTIONINPUTCOLORSPACEENTRY "Input Color Space"
#define OPTIONOUTPUTCOLORSPACEENTRY "Output Color Space"
#define OPTIONINPUTCOLORPROFILEENTRY "Input Color Profile"
#define OPTIONOUTPUTCOLORPROFILEENTRY "Output Color Profile"
#define OPTIONBRIGHTNESSMULTIPLIERENTRY "Brightness Multiplier"
#define OPTIONUSEBLACKPOINTENTRY "Use Black Point"
#define OPTIONBLACKPOINTENTRY "Black Point"
#define OPTIONUSEWHITEPOINTENTRY "Use White Point"
#define OPTIONWHITEPOINTENTRY "White Point"
//-- Extended demosaicing settings ----------------------------------------------------------
#define OPTIONDCBITERATIONSENTRY "Dcb Iterations"
#define OPTIONDCBENHANCEFLENTRY "Dcb Enhance Filter"
#define OPTIONEECIREFINEENTRY "Eeci Refine"
#define OPTIONESMEDPASSESENTRY "Es Median Filter Passes"
#define OPTIONNRCHROMINANCETHRESHOLDENTRY "Noise Reduction Chrominance Threshold"
#define OPTIONEXPOCORRECTIONENTRY "Expo Correction"
#define OPTIONEXPOCORRECTIONSHIFTENTRY "Expo Correction Shift"
#define OPTIONEXPOCORRECTIONHIGHLIGHTENTRY "Expo Correction Highlight"
#include "rawdecodingsettings.h"
namespace KDcrawIface
{
RawDecodingSettings::RawDecodingSettings()
{
fixColorsHighlights = false;
autoBrightness = true;
sixteenBitsImage = false;
brightness = 1.0;
RAWQuality = BILINEAR;
inputColorSpace = NOINPUTCS;
outputColorSpace = SRGB;
RGBInterpolate4Colors = false;
DontStretchPixels = false;
unclipColors = 0;
whiteBalance = CAMERA;
customWhiteBalance = 6500;
customWhiteBalanceGreen = 1.0;
medianFilterPasses = 0;
halfSizeColorImage = false;
enableBlackPoint = false;
blackPoint = 0;
enableWhitePoint = false;
whitePoint = 0;
NRType = NONR;
NRThreshold = 0;
enableCACorrection = false;
caMultiplier[0] = 0.0;
caMultiplier[1] = 0.0;
inputProfile = QString();
outputProfile = QString();
deadPixelMap = QString();
whiteBalanceArea = QRect();
//-- Extended demosaicing settings ----------------------------------------------------------
dcbIterations = -1;
dcbEnhanceFl = false;
eeciRefine = false;
esMedPasses = 0;
NRChroThreshold = 0;
expoCorrection = false;
expoCorrectionShift = 1.0;
expoCorrectionHighlight = 0.0;
}
RawDecodingSettings::~RawDecodingSettings()
{
}
RawDecodingSettings& RawDecodingSettings::operator=(const RawDecodingSettings& o)
{
fixColorsHighlights = o.fixColorsHighlights;
autoBrightness = o.autoBrightness;
sixteenBitsImage = o.sixteenBitsImage;
brightness = o.brightness;
RAWQuality = o.RAWQuality;
inputColorSpace = o.inputColorSpace;
outputColorSpace = o.outputColorSpace;
RGBInterpolate4Colors = o.RGBInterpolate4Colors;
DontStretchPixels = o.DontStretchPixels;
unclipColors = o.unclipColors;
whiteBalance = o.whiteBalance;
customWhiteBalance = o.customWhiteBalance;
customWhiteBalanceGreen = o.customWhiteBalanceGreen;
halfSizeColorImage = o.halfSizeColorImage;
enableBlackPoint = o.enableBlackPoint;
blackPoint = o.blackPoint;
enableWhitePoint = o.enableWhitePoint;
whitePoint = o.whitePoint;
NRType = o.NRType;
NRThreshold = o.NRThreshold;
enableCACorrection = o.enableCACorrection;
caMultiplier[0] = o.caMultiplier[0];
caMultiplier[1] = o.caMultiplier[1];
medianFilterPasses = o.medianFilterPasses;
inputProfile = o.inputProfile;
outputProfile = o.outputProfile;
deadPixelMap = o.deadPixelMap;
whiteBalanceArea = o.whiteBalanceArea;
//-- Extended demosaicing settings ----------------------------------------------------------
dcbIterations = o.dcbIterations;
dcbEnhanceFl = o.dcbEnhanceFl;
eeciRefine = o.eeciRefine;
esMedPasses = o.esMedPasses;
NRChroThreshold = o.NRChroThreshold;
expoCorrection = o.expoCorrection;
expoCorrectionShift = o.expoCorrectionShift;
expoCorrectionHighlight = o.expoCorrectionHighlight;
return *this;
}
bool RawDecodingSettings::operator==(const RawDecodingSettings& o) const
{
return fixColorsHighlights == o.fixColorsHighlights
&& autoBrightness == o.autoBrightness
&& sixteenBitsImage == o.sixteenBitsImage
&& brightness == o.brightness
&& RAWQuality == o.RAWQuality
&& inputColorSpace == o.inputColorSpace
&& outputColorSpace == o.outputColorSpace
&& RGBInterpolate4Colors == o.RGBInterpolate4Colors
&& DontStretchPixels == o.DontStretchPixels
&& unclipColors == o.unclipColors
&& whiteBalance == o.whiteBalance
&& customWhiteBalance == o.customWhiteBalance
&& customWhiteBalanceGreen == o.customWhiteBalanceGreen
&& halfSizeColorImage == o.halfSizeColorImage
&& enableBlackPoint == o.enableBlackPoint
&& blackPoint == o.blackPoint
&& enableWhitePoint == o.enableWhitePoint
&& whitePoint == o.whitePoint
&& NRType == o.NRType
&& NRThreshold == o.NRThreshold
&& enableCACorrection == o.enableCACorrection
&& caMultiplier[0] == o.caMultiplier[0]
&& caMultiplier[1] == o.caMultiplier[1]
&& medianFilterPasses == o.medianFilterPasses
&& inputProfile == o.inputProfile
&& outputProfile == o.outputProfile
&& deadPixelMap == o.deadPixelMap
&& whiteBalanceArea == o.whiteBalanceArea
//-- Extended demosaicing settings ----------------------------------------------------------
&& dcbIterations == o.dcbIterations
&& dcbEnhanceFl == o.dcbEnhanceFl
&& eeciRefine == o.eeciRefine
&& esMedPasses == o.esMedPasses
&& NRChroThreshold == o.NRChroThreshold
&& expoCorrection == o.expoCorrection
&& expoCorrectionShift == o.expoCorrectionShift
&& expoCorrectionHighlight == o.expoCorrectionHighlight
;
}
void RawDecodingSettings::optimizeTimeLoading()
{
fixColorsHighlights = false;
autoBrightness = true;
sixteenBitsImage = true;
brightness = 1.0;
RAWQuality = BILINEAR;
inputColorSpace = NOINPUTCS;
outputColorSpace = SRGB;
RGBInterpolate4Colors = false;
DontStretchPixels = false;
unclipColors = 0;
whiteBalance = CAMERA;
customWhiteBalance = 6500;
customWhiteBalanceGreen = 1.0;
halfSizeColorImage = true;
medianFilterPasses = 0;
enableBlackPoint = false;
blackPoint = 0;
enableWhitePoint = false;
whitePoint = 0;
NRType = NONR;
NRThreshold = 0;
enableCACorrection = false;
caMultiplier[0] = 0.0;
caMultiplier[1] = 0.0;
inputProfile = QString();
outputProfile = QString();
deadPixelMap = QString();
whiteBalanceArea = QRect();
//-- Extended demosaicing settings ----------------------------------------------------------
dcbIterations = -1;
dcbEnhanceFl = false;
eeciRefine = false;
esMedPasses = 0;
NRChroThreshold = 0;
expoCorrection = false;
expoCorrectionShift = 1.0;
expoCorrectionHighlight = 0.0;
}
void RawDecodingSettings::readSettings(KConfigGroup& group)
{
RawDecodingSettings defaultPrm;
fixColorsHighlights = group.readEntry(OPTIONFIXCOLORSHIGHLIGHTSENTRY, defaultPrm.fixColorsHighlights);
sixteenBitsImage = group.readEntry(OPTIONDECODESIXTEENBITENTRY, defaultPrm.sixteenBitsImage);
whiteBalance = (WhiteBalance)
group.readEntry(OPTIONWHITEBALANCEENTRY, (int)defaultPrm.whiteBalance);
customWhiteBalance = group.readEntry(OPTIONCUSTOMWHITEBALANCEENTRY, defaultPrm.customWhiteBalance);
customWhiteBalanceGreen = group.readEntry(OPTIONCUSTOMWBGREENENTRY, defaultPrm.customWhiteBalanceGreen);
RGBInterpolate4Colors = group.readEntry(OPTIONFOURCOLORRGBENTRY, defaultPrm.RGBInterpolate4Colors);
unclipColors = group.readEntry(OPTIONUNCLIPCOLORSENTRY, defaultPrm.unclipColors);
DontStretchPixels = group.readEntry(OPTIONDONTSTRETCHPIXELSENTRY, defaultPrm.DontStretchPixels);
NRType = (NoiseReduction)
group.readEntry(OPTIONNOISEREDUCTIONTYPEENTRY, (int)defaultPrm.NRType);
brightness = group.readEntry(OPTIONBRIGHTNESSMULTIPLIERENTRY, defaultPrm.brightness);
enableBlackPoint = group.readEntry(OPTIONUSEBLACKPOINTENTRY, defaultPrm.enableBlackPoint);
blackPoint = group.readEntry(OPTIONBLACKPOINTENTRY, defaultPrm.blackPoint);
enableWhitePoint = group.readEntry(OPTIONUSEWHITEPOINTENTRY, defaultPrm.enableWhitePoint);
whitePoint = group.readEntry(OPTIONWHITEPOINTENTRY, defaultPrm.whitePoint);
medianFilterPasses = group.readEntry(OPTIONMEDIANFILTERPASSESENTRY, defaultPrm.medianFilterPasses);
NRThreshold = group.readEntry(OPTIONNOISEREDUCTIONTHRESHOLDENTRY, defaultPrm.NRThreshold);
enableCACorrection = group.readEntry(OPTIONUSECACORRECTIONENTRY, defaultPrm.enableCACorrection);
caMultiplier[0] = group.readEntry(OPTIONCAREDMULTIPLIERENTRY, defaultPrm.caMultiplier[0]);
caMultiplier[1] = group.readEntry(OPTIONCABLUEMULTIPLIERENTRY, defaultPrm.caMultiplier[1]);
RAWQuality = (DecodingQuality)
group.readEntry(OPTIONDECODINGQUALITYENTRY, (int)defaultPrm.RAWQuality);
outputColorSpace = (OutputColorSpace)
group.readEntry(OPTIONOUTPUTCOLORSPACEENTRY, (int)defaultPrm.outputColorSpace);
autoBrightness = group.readEntry(OPTIONAUTOBRIGHTNESSENTRY, defaultPrm.autoBrightness);
//-- Extended demosaicing settings ----------------------------------------------------------
dcbIterations = group.readEntry(OPTIONDCBITERATIONSENTRY, defaultPrm.dcbIterations);
dcbEnhanceFl = group.readEntry(OPTIONDCBENHANCEFLENTRY, defaultPrm.dcbEnhanceFl);
eeciRefine = group.readEntry(OPTIONEECIREFINEENTRY, defaultPrm.eeciRefine);
esMedPasses = group.readEntry(OPTIONESMEDPASSESENTRY, defaultPrm.esMedPasses);
NRChroThreshold = group.readEntry(OPTIONNRCHROMINANCETHRESHOLDENTRY, defaultPrm.NRChroThreshold);
expoCorrection = group.readEntry(OPTIONEXPOCORRECTIONENTRY, defaultPrm.expoCorrection);
expoCorrectionShift = group.readEntry(OPTIONEXPOCORRECTIONSHIFTENTRY, defaultPrm.expoCorrectionShift);
expoCorrectionHighlight = group.readEntry(OPTIONEXPOCORRECTIONHIGHLIGHTENTRY, defaultPrm.expoCorrectionHighlight);
}
void RawDecodingSettings::writeSettings(KConfigGroup& group)
{
group.writeEntry(OPTIONFIXCOLORSHIGHLIGHTSENTRY, fixColorsHighlights);
group.writeEntry(OPTIONDECODESIXTEENBITENTRY, sixteenBitsImage);
group.writeEntry(OPTIONWHITEBALANCEENTRY, (int)whiteBalance);
group.writeEntry(OPTIONCUSTOMWHITEBALANCEENTRY, customWhiteBalance);
group.writeEntry(OPTIONCUSTOMWBGREENENTRY, customWhiteBalanceGreen);
group.writeEntry(OPTIONFOURCOLORRGBENTRY, RGBInterpolate4Colors);
group.writeEntry(OPTIONUNCLIPCOLORSENTRY, unclipColors);
group.writeEntry(OPTIONDONTSTRETCHPIXELSENTRY, DontStretchPixels);
group.writeEntry(OPTIONNOISEREDUCTIONTYPEENTRY, (int)NRType);
group.writeEntry(OPTIONBRIGHTNESSMULTIPLIERENTRY, brightness);
group.writeEntry(OPTIONUSEBLACKPOINTENTRY, enableBlackPoint);
group.writeEntry(OPTIONBLACKPOINTENTRY, blackPoint);
group.writeEntry(OPTIONUSEWHITEPOINTENTRY, enableWhitePoint);
group.writeEntry(OPTIONWHITEPOINTENTRY, whitePoint);
group.writeEntry(OPTIONMEDIANFILTERPASSESENTRY, medianFilterPasses);
group.writeEntry(OPTIONNOISEREDUCTIONTHRESHOLDENTRY, NRThreshold);
group.writeEntry(OPTIONUSECACORRECTIONENTRY, enableCACorrection);
group.writeEntry(OPTIONCAREDMULTIPLIERENTRY, caMultiplier[0]);
group.writeEntry(OPTIONCABLUEMULTIPLIERENTRY, caMultiplier[1]);
group.writeEntry(OPTIONDECODINGQUALITYENTRY, (int)RAWQuality);
group.writeEntry(OPTIONOUTPUTCOLORSPACEENTRY, (int)outputColorSpace);
group.writeEntry(OPTIONAUTOBRIGHTNESSENTRY, autoBrightness);
//-- Extended demosaicing settings ----------------------------------------------------------
group.writeEntry(OPTIONDCBITERATIONSENTRY, dcbIterations);
group.writeEntry(OPTIONDCBENHANCEFLENTRY, dcbEnhanceFl);
group.writeEntry(OPTIONEECIREFINEENTRY, eeciRefine);
group.writeEntry(OPTIONESMEDPASSESENTRY, esMedPasses);
group.writeEntry(OPTIONNRCHROMINANCETHRESHOLDENTRY, NRChroThreshold);
group.writeEntry(OPTIONEXPOCORRECTIONENTRY, expoCorrection);
group.writeEntry(OPTIONEXPOCORRECTIONSHIFTENTRY, expoCorrectionShift);
group.writeEntry(OPTIONEXPOCORRECTIONHIGHLIGHTENTRY, expoCorrectionHighlight);
}
QDebug operator<<(QDebug dbg, const RawDecodingSettings& s)
{
dbg.nospace() << endl;
dbg.nospace() << "-- RAW DECODING SETTINGS --------------------------------" << endl;
dbg.nospace() << "-- autoBrightness: " << s.autoBrightness << endl;
dbg.nospace() << "-- sixteenBitsImage: " << s.sixteenBitsImage << endl;
dbg.nospace() << "-- brightness: " << s.brightness << endl;
dbg.nospace() << "-- RAWQuality: " << s.RAWQuality << endl;
dbg.nospace() << "-- inputColorSpace: " << s.inputColorSpace << endl;
dbg.nospace() << "-- outputColorSpace: " << s.outputColorSpace << endl;
dbg.nospace() << "-- RGBInterpolate4Colors: " << s.RGBInterpolate4Colors << endl;
dbg.nospace() << "-- DontStretchPixels: " << s.DontStretchPixels << endl;
dbg.nospace() << "-- unclipColors: " << s.unclipColors << endl;
dbg.nospace() << "-- whiteBalance: " << s.whiteBalance << endl;
dbg.nospace() << "-- customWhiteBalance: " << s.customWhiteBalance << endl;
dbg.nospace() << "-- customWhiteBalanceGreen: " << s.customWhiteBalanceGreen << endl;
dbg.nospace() << "-- halfSizeColorImage: " << s.halfSizeColorImage << endl;
dbg.nospace() << "-- enableBlackPoint: " << s.enableBlackPoint << endl;
dbg.nospace() << "-- blackPoint: " << s.blackPoint << endl;
dbg.nospace() << "-- enableWhitePoint: " << s.enableWhitePoint << endl;
dbg.nospace() << "-- whitePoint: " << s.whitePoint << endl;
dbg.nospace() << "-- NoiseReductionType: " << s.NRType << endl;
dbg.nospace() << "-- NoiseReductionThreshold: " << s.NRThreshold << endl;
dbg.nospace() << "-- enableCACorrection: " << s.enableCACorrection << endl;
dbg.nospace() << "-- caMultiplier: " << s.caMultiplier[0]
<< ", " << s.caMultiplier[1] << endl;
dbg.nospace() << "-- medianFilterPasses: " << s.medianFilterPasses << endl;
dbg.nospace() << "-- inputProfile: " << s.inputProfile << endl;
dbg.nospace() << "-- outputProfile: " << s.outputProfile << endl;
dbg.nospace() << "-- deadPixelMap: " << s.deadPixelMap << endl;
dbg.nospace() << "-- whiteBalanceArea: " << s.whiteBalanceArea << endl;
//-- Extended demosaicing settings ----------------------------------------------------------
dbg.nospace() << "-- dcbIterations: " << s.dcbIterations << endl;
dbg.nospace() << "-- dcbEnhanceFl: " << s.dcbEnhanceFl << endl;
dbg.nospace() << "-- eeciRefine: " << s.eeciRefine << endl;
dbg.nospace() << "-- esMedPasses: " << s.esMedPasses << endl;
dbg.nospace() << "-- NRChrominanceThreshold: " << s.NRChroThreshold << endl;
dbg.nospace() << "-- expoCorrection: " << s.expoCorrection << endl;
dbg.nospace() << "-- expoCorrectionShift: " << s.expoCorrectionShift << endl;
dbg.nospace() << "-- expoCorrectionHighlight: " << s.expoCorrectionHighlight << endl;
dbg.nospace() << "---------------------------------------------------------" << endl;
return dbg.space();
}
} // namespace KDcrawIface

View file

@ -0,0 +1,372 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-12-09
* @brief Raw decoding settings
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2007-2008 by Guillaume Castagnino
* <a href="mailto:casta at xwing dot info">casta at xwing dot info</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RAW_DECODING_SETTINGS_H
#define RAW_DECODING_SETTINGS_H
// Qt includes
#include <QtCore/QRect>
#include <QtCore/QString>
#include <QtCore/QDebug>
// KDE includes
#include <kconfiggroup.h>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT RawDecodingSettings
{
public:
/** RAW decoding Interpolation methods
*
* NOTE: from original dcraw demosaic
*
* Bilinear: use high-speed but low-quality bilinear
* interpolation (default - for slow computer). In this method,
* the red value of a non-red pixel is computed as the average of
* the adjacent red pixels, and similar for blue and green.
* VNG: use Variable Number of Gradients interpolation.
* This method computes gradients near the pixel of interest and uses
* the lower gradients (representing smoother and more similar parts
* of the image) to make an estimate.
* PPG: use Patterned Pixel Grouping interpolation.
* Pixel Grouping uses assumptions about natural scenery in making estimates.
* It has fewer color artifacts on natural images than the Variable Number of
* Gradients method.
* AHD: use Adaptive Homogeneity-Directed interpolation.
* This method selects the direction of interpolation so as to
* maximize a homogeneity metric, thus typically minimizing color artifacts.
*
* NOTE: from GPL2 demosaic pack.
*
* DCB: DCB interpolation (see http://www.linuxphoto.org/html/dcb.html for details)
* PL_AHD: modified AHD interpolation (see http://sites.google.com/site/demosaicalgorithms/modified-dcraw
* for details).
* AFD: demosaicing through 5 pass median filter from PerfectRaw project.
* VCD: VCD interpolation.
* VCD_AHD: mixed demosaicing between VCD and AHD.
* LMMSE: LMMSE interpolation from PerfectRaw.
*
* NOTE: from GPL3 demosaic pack.
*
* AMAZE: AMaZE interpolation and color aberration removal from RawTherapee project.
*/
enum DecodingQuality
{
// from original dcraw demosaic
BILINEAR = 0,
VNG = 1,
PPG = 2,
AHD = 3,
// Extended demosaicing method from GPL2 demosaic pack
DCB = 4,
PL_AHD = 5,
AFD = 6,
VCD = 7,
VCD_AHD = 8,
LMMSE = 9,
// Extended demosaicing methods from GPL3 demosaic pack
AMAZE = 10
};
/** White balances alternatives
* NONE: no white balance used : reverts to standard daylight D65 WB.
* CAMERA: Use the camera embedded WB if available. Reverts to NONE if not.
* AUTO: Averages an auto WB on the entire image.
* CUSTOM: Let use set it's own temperature and green factor (later converted to RGBG factors).
* AERA: Let use an aera from image to average white balance (see whiteBalanceArea for details).
*/
enum WhiteBalance
{
NONE = 0,
CAMERA = 1,
AUTO = 2,
CUSTOM = 3,
AERA = 4
};
/** Noise Reduction method to apply before demosaicing
* NONR: No noise reduction.
* WAVELETSNR: wavelets correction to erase noise while preserving real detail. It's applied after interpolation.
* FBDDNR: Fake Before Demosaicing Denoising noise reduction. It's applied before interpolation.
* LINENR: CFA Line Denoise. It's applied after interpolation.
* IMPULSENR: Impulse Denoise. It's applied after interpolation.
*/
enum NoiseReduction
{
NONR = 0,
WAVELETSNR,
FBDDNR,
LINENR,
IMPULSENR
};
/** Input color profile used to decoded image
* NOINPUTCS: No input color profile.
* EMBEDDED: Use the camera profile embedded in RAW file if exist.
* CUSTOMINPUTCS: Use a custom input color space profile.
*/
enum InputColorSpace
{
NOINPUTCS = 0,
EMBEDDED,
CUSTOMINPUTCS
};
/** Output RGB color space used to decoded image
* RAWCOLOR: No output color profile (Linear RAW).
* SRGB: Use standard sRGB color space.
* ADOBERGB: Use standard Adobe RGB color space.
* WIDEGAMMUT: Use standard RGB Wide Gamut color space.
* PROPHOTO: Use standard RGB Pro Photo color space.
* CUSTOMOUTPUTCS: Use a custom workspace color profile.
*/
enum OutputColorSpace
{
RAWCOLOR = 0,
SRGB,
ADOBERGB,
WIDEGAMMUT,
PROPHOTO,
CUSTOMOUTPUTCS
};
/** Standard constructor with default settings
*/
RawDecodingSettings();
/** Equivalent to the copy constructor
*/
RawDecodingSettings& operator=(const RawDecodingSettings& prm);
/** Compare for equality
*/
bool operator==(const RawDecodingSettings& o) const;
/** Standard destructor
*/
virtual ~RawDecodingSettings();
/** Method to use a settings to optimize time loading, for exemple to compute image histogram
*/
void optimizeTimeLoading();
/** Methods to read/write settings from/to a config file
*/
void readSettings(KConfigGroup& group);
void writeSettings(KConfigGroup& group);
public:
/** If true, images with overblown channels are processed much more accurate,
* without 'pink clouds' (and blue highlights under tungsteen lamps).
*/
bool fixColorsHighlights;
/** If false, use a fixed white level, ignoring the image histogram.
*/
bool autoBrightness;
/** Turn on RAW file decoding in 16 bits per color per pixel instead 8 bits.
*/
bool sixteenBitsImage;
/** Half-size color image decoding (twice as fast as "enableRAWQuality").
* Turn on this option to reduce time loading to render histogram for example,
* no to render an image to screen.
*/
bool halfSizeColorImage;
/** White balance type to use. See WhiteBalance values for detail
*/
WhiteBalance whiteBalance;
/** The temperature and the green multiplier of the custom white balance
*/
int customWhiteBalance;
double customWhiteBalanceGreen;
/** Turn on RAW file decoding using RGB interpolation as four colors.
*/
bool RGBInterpolate4Colors;
/** For cameras with non-square pixels, do not stretch the image to its
* correct aspect ratio. In any case, this option guarantees that each
* output pixel corresponds to one RAW pixel.
*/
bool DontStretchPixels;
/** Unclip Highlight color level:
* 0 = Clip all highlights to solid white.
* 1 = Leave highlights unclipped in various shades of pink.
* 2 = Blend clipped and unclipped values together for a gradual
* fade to white.
* 3-9 = Reconstruct highlights. Low numbers favor whites; high numbers
* favor colors.
*/
int unclipColors;
/** RAW quality decoding factor value. See DecodingQuality values
* for details.
*/
DecodingQuality RAWQuality;
/** After interpolation, clean up color artifacts by repeatedly applying
* a 3x3 median filter to the R-G and B-G channels.
*/
int medianFilterPasses;
/** Noise reduction method to apply before demosaicing.
*/
NoiseReduction NRType;
/** Noise reduction threshold value. Null value disable NR. Range is between 100 and 1000.
* For IMPULSENR : set the amount of Luminance impulse denoise.
*/
int NRThreshold;
/** Turn on chromatic aberrations correction
*/
bool enableCACorrection;
/** Magnification factor for Red and Blue layers
* - caMultiplier[0] = amount of correction on red-green axis.
* - caMultiplier[1] = amount of correction on blue-yellow axis.
* - Both values set to 0.0 = automatic CA correction.
*/
double caMultiplier[2];
/** Brightness of output image.
*/
double brightness;
/** Turn on the black point setting to decode RAW image.
*/
bool enableBlackPoint;
/** Black Point value of output image.
*/
int blackPoint;
/** Turn on the white point setting to decode RAW image.
*/
bool enableWhitePoint;
/** White Point value of output image.
*/
int whitePoint;
/** The input color profile used to decoded RAW data. See OutputColorProfile
* values for details.
*/
InputColorSpace inputColorSpace;
/** Path to custom input ICC profile to define the camera's raw colorspace.
*/
QString inputProfile;
/** The output color profile used to decoded RAW data. See OutputColorProfile
* values for details.
*/
OutputColorSpace outputColorSpace;
/** Path to custom output ICC profile to define the color workspace.
*/
QString outputProfile;
/** Path to text file including dead pixel list.
*/
QString deadPixelMap;
/** Rectangle used to calculate the white balance by averaging the region of image.
*/
QRect whiteBalanceArea;
//-- Extended demosaicing settings ----------------------------------------------------------
/// For DCB interpolation.
/** Number of DCB median filtering correction passes.
* -1 : disable (default)
* 1-10 : DCB correction passes
*/
int dcbIterations;
/** Turn on the DCB interpolation with enhance interpolated colors.
*/
bool dcbEnhanceFl;
/// For VCD_AHD interpolation.
/** Turn on the EECI refine for VCD Demosaicing.
*/
bool eeciRefine;
/** Use edge-sensitive median filtering for artifact supression after VCD demosaicing.
* 0 : disable (default)
* 1-10 : median filter passes.
*/
int esMedPasses;
/** For IMPULSENR Noise reduction. Set the amount of Chrominance impulse denoise.
Null value disable NR. Range is between 100 and 1000.
*/
int NRChroThreshold;
/** Turn on the Exposure Correction before interpolation.
*/
bool expoCorrection;
/** Shift of Exposure Correction before interpolation in linear scale.
* Usable range is from 0.25 (darken image 1 stop : -2EV) to 8.0 (lighten ~1.5 photographic stops : +3EV).
*/
double expoCorrectionShift;
/** Amount of highlight preservation for exposure correction before interpolation in E.V.
* Usable range is from 0.0 (linear exposure shift, highlights may blow) to 1.0 (maximum highlights preservation)
* This settings can only take effect if expoCorrectionShift > 1.0.
*/
double expoCorrectionHighlight;
};
//! kDebug() stream operator. Writes settings @a s to the debug output in a nicely formatted way.
LIBKDCRAW_EXPORT QDebug operator<<(QDebug dbg, const RawDecodingSettings& s);
} // namespace KDcrawIface
#endif /* RAW_DECODING_SETTINGS_H */

View file

@ -0,0 +1,99 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2005-11-06
* @brief list of RAW file extensions supported by libraw
*
* @author Copyright (C) 2005-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RAW_FILES_H
#define RAW_FILES_H
// NOTE: extension list Version 1 and 2 are taken from http://www.cybercom.net/~dcoffin/dcraw/rawphoto.c
// Ext Descriptions From
// www.file-extensions.org
// en.wikipedia.org/wiki/RAW_file_format
// filext.com
static const char raw_file_extentions[] =
// NOTE: VERSION 1
"*.bay " // Casio Digital Camera Raw File Format.
"*.bmq " // NuCore Raw Image File.
"*.cr2 " // Canon Digital Camera RAW Image Format version 2.0. These images are based on the TIFF image standard.
"*.crw " // Canon Digital Camera RAW Image Format version 1.0.
"*.cs1 " // Capture Shop Raw Image File.
"*.dc2 " // Kodak DC25 Digital Camera File.
"*.dcr " // Kodak Digital Camera Raw Image Format for these models: Kodak DSC Pro SLR/c, Kodak DSC Pro SLR/n, Kodak DSC Pro 14N, Kodak DSC PRO 14nx.
"*.dng " // Adobe Digital Negative: DNG is publicly available archival format for the raw files generated by digital cameras. By addressing the lack of an open standard for the raw files created by individual camera models, DNG helps ensure that photographers will be able to access their files in the future.
"*.erf " // Epson Digital Camera Raw Image Format.
"*.fff " // Imacon Digital Camera Raw Image Format.
"*.hdr " // Leaf Raw Image File.
"*.k25 " // Kodak DC25 Digital Camera Raw Image Format.
"*.kdc " // Kodak Digital Camera Raw Image Format.
"*.mdc " // Minolta RD175 Digital Camera Raw Image Format.
"*.mos " // Mamiya Digital Camera Raw Image Format.
"*.mrw " // Minolta Dimage Digital Camera Raw Image Format.
"*.nef " // Nikon Digital Camera Raw Image Format.
"*.orf " // Olympus Digital Camera Raw Image Format.
"*.pef " // Pentax Digital Camera Raw Image Format.
"*.pxn " // Logitech Digital Camera Raw Image Format.
"*.raf " // Fuji Digital Camera Raw Image Format.
"*.raw " // Panasonic Digital Camera Image Format.
"*.rdc " // Digital Foto Maker Raw Image File.
"*.sr2 " // Sony Digital Camera Raw Image Format.
"*.srf " // Sony Digital Camera Raw Image Format for DSC-F828 8 megapixel digital camera or Sony DSC-R1
"*.x3f " // Sigma Digital Camera Raw Image Format for devices based on Foveon X3 direct image sensor.
"*.arw " // Sony Digital Camera Raw Image Format for Alpha devices.
// NOTE: VERSION 2
"*.3fr " // Hasselblad Digital Camera Raw Image Format.
"*.cine " // Phantom Software Raw Image File.
"*.ia " // Sinar Raw Image File.
"*.kc2 " // Kodak DCS200 Digital Camera Raw Image Format.
"*.mef " // Mamiya Digital Camera Raw Image Format.
"*.nrw " // Nikon Digital Camera Raw Image Format.
"*.qtk " // Apple Quicktake 100/150 Digital Camera Raw Image Format.
"*.rw2 " // Panasonic LX3 Digital Camera Raw Image Format.
"*.sti " // Sinar Capture Shop Raw Image File.
// NOTE: VERSION 3
"*.rwl " // Leica Digital Camera Raw Image Format.
// NOTE: VERSION 4
"*.srw "; // Samnsung Raw Image Format.
/* TODO: check if these format are supported
"*.drf " // Kodak Digital Camera Raw Image Format.
"*.dsc " // Kodak Digital Camera Raw Image Format.
"*.ptx " // Pentax Digital Camera Raw Image Format.
"*.cap " // Phase One Digital Camera Raw Image Format.
"*.iiq " // Phase One Digital Camera Raw Image Format.
"*.rwz " // Rawzor Digital Camera Raw Image Format.
*/
// increment this number whenever you change the above string
static const int raw_file_extensions_version = 4;
#endif // RAW_FILES_H

View file

@ -0,0 +1,149 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-16
* @brief a combo box widget re-implemented with a
* reset button to switch to a default item
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_rcombobox.cpp"
// Qt includes
#include <QToolButton>
// KDE includes
#include <kdialog.h>
#include <klocale.h>
#include <kiconloader.h>
namespace KDcrawIface
{
class RComboBox::Private
{
public:
Private()
{
defaultIndex = 0;
resetButton = 0;
combo = 0;
}
int defaultIndex;
QToolButton* resetButton;
KComboBox* combo;
};
RComboBox::RComboBox(QWidget* const parent)
: KHBox(parent), d(new Private)
{
d->combo = new KComboBox(this);
d->resetButton = new QToolButton(this);
d->resetButton->setAutoRaise(true);
d->resetButton->setFocusPolicy(Qt::NoFocus);
d->resetButton->setIcon(SmallIcon("document-revert"));
d->resetButton->setToolTip(i18nc("@info:tooltip", "Reset to default value"));
setStretchFactor(d->combo, 10);
setMargin(0);
setSpacing(KDialog::spacingHint());
// -------------------------------------------------------------
connect(d->resetButton, SIGNAL(clicked()),
this, SLOT(slotReset()));
connect(d->combo, SIGNAL(activated(int)),
this, SLOT(slotItemActivated(int)));
connect(d->combo, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotCurrentIndexChanged(int)));
}
RComboBox::~RComboBox()
{
delete d;
}
KComboBox* RComboBox::combo() const
{
return d->combo;
}
void RComboBox::addItem(const QString& t, int index)
{
d->combo->addItem(t, index);
}
void RComboBox::insertItem(int index, const QString& t)
{
d->combo->insertItem(index, t);
}
int RComboBox::currentIndex() const
{
return d->combo->currentIndex();
}
void RComboBox::setCurrentIndex(int v)
{
d->combo->setCurrentIndex(v);
}
int RComboBox::defaultIndex() const
{
return d->defaultIndex;
}
void RComboBox::setDefaultIndex(int v)
{
d->defaultIndex = v;
d->combo->setCurrentIndex(d->defaultIndex);
slotItemActivated(v);
}
void RComboBox::slotReset()
{
d->combo->setCurrentIndex(d->defaultIndex);
d->resetButton->setEnabled(false);
slotItemActivated(d->defaultIndex);
emit reset();
}
void RComboBox::slotItemActivated(int v)
{
d->resetButton->setEnabled(v != d->defaultIndex);
emit activated(v);
}
void RComboBox::slotCurrentIndexChanged(int v)
{
d->resetButton->setEnabled(v != d->defaultIndex);
emit currentIndexChanged(v);
}
} // namespace KDcrawIface

View file

@ -0,0 +1,86 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-16
* @brief a combo box widget re-implemented with a
* reset button to switch to a default item
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RCOMBOBOX_H
#define RCOMBOBOX_H
// KDE includes
#include <khbox.h>
#include <kcombobox.h>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT RComboBox : public KHBox
{
Q_OBJECT
public:
RComboBox(QWidget* const parent=0);
~RComboBox();
void setCurrentIndex(int d);
int currentIndex() const;
void setDefaultIndex(int d);
int defaultIndex() const;
KComboBox* combo() const;
void addItem(const QString& t, int index = -1);
void insertItem(int index, const QString& t);
Q_SIGNALS:
void reset();
void activated(int);
void currentIndexChanged(int);
public Q_SLOTS:
void slotReset();
private Q_SLOTS:
void slotItemActivated(int);
void slotCurrentIndexChanged(int);
private:
class Private;
Private* const d;
};
} // namespace KDcrawIface
#endif /* RCOMBOBOX_H */

View file

@ -0,0 +1,827 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-03-14
* @brief A widget to host settings as expander box
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2008-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2010 by Manuel Viet
* <a href="mailto:contact at 13zenrv dot fr">contact at 13zenrv dot fr</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_rexpanderbox.cpp"
// Qt includes
#include <QMouseEvent>
#include <QPainter>
#include <QPen>
#include <QCursor>
#include <QStyle>
#include <QStyleOption>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QCheckBox>
// KDE includes
#include <kseparator.h>
#include <kdebug.h>
#include <kglobalsettings.h>
#include <kdialog.h>
#include <klocale.h>
namespace KDcrawIface
{
RClickLabel::RClickLabel(QWidget* const parent)
: QLabel(parent)
{
setCursor(Qt::PointingHandCursor);
}
RClickLabel::RClickLabel(const QString& text, QWidget* const parent)
: QLabel(text, parent)
{
setCursor(Qt::PointingHandCursor);
}
RClickLabel::~RClickLabel()
{
}
void RClickLabel::mousePressEvent(QMouseEvent* event)
{
QLabel::mousePressEvent(event);
/*
* In some contexts, like QGraphicsView, there will be no
* release event if the press event was not accepted.
*/
if (event->button() == Qt::LeftButton)
{
event->accept();
}
}
void RClickLabel::mouseReleaseEvent(QMouseEvent* event)
{
QLabel::mouseReleaseEvent(event);
if (event->button() == Qt::LeftButton)
{
emit leftClicked();
emit activated();
event->accept();
}
}
void RClickLabel::keyPressEvent(QKeyEvent* e)
{
switch (e->key())
{
case Qt::Key_Down:
case Qt::Key_Right:
case Qt::Key_Space:
emit activated();
return;
default:
break;
}
QLabel::keyPressEvent(e);
}
// ------------------------------------------------------------------------
RSqueezedClickLabel::RSqueezedClickLabel(QWidget* const parent)
: KSqueezedTextLabel(parent)
{
setCursor(Qt::PointingHandCursor);
}
RSqueezedClickLabel::RSqueezedClickLabel(const QString& text, QWidget* const parent)
: KSqueezedTextLabel(text, parent)
{
setCursor(Qt::PointingHandCursor);
}
RSqueezedClickLabel::~RSqueezedClickLabel()
{
}
void RSqueezedClickLabel::mouseReleaseEvent(QMouseEvent* event)
{
KSqueezedTextLabel::mouseReleaseEvent(event);
if (event->button() == Qt::LeftButton)
{
emit leftClicked();
emit activated();
event->accept();
}
}
void RSqueezedClickLabel::mousePressEvent(QMouseEvent* event)
{
QLabel::mousePressEvent(event);
/*
* In some contexts, like QGraphicsView, there will be no
* release event if the press event was not accepted.
*/
if (event->button() == Qt::LeftButton)
{
event->accept();
}
}
void RSqueezedClickLabel::keyPressEvent(QKeyEvent* e)
{
switch (e->key())
{
case Qt::Key_Down:
case Qt::Key_Right:
case Qt::Key_Space:
emit activated();
return;
default:
break;
}
QLabel::keyPressEvent(e);
}
// ------------------------------------------------------------------------
RArrowClickLabel::RArrowClickLabel(QWidget* const parent)
: QWidget(parent), m_arrowType(Qt::DownArrow)
{
setCursor(Qt::PointingHandCursor);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_size = 8;
m_margin = 2;
}
void RArrowClickLabel::setArrowType(Qt::ArrowType type)
{
m_arrowType = type;
update();
}
RArrowClickLabel::~RArrowClickLabel()
{
}
Qt::ArrowType RArrowClickLabel::arrowType() const
{
return m_arrowType;
}
void RArrowClickLabel::mousePressEvent(QMouseEvent* event)
{
/*
* In some contexts, like QGraphicsView, there will be no
* release event if the press event was not accepted.
*/
if (event->button() == Qt::LeftButton)
{
event->accept();
}
}
void RArrowClickLabel::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
emit leftClicked();
}
}
void RArrowClickLabel::paintEvent(QPaintEvent*)
{
// Inspired by karrowbutton.cpp,
// Copyright (C) 2001 Frerich Raabe <raabe@kde.org>
QPainter p(this);
QStyleOptionFrame opt;
opt.init(this);
opt.lineWidth = 2;
opt.midLineWidth = 0;
/*
p.fillRect( rect(), palette().brush( QPalette::Background ) );
style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this);
*/
if (m_arrowType == Qt::NoArrow)
return;
if (width() < m_size + m_margin || height() < m_size + m_margin)
return; // don't draw arrows if we are too small
unsigned int x = 0, y = 0;
if (m_arrowType == Qt::DownArrow)
{
x = (width() - m_size) / 2;
y = height() - (m_size + m_margin);
}
else if (m_arrowType == Qt::UpArrow)
{
x = (width() - m_size) / 2;
y = m_margin;
}
else if (m_arrowType == Qt::RightArrow)
{
x = width() - (m_size + m_margin);
y = (height() - m_size) / 2;
}
else // arrowType == LeftArrow
{
x = m_margin;
y = (height() - m_size) / 2;
}
/*
if (isDown())
{
++x;
++y;
}
*/
QStyle::PrimitiveElement e = QStyle::PE_IndicatorArrowLeft;
switch (m_arrowType)
{
case Qt::LeftArrow:
e = QStyle::PE_IndicatorArrowLeft;
break;
case Qt::RightArrow:
e = QStyle::PE_IndicatorArrowRight;
break;
case Qt::UpArrow:
e = QStyle::PE_IndicatorArrowUp;
break;
case Qt::DownArrow:
e = QStyle::PE_IndicatorArrowDown;
break;
case Qt::NoArrow:
break;
}
opt.state |= QStyle::State_Enabled;
opt.rect = QRect( x, y, m_size, m_size);
style()->drawPrimitive( e, &opt, &p, this );
}
QSize RArrowClickLabel::sizeHint() const
{
return QSize(m_size + 2*m_margin, m_size + 2*m_margin);
}
// ------------------------------------------------------------------------
class RLabelExpander::Private
{
public:
Private()
{
clickLabel = 0;
containerWidget = 0;
pixmapLabel = 0;
grid = 0;
arrow = 0;
line = 0;
hbox = 0;
checkBox = 0;
expandByDefault = true;
}
bool expandByDefault;
QCheckBox* checkBox;
QLabel* pixmapLabel;
QWidget* containerWidget;
QGridLayout* grid;
KSeparator* line;
QWidget* hbox;
RArrowClickLabel* arrow;
RClickLabel* clickLabel;
};
RLabelExpander::RLabelExpander(QWidget* const parent)
: QWidget(parent), d(new Private)
{
d->grid = new QGridLayout(this);
d->line = new KSeparator(Qt::Horizontal, this);
d->hbox = new QWidget(this);
d->arrow = new RArrowClickLabel(d->hbox);
d->checkBox = new QCheckBox(d->hbox);
d->pixmapLabel = new QLabel(d->hbox);
d->clickLabel = new RClickLabel(d->hbox);
QHBoxLayout* const hlay = new QHBoxLayout(d->hbox);
hlay->addWidget(d->arrow);
hlay->addWidget(d->checkBox);
hlay->addWidget(d->pixmapLabel);
hlay->addWidget(d->clickLabel, 10);
hlay->setMargin(0);
hlay->setSpacing(KDialog::spacingHint());
d->pixmapLabel->installEventFilter(this);
d->pixmapLabel->setCursor(Qt::PointingHandCursor);
d->hbox->setCursor(Qt::PointingHandCursor);
setCheckBoxVisible(false);
d->grid->addWidget(d->line, 0, 0, 1, 3);
d->grid->addWidget(d->hbox, 1, 0, 1, 3);
d->grid->setColumnStretch(2, 10);
d->grid->setMargin(KDialog::spacingHint());
d->grid->setSpacing(KDialog::spacingHint());
connect(d->arrow, SIGNAL(leftClicked()),
this, SLOT(slotToggleContainer()));
connect(d->clickLabel, SIGNAL(activated()),
this, SLOT(slotToggleContainer()));
connect(d->checkBox, SIGNAL(toggled(bool)),
this, SIGNAL(signalToggled(bool)));
}
RLabelExpander::~RLabelExpander()
{
delete d;
}
void RLabelExpander::setCheckBoxVisible(bool b)
{
d->checkBox->setVisible(b);
}
bool RLabelExpander::checkBoxIsVisible() const
{
return d->checkBox->isVisible();
}
void RLabelExpander::setChecked(bool b)
{
d->checkBox->setChecked(b);
}
bool RLabelExpander::isChecked() const
{
return d->checkBox->isChecked();
}
void RLabelExpander::setLineVisible(bool b)
{
d->line->setVisible(b);
}
bool RLabelExpander::lineIsVisible() const
{
return d->line->isVisible();
}
void RLabelExpander::setText(const QString& txt)
{
d->clickLabel->setText(QString("<qt><b>%1</b></qt>").arg(txt));
}
QString RLabelExpander::text() const
{
return d->clickLabel->text();
}
void RLabelExpander::setIcon(const QPixmap& pix)
{
d->pixmapLabel->setPixmap(pix);
}
const QPixmap* RLabelExpander::icon() const
{
return d->pixmapLabel->pixmap();
}
void RLabelExpander::setWidget(QWidget* const widget)
{
if (widget)
{
d->containerWidget = widget;
d->containerWidget->setParent(this);
d->grid->addWidget(d->containerWidget, 2, 0, 1, 3);
}
}
QWidget* RLabelExpander::widget() const
{
return d->containerWidget;
}
void RLabelExpander::setExpandByDefault(bool b)
{
d->expandByDefault = b;
}
bool RLabelExpander::isExpandByDefault() const
{
return d->expandByDefault;
}
void RLabelExpander::setExpanded(bool b)
{
if (d->containerWidget)
{
d->containerWidget->setVisible(b);
if (b)
d->arrow->setArrowType(Qt::DownArrow);
else
d->arrow->setArrowType(Qt::RightArrow);
}
emit signalExpanded(b);
}
bool RLabelExpander::isExpanded() const
{
return (d->arrow->arrowType() == Qt::DownArrow);
}
void RLabelExpander::slotToggleContainer()
{
if (d->containerWidget)
setExpanded(!d->containerWidget->isVisible());
}
bool RLabelExpander::eventFilter(QObject* obj, QEvent* ev)
{
if ( obj == d->pixmapLabel)
{
if ( ev->type() == QEvent::MouseButtonRelease)
{
slotToggleContainer();
return false;
}
else
{
return false;
}
}
else
{
// pass the event on to the parent class
return QWidget::eventFilter(obj, ev);
}
}
// ------------------------------------------------------------------------
class RExpanderBox::Private
{
public:
Private(RExpanderBox* const box)
{
parent = box;
vbox = 0;
}
void createItem(int index, QWidget* const w, const QPixmap& pix, const QString& txt,
const QString& objName, bool expandBydefault)
{
RLabelExpander* const exp = new RLabelExpander(parent->viewport());
exp->setText(txt);
exp->setIcon(pix);
exp->setWidget(w);
exp->setLineVisible(!wList.isEmpty());
exp->setObjectName(objName);
exp->setExpandByDefault(expandBydefault);
if (index >= 0)
{
vbox->insertWidget(index, exp);
wList.insert(index, exp);
}
else
{
vbox->addWidget(exp);
wList.append(exp);
}
parent->connect(exp, SIGNAL(signalExpanded(bool)),
parent, SLOT(slotItemExpanded(bool)));
parent->connect(exp, SIGNAL(signalToggled(bool)),
parent, SLOT(slotItemToggled(bool)));
}
public:
QList<RLabelExpander*> wList;
QVBoxLayout* vbox;
RExpanderBox* parent;
};
RExpanderBox::RExpanderBox(QWidget* const parent)
: QScrollArea(parent), d(new Private(this))
{
setFrameStyle(QFrame::NoFrame);
setWidgetResizable(true);
QWidget* const main = new QWidget(viewport());
d->vbox = new QVBoxLayout(main);
d->vbox->setMargin(0);
d->vbox->setSpacing(KDialog::spacingHint());
setWidget(main);
setAutoFillBackground(false);
viewport()->setAutoFillBackground(false);
main->setAutoFillBackground(false);
}
RExpanderBox::~RExpanderBox()
{
d->wList.clear();
delete d;
}
void RExpanderBox::setCheckBoxVisible(int index, bool b)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setCheckBoxVisible(b);
}
bool RExpanderBox::checkBoxIsVisible(int index) const
{
if (index > d->wList.count() || index < 0) return false;
return d->wList[index]->checkBoxIsVisible();
}
void RExpanderBox::setChecked(int index, bool b)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setChecked(b);
}
bool RExpanderBox::isChecked(int index) const
{
if (index > d->wList.count() || index < 0) return false;
return d->wList[index]->isChecked();
}
void RExpanderBox::addItem(QWidget* const w, const QPixmap& pix, const QString& txt,
const QString& objName, bool expandBydefault)
{
d->createItem(-1, w, pix, txt, objName, expandBydefault);
}
void RExpanderBox::addItem(QWidget* const w, const QString& txt,
const QString& objName, bool expandBydefault)
{
addItem(w, QPixmap(), txt, objName, expandBydefault);
}
void RExpanderBox::addStretch()
{
d->vbox->addStretch(10);
}
void RExpanderBox::insertItem(int index, QWidget* const w, const QPixmap& pix, const QString& txt,
const QString& objName, bool expandBydefault)
{
d->createItem(index, w, pix, txt, objName, expandBydefault);
}
void RExpanderBox::slotItemExpanded(bool b)
{
RLabelExpander* const exp = dynamic_cast<RLabelExpander*>(sender());
if (exp)
{
int index = indexOf(exp);
emit signalItemExpanded(index, b);
}
}
void RExpanderBox::slotItemToggled(bool b)
{
RLabelExpander* const exp = dynamic_cast<RLabelExpander*>(sender());
if (exp)
{
int index = indexOf(exp);
emit signalItemToggled(index, b);
}
}
void RExpanderBox::insertItem(int index, QWidget* const w, const QString& txt,
const QString& objName, bool expandBydefault)
{
insertItem(index, w, QPixmap(), txt, objName, expandBydefault);
}
void RExpanderBox::insertStretch(int index)
{
d->vbox->insertStretch(index, 10);
}
void RExpanderBox::removeItem(int index)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->hide();
d->wList.removeAt(index);
}
void RExpanderBox::setItemText(int index, const QString& txt)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setText(txt);
}
QString RExpanderBox::itemText(int index) const
{
if (index > d->wList.count() || index < 0) return QString();
return d->wList[index]->text();
}
void RExpanderBox::setItemIcon(int index, const QPixmap& pix)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setIcon(pix);
}
const QPixmap* RExpanderBox::itemIcon(int index) const
{
if (index > d->wList.count() || index < 0) return 0;
return d->wList[index]->icon();
}
int RExpanderBox::count() const
{
return d->wList.count();
}
void RExpanderBox::setItemToolTip(int index, const QString& tip)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setToolTip(tip);
}
QString RExpanderBox::itemToolTip(int index) const
{
if (index > d->wList.count() || index < 0) return QString();
return d->wList[index]->toolTip();
}
void RExpanderBox::setItemEnabled(int index, bool enabled)
{
if (index > d->wList.count() || index < 0) return;
d->wList[index]->setEnabled(enabled);
}
bool RExpanderBox::isItemEnabled(int index) const
{
if (index > d->wList.count() || index < 0) return false;
return d->wList[index]->isEnabled();
}
RLabelExpander* RExpanderBox::widget(int index) const
{
if (index > d->wList.count() || index < 0) return 0;
return d->wList[index];
}
int RExpanderBox::indexOf(RLabelExpander* const widget) const
{
for (int i = 0 ; i < count(); ++i)
{
RLabelExpander* const exp = d->wList[i];
if (widget == exp)
return i;
}
return -1;
}
void RExpanderBox::setItemExpanded(int index, bool b)
{
if (index > d->wList.count() || index < 0) return;
RLabelExpander* const exp = d->wList[index];
if (!exp) return;
exp->setExpanded(b);
}
bool RExpanderBox::isItemExpanded(int index) const
{
if (index > d->wList.count() || index < 0) return false;
RLabelExpander* const exp = d->wList[index];
if (!exp) return false;
return (exp->isExpanded());
}
void RExpanderBox::readSettings(KConfigGroup& group)
{
for (int i = 0 ; i < count(); ++i)
{
RLabelExpander* const exp = d->wList[i];
if (exp)
{
exp->setExpanded(group.readEntry(QString("%1 Expanded").arg(exp->objectName()),
exp->isExpandByDefault()));
}
}
}
void RExpanderBox::writeSettings(KConfigGroup& group)
{
for (int i = 0 ; i < count(); ++i)
{
RLabelExpander* const exp = d->wList[i];
if (exp)
{
group.writeEntry(QString("%1 Expanded").arg(exp->objectName()),
exp->isExpanded());
}
}
}
// ------------------------------------------------------------------------
RExpanderBoxExclusive::RExpanderBoxExclusive(QWidget* const parent)
: RExpanderBox(parent)
{
setIsToolBox(true);
}
RExpanderBoxExclusive::~RExpanderBoxExclusive()
{
}
void RExpanderBoxExclusive::slotItemExpanded(bool b)
{
RLabelExpander* const exp = dynamic_cast<RLabelExpander*>(sender());
if (!exp) return;
if (isToolBox() && b)
{
int item = 0;
while (item < count())
{
if (isItemExpanded(item) && item != indexOf(exp))
{
setItemExpanded(item, false);
}
item++;
}
}
emit signalItemExpanded(indexOf(exp), b);
}
void RExpanderBoxExclusive::setIsToolBox(bool b)
{
m_toolbox = b;
}
bool RExpanderBoxExclusive::isToolBox() const
{
return (m_toolbox);
}
} // namespace KDcrawIface

View file

@ -0,0 +1,299 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-03-14
* @brief A widget to host settings as expander box
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2008-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2010 by Manuel Viet
* <a href="mailto:contact at 13zenrv dot fr">contact at 13zenrv dot fr</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef REXPANDERBOX_H
#define REXPANDERBOX_H
// Qt includes
#include <QtCore/QObject>
#include <QtGui/QPixmap>
#include <QtGui/QLabel>
#include <QtGui/QWidget>
#include <QtGui/QScrollArea>
// KDE includes
#include <ksqueezedtextlabel.h>
#include <kconfig.h>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT RClickLabel : public QLabel
{
Q_OBJECT
public:
RClickLabel(QWidget* const parent = 0);
explicit RClickLabel(const QString& text, QWidget* const parent = 0);
~RClickLabel();
Q_SIGNALS:
/// Emitted when activated by left mouse click
void leftClicked();
/// Emitted when activated, by mouse or key press
void activated();
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
};
// -------------------------------------------------------------------------
class LIBKDCRAW_EXPORT RSqueezedClickLabel : public KSqueezedTextLabel
{
Q_OBJECT
public:
RSqueezedClickLabel(QWidget* const parent = 0);
explicit RSqueezedClickLabel(const QString& text, QWidget* const parent = 0);
~RSqueezedClickLabel();
Q_SIGNALS:
void leftClicked();
void activated();
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
};
// -------------------------------------------------------------------------
class LIBKDCRAW_EXPORT RArrowClickLabel : public QWidget
{
Q_OBJECT
public:
RArrowClickLabel(QWidget* const parent = 0);
~RArrowClickLabel();
void setArrowType(Qt::ArrowType arrowType);
Qt::ArrowType arrowType() const;
virtual QSize sizeHint () const;
Q_SIGNALS:
void leftClicked();
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void paintEvent(QPaintEvent* event);
protected:
Qt::ArrowType m_arrowType;
int m_size;
int m_margin;
};
// -------------------------------------------------------------------------
class LIBKDCRAW_EXPORT RLabelExpander : public QWidget
{
Q_OBJECT
public:
RLabelExpander(QWidget* const parent = 0);
~RLabelExpander();
void setCheckBoxVisible(bool b);
bool checkBoxIsVisible() const;
void setChecked(bool b);
bool isChecked() const;
void setLineVisible(bool b);
bool lineIsVisible() const;
void setText(const QString& txt);
QString text() const;
void setIcon(const QPixmap& pix);
const QPixmap* icon() const;
void setWidget(QWidget* const widget);
QWidget* widget() const;
void setExpanded(bool b);
bool isExpanded() const;
void setExpandByDefault(bool b);
bool isExpandByDefault() const;
Q_SIGNALS:
void signalExpanded(bool);
void signalToggled(bool);
private Q_SLOTS:
void slotToggleContainer();
private:
bool eventFilter(QObject* obj, QEvent* ev);
private:
class Private;
Private* const d;
};
// -------------------------------------------------------------------------
class LIBKDCRAW_EXPORT RExpanderBox : public QScrollArea
{
Q_OBJECT
public:
RExpanderBox(QWidget* const parent = 0);
~RExpanderBox();
/** Add RLabelExpander item at end of box layout with these settings :
'w' : the widget hosted by RLabelExpander.
'pix' : pixmap used as icon to item title.
'txt' : text used as item title.
'objName' : item object name used to read/save expanded settings to rc file.
'expandBydefault' : item state by default (expanded or not).
*/
void addItem(QWidget* const w, const QPixmap& pix, const QString& txt,
const QString& objName, bool expandBydefault);
void addItem(QWidget* const w, const QString& txt,
const QString& objName, bool expandBydefault);
/** Insert RLabelExpander item at box layout index with these settings :
'w' : the widget hosted by RLabelExpander.
'pix' : pixmap used as icon to item title.
'txt' : text used as item title.
'objName' : item object name used to read/save expanded settings to rc file.
'expandBydefault' : item state by default (expanded or not).
*/
void insertItem(int index, QWidget* const w, const QPixmap& pix, const QString& txt,
const QString& objName, bool expandBydefault);
void insertItem(int index, QWidget* const w, const QString& txt,
const QString& objName, bool expandBydefault);
void removeItem(int index);
void setCheckBoxVisible(int index, bool b);
bool checkBoxIsVisible(int index) const;
void setChecked(int index, bool b);
bool isChecked(int index) const;
void setItemText(int index, const QString& txt);
QString itemText (int index) const;
void setItemIcon(int index, const QPixmap& pix);
const QPixmap* itemIcon(int index) const;
void setItemToolTip(int index, const QString& tip);
QString itemToolTip(int index) const;
void setItemEnabled(int index, bool enabled);
bool isItemEnabled(int index) const;
void addStretch();
void insertStretch(int index);
void setItemExpanded(int index, bool b);
bool isItemExpanded(int index) const;
int count() const;
RLabelExpander* widget(int index) const;
int indexOf(RLabelExpander* const widget) const;
virtual void readSettings(KConfigGroup& group);
virtual void writeSettings(KConfigGroup& group);
Q_SIGNALS:
void signalItemExpanded(int index, bool b);
void signalItemToggled(int index, bool b);
private Q_SLOTS:
void slotItemExpanded(bool b);
void slotItemToggled(bool b);
private:
class Private;
Private* const d;
};
// -------------------------------------------------------------------------
class LIBKDCRAW_EXPORT RExpanderBoxExclusive : public RExpanderBox
{
Q_OBJECT
public:
RExpanderBoxExclusive(QWidget* const parent = 0);
~RExpanderBoxExclusive();
/** Show one expander open at most */
void setIsToolBox(bool b);
bool isToolBox() const;
private Q_SLOTS:
void slotItemExpanded(bool b);
private:
bool m_toolbox;
};
} // namespace KDcrawIface
#endif // REXPANDERBOX_H

View file

@ -0,0 +1,239 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-16
* @brief Integer and double num input widget
* re-implemented with a reset button to switch to
* a default value
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_rnuminput.cpp"
// Qt includes
#include <QToolButton>
// KDE includes
#include <klocale.h>
#include <kiconloader.h>
#include <kdialog.h>
namespace KDcrawIface
{
class RIntNumInput::Private
{
public:
Private()
{
defaultValue = 0;
resetButton = 0;
input = 0;
}
int defaultValue;
QToolButton* resetButton;
KIntNumInput* input;
};
RIntNumInput::RIntNumInput(QWidget* const parent)
: KHBox(parent), d(new Private)
{
d->input = new KIntNumInput(this);
d->resetButton = new QToolButton(this);
d->resetButton->setAutoRaise(true);
d->resetButton->setFocusPolicy(Qt::NoFocus);
d->resetButton->setIcon(SmallIcon("document-revert"));
d->resetButton->setToolTip(i18nc("@info:tooltip", "Reset to default value"));
setStretchFactor(d->input, 10);
setMargin(0);
setSpacing(KDialog::spacingHint());
// -------------------------------------------------------------
connect(d->resetButton, SIGNAL(clicked()),
this, SLOT(slotReset()));
connect(d->input, SIGNAL(valueChanged(int)),
this, SLOT(slotValueChanged(int)));
}
RIntNumInput::~RIntNumInput()
{
delete d;
}
KIntNumInput* RIntNumInput::input() const
{
return d->input;
}
void RIntNumInput::setSliderEnabled(bool b)
{
d->input->setSliderEnabled(b);
}
void RIntNumInput::setRange(int min, int max, int step)
{
d->input->setRange(min, max, step);
}
int RIntNumInput::value() const
{
return d->input->value();
}
void RIntNumInput::setValue(int v)
{
d->input->setValue(v);
}
int RIntNumInput::defaultValue() const
{
return d->defaultValue;
}
void RIntNumInput::setDefaultValue(int v)
{
d->defaultValue = v;
d->input->setValue(d->defaultValue);
slotValueChanged(v);
}
void RIntNumInput::slotReset()
{
d->input->setValue(d->defaultValue);
d->resetButton->setEnabled(false);
emit reset();
}
void RIntNumInput::slotValueChanged(int v)
{
d->resetButton->setEnabled(v != d->defaultValue);
emit valueChanged(v);
}
// ----------------------------------------------------
class RDoubleNumInput::Private
{
public:
Private()
{
defaultValue = 0.0;
resetButton = 0;
input = 0;
}
double defaultValue;
QToolButton* resetButton;
KDoubleNumInput* input;
};
RDoubleNumInput::RDoubleNumInput(QWidget* const parent)
: KHBox(parent), d(new Private)
{
d->input = new KDoubleNumInput(this);
d->resetButton = new QToolButton(this);
d->resetButton->setAutoRaise(true);
d->resetButton->setFocusPolicy(Qt::NoFocus);
d->resetButton->setIcon(SmallIcon("document-revert"));
d->resetButton->setToolTip(i18nc("@info:tooltip", "Reset to default value"));
setStretchFactor(d->input, 10);
setMargin(0);
setSpacing(KDialog::spacingHint());
// -------------------------------------------------------------
connect(d->resetButton, SIGNAL(clicked()),
this, SLOT(slotReset()));
connect(d->input, SIGNAL(valueChanged(double)),
this, SLOT(slotValueChanged(double)));
}
RDoubleNumInput::~RDoubleNumInput()
{
delete d;
}
KDoubleNumInput* RDoubleNumInput::input() const
{
return d->input;
}
void RDoubleNumInput::setDecimals(int p)
{
d->input->setDecimals(p);
}
void RDoubleNumInput::setRange(double min, double max, double step, bool slider)
{
d->input->setRange(min, max, step, slider);
}
double RDoubleNumInput::value() const
{
return d->input->value();
}
void RDoubleNumInput::setValue(double v)
{
d->input->setValue(v);
}
double RDoubleNumInput::defaultValue() const
{
return d->defaultValue;
}
void RDoubleNumInput::setDefaultValue(double v)
{
d->defaultValue = v;
d->input->setValue(d->defaultValue);
slotValueChanged(v);
}
void RDoubleNumInput::slotReset()
{
d->input->setValue(d->defaultValue);
d->resetButton->setEnabled(false);
emit reset();
}
void RDoubleNumInput::slotValueChanged(double v)
{
d->resetButton->setEnabled(v != d->defaultValue);
emit valueChanged(v);
}
} // namespace KDcrawIface

View file

@ -0,0 +1,125 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-16
* @brief Integer and double num input widget
* re-implemented with a reset button to switch to
* a default value
*
* @author Copyright (C) 2008-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef RNUMINPUT_H
#define RNUMINPUT_H
// KDE includes
#include <khbox.h>
#include <knuminput.h>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
class LIBKDCRAW_EXPORT RIntNumInput : public KHBox
{
Q_OBJECT
public:
RIntNumInput(QWidget* const parent=0);
~RIntNumInput();
int value() const;
void setSliderEnabled(bool b);
void setRange(int min, int max, int step);
void setDefaultValue(int d);
int defaultValue() const;
KIntNumInput* input() const;
Q_SIGNALS:
void reset();
void valueChanged(int);
public Q_SLOTS:
void setValue(int d);
void slotReset();
private Q_SLOTS:
void slotValueChanged(int);
private:
class Private;
Private* const d;
};
// ---------------------------------------------------------
class LIBKDCRAW_EXPORT RDoubleNumInput : public KHBox
{
Q_OBJECT
public:
RDoubleNumInput(QWidget* const parent=0);
~RDoubleNumInput();
double value() const;
void setDecimals(int p);
void setRange(double min, double max, double step, bool slider=true);
void setDefaultValue(double d);
double defaultValue() const;
KDoubleNumInput* input() const;
Q_SIGNALS:
void reset();
void valueChanged(double);
public Q_SLOTS:
void setValue(double d);
void slotReset();
private Q_SLOTS:
void slotValueChanged(double);
private:
class Private;
Private* const d;
};
} // namespace KDcrawIface
#endif /* RNUMINPUT_H */

View file

@ -0,0 +1,200 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-21
* @brief a combo box with a width not depending of text
* content size
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2008 by Andi Clemens
* <a href="mailto:andi dot clemens at googlemail dot com">andi dot clemens at googlemail dot com</a>
* @author Copyright (C) 2005 by Tom Albers
* <a href="mailto:tomalbers at kde dot nl">tomalbers at kde dot nl</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_squeezedcombobox.cpp"
// Qt includes
#include <QComboBox>
#include <QPair>
#include <QTimer>
#include <QStyle>
#include <QApplication>
#include <QToolTip>
#include <QResizeEvent>
namespace KDcrawIface
{
class SqueezedComboBox::Private
{
public:
Private()
{
timer = 0;
}
QMap<int, QString> originalItems;
QTimer* timer;
};
SqueezedComboBox::SqueezedComboBox(QWidget* const parent, const char* name)
: QComboBox(parent), d(new Private)
{
setObjectName(name);
setMinimumWidth(100);
d->timer = new QTimer(this);
d->timer->setSingleShot(true);
connect(d->timer, SIGNAL(timeout()),
this, SLOT(slotTimeOut()));
connect(this, SIGNAL(activated(int)),
SLOT(slotUpdateToolTip(int)));
}
SqueezedComboBox::~SqueezedComboBox()
{
d->originalItems.clear();
delete d->timer;
delete d;
}
bool SqueezedComboBox::contains(const QString& text) const
{
if (text.isEmpty())
return false;
for (QMap<int, QString>::const_iterator it = d->originalItems.constBegin() ; it != d->originalItems.constEnd(); ++it)
{
if (it.value() == text)
return true;
}
return false;
}
QSize SqueezedComboBox::sizeHint() const
{
ensurePolished();
QFontMetrics fm = fontMetrics();
int maxW = count() ? 18 : 7 * fm.width(QChar('x')) + 18;
int maxH = qMax( fm.lineSpacing(), 14 ) + 2;
QStyleOptionComboBox options;
options.initFrom(this);
return style()->sizeFromContents(QStyle::CT_ComboBox, &options,
QSize(maxW, maxH), this).expandedTo(QApplication::globalStrut());
}
void SqueezedComboBox::insertSqueezedItem(const QString& newItem, int index,
const QVariant& userData)
{
d->originalItems[index] = newItem;
QComboBox::insertItem(index, squeezeText(newItem), userData);
// if this is the first item, set the tooltip.
if (index == 0)
slotUpdateToolTip(0);
}
void SqueezedComboBox::insertSqueezedList(const QStringList& newItems, int index)
{
for(QStringList::const_iterator it = newItems.constBegin() ; it != newItems.constEnd() ; ++it)
{
insertSqueezedItem(*it, index);
index++;
}
}
void SqueezedComboBox::addSqueezedItem(const QString& newItem,
const QVariant& userData)
{
insertSqueezedItem(newItem, count(), userData);
}
void SqueezedComboBox::setCurrent(const QString& itemText)
{
QString squeezedText = squeezeText(itemText);
qint32 itemIndex = findText(squeezedText);
if (itemIndex >= 0)
setCurrentIndex(itemIndex);
}
void SqueezedComboBox::resizeEvent(QResizeEvent *)
{
d->timer->start(200);
}
void SqueezedComboBox::slotTimeOut()
{
for (QMap<int, QString>::iterator it = d->originalItems.begin() ; it != d->originalItems.end(); ++it)
{
setItemText( it.key(), squeezeText( it.value() ) );
}
}
QString SqueezedComboBox::squeezeText(const QString& original) const
{
// not the complete widgetSize is usable. Need to compensate for that.
int widgetSize = width()-30;
QFontMetrics fm( fontMetrics() );
// If we can fit the full text, return that.
if (fm.width(original) < widgetSize)
return(original);
// We need to squeeze.
QString sqItem = original; // prevent empty return value;
widgetSize = widgetSize-fm.width("...");
for (int i = 0 ; i != original.length(); ++i)
{
if ((int)fm.width(original.right(i)) > widgetSize)
{
sqItem = QString(original.left(i) + "...");
break;
}
}
return sqItem;
}
void SqueezedComboBox::slotUpdateToolTip(int index)
{
setToolTip(d->originalItems[index]);
}
QString SqueezedComboBox::itemHighlighted() const
{
int curItem = currentIndex();
return d->originalItems[curItem];
}
QString SqueezedComboBox::item(int index) const
{
return d->originalItems[index];
}
} // namespace KDcrawIface

View file

@ -0,0 +1,165 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-08-21
* @brief a combo box with a width not depending of text
* content size
*
* @author Copyright (C) 2006-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2008 by Andi Clemens
* <a href="mailto:andi dot clemens at googlemail dot com">andi dot clemens at googlemail dot com</a>
* @author Copyright (C) 2005 by Tom Albers
* <a href="mailto:tomalbers at kde dot nl">tomalbers at kde dot nl</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef SQUEEZEDCOMBOBOX_H
#define SQUEEZEDCOMBOBOX_H
// Qt includes
#include <QtGui/QComboBox>
// Local includes
#include "libkdcraw_export.h"
namespace KDcrawIface
{
/** @class SqueezedComboBox
*
* This widget is a QComboBox, but then a little bit
* different. It only shows the right part of the items
* depending on de size of the widget. When it is not
* possible to show the complete item, it will be shortened
* and "..." will be prepended.
*/
class LIBKDCRAW_EXPORT SqueezedComboBox : public QComboBox
{
Q_OBJECT
public:
/**
* Constructor
* @param parent parent widget
* @param name name to give to the widget
*/
explicit SqueezedComboBox(QWidget* const parent = 0, const char* name = 0 );
/**
* destructor
*/
virtual ~SqueezedComboBox();
/**
*
* Returns true if the combobox contains the original (not-squeezed)
* version of text.
* @param text the original (not-squeezed) text to check for
*/
bool contains(const QString& text) const;
/**
* This inserts a item to the list. See QComboBox::insertItem()
* for details. Please do not use QComboBox::insertItem() to this
* widget, as that will fail.
* @param newItem the original (long version) of the item which needs
* to be added to the combobox
* @param index the position in the widget.
* @param userData custom meta-data assigned to new item.
*/
void insertSqueezedItem(const QString& newItem, int index,
const QVariant& userData=QVariant());
/**
* This inserts items to the list. See QComboBox::insertItems()
* for details. Please do not use QComboBox:: insertItems() to this
* widget, as that will fail.
* @param newItems the originals (long version) of the items which needs
* to be added to the combobox
* @param index the position in the widget.
*/
void insertSqueezedList(const QStringList& newItems, int index);
/**
* Append an item.
* @param newItem the original (long version) of the item which needs
* to be added to the combobox
* @param userData custom meta-data assigned to new item.
*/
void addSqueezedItem(const QString& newItem,
const QVariant& userData=QVariant());
/**
* Set the current item to the one matching the given text.
*
* @param itemText the original (long version) of the item text
*/
void setCurrent(const QString& itemText);
/**
* This method returns the full text (not squeezed) of the currently
* highlighted item.
* @return full text of the highlighted item
*/
QString itemHighlighted() const;
/**
* This method returns the full text (not squeezed) for the index.
* @param index the position in the widget.
* @return full text of the item
*/
QString item(int index) const;
/**
* Sets the sizeHint() of this widget.
*/
virtual QSize sizeHint() const;
private Q_SLOTS:
void slotTimeOut();
void slotUpdateToolTip(int index);
private:
void resizeEvent(QResizeEvent*);
QString squeezeText(const QString& original) const;
// Prevent these from being used.
QString currentText() const;
void setCurrentText(const QString& itemText);
void insertItem(const QString& text);
void insertItem(qint32 index, const QString& text);
void insertItem(int index, const QIcon& icon, const QString& text, const QVariant& userData=QVariant());
void insertItems(int index, const QStringList& list);
void addItem(const QString& text);
void addItem(const QIcon& icon, const QString& text, const QVariant& userData=QVariant());
void addItems(const QStringList& texts);
QString itemText(int index) const;
private:
class Private;
Private* const d;
};
} // namespace KDcrawIface
#endif // SQUEEZEDCOMBOBOX_H

View file

@ -0,0 +1,33 @@
/** ===========================================================
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-02-12
* @brief libraw program interface for KDE
*
* @author Copyright (C) 2007-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KDCRAW_VERSION_H
#define KDCRAW_VERSION_H
// Before changing the line below, make sure that FindKdcraw.cmake can still parse it
static const char kdcraw_version[] = "${DCRAW_LIB_VERSION_STRING}";
#define KDCRAW_VERSION ${DCRAW_LIB_VERSION_ID}
#endif // KDCRAW_VERSION_H

View file

@ -0,0 +1,28 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-12-09
# @brief a tread-safe libraw C++ program interface for KDE
#
# @author Copyright (C) 2006-2012 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
FILE(GLOB icmfiles *.icm *.icc)
INSTALL(FILES ${icmfiles}
DESTINATION ${DATA_INSTALL_DIR}/libkdcraw/profiles )

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,33 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-12-09
# @brief a tread-safe libraw C++ program interface for KDE
#
# @author Copyright (C) 2006-2013 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libkdcraw)
SET(raw2png_SRCS raw2png.cpp)
ADD_EXECUTABLE(raw2png ${raw2png_SRCS})
TARGET_LINK_LIBRARIES(raw2png kdcraw ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
SET(libinfo_SRCS libinfo.cpp)
ADD_EXECUTABLE(libinfo ${libinfo_SRCS})
TARGET_LINK_LIBRARIES(libinfo kdcraw ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})

View file

@ -0,0 +1,49 @@
/** ===========================================================
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2013-09-07
* @brief a command line tool to show libkdcraw info
*
* @author Copyright (C) 2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Qt includes
#include <QString>
#include <QDebug>
// Local includes
#include "kdcraw.h"
using namespace KDcrawIface;
int main(int /*argc*/, char** /*argv*/)
{
qDebug() << "Libkdcraw version : " << KDcraw::version(),
qDebug() << "Libraw version : " << KDcraw::librawVersion();
qDebug() << "Use OpenMP : " << KDcraw::librawUseGomp();
qDebug() << "Use RawSpeed : " << KDcraw::librawUseRawSpeed();
qDebug() << "Use GPL2 Pack : " << KDcraw::librawUseGPL2DemosaicPack();
qDebug() << "Use GPL3 Pack : " << KDcraw::librawUseGPL3DemosaicPack();
qDebug() << "Raw files list : " << KDcraw::rawFilesList();
qDebug() << "Raw files version : " << KDcraw::rawFilesVersion();
qDebug() << "Supported camera : " << KDcraw::supportedCamera();
return 0;
}

138
libkdcraw/tests/raw2png.cpp Normal file
View file

@ -0,0 +1,138 @@
/** ===========================================================
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2008-15-09
* @brief a command line tool to convert RAW file to PNG
*
* @author Copyright (C) 2008-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Qt includes
#include <QString>
#include <QFile>
#include <QFileInfo>
#include <QDebug>
// Local includes
#include "kdcraw.h"
#include "rawdecodingsettings.h"
using namespace KDcrawIface;
int main(int argc, char** argv)
{
if(argc != 2)
{
qDebug() << "raw2png - RAW Camera Image to PNG Converter";
qDebug() << "Usage: <rawfile>";
return -1;
}
QString filePath(argv[1]);
QFileInfo input(filePath);
QString previewFilePath(input.baseName() + QString(".preview.png"));
QFileInfo previewOutput(previewFilePath);
QString halfFilePath(input.baseName() + QString(".half.png"));
QFileInfo halfOutput(halfFilePath);
QString fullFilePath(input.baseName() + QString(".full.png"));
QFileInfo fullOutput(fullFilePath);
QImage image;
DcrawInfoContainer identify;
// -----------------------------------------------------------
qDebug() << "raw2png: Identify RAW image from " << input.fileName();
KDcraw rawProcessor;
if (!rawProcessor.rawFileIdentify(identify, filePath))
{
qDebug() << "raw2png: Idendify RAW image failed. Aborted...";
return -1;
}
int width = identify.imageSize.width();
int height = identify.imageSize.height();
qDebug() << "raw2png: Raw image info:";
qDebug() << "--- Date: " << identify.dateTime.toString(Qt::ISODate);
qDebug() << "--- Make: " << identify.make;
qDebug() << "--- Model: " << identify.model;
qDebug() << "--- Size: " << width << "x" << height;
qDebug() << "--- Filter: " << identify.filterPattern;
qDebug() << "--- Colors: " << identify.rawColors;
// -----------------------------------------------------------
qDebug() << "raw2png: Loading RAW image preview";
if (!rawProcessor.loadRawPreview(image, filePath))
{
qDebug() << "raw2png: Loading RAW image preview failed. Aborted...";
return -1;
}
qDebug() << "raw2png: Saving preview image to "
<< previewOutput.fileName() << " size ("
<< image.width() << "x" << image.height()
<< ")";
image.save(previewFilePath, "PNG");
// -----------------------------------------------------------
qDebug() << "raw2png: Loading half RAW image";
image = QImage();
if (!rawProcessor.loadHalfPreview(image, filePath))
{
qDebug() << "raw2png: Loading half RAW image failed. Aborted...";
return -1;
}
qDebug() << "raw2png: Saving half image to "
<< halfOutput.fileName() << " size ("
<< image.width() << "x" << image.height()
<< ")";
image.save(halfFilePath, "PNG");
// -----------------------------------------------------------
qDebug() << "raw2png: Loading full RAW image";
image = QImage();
RawDecodingSettings settings;
settings.halfSizeColorImage = false;
settings.sixteenBitsImage = false;
settings.RGBInterpolate4Colors = false;
settings.RAWQuality = RawDecodingSettings::BILINEAR;
if (!rawProcessor.loadFullImage(image, filePath, settings))
{
qDebug() << "raw2png: Loading full RAW image failed. Aborted...";
return -1;
}
qDebug() << "raw2png: Saving full RAW image to "
<< fullOutput.fileName() << " size ("
<< image.width() << "x" << image.height()
<< ")";
image.save(fullFilePath, "PNG");
return 0;
}

2
libkexiv2/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.kate-swp
tests/databases/*/*.db

11
libkexiv2/AUTHORS Normal file
View file

@ -0,0 +1,11 @@
AUTHORS AND MAINTAINERS:
Caulier Gilles <caulier dot gilles at gmail dot com>
Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
CONTRIBUTORS:
Angelo Naselli <anaselli at linux dot it>
Gerhard Kulzer <gerhard at kulzer dot net>
Achim Bohnet <ach at mpe dot mpg dot de>
Guillaume Castagnino <guilc at fr dot st>

69
libkexiv2/CMakeLists.txt Normal file
View file

@ -0,0 +1,69 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-09-15
# @brief Exiv2 library interface for KDE
#
# @author Copyright (C) 2006-2014 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
PROJECT(libkexiv2)
MESSAGE(STATUS "----------------------------------------------------------------------------------")
MESSAGE(STATUS "Starting CMake configuration for: libkexiv2")
FIND_PACKAGE(KDE4 REQUIRED 4.14.3)
INCLUDE(KDE4Defaults)
INCLUDE(MacroLibrary)
INCLUDE(MacroOptionalAddSubdirectory)
INCLUDE(MacroOptionalFindPackage)
INCLUDE(FindPackageHandleStandardArgs)
ADD_DEFINITIONS (${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
INCLUDE_DIRECTORIES (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
SET(LIBKEXIV2_AREA_CODE_GENERAL 51003)
ADD_DEFINITIONS(-DKDE_DEFAULT_DEBUG_AREA=${LIBKEXIV2_AREA_CODE_GENERAL})
SET(EXIV2_MIN_VERSION "0.21")
FIND_PACKAGE(Exiv2)
MACRO_LOG_FEATURE(EXIV2_FOUND "Exiv2" "Required to build libkexiv2." "http://www.exiv2.org"
TRUE ${EXIV2_MIN_VERSION} "")
# =======================================================
# Set env. variables accordinly.
SET(KEXIV2_LIB_VERSION_STRING "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_RELEASE}")
SET(KEXIV2_LIB_VERSION_ID "0x0${KDE_VERSION_MAJOR}0${KDE_VERSION_MINOR}0${KDE_VERSION_RELEASE}")
SET(KEXIV2_LIB_SO_VERSION_STRING "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_RELEASE}")
# =======================================================
IF (EXIV2_FOUND)
ADD_SUBDIRECTORY(libkexiv2)
IF(KDE4_BUILD_TESTS)
MACRO_OPTIONAL_ADD_SUBDIRECTORY(tests)
ENDIF(KDE4_BUILD_TESTS)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libkexiv2.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkexiv2.pc)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libkexiv2.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
ENDIF (EXIV2_FOUND)
MACRO_DISPLAY_FEATURE_LOG()

340
libkexiv2/COPYING Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. 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.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE 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.
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
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This 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 Library General
Public License instead of this License.

View file

@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

481
libkexiv2/COPYING.LIB Normal file
View file

@ -0,0 +1,481 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library 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 Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

602
libkexiv2/ChangeLog Normal file
View file

@ -0,0 +1,602 @@
V 0.1.5 - 2007-05-08
----------------------------------------------------------------------------
Fixing: libtools version info again, we found not to be back compatible
with libkexiv 0.1.1, unfortunately since 0.1.2 version.
----------------------------------------------------------------------------
V 0.1.4 - 2007-05-06
----------------------------------------------------------------------------
Fixing: libtools version info
2007-05-06 21:23 anaselli
* [r661885] libkexiv2/ChangeLog, libkexiv2/Makefile.am,
libkexiv2/libkexiv2.lsm, libkexiv2/libkexiv2.pc.in,
libkexiv2/version.h:
Release 0.1.4
- fix libtools version-info
CCMAIL: kde-imaging@kde.org, digikam-devel@kde.org
2007-05-06 21:14 anaselli
* [r661883] libkexiv2/Makefile.am:
Changed to add libtools version managing into prepare script
(hope this will avoid to forget it)
----------------------------------------------------------------------------
v 0.1.3 - 2007-05-05
----------------------------------------------------------------------------
2007-05-05 14:01 gkulzer
* [r661413] libkexiv2/ChangeLog:
0.1.3 release, coordinated with digiKam 0.9.2-beta1 release
2007-05-05 12:09 gkulzer
* [r661379] libkexiv2/ChangeLog, libkexiv2/NEWS,
libkexiv2/libkexiv2.lsm:
0.1.3 release, coordinated with digiKam 0.9.2-beta1 release
2007-05-02 07:11 cgilles
* [r660285] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h,
libkexiv2/libkexiv2_export.h, libkexiv2/version.h:
fix headers
2007-05-02 06:42 cgilles
* [r660276] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
libkexiv2 from trunk : test if file is readable before to load it
in Exiv2.
CCBUGS: 144895
* [r658899] BUG:144455
thanks a lot to Stéphane Pontier, corrected a lot of spelling errors
and missing mails
M /trunk/extragear/libs/libkexiv2/libkexiv2_export.h
M /trunk/extragear/libs/libkexiv2/kexiv2.cpp
M /trunk/extragear/libs/libkexiv2/version.h
M /trunk/extragear/libs/libkexiv2/kexiv2.h
* [r658847] GPS problem solved. BUG:144604
M /trunk/extragear/libs/libkexiv2/kexiv2.cpp
Gilles patch
* [r658711]M /trunk/extragear/libs/libkexiv2/libkexiv2.pc.in
M /trunk/extragear/libs/libkexiv2/kexiv2.cpp
M /trunk/extragear/libs/libkexiv2/libkexiv2.lsm
M /trunk/extragear/libs/libkexiv2/version.h
M /trunk/extragear/libs/libkexiv2/NEWS
M /trunk/extragear/libs/libkexiv2/README
M /trunk/extragear/libs/libkexiv2/kexiv2.h
V 0.1.2 - 2007-04-07
----------------------------------------------------------------------------
2007-03-26 07:54 cgilles
* [r646581] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
libkexiv2 from trunk : polish API : all "get...()" method must
use const operator.
2007-03-15 11:10 anaselli
* [r642771] libkexiv2/Makefile.am, libkexiv2/NEWS:
API changed, please check if it is correct.
CCMAIL: caulier.gilles@kdemail.net
2007-03-15 09:09 cgilles
* [r642722] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
libkexiv2 from trunk : Fix broken compilation with current Exiv2
implementation (next 0.14.0 release), duing a change with C++
Exception rule. I recommend to cleanup and recompile this library
and clients program witch use it.
Note : libkexiv2 still compatible with older Exiv2 releases 0.12
and 0.13
CCMAIL: digikam-devel@kde.org
2007-03-14 12:12 cgilles
* [r642432] libkexiv2/NEWS:
--Cette ligupdatene, et les suivantes ci-dessous, seront
ignorées--
M NEWS
2007-03-14 12:11 cgilles
* [r642431] libkexiv2/kexiv2.cpp:
libkexiv2 from trunk : patch from Arnd Baecker about to avoid the
GPS accuracy loss
BUG: 140297
2007-03-14 12:05 cgilles
* [r642427] libkexiv2/kexiv2.cpp:
sanity check again about empty byte array
2007-03-14 11:58 cgilles
* [r642421] libkexiv2/libkexiv2.lsm:
fix version
2007-03-14 11:58 cgilles
* [r642420] libkexiv2/libkexiv2.pc.in:
fix version
2007-03-14 11:57 cgilles
* [r642419] libkexiv2/version.h:
fix version
2007-03-11 10:58 cgilles
* [r641445] libkexiv2/kexiv2.cpp:
libkexiv2 from trunk : when Exiv2 0.14.0 will be available, a new
tag Exif.Image.ProcessingSoftware will be use to store program
informations
2007-03-11 10:31 cgilles
* [r641437] libkexiv2/NEWS:
update
2007-03-11 10:30 cgilles
* [r641436] libkexiv2/kexiv2.cpp:
fix comment
2007-03-11 10:29 cgilles
* [r641435] libkexiv2/kexiv2.cpp:
libkexiv2 from trunk : set the Exif.Image.Software tag only if it
doesn't exist.
BUG: 142564
2007-02-28 22:19 ach
* [r638128] libkexiv2:
libkexiv2: ignore Makefile.in
2007-02-28 22:14 ach
* [r638127] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h,
libkexiv2/libkexiv2_export.h, libkexiv2/version.h:
libkexiv2: remove unnecessary line break in license notice
2007-02-28 22:13 ach
* [r638126] libkexiv2/AUTHORS:
libkexiv2: add final newline to AUTHORS
----------------------------------------------------------------------------
V 0.1.1 - 2007-02-24
----------------------------------------------------------------------------
2007-02-24 20:53 anaselli
* [r636958] libkexiv2/ChangeLog, libkexiv2/Makefile.am,
libkexiv2/NEWS, libkexiv2/libkexiv2.lsm,
libkexiv2/libkexiv2.pc.in, libkexiv2/version.h:
libkexiv2 0.1.1
bug fixing release
CCMAIL:kde-imaging@kde.org
2007-02-22 12:01 cgilles
* [r636211] kipi-plugins/kipiplugins.kdevelop,
kipi-plugins/rawconverter/batchdialog.cpp,
kipi-plugins/rawconverter/singledialog.cpp,
libkdcraw/dcraw/dcraw.c, libkdcraw/dcraw/kdcraw.1,
libkdcraw/dcrawbinary.cpp, libkdcraw/dcrawsettingswidget.cpp,
libkdcraw/dcrawsettingswidget.h, libkdcraw/kdcraw.cpp,
libkdcraw/libkdcraw.kdevelop, libkdcraw/rawdecodingsettings.h,
libkexiv2/libkexiv2.kdevelop:
libkdcraw from trunk : backport last dcraw implementation "8.60"
: the old noise reduction algorithm used with 8.54 version have
been remplaced by a wavelet algorithm witch is more intuitive,
more easy to use (just one threshold setting) and very powerfull.
Kipi-plugins RAWConverter from svn trunk is fixed.
The patch to use libkdcraw with current implementation of digiKam
have been updated :
http://digikam3rdparty.free.fr/misc.tarballs/libkdcrawdigikamport.patch
CCMAIL: digikam-users@kde.org
CCMAIL: digikam-devel@kde.org
CCMAIL: kde-imaging@kde.org
2007-02-20 17:22 cgilles
* [r635684] libkexiv2/kexiv2.cpp:
libkexiv2 from trunk : sanity check if QByteArray are null size
everywhere
Feedback welcome...
CCBUGS:141980
2007-02-16 22:01 cgilles
* [r634334] kipi-plugins/rawconverter/actionthread.cpp,
kipi-plugins/rawconverter/rawdecodingiface.cpp,
libkdcraw/kdcraw.cpp, libkexiv2/kexiv2.cpp:
fix comments
2007-02-16 15:44 cgilles
* [r634186] libkexiv2/libkexiv2.kdevelop:
kdevelop project
2007-02-16 15:44 cgilles
* [r634184] libkexiv2/AUTHORS, libkexiv2/kexiv2.cpp,
libkexiv2/kexiv2.h, libkexiv2/libkexiv2.lsm:
fix email
2007-02-15 13:15 cgilles
* [r633835] libkexiv2/kexiv2.cpp:
indent
2007-02-13 22:41 ach
* [r633377] libkexiv2/README:
fix library name in README
2007-02-12 15:26 cgilles
* [r632868] libkexiv2/configure.in.in:
this condition is unused everywhere. removed
2007-02-12 09:24 cgilles
* [r632763] libkexiv2/configure.in.in:
revert
2007-02-12 08:32 cgilles
* [r632755] libkexiv2/configure.in.in:
polish
----------------------------------------------------------------------------
V 0.1.0 - 2007-02-11
----------------------------------------------------------------------------
2007-02-11 20:44 anaselli
* [r632646] libkexiv2/ChangeLog, libkexiv2/libkexiv2.lsm,
libkexiv2/libkexiv2.pc.in:
libkexiv2 0.1.0
CCMAIL:kde-imaging@kde.org
2007-02-09 06:50 cgilles
* [r631791] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
libkexiv2 from trunk : new method to extract Exiv2 library
release numbers
2007-02-06 22:12 cgilles
* [r630973] libkexiv2/version.h:
compile
2007-02-06 22:04 cgilles
* [r630967] libkexiv2/Makefile.am, libkexiv2/version.h:
libkexiv2 from trunk : add version header file for this library
CCMAIL: Achim Bohnet <ach@mpe.mpg.de>
2007-02-06 21:39 cgilles
* [r630957] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
2 new methods to set IPTC or Exif tag using a bytes array
2007-02-05 20:16 cgilles
* [r630585] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
factorize source code
2007-02-05 14:38 cgilles
* [r630488] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
add boolean flag to add or not program name when a tag is
changed/added
2007-02-05 14:00 cgilles
* [r630471] libkexiv2/kexiv2.h:
set load() like virtual method. Re-implemented in digiKam core
2007-01-30 12:18 cgilles
* [r628573] libkexiv2/README:
update
2007-01-30 12:16 cgilles
* [r628572] libkexiv2/README:
update
2007-01-30 12:12 cgilles
* [r628569] libkexiv2/README:
update
2007-01-30 11:57 cgilles
* [r628566] libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h:
libkexiv2 from trunk : polish implementation. Fix API doc
2007-01-30 11:18 cgilles
* [r628554] libkexiv2/kexiv2.h:
libkexiv2 from trunk : Finamize API doc.
2007-01-30 10:23 cgilles
* [r628541] libkexiv2/kexiv2_export.h:
wrong file name
2007-01-30 10:22 cgilles
* [r628540] kipi-plugins/galleryexport/gallerytalker.cpp,
kipi-plugins/gpssync/gpslistviewitem.cpp,
kipi-plugins/gpssync/plugin_gpssync.cpp,
kipi-plugins/jpeglossless/jpegtransform.h,
kipi-plugins/metadataedit/exifadjust.cpp,
kipi-plugins/metadataedit/exifcaption.cpp,
kipi-plugins/metadataedit/exifdatetime.cpp,
kipi-plugins/metadataedit/exifdevice.cpp,
kipi-plugins/metadataedit/exifeditdialog.cpp,
kipi-plugins/metadataedit/exiflens.cpp,
kipi-plugins/metadataedit/exiflight.cpp,
kipi-plugins/metadataedit/iptccaption.cpp,
kipi-plugins/metadataedit/iptccategories.cpp,
kipi-plugins/metadataedit/iptccredits.cpp,
kipi-plugins/metadataedit/iptcdatetime.cpp,
kipi-plugins/metadataedit/iptceditdialog.cpp,
kipi-plugins/metadataedit/iptckeywords.cpp,
kipi-plugins/metadataedit/iptcorigin.cpp,
kipi-plugins/metadataedit/iptcstatus.cpp,
kipi-plugins/metadataedit/iptcsubjects.cpp,
kipi-plugins/metadataedit/plugin_metadataedit.cpp,
kipi-plugins/rawconverter/dcrawiface.cpp,
kipi-plugins/sendimages/sendimages.cpp,
kipi-plugins/timeadjust/timeadjustdialog.cpp,
libkexiv2/Makefile.am, libkexiv2/kexiv2.cpp, libkexiv2/kexiv2.h,
libkexiv2/kexiv2_export.h, libkexiv2/libkexiv2.cpp,
libkexiv2/libkexiv2.h:
kipi-plugins from trunk : fix libkexiv2 header file name
2007-01-30 09:45 cgilles
* [r628536] kipi-plugins/galleryexport/gallerytalker.cpp,
kipi-plugins/gpssync/gpslistviewitem.cpp,
kipi-plugins/gpssync/plugin_gpssync.cpp,
kipi-plugins/jpeglossless/jpegtransform.cpp,
kipi-plugins/jpeglossless/jpegtransform.h,
kipi-plugins/metadataedit/exifadjust.cpp,
kipi-plugins/metadataedit/exifcaption.cpp,
kipi-plugins/metadataedit/exifdatetime.cpp,
kipi-plugins/metadataedit/exifdevice.cpp,
kipi-plugins/metadataedit/exifeditdialog.cpp,
kipi-plugins/metadataedit/exiflens.cpp,
kipi-plugins/metadataedit/exiflight.cpp,
kipi-plugins/metadataedit/iptccaption.cpp,
kipi-plugins/metadataedit/iptccategories.cpp,
kipi-plugins/metadataedit/iptccredits.cpp,
kipi-plugins/metadataedit/iptcdatetime.cpp,
kipi-plugins/metadataedit/iptceditdialog.cpp,
kipi-plugins/metadataedit/iptckeywords.cpp,
kipi-plugins/metadataedit/iptcorigin.cpp,
kipi-plugins/metadataedit/iptcstatus.cpp,
kipi-plugins/metadataedit/iptcsubjects.cpp,
kipi-plugins/metadataedit/plugin_metadataedit.cpp,
kipi-plugins/rawconverter/dcrawiface.cpp,
kipi-plugins/sendimages/sendimages.cpp,
kipi-plugins/timeadjust/timeadjustdialog.cpp,
libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2.h:
kipi-plugins from trunk : fix libkexiv2 namespace and interface
class name
2007-01-30 09:02 cgilles
* [r628532] libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2.h:
libkexiv2 from trunk : backport new method to handle color
work-space of image. update API doc.
2007-01-29 23:36 ach
* [r628396] libkexiv2/libkexiv2.h:
libkexiv2: s/informations/information/
2007-01-29 21:19 lure
* [r628356] libkexiv2/libkexiv2.h:
Fix broken comment - did not compile on Kubuntu Feisty
2007-01-29 19:57 cgilles
* [r628333] libkexiv2/libkexiv2.h:
libkexiv2 from trunk : Doxygen API (uncomplete)
2007-01-29 16:49 cgilles
* [r628263] libkexiv2/libkexiv2.pc.in:
update
2007-01-29 14:18 cgilles
* [r628206] libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2.h:
libkexiv2 from trunk : backport all common methods from
Digikam::DMetadata class. Backport all fix about comments
encoding from Marcel. The implementation is clean now and ready
to use with digiKam core.
CCMAIL : marcel.wiesweg@gmx.de, digikam-devel@kde.org,
kde-imaging@kde.org
2007-01-29 09:50 cgilles
* [r628140] libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2.h:
new protected methods to use with derivated class
2007-01-28 10:32 ach
* [r627809] libkexiv2/libkexiv2.lsm, libkexiv2/libkexiv2.pc.in,
prepare_libkexiv2.rb:
libkexiv2: use same version everywhere
2007-01-28 09:54 ach
* [r627801] libkexiv2/libkexiv2.pc.in:
libkexiv2: fix libkexiv2.pc pkg-config file
2007-01-28 09:47 ach
* [r627799] libkexiv2/configure.in.in:
libkexiv2: Fix configure. PKGCONFIGFOUND was not set.
CCMAIL: kde-imaging@kde.org
2007-01-27 12:40 cgilles
* [r627622] libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2_export.h:
kipi-plugins from trunk : libkexiv2 : do not use kdDebug() here
because it's not thread-safe. Use qDebug() instead...
CCBUGS: 133026
2007-01-27 10:57 cgilles
* [r627593] libkexiv2/README:
update
2007-01-26 20:59 cgilles
* [r627509] libkexiv2/libkexiv2.lsm:
update
2007-01-26 20:40 cgilles
* [r627501] kipi-plugins/NEWS, kipi-plugins/README,
kipi-plugins/common/Makefile.am, kipi-plugins/common/exiv2iface,
kipi-plugins/configure.in.bot, kipi-plugins/configure.in.in,
kipi-plugins/galleryexport/Makefile.am,
kipi-plugins/galleryexport/gallerytalker.cpp,
kipi-plugins/gpssync/Makefile.am,
kipi-plugins/gpssync/gpslistviewitem.cpp,
kipi-plugins/gpssync/gpslistviewitem.h,
kipi-plugins/gpssync/plugin_gpssync.cpp,
kipi-plugins/gpssync/plugin_gpssync.h,
kipi-plugins/jpeglossless/Makefile.am,
kipi-plugins/jpeglossless/jpegtransform.cpp,
kipi-plugins/jpeglossless/jpegtransform.h,
kipi-plugins/metadataedit/Makefile.am,
kipi-plugins/metadataedit/exifadjust.cpp,
kipi-plugins/metadataedit/exifcaption.cpp,
kipi-plugins/metadataedit/exifdatetime.cpp,
kipi-plugins/metadataedit/exifdevice.cpp,
kipi-plugins/metadataedit/exifeditdialog.cpp,
kipi-plugins/metadataedit/exiflens.cpp,
kipi-plugins/metadataedit/exiflight.cpp,
kipi-plugins/metadataedit/iptccaption.cpp,
kipi-plugins/metadataedit/iptccategories.cpp,
kipi-plugins/metadataedit/iptccredits.cpp,
kipi-plugins/metadataedit/iptcdatetime.cpp,
kipi-plugins/metadataedit/iptceditdialog.cpp,
kipi-plugins/metadataedit/iptckeywords.cpp,
kipi-plugins/metadataedit/iptcorigin.cpp,
kipi-plugins/metadataedit/iptcstatus.cpp,
kipi-plugins/metadataedit/iptcsubjects.cpp,
kipi-plugins/metadataedit/plugin_metadataedit.cpp,
kipi-plugins/rawconverter/Makefile.am,
kipi-plugins/rawconverter/dcrawiface.cpp,
kipi-plugins/rawconverter/dcrawiface.h,
kipi-plugins/sendimages/Makefile.am,
kipi-plugins/sendimages/sendimages.cpp,
kipi-plugins/sendimages/sendimages.h,
kipi-plugins/sync/Makefile.am,
kipi-plugins/sync/gallerytalker.cpp,
kipi-plugins/timeadjust/Makefile.am,
kipi-plugins/timeadjust/timeadjustdialog.cpp,
kipi-plugins/timeadjust/timeadjustdialog.h,
libkexiv2/libkexiv2.cpp, libkexiv2/libkexiv2.h:
kipi-plugins from trunk : all plugins use the new shared library
libkexiv2 instead KipiPlugins::EXiv2Iface class.
Marcel, next stage is to derivate the DigiKam::DMetadata class
from LibKExiv2. Let's me hear when you whant to do it...
CCMAIL: digikam-devel@kde.org, kde-imaging@kde.org,
marcel.wiesweg@gmx.de
2007-01-26 15:51 cgilles
* [r627439] libkexiv2/configure.in.bot, libkexiv2/configure.in.in:
compile
2007-01-26 15:38 cgilles
* [r627433] libkexiv2/libkexiv2.h:
using Export rules
2007-01-26 13:14 cgilles
* [r627401] libkexiv2/README:
update
2007-01-26 13:10 cgilles
* [r627400] libkexiv2/README:
update
2007-01-26 13:09 cgilles
* [r627399] libkexiv2/Makefile.am, libkexiv2/exiv2iface.cpp,
libkexiv2/exiv2iface.h, libkexiv2/libkexiv2.cpp,
libkexiv2/libkexiv2.h:
exiv2iface ==> libkexiv2
new namespace
2007-01-26 12:58 cgilles
* [r627393] libkexiv2/exiv2iface.cpp, libkexiv2/exiv2iface.h,
libkexiv2/libkexiv2_export.h:
fix header
2007-01-26 12:55 cgilles
* [r627390] libkexiv2, libkexiv2/AUTHORS, libkexiv2/COPYING,
libkexiv2/ChangeLog, libkexiv2/INSTALL, libkexiv2/Makefile.am,
libkexiv2/NEWS, libkexiv2/README, libkexiv2/configure.in.in,
libkexiv2/exiv2iface.cpp, libkexiv2/exiv2iface.h,
libkexiv2/libkexiv2.lsm, libkexiv2/libkexiv2.pc.in,
libkexiv2/libkexiv2_export.h:
New common library witch will be used by digiKam and kipi-plugins
to handle Pictures metadata (Exif/Iptc).
This shared library is a wrapper around Exiv2 library. It give a
Qt like interface to control
Exiv2 actions on pictures. Using this library will remove all
duplicate code on kipi-plugins::exiv2iface and
digikam::dmetadata.
The current implementation is the same than
kipi-plugins/exiv2iface. This library is not yet used in
digiKam/kipi-plugins.
We will added a new depency to this library in kipi-plugins in
first and later to digiKam.
CCMAIL: digikam-devel@kde.org, kde-imaging@kde.org,
marcel.wiesweg@gmx.de

2
libkexiv2/Messages.sh Executable file
View file

@ -0,0 +1,2 @@
#! /bin/sh
$XGETTEXT libkexiv2/*.cpp -o $podir/libkexiv2.pot

101
libkexiv2/NEWS Normal file
View file

@ -0,0 +1,101 @@
0.6.0 - Released with KDE 4.4.0
------------------------------------------------------------------------
- New widgets shared between digiKam and kipi-plugins to play with IPTC Subjects and Language Alternative.
0.5.0 - Released with KDE 4.3.0
------------------------------------------------------------------------
- New option to enable/disable file timestamp updating when metadata are saved.
0.4.0 - Released with KDE 4.2.0
------------------------------------------------------------------------
- Use kDebug(51003) instead qDebug()
- New option to enable/disable Raw metadata writting.
0.3.0 - Released with KDE 4.1.2
------------------------------------------------------------------------
- API changed: Added 2 new static methods to init and clear non re-entrant Adobe XMP
SDK code from Exiv2 core. This code must be called before and after
all multithreaded operations with KExiv2.
* initializeExiv2().
* cleanupExiv2().
Added a new method to load image data from a byte array.
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 166424: Crash when editing Caption with Digikam4 SVN.
0.2.0 - Released with KDE 4.1.0
------------------------------------------------------------------------
Port to CMake/KDE4/QT4
Support of XMP metadata (require Exiv2 0.16)
Split methods to separate files to provide a more readable implementation.
New method to fix orientation of a QImage accordingly with Exif orientation tag.
Moved from extragear/libs to kdegraphics/libs
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 146864: Lesser XMP support in digiKam.
0.1.7
------------------------------------------------------------------------
- API changed: Added a version method to get runtime library version.
- Fix RemoveIptcTag() to handle all redondant Iptc tags at the same time.
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 157552: negative altitudes are not shown in metadata GPS sidebar
0.1.6
------------------------------------------------------------------------
- API Changed : Kexiv2 destructor is now virtual.
Krazy Code Checker fix (http://www.englishbreakfastnetwork.org/krazy)
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 137750: color mode2 nikon d70s not recognized as adobe rgb
002 ==> 149267: digiKam crashes after finding gif,avi,txt and so on.
003 ==> 148182: Iptc.Application2.Keywords appends always the 0-byte.
0.1.5
------------------------------------------------------------------------
Fix release version information.
0.1.4
------------------------------------------------------------------------
Fix release version information.
0.1.3
------------------------------------------------------------------------
New features
- API changed: added 4 new static methods to get Exif/Iptc tags description/title.
moved depreceate protected methods used by digiKam core to private.
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 144604: Rotation causes Exif data corruption. GPS data fix
General : Make size of icons used in album icon view more configurable using a slider
in status bar.
General : Removing direct Exiv2 library depency. libkexiv2 interface is used everywhere
instead.
0.1.2
------------------------------------------------------------------------
New features
- added support for exiv2 from svn (next 0.14.0 release)
- API changed: added printExiv2ExceptionError to manage Exiv2 C++ Exception error message
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 142564: digiKam-signature in iptc and exif tags.
002 ==> 140297: GPS kipi plugin truncates input coordinates, introducing inacuracy.
0.1.1
------------------------------------------------------------------------
Bugs fixed from B.K.O (http://bugs.kde.org):
001 ==> 141980: digiKam crash when rescan certain files exiv2.
0.1.0
------------------------------------------------------------------------
First implementation
For details and info about previous versions, see ChangeLog.

75
libkexiv2/README Normal file
View file

@ -0,0 +1,75 @@
EXIV2 Library interface for KDE
This library is a part of digiKam project (http://www.digikam.org)
-- AUTHORS ------------------------------------------------------------
See AUTHORS file for details.
-- ABOUT --------------------------------------------------------------
Libkexiv2 is a wrapper around Exiv2 library to manipulate pictures
metadata as EXIF/IPTC and XMP. Metadata interface follow this paper:
http://www.metadataworkinggroup.com/pdf/mwg_guidance.pdf
This library is used by kipi-plugins, digiKam and others kipi host programs.
The library documentation is available on header files.
-- DEPENDENCIES -------------------------------------------------------
CMake >= 2.8.x http://www.cmake.org
libqt >= 4.6.x http://www.qtsoftware.com
libkde >= 4.4.x http://www.kde.org
libexiv2 >= 0.21.0 http://www.exiv2.org
-- INSTALL ------------------------------------------------------------
In order to compile, especially when QT3/Qt4 are installed at the same time,
just use something like that:
# export VERBOSE=1
# export QTDIR=/usr/lib/qt4/
# export PATH=$QTDIR/bin:$PATH
# cmake .
# make
Usual CMake options:
-DCMAKE_INSTALL_PREFIX : decide where the program will be install on your computer.
-DCMAKE_BUILD_TYPE : decide which type of build you want. You can chose between "debugfull", "debug", "profile", "relwithdebinfo" and "release". The default is "relwithdebinfo" (-O2 -g).
Compared to old KDE3 autoconf options:
"cmake . -DCMAKE_BUILD_TYPE=debugfull" is equivalent to "./configure --enable-debug=full"
"cmake . -DCMAKE_INSTALL_PREFIX=/usr" is equivalent to "./configure --prefix=/usr"
More details can be found ata this url: http://techbase.kde.org/Development/Tutorials/CMake#Environment_Variables
Note: To know KDE install path on your computer, use 'kde-config --prefix' command line like this (with full debug object enabled):
"cmake . -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`"
-- CONTACT ------------------------------------------------------------
If you have questions, comments, suggestions to make do email at:
kde-imaging@kde.org
IRC channel from freenode.net server:
#kde-imaging
-- BUGS ---------------------------------------------------------------
IMPORTANT : the bugreports and wishlist are hosted by the KDE bugs report
system who can be contacted by the standard Kde help menu of plugins dialog.
A mail will be automatically sent to the Kipi mailing list.
There is no need to contact directly the Kipi mailing list for a bug report
or a devel wish.
The current Kipi bugs and devel wish reported to the Kde bugs report can be see
at this url:
http://bugs.kde.org/buglist.cgi?product=digikam&component=libkexiv2&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED

3
libkexiv2/TODO Normal file
View file

@ -0,0 +1,3 @@
- Extract GPS info from XMP tags.
- Exif/Iptc => Xmp synchronization.
- Xmp side-car file support.

View file

@ -0,0 +1,12 @@
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=${BIN_INSTALL_DIR}
libdir=${LIB_INSTALL_DIR}
includedir=${INCLUDE_INSTALL_DIR}
Name: libkexiv2
Description: A C++ library to manipulate EXIF/IPTC/XMP metadata using Exiv2 library. This library is used by digiKam and kipi-plugins.
URL: http://www.digikam.org
Requires:
Version: ${KEXIV2_LIB_VERSION_STRING}
Libs: -L${LIB_INSTALL_DIR} -lkexiv2
Cflags: -I${INCLUDE_INSTALL_DIR}

View file

@ -0,0 +1,72 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-09-15
# @brief Exiv2 library interface for KDE
#
# @author Copyright (C) 2006-2014 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
INCLUDE_DIRECTORIES(${EXIV2_INCLUDE_DIR})
ADD_DEFINITIONS(${EXIV2_DEFINITIONS})
ADD_DEFINITIONS(${KDE4_ENABLE_EXCEPTIONS})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h)
# This was used to enable catching of exceptions thrown by libexiv2.
# We use now #pragma GCC visibility push(default) around the headers
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
SET(kexiv2_LIB_SRCS kexiv2.cpp
kexiv2_p.cpp
kexiv2image.cpp
kexiv2comments.cpp
kexiv2exif.cpp
kexiv2iptc.cpp
kexiv2gps.cpp
kexiv2xmp.cpp
kexiv2previews.cpp
altlangstredit.cpp
msgtextedit.cpp
countryselector.cpp
subjectwidget.cpp
rotationmatrix.cpp
)
KDE4_ADD_LIBRARY(kexiv2 SHARED ${kexiv2_LIB_SRCS})
TARGET_LINK_LIBRARIES(kexiv2 ${KDE4_KDEUI_LIBS} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY} ${EXIV2_LIBRARIES})
SET_TARGET_PROPERTIES(kexiv2 PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION})
INSTALL(FILES topicset.iptc-subjectcode.xml DESTINATION ${DATA_INSTALL_DIR}/libkexiv2/data)
INSTALL(FILES kexiv2.h
kexiv2data.h
kexiv2previews.h
libkexiv2_export.h
msgtextedit.h
subjectwidget.h
altlangstredit.h
countryselector.h
rotationmatrix.h
${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION ${INCLUDE_INSTALL_DIR}/libkexiv2
COMPONENT Devel
)

1067
libkexiv2/libkexiv2/Doxyfile Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,14 @@
/** @mainpage libKExiv2
libKExiv2 is a wrapper around <a href="http://exiv2.org/">exiv2</a>, providing read/write access to EXIF, IPTC and XMP metadata. The main differences to <a href="http://exiv2.org/">exiv2</a> are:
<ul>
<li> Functions take standard Qt containers as parameters
<li> Helper functions for GPS data
<li> Transparent XMP sidecar support
</ul>
To get started, have a look at the KExiv2Iface::KExiv2 class.
@see KExiv2Iface::KExiv2
*/

View file

@ -0,0 +1,537 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-06-15
* @brief multi-languages string editor
*
* @author Copyright (C) 2009-2013 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_altlangstredit.cpp"
// Qt includes
#include <QEvent>
#include <QStyle>
#include <QLabel>
#include <QMap>
#include <QToolButton>
#include <QGridLayout>
// KDE includes
#include <kdialog.h>
#include <kglobal.h>
#include <kiconloader.h>
#include <klocale.h>
#include <ktextedit.h>
#include <kcombobox.h>
#include <kdebug.h>
// Local includes
#include "msgtextedit.h"
namespace KExiv2Iface
{
class AltLangStrEdit::Private
{
public:
Private()
{
valueEdit = 0;
titleLabel = 0;
delValueButton = 0;
languageCB = 0;
linesVisible = 0;
currentLanguage = "x-default";
// We cannot use KLocale::allLanguagesList() here because KDE only
// support 2 characters country codes. XMP require 2+2 characters language+country
// following ISO 3066 (http://babelwiki.babelzilla.org/index.php?title=Language_codes)
// The first one from the list is the Default Language code specified by XMP paper
languageCodeMap.insert( "x-default", i18n("Default Language") );
// Standard ISO 3066 country codes.
languageCodeMap.insert( "af-ZA", i18n("Afrikaans (South Africa)") );
languageCodeMap.insert( "am-ET", i18n("Amharic (Ethiopia)") );
languageCodeMap.insert( "ar-AE", i18n("Arabic (UAE)") );
languageCodeMap.insert( "ar-BH", i18n("Arabic (Bahrain)") );
languageCodeMap.insert( "ar-DZ", i18n("Arabic (Algeria)") );
languageCodeMap.insert( "ar-EG", i18n("Arabic (Egypt)") );
languageCodeMap.insert( "ar-IQ", i18n("Arabic (Iraq)") );
languageCodeMap.insert( "ar-JO", i18n("Arabic (Jordan)") );
languageCodeMap.insert( "ar-KW", i18n("Arabic (Kuwait)") );
languageCodeMap.insert( "ar-LB", i18n("Arabic (Lebanon)") );
languageCodeMap.insert( "ar-LY", i18n("Arabic (Libya)") );
languageCodeMap.insert( "ar-MA", i18n("Arabic (Morocco)") );
languageCodeMap.insert( "ar-OM", i18n("Arabic (Oman)") );
languageCodeMap.insert( "ar-QA", i18n("Arabic (Qatar)") );
languageCodeMap.insert( "ar-SA", i18n("Arabic (Saudi Arabia)") );
languageCodeMap.insert( "ar-SY", i18n("Arabic (Syria)") );
languageCodeMap.insert( "ar-TN", i18n("Arabic (Tunisia)") );
languageCodeMap.insert( "ar-YE", i18n("Arabic (Yemen)") );
languageCodeMap.insert( "as-IN", i18n("Assamese (India)") );
languageCodeMap.insert( "ba-RU", i18n("Bashkir (Russia)") );
languageCodeMap.insert( "be-BY", i18n("Belarusian (Belarus)") );
languageCodeMap.insert( "bg-BG", i18n("Bulgarian (Bulgaria)") );
languageCodeMap.insert( "bn-IN", i18n("Bengali (India)") );
languageCodeMap.insert( "bo-BT", i18n("Tibetan (Bhutan)") );
languageCodeMap.insert( "bo-CN", i18n("Tibetan (PRC)") );
languageCodeMap.insert( "br-FR", i18n("Breton (France)") );
languageCodeMap.insert( "ca-AD", i18n("Catalan (Andorra)") );
languageCodeMap.insert( "ca-ES", i18n("Catalan (Spain)") );
languageCodeMap.insert( "ca-FR", i18n("Catalan (France)") );
languageCodeMap.insert( "co-FR", i18n("Corsican (France)") );
languageCodeMap.insert( "cs-CZ", i18n("Czech (Czech Republic)") );
languageCodeMap.insert( "cy-GB", i18n("Welsh (United Kingdom)") );
languageCodeMap.insert( "da-DK", i18n("Danish (Denmark)") );
languageCodeMap.insert( "de-AT", i18n("German (Austria)") );
languageCodeMap.insert( "de-CH", i18n("German (Switzerland)") );
languageCodeMap.insert( "de-DE", i18n("German (Germany)") );
languageCodeMap.insert( "de-LI", i18n("German (Liechtenstein)") );
languageCodeMap.insert( "de-LU", i18n("German (Luxembourg)") );
languageCodeMap.insert( "el-GR", i18n("Greek (Greece)") );
languageCodeMap.insert( "en-AU", i18n("English (Australia)") );
languageCodeMap.insert( "en-BZ", i18n("English (Belize)") );
languageCodeMap.insert( "en-CA", i18n("English (Canada)") );
languageCodeMap.insert( "en-CB", i18n("English (Caribbean)") );
languageCodeMap.insert( "en-GB", i18n("English (United Kingdom)") );
languageCodeMap.insert( "en-IE", i18n("English (Ireland)") );
languageCodeMap.insert( "en-IN", i18n("English (India)") );
languageCodeMap.insert( "en-JA", i18n("English (Jamaica)") );
languageCodeMap.insert( "en-MY", i18n("English (Malaysia)") );
languageCodeMap.insert( "en-NZ", i18n("English (New Zealand)") );
languageCodeMap.insert( "en-PH", i18n("English (Philippines)") );
languageCodeMap.insert( "en-SG", i18n("English (Singapore)") );
languageCodeMap.insert( "en-TT", i18n("English (Trinidad)") );
languageCodeMap.insert( "en-US", i18n("English (United States)") );
languageCodeMap.insert( "en-ZA", i18n("English (South Africa)") );
languageCodeMap.insert( "en-ZW", i18n("English (Zimbabwe)") );
languageCodeMap.insert( "es-AR", i18n("Spanish (Argentina)") );
languageCodeMap.insert( "es-BO", i18n("Spanish (Bolivia)") );
languageCodeMap.insert( "es-CL", i18n("Spanish (Chile)") );
languageCodeMap.insert( "es-CO", i18n("Spanish (Colombia)") );
languageCodeMap.insert( "es-CR", i18n("Spanish (Costa Rica)") );
languageCodeMap.insert( "es-DO", i18n("Spanish (Dominican Republic)") );
languageCodeMap.insert( "es-EC", i18n("Spanish (Ecuador)") );
languageCodeMap.insert( "es-ES", i18n("Spanish (Spain)") );
languageCodeMap.insert( "es-GT", i18n("Spanish (Guatemala)") );
languageCodeMap.insert( "es-HN", i18n("Spanish (Honduras)") );
languageCodeMap.insert( "es-MX", i18n("Spanish (Mexico)") );
languageCodeMap.insert( "es-NI", i18n("Spanish (Nicaragua)") );
languageCodeMap.insert( "es-PA", i18n("Spanish (Panama)") );
languageCodeMap.insert( "es-PE", i18n("Spanish (Peru)") );
languageCodeMap.insert( "es-PR", i18n("Spanish (Puerto Rico)") );
languageCodeMap.insert( "es-PY", i18n("Spanish (Paraguay)") );
languageCodeMap.insert( "es-SV", i18n("Spanish (El Salvador)") );
languageCodeMap.insert( "es-UR", i18n("Spanish (Uruguay)") );
languageCodeMap.insert( "es-US", i18n("Spanish (United States)") );
languageCodeMap.insert( "es-VE", i18n("Spanish (Venezuela)") );
languageCodeMap.insert( "et-EE", i18n("Estonian (Estonia)") );
languageCodeMap.insert( "eu-ES", i18n("Basque (Basque Country)") );
languageCodeMap.insert( "fa-IR", i18n("Persian (Iran)") );
languageCodeMap.insert( "fi-FI", i18n("Finnish (Finland)") );
languageCodeMap.insert( "fo-FO", i18n("Faeroese (Faero Islands)") );
languageCodeMap.insert( "fr-BE", i18n("French (Belgium)") );
languageCodeMap.insert( "fr-CA", i18n("French (Canada)") );
languageCodeMap.insert( "fr-CH", i18n("French (Switzerland)") );
languageCodeMap.insert( "fr-FR", i18n("French (France)") );
languageCodeMap.insert( "fr-LU", i18n("French (Luxembourg)") );
languageCodeMap.insert( "fr-MC", i18n("French (Monaco)") );
languageCodeMap.insert( "fy-NL", i18n("Frisian (Netherlands)") );
languageCodeMap.insert( "ga-IE", i18n("Irish (Ireland)") );
languageCodeMap.insert( "gl-ES", i18n("Galician (Galicia)") );
languageCodeMap.insert( "gu-IN", i18n("Gujarati (India)") );
languageCodeMap.insert( "he-IL", i18n("Hebrew (Israel)") );
languageCodeMap.insert( "hi-IN", i18n("Hindi (India)") );
languageCodeMap.insert( "hr-BA", i18n("Croatian (Bosnia and Herzegovina, Latin)") );
languageCodeMap.insert( "hr-HR", i18n("Croatian (Croatia)") );
languageCodeMap.insert( "hu-HU", i18n("Hungarian (Hungary)") );
languageCodeMap.insert( "hy-AM", i18n("Armenian (Armenia)") );
languageCodeMap.insert( "id-ID", i18n("(Indonesian)") );
languageCodeMap.insert( "ii-CN", i18n("Yi (PRC)") );
languageCodeMap.insert( "is-IS", i18n("Icelandic (Iceland)") );
languageCodeMap.insert( "it-CH", i18n("Italian (Switzerland)") );
languageCodeMap.insert( "it-IT", i18n("Italian (Italy)") );
languageCodeMap.insert( "ja-JP", i18n("Japanese (Japan)") );
languageCodeMap.insert( "ka-GE", i18n("Georgian (Georgia)") );
languageCodeMap.insert( "kk-KZ", i18n("Kazakh (Kazakhstan)") );
languageCodeMap.insert( "kl-GL", i18n("Greenlandic (Greenland)") );
languageCodeMap.insert( "km-KH", i18n("Khmer (Cambodia)") );
languageCodeMap.insert( "kn-IN", i18n("Kannada (India)") );
languageCodeMap.insert( "ko-KR", i18n("Korean (South Korea)") );
languageCodeMap.insert( "ky-KG", i18n("Kyrgyz (Kyrgyzstan)") );
languageCodeMap.insert( "lb-LU", i18n("Luxembourgish (Luxembourg)") );
languageCodeMap.insert( "lo-LA", i18n("Lao (Lao PDR)") );
languageCodeMap.insert( "lt-LT", i18n("Lithuanian (Lithuania)") );
languageCodeMap.insert( "lv-LV", i18n("Latvian (Latvia)") );
languageCodeMap.insert( "mi-NZ", i18n("Maori (New Zealand)") );
languageCodeMap.insert( "mk-MK", i18n("Macedonian (Macedonia)") );
languageCodeMap.insert( "ml-IN", i18n("Malayalam (India)") );
languageCodeMap.insert( "mn-CN", i18n("Mongolian (PRC)") );
languageCodeMap.insert( "mn-MN", i18n("Mongolian (Mongolia)") );
languageCodeMap.insert( "mr-IN", i18n("Marathi (India)") );
languageCodeMap.insert( "ms-BN", i18n("Malay (Brunei Darussalam)") );
languageCodeMap.insert( "ms-MY", i18n("Malay (Malaysia)") );
languageCodeMap.insert( "mt-MT", i18n("Maltese (Malta)") );
languageCodeMap.insert( "nb-NO", i18n("Norwegian Bokmål (Norway)") );
languageCodeMap.insert( "ne-NP", i18n("Nepali (Nepal)") );
languageCodeMap.insert( "nl-BE", i18n("Dutch (Belgium)") );
languageCodeMap.insert( "nl-NL", i18n("Dutch (Netherlands)") );
languageCodeMap.insert( "nn-NO", i18n("Norwegian Nynorsk (Norway)") );
languageCodeMap.insert( "ns-ZA", i18n("Sesotho sa Leboa (South Africa)") );
languageCodeMap.insert( "oc-FR", i18n("Occitan (France)") );
languageCodeMap.insert( "or-IN", i18n("Oriya (India)") );
languageCodeMap.insert( "pa-IN", i18n("Punjabi (India)") );
languageCodeMap.insert( "pl-PL", i18n("Polish (Poland)") );
languageCodeMap.insert( "ps-AF", i18n("Pashto (Afghanistan)") );
languageCodeMap.insert( "pt-BR", i18n("Portuguese (Brazil)") );
languageCodeMap.insert( "pt-PT", i18n("Portuguese (Portugal)") );
languageCodeMap.insert( "rm-CH", i18n("Romansh (Switzerland)") );
languageCodeMap.insert( "ro-RO", i18n("Romanian (Romania)") );
languageCodeMap.insert( "ru-RU", i18n("Russian (Russia)") );
languageCodeMap.insert( "rw-RW", i18n("Kinyarwanda (Rwanda)") );
languageCodeMap.insert( "sa-IN", i18n("Sanskrit (India)") );
languageCodeMap.insert( "se-FI", i18n("Sami (Northern, Finland)") );
languageCodeMap.insert( "se-NO", i18n("Sami (Northern, Norway)") );
languageCodeMap.insert( "se-SE", i18n("Sami (Northern, Sweden)") );
languageCodeMap.insert( "si-LK", i18n("Sinhala (Sri Lanka)") );
languageCodeMap.insert( "sk-SK", i18n("Slovak (Slovakia)") );
languageCodeMap.insert( "sl-SI", i18n("Slovenian (Slovenia)") );
languageCodeMap.insert( "sq-AL", i18n("Albanian (Albania)") );
languageCodeMap.insert( "sv-FI", i18n("Swedish (Finland)") );
languageCodeMap.insert( "sv-SE", i18n("Swedish (Sweden)") );
languageCodeMap.insert( "sw-KE", i18n("Swahili (Kenya)") );
languageCodeMap.insert( "ta-IN", i18n("Tamil (India)") );
languageCodeMap.insert( "te-IN", i18n("Telugu (India)") );
languageCodeMap.insert( "th-TH", i18n("Thai (Thailand)") );
languageCodeMap.insert( "tk-TM", i18n("Turkmen (Turkmenistan)") );
languageCodeMap.insert( "tn-ZA", i18n("Setswana Tswana (South Africa)") );
languageCodeMap.insert( "tr-IN", i18n("Urdu (India)") );
languageCodeMap.insert( "tr-TR", i18n("Turkish (Turkey)") );
languageCodeMap.insert( "tt-RU", i18n("Tatar (Russia)") );
languageCodeMap.insert( "ug-CN", i18n("Uighur (PRC)") );
languageCodeMap.insert( "uk-UA", i18n("Ukrainian (Ukraine)") );
languageCodeMap.insert( "ur-PK", i18n("Urdu (Pakistan)") );
languageCodeMap.insert( "vi-VN", i18n("Vietnamese (Vietnam)") );
languageCodeMap.insert( "wo-SN", i18n("Wolof (Senegal)") );
languageCodeMap.insert( "xh-ZA", i18n("isiXhosa Xhosa (South Africa)") );
languageCodeMap.insert( "yo-NG", i18n("Yoruba (Nigeria)") );
languageCodeMap.insert( "zh-CN", i18n("Chinese (PRC)") );
languageCodeMap.insert( "zh-HK", i18n("Chinese (Hong Kong SAR, PRC)") );
languageCodeMap.insert( "zh-MO", i18n("Chinese (Macao SAR)") );
languageCodeMap.insert( "zh-SG", i18n("Chinese (Singapore)") );
languageCodeMap.insert( "zh-TW", i18n("Chinese (Taiwan)") );
languageCodeMap.insert( "zu-ZA", i18n("isiZulu Zulu (South Africa)") );
}
~Private()
{
languageCodeMap.clear();
}
public:
typedef QMap<QString, QString> LanguageCodeMap;
LanguageCodeMap languageCodeMap;
QString currentLanguage;
uint linesVisible;
QLabel* titleLabel;
QToolButton* delValueButton;
MsgTextEdit* valueEdit;
KComboBox* languageCB;
KExiv2::AltLangMap values;
};
AltLangStrEdit::AltLangStrEdit(QWidget* parent)
: QWidget(parent), d(new Private)
{
QGridLayout* const grid = new QGridLayout(this);
d->titleLabel = new QLabel(this);
d->delValueButton = new QToolButton(this);
d->delValueButton->setIcon(SmallIcon("edit-clear"));
d->delValueButton->setToolTip(i18n("Remove entry for this language"));
d->delValueButton->setEnabled(false);
d->languageCB = new KComboBox(this);
d->languageCB->setSizeAdjustPolicy(KComboBox::AdjustToContents);
d->languageCB->setWhatsThis(i18n("Select item language here."));
d->valueEdit = new MsgTextEdit(this);
d->valueEdit->setCheckSpellingEnabled(true);
// --------------------------------------------------------
grid->setAlignment( Qt::AlignTop );
grid->addWidget(d->titleLabel, 0, 0, 1, 1);
grid->addWidget(d->languageCB, 0, 2, 1, 1);
grid->addWidget(d->delValueButton, 0, 3, 1, 1);
grid->addWidget(d->valueEdit, 1, 0, 1,-1);
grid->setColumnStretch(1, 10);
grid->setMargin(0);
grid->setSpacing(KDialog::spacingHint());
loadLangAltListEntries();
// --------------------------------------------------------
connect(d->languageCB, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotSelectionChanged()));
connect(d->delValueButton, SIGNAL(clicked()),
this, SLOT(slotDeleteValue()));
connect(d->valueEdit, SIGNAL(textChanged()),
this, SLOT(slotTextChanged()));
}
AltLangStrEdit::~AltLangStrEdit()
{
delete d;
}
QString AltLangStrEdit::currentLanguageCode() const
{
return d->currentLanguage;
}
void AltLangStrEdit::setCurrentLanguageCode(const QString& lang)
{
if(d->currentLanguage.isEmpty())
{
d->currentLanguage = "x-default";
}
else
{
d->currentLanguage = lang;
}
}
QString AltLangStrEdit::languageCode(int index) const
{
return d->languageCB->itemText(index);
}
void AltLangStrEdit::setTitle(const QString& title)
{
d->titleLabel->setText(title);
}
void AltLangStrEdit::setClickMessage(const QString& msg)
{
d->valueEdit->setClickMessage(msg);
}
void AltLangStrEdit::reset()
{
setValues(KExiv2::AltLangMap());
}
void AltLangStrEdit::slotDeleteValue()
{
d->values.remove(d->currentLanguage);
setValues(d->values);
emit signalValueDeleted(d->currentLanguage);
}
void AltLangStrEdit::slotSelectionChanged()
{
d->currentLanguage = d->languageCB->currentText();
// There are bogus signals caused by spell checking, see bug #141663.
// so we must block signals here.
d->valueEdit->blockSignals(true);
QString langISO3066 = d->currentLanguage;
langISO3066.replace('-', '_');
d->valueEdit->setSpellCheckingLanguage(langISO3066);
QString text = d->values.value(d->currentLanguage);
d->valueEdit->setText(text);
d->delValueButton->setEnabled(!text.isNull());
d->valueEdit->blockSignals(false);
d->languageCB->setToolTip(d->languageCodeMap.value(d->currentLanguage));
emit signalSelectionChanged(d->currentLanguage);
}
void AltLangStrEdit::setValues(const KExiv2::AltLangMap& values)
{
d->values = values;
loadLangAltListEntries();
d->valueEdit->blockSignals(true);
QString text = d->values.value(d->currentLanguage);
d->valueEdit->setText(text);
d->delValueButton->setEnabled(!text.isNull());
d->valueEdit->blockSignals(false);
}
KExiv2::AltLangMap& AltLangStrEdit::values()
{
return d->values;
}
void AltLangStrEdit::loadLangAltListEntries()
{
d->languageCB->blockSignals(true);
d->languageCB->clear();
// In first we fill already assigned languages.
QStringList list = d->values.keys();
if (!list.isEmpty())
{
foreach(const QString& item, list)
{
d->languageCB->addItem(item);
d->languageCB->setItemIcon(d->languageCB->count()-1, SmallIcon("dialog-ok"));
}
d->languageCB->insertSeparator(d->languageCB->count());
}
// ...and now, all the rest...
for (Private::LanguageCodeMap::Iterator it = d->languageCodeMap.begin();
it != d->languageCodeMap.end(); ++it)
{
if (!list.contains(it.key()))
{
d->languageCB->addItem(it.key());
}
}
d->languageCB->setCurrentItem(d->currentLanguage);
d->languageCB->blockSignals(false);
}
QString AltLangStrEdit::defaultAltLang() const
{
return d->values.value(QString("x-default"));
}
bool AltLangStrEdit::asDefaultAltLang() const
{
return !defaultAltLang().isNull();
}
void AltLangStrEdit::slotTextChanged()
{
QString editedText = d->valueEdit->toPlainText();
QString previousText = d->values.value(d->currentLanguage);
// Special case : if edited and previous strings are empty, do nothing.
// See bug #152948.
if (editedText.isEmpty() && previousText.isNull())
{
return;
}
if (editedText.isEmpty())
{
slotDeleteValue();
}
else if (previousText.isNull())
{
addCurrent();
}
else if (editedText != previousText)
{
// we cannot trust that the text actually changed
// (there are bogus signals caused by spell checking, see bug #141663)
// so we have to check before marking the metadata as modified.
d->values.insert(d->currentLanguage, editedText);
emit signalModified(d->currentLanguage, editedText);
}
}
void AltLangStrEdit::addCurrent()
{
QString text = d->valueEdit->toPlainText();
d->values.insert(d->currentLanguage, text);
loadLangAltListEntries();
d->delValueButton->setEnabled(true);
emit signalValueAdded(d->currentLanguage, text);
}
void AltLangStrEdit::setLinesVisible(uint lines)
{
d->linesVisible = lines;
if (d->linesVisible == 0)
{
d->valueEdit->setFixedHeight(QWIDGETSIZE_MAX); // reset
}
else
{
d->valueEdit->setFixedHeight(d->valueEdit->fontMetrics().lineSpacing() * d->linesVisible +
d->valueEdit->contentsMargins().top() +
d->valueEdit->contentsMargins().bottom() +
1 +
2*(d->valueEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) +
d->valueEdit->style()->pixelMetric(QStyle::PM_FocusFrameVMargin))
);
}
// It's not possible to display scrollbar properlly if size is too small
if (d->linesVisible < 3)
{
d->valueEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
}
uint AltLangStrEdit::linesVisible() const
{
return d->linesVisible;
}
void AltLangStrEdit::changeEvent(QEvent* e)
{
if (e->type() == QEvent::FontChange)
{
setLinesVisible(linesVisible());
}
QWidget::changeEvent(e);
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,115 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-06-15
* @brief multi-languages string editor
*
* @author Copyright (C) 2009-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef ALTLANGSTREDIT_H
#define ALTLANGSTREDIT_H
// Qt includes
#include <QtGui/QWidget>
#include <QtCore/QString>
// Local includes
#include "libkexiv2_export.h"
#include "kexiv2.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT AltLangStrEdit : public QWidget
{
Q_OBJECT
public:
AltLangStrEdit(QWidget* parent);
~AltLangStrEdit();
void setTitle(const QString& title);
void setClickMessage(const QString& msg);
void setCurrentLanguageCode(const QString& lang);
QString currentLanguageCode() const;
QString languageCode(int index) const;
void setValues(const KExiv2::AltLangMap& values);
KExiv2::AltLangMap& values();
/** Fix lines visibile in text editor to lines. If zero, do not fix layout to number of lines visible.
*/
void setLinesVisible(uint lines);
uint linesVisible() const;
QString defaultAltLang() const;
bool asDefaultAltLang() const;
/**
* Reset widget, clear all entries
*/
void reset();
/**
* Ensure that the current language is added to the list of entries,
* even if the text is empty.
* signalValueAdded() will be emitted.
*/
void addCurrent();
Q_SIGNALS:
/**
* Emitted when the user changes the text for the current language.
*/
void signalModified(const QString& lang, const QString& text);
/// Emitted when the current language changed
void signalSelectionChanged(const QString& lang);
/// Emitted when an entry for a new language is added
void signalValueAdded(const QString& lang, const QString& text);
/// Emitted when the entry for a language is removed.
void signalValueDeleted(const QString& lang);
protected Q_SLOTS:
void slotTextChanged();
void slotSelectionChanged();
void slotDeleteValue();
protected:
void loadLangAltListEntries();
virtual void changeEvent(QEvent* e);
private:
class Private;
Private* const d;
};
} // namespace KExiv2Iface
#endif // ALTLANGSTREDIT_H

View file

@ -0,0 +1,370 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-07-07
* @brief country selector combo-box.
*
* @author Copyright (C) 2009-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "countryselector.h"
// Qt includes
#include <QMap>
#include <QVariant>
// KDE includes
#include <klocale.h>
#include <kdebug.h>
namespace KExiv2Iface
{
class CountrySelector::Private
{
public:
Private()
{
// We cannot use KLocale::allCountriesList() here because KDE only
// support 2 characters country codes. XMP require 3 characters country
// following ISO 3166 (http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html)
// Standard ISO 3166 country codes.
countryCodeMap.insert( "AFG", i18n("Afghanistan") );
countryCodeMap.insert( "ALB", i18n("Albania") );
countryCodeMap.insert( "DZA", i18n("Algeria") );
countryCodeMap.insert( "ASM", i18n("American Samoa") );
countryCodeMap.insert( "AND", i18n("Andorra") );
countryCodeMap.insert( "AGO", i18n("Angola") );
countryCodeMap.insert( "AIA", i18n("Anguilla") );
countryCodeMap.insert( "AGO", i18n("Angola") );
countryCodeMap.insert( "ATA", i18n("Antarctica") );
countryCodeMap.insert( "ATG", i18n("Antigua and Barbuda") );
countryCodeMap.insert( "ARG", i18n("Argentina") );
countryCodeMap.insert( "ARM", i18n("Armenia") );
countryCodeMap.insert( "ABW", i18n("Aruba") );
countryCodeMap.insert( "AUS", i18n("Australia") );
countryCodeMap.insert( "AUT", i18n("Austria") );
countryCodeMap.insert( "AZE", i18n("Azerbaijan") );
countryCodeMap.insert( "BHS", i18n("Bahamas") );
countryCodeMap.insert( "BHR", i18n("Bahrain") );
countryCodeMap.insert( "BGD", i18n("Bangladesh") );
countryCodeMap.insert( "BRB", i18n("Barbados") );
countryCodeMap.insert( "BLR", i18n("Belarus") );
countryCodeMap.insert( "BEL", i18n("Belgium") );
countryCodeMap.insert( "BLZ", i18n("Belize") );
countryCodeMap.insert( "BEN", i18n("Benin") );
countryCodeMap.insert( "BMU", i18n("Bermuda") );
countryCodeMap.insert( "BTN", i18n("Bhutan") );
countryCodeMap.insert( "BOL", i18n("Bolivia") );
countryCodeMap.insert( "BIH", i18n("Bosnia and Herzegovina") );
countryCodeMap.insert( "BWA", i18n("Botswana") );
countryCodeMap.insert( "BVT", i18n("Bouvet Island") );
countryCodeMap.insert( "BRA", i18n("Brazil") );
countryCodeMap.insert( "IOT", i18n("British Indian Ocean Territory") );
countryCodeMap.insert( "VGB", i18n("British Virgin Islands") );
countryCodeMap.insert( "BRN", i18n("Brunei Darussalam") );
countryCodeMap.insert( "BGR", i18n("Bulgaria") );
countryCodeMap.insert( "BFA", i18n("Burkina Faso") );
countryCodeMap.insert( "BDI", i18n("Burundi") );
countryCodeMap.insert( "KHM", i18n("Cambodia") );
countryCodeMap.insert( "CMR", i18n("Cameroon") );
countryCodeMap.insert( "CAN", i18n("Canada") );
countryCodeMap.insert( "CPV", i18n("Cape Verde") );
countryCodeMap.insert( "CYM", i18n("Cayman Islands") );
countryCodeMap.insert( "CAF", i18n("Central African Republic") );
countryCodeMap.insert( "TCD", i18n("Chad") );
countryCodeMap.insert( "CHL", i18n("Chile") );
countryCodeMap.insert( "CHN", i18n("China") );
countryCodeMap.insert( "CXR", i18n("Christmas Island ") );
countryCodeMap.insert( "CCK", i18n("Cocos Islands") );
countryCodeMap.insert( "COL", i18n("Colombia") );
countryCodeMap.insert( "COM", i18n("Comoros") );
countryCodeMap.insert( "COD", i18n("Zaire") );
countryCodeMap.insert( "COG", i18n("Congo") );
countryCodeMap.insert( "COK", i18n("Cook Islands") );
countryCodeMap.insert( "CRI", i18n("Costa Rica") );
countryCodeMap.insert( "CIV", i18n("Ivory Coast") );
countryCodeMap.insert( "CUB", i18n("Cuba") );
countryCodeMap.insert( "CYP", i18n("Cyprus") );
countryCodeMap.insert( "CZE", i18n("Czech Republic") );
countryCodeMap.insert( "DNK", i18n("Denmark") );
countryCodeMap.insert( "DJI", i18n("Djibouti") );
countryCodeMap.insert( "DMA", i18n("Dominica") );
countryCodeMap.insert( "DOM", i18n("Dominican Republic") );
countryCodeMap.insert( "ECU", i18n("Ecuador") );
countryCodeMap.insert( "EGY", i18n("Egypt") );
countryCodeMap.insert( "SLV", i18n("El Salvador") );
countryCodeMap.insert( "GNQ", i18n("Equatorial Guinea") );
countryCodeMap.insert( "ERI", i18n("Eritrea") );
countryCodeMap.insert( "EST", i18n("Estonia") );
countryCodeMap.insert( "ETH", i18n("Ethiopia") );
countryCodeMap.insert( "FRO", i18n("Faeroe Islands") );
countryCodeMap.insert( "FLK", i18n("Falkland Islands") );
countryCodeMap.insert( "FJI", i18n("Fiji Islands") );
countryCodeMap.insert( "FIN", i18n("Finland") );
countryCodeMap.insert( "FRA", i18n("France") );
countryCodeMap.insert( "GUF", i18n("French Guiana") );
countryCodeMap.insert( "PYF", i18n("French Polynesia") );
countryCodeMap.insert( "ATF", i18n("French Southern Territories") );
countryCodeMap.insert( "GAB", i18n("Gabon") );
countryCodeMap.insert( "GMB", i18n("Gambia") );
countryCodeMap.insert( "GEO", i18n("Georgia") );
countryCodeMap.insert( "DEU", i18n("Germany") );
countryCodeMap.insert( "GHA", i18n("Ghana") );
countryCodeMap.insert( "GIB", i18n("Gibraltar") );
countryCodeMap.insert( "GRC", i18n("Greece") );
countryCodeMap.insert( "GRL", i18n("Greenland") );
countryCodeMap.insert( "GRD", i18n("Grenada") );
countryCodeMap.insert( "GLP", i18n("Guadaloupe") );
countryCodeMap.insert( "GUM", i18n("Guam") );
countryCodeMap.insert( "GTM", i18n("Guatemala") );
countryCodeMap.insert( "GIN", i18n("Guinea") );
countryCodeMap.insert( "GNB", i18n("Guinea-Bissau") );
countryCodeMap.insert( "GUY", i18n("Guyana") );
countryCodeMap.insert( "HTI", i18n("Haiti") );
countryCodeMap.insert( "HMD", i18n("Heard and McDonald Islands") );
countryCodeMap.insert( "VAT", i18n("Vatican") );
countryCodeMap.insert( "HND", i18n("Honduras") );
countryCodeMap.insert( "HKG", i18n("Hong Kong") );
countryCodeMap.insert( "HRV", i18n("Croatia") );
countryCodeMap.insert( "HUN", i18n("Hungary") );
countryCodeMap.insert( "ISL", i18n("Iceland") );
countryCodeMap.insert( "IND", i18n("India") );
countryCodeMap.insert( "IDN", i18n("Indonesia") );
countryCodeMap.insert( "IRN", i18n("Iran") );
countryCodeMap.insert( "IRQ", i18n("Iraq") );
countryCodeMap.insert( "IRL", i18n("Ireland") );
countryCodeMap.insert( "ISR", i18n("Israel") );
countryCodeMap.insert( "ITA", i18n("Italy") );
countryCodeMap.insert( "JAM", i18n("Jamaica") );
countryCodeMap.insert( "JPN", i18n("Japan") );
countryCodeMap.insert( "JOR", i18n("Jordan") );
countryCodeMap.insert( "KAZ", i18n("Kazakhstan") );
countryCodeMap.insert( "KEN", i18n("Kenya") );
countryCodeMap.insert( "KIR", i18n("Kiribati") );
countryCodeMap.insert( "PRK", i18n("North-Korea") );
countryCodeMap.insert( "KOR", i18n("South-Korea") );
countryCodeMap.insert( "KWT", i18n("Kuwait") );
countryCodeMap.insert( "KGZ", i18n("Kyrgyz Republic") );
countryCodeMap.insert( "LAO", i18n("Lao") );
countryCodeMap.insert( "LVA", i18n("Latvia") );
countryCodeMap.insert( "LBN", i18n("Lebanon") );
countryCodeMap.insert( "LSO", i18n("Lesotho") );
countryCodeMap.insert( "LBR", i18n("Liberia") );
countryCodeMap.insert( "LBY", i18n("Libyan Arab Jamahiriya") );
countryCodeMap.insert( "LIE", i18n("Liechtenstein") );
countryCodeMap.insert( "LTU", i18n("Lithuania") );
countryCodeMap.insert( "LUX", i18n("Luxembourg") );
countryCodeMap.insert( "MAC", i18n("Macao") );
countryCodeMap.insert( "MKD", i18n("Macedonia") );
countryCodeMap.insert( "MDG", i18n("Madagascar") );
countryCodeMap.insert( "MWI", i18n("Malawi") );
countryCodeMap.insert( "MYS", i18n("Malaysia") );
countryCodeMap.insert( "MDV", i18n("Maldives") );
countryCodeMap.insert( "MLI", i18n("Mali") );
countryCodeMap.insert( "MLT", i18n("Malta") );
countryCodeMap.insert( "MHL", i18n("Marshall Islands") );
countryCodeMap.insert( "MTQ", i18n("Martinique") );
countryCodeMap.insert( "MRT", i18n("Mauritania") );
countryCodeMap.insert( "MUS", i18n("Mauritius") );
countryCodeMap.insert( "MYT", i18n("Mayotte") );
countryCodeMap.insert( "MEX", i18n("Mexico") );
countryCodeMap.insert( "FSM", i18n("Micronesia") );
countryCodeMap.insert( "MDA", i18n("Moldova") );
countryCodeMap.insert( "MCO", i18n("Monaco") );
countryCodeMap.insert( "MNG", i18n("Mongolia") );
countryCodeMap.insert( "MSR", i18n("Montserrat") );
countryCodeMap.insert( "MAR", i18n("Morocco") );
countryCodeMap.insert( "MOZ", i18n("Mozambique") );
countryCodeMap.insert( "MMR", i18n("Myanmar") );
countryCodeMap.insert( "NAM", i18n("Namibia") );
countryCodeMap.insert( "NRU", i18n("Nauru") );
countryCodeMap.insert( "NPL", i18n("Nepal") );
countryCodeMap.insert( "ANT", i18n("Netherlands Antilles") );
countryCodeMap.insert( "NLD", i18n("Netherlands") );
countryCodeMap.insert( "NCL", i18n("New Caledonia") );
countryCodeMap.insert( "NZL", i18n("New Zealand") );
countryCodeMap.insert( "NIC", i18n("Nicaragua") );
countryCodeMap.insert( "NER", i18n("Niger") );
countryCodeMap.insert( "NGA", i18n("Nigeria") );
countryCodeMap.insert( "NIU", i18n("Niue") );
countryCodeMap.insert( "NFK", i18n("Norfolk Island") );
countryCodeMap.insert( "MNP", i18n("Northern Mariana Islands") );
countryCodeMap.insert( "NOR", i18n("Norway") );
countryCodeMap.insert( "OMN", i18n("Oman") );
countryCodeMap.insert( "PAK", i18n("Pakistan") );
countryCodeMap.insert( "PLW", i18n("Palau") );
countryCodeMap.insert( "PSE", i18n("Palestinian Territory") );
countryCodeMap.insert( "PAN", i18n("Panama") );
countryCodeMap.insert( "PNG", i18n("Papua New Guinea") );
countryCodeMap.insert( "PRY", i18n("Paraguay") );
countryCodeMap.insert( "PER", i18n("Peru") );
countryCodeMap.insert( "PHL", i18n("Philippines") );
countryCodeMap.insert( "PCN", i18n("Pitcairn Island") );
countryCodeMap.insert( "POL", i18n("Poland") );
countryCodeMap.insert( "PRT", i18n("Portugal") );
countryCodeMap.insert( "PRI", i18n("Puerto Rico") );
countryCodeMap.insert( "QAT", i18n("Qatar") );
countryCodeMap.insert( "REU", i18n("Reunion") );
countryCodeMap.insert( "ROU", i18n("Romania") );
countryCodeMap.insert( "RUS", i18n("Russian Federation") );
countryCodeMap.insert( "RWA", i18n("Rwanda") );
countryCodeMap.insert( "SHN", i18n("St. Helena") );
countryCodeMap.insert( "KNA", i18n("St. Kitts and Nevis") );
countryCodeMap.insert( "LCA", i18n("St. Lucia") );
countryCodeMap.insert( "SPM", i18n("St. Pierre and Miquelon") );
countryCodeMap.insert( "VCT", i18n("St. Vincent and the Grenadines") );
countryCodeMap.insert( "WSM", i18n("Samoa") );
countryCodeMap.insert( "SMR", i18n("San Marino") );
countryCodeMap.insert( "STP", i18n("Sao Tome and Principe") );
countryCodeMap.insert( "SAU", i18n("Saudi Arabia") );
countryCodeMap.insert( "SEN", i18n("Senegal") );
countryCodeMap.insert( "SCG", i18n("Serbia and Montenegro") );
countryCodeMap.insert( "SYC", i18n("Seychelles") );
countryCodeMap.insert( "SLE", i18n("Sierra Leone") );
countryCodeMap.insert( "SGP", i18n("Singapore") );
countryCodeMap.insert( "SVK", i18n("Slovakia") );
countryCodeMap.insert( "SVN", i18n("Slovenia") );
countryCodeMap.insert( "SLB", i18n("Solomon Islands") );
countryCodeMap.insert( "SOM", i18n("Somalia") );
countryCodeMap.insert( "ZAF", i18n("South Africa") );
countryCodeMap.insert( "SGS", i18n("South Georgia and the South Sandwich Islands") );
countryCodeMap.insert( "ESP", i18n("Spain") );
countryCodeMap.insert( "LKA", i18n("Sri Lanka") );
countryCodeMap.insert( "SDN", i18n("Sudan") );
countryCodeMap.insert( "SUR", i18n("Suriname") );
countryCodeMap.insert( "SJM", i18n("Svalbard & Jan Mayen Islands") );
countryCodeMap.insert( "SWZ", i18n("Swaziland") );
countryCodeMap.insert( "SWE", i18n("Sweden") );
countryCodeMap.insert( "CHE", i18n("Switzerland") );
countryCodeMap.insert( "SYR", i18n("Syrian Arab Republic") );
countryCodeMap.insert( "TWN", i18n("Taiwan") );
countryCodeMap.insert( "TJK", i18n("Tajikistan") );
countryCodeMap.insert( "TZA", i18n("Tanzania") );
countryCodeMap.insert( "THA", i18n("Thailand") );
countryCodeMap.insert( "TLS", i18n("Timor-Leste") );
countryCodeMap.insert( "TGO", i18n("Togo") );
countryCodeMap.insert( "TKL", i18n("Tokelau Islands") );
countryCodeMap.insert( "TON", i18n("Tonga") );
countryCodeMap.insert( "TTO", i18n("Trinidad and Tobago") );
countryCodeMap.insert( "TUN", i18n("Tunisia") );
countryCodeMap.insert( "TUR", i18n("Turkey") );
countryCodeMap.insert( "TKM", i18n("Turkmenistan") );
countryCodeMap.insert( "TCA", i18n("Turks and Caicos Islands") );
countryCodeMap.insert( "TUV", i18n("Tuvalu") );
countryCodeMap.insert( "VIR", i18n("US Virgin Islands") );
countryCodeMap.insert( "UGA", i18n("Uganda") );
countryCodeMap.insert( "UKR", i18n("Ukraine") );
countryCodeMap.insert( "ARE", i18n("United Arab Emirates") );
countryCodeMap.insert( "GBR", i18n("United Kingdom") );
countryCodeMap.insert( "UMI", i18n("United States Minor Outlying Islands") );
countryCodeMap.insert( "USA", i18n("United States of America") );
countryCodeMap.insert( "URY", i18n("Uruguay, Eastern Republic of") );
countryCodeMap.insert( "UZB", i18n("Uzbekistan") );
countryCodeMap.insert( "VUT", i18n("Vanuatu") );
countryCodeMap.insert( "VEN", i18n("Venezuela") );
countryCodeMap.insert( "VNM", i18n("Viet Nam") );
countryCodeMap.insert( "WLF", i18n("Wallis and Futuna Islands ") );
countryCodeMap.insert( "ESH", i18n("Western Sahara") );
countryCodeMap.insert( "YEM", i18n("Yemen") );
countryCodeMap.insert( "ZMB", i18n("Zambia") );
countryCodeMap.insert( "ZWE", i18n("Zimbabwe") );
// Supplemental IPTC/IIM country codes.
countryCodeMap.insert( "XUN", i18n("United Nations") );
countryCodeMap.insert( "XEU", i18n("European Union") );
countryCodeMap.insert( "XSP", i18n("Space") );
countryCodeMap.insert( "XSE", i18n("At Sea") );
countryCodeMap.insert( "XIF", i18n("In Flight") );
countryCodeMap.insert( "XEN", i18n("England") );
countryCodeMap.insert( "XSC", i18n("Scotland") );
countryCodeMap.insert( "XNI", i18n("Northern Ireland") );
countryCodeMap.insert( "XWA", i18n("Wales") );
countryCodeMap.insert( "PSE", i18n("Palestine") );
countryCodeMap.insert( "GZA", i18n("Gaza") );
countryCodeMap.insert( "JRO", i18n("Jericho") );
}
typedef QMap<QString, QString> CountryCodeMap;
CountryCodeMap countryCodeMap;
};
CountrySelector::CountrySelector(QWidget* parent)
: KComboBox(parent), d(new Private)
{
for (Private::CountryCodeMap::Iterator it = d->countryCodeMap.begin();
it != d->countryCodeMap.end(); ++it)
{
addItem(QString("%1 - %2").arg(it.key()).arg(it.value()));
}
model()->sort(0);
insertSeparator(count());
addItem(i18nc("Unknown country", "Unknown"));
}
CountrySelector::~CountrySelector()
{
delete d;
}
void CountrySelector::setCountry(const QString& countryCode)
{
// NOTE: if countryCode is empty or do not matches code map, unknow is selected from the list.
int id = count()-1;
for (int i = 0 ; i < d->countryCodeMap.count() ; i++)
{
if (itemText(i).left(3) == countryCode)
{
id = i;
break;
}
}
setCurrentIndex(id);
kDebug() << count() << " :: " << id;
}
bool CountrySelector::country(QString& countryCode, QString& countryName)
{
// Unknow is selected ?
if (currentIndex() == count()-1)
return false;
countryName = currentText().mid(6);
countryCode = currentText().left(3);
return true;
}
QString CountrySelector::countryForCode(const QString& countryCode)
{
Private priv;
return (priv.countryCodeMap[countryCode]);
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,66 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-07-07
* @brief country selector combo-box.
*
* @author Copyright (C) 2009-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef COUNTRY_SELECTOR_H
#define COUNTRY_SELECTOR_H
// Qt includes
#include <QtCore/QString>
#include <QtGui/QWidget>
// KDE includes
#include <kcombobox.h>
// Local includes
#include "libkexiv2_export.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT CountrySelector : public KComboBox
{
public:
CountrySelector(QWidget* parent);
~CountrySelector();
void setCountry(const QString& countryCode);
bool country(QString& countryCode, QString& countryName);
static QString countryForCode(const QString& countryCode);
private:
class Private;
Private* const d;
};
} // namespace KExiv2Iface
#endif // COUNTRY_SELECTOR_H

View file

@ -0,0 +1,544 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-15
* @brief Exiv2 library interface for KDE
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2013 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2.h"
#include "kexiv2_p.h"
// Local includes
#include "version.h"
namespace KExiv2Iface
{
KExiv2Data::KExiv2Data()
: d(0)
{
}
KExiv2Data::KExiv2Data(const KExiv2Data& other)
{
d = other.d;
}
KExiv2Data::~KExiv2Data()
{
}
KExiv2Data& KExiv2Data::operator=(const KExiv2Data& other)
{
d = other.d;
return *this;
}
// -------------------------------------------------------------------------------------------
KExiv2::KExiv2()
: d(new Private)
{
}
KExiv2::KExiv2(const KExiv2& metadata)
: d(new Private)
{
d->copyPrivateData(metadata.d);
}
KExiv2::KExiv2(const KExiv2Data& data)
: d(new Private)
{
setData(data);
}
KExiv2::KExiv2(const QString& filePath)
: d(new Private)
{
load(filePath);
}
KExiv2::~KExiv2()
{
delete d;
}
KExiv2& KExiv2::operator=(const KExiv2& metadata)
{
d->copyPrivateData(metadata.d);
return *this;
}
//-- Statics methods ----------------------------------------------
bool KExiv2::initializeExiv2()
{
#ifdef _XMP_SUPPORT_
if (!Exiv2::XmpParser::initialize())
return false;
registerXmpNameSpace(QString("http://ns.adobe.com/lightroom/1.0/"), QString("lr"));
registerXmpNameSpace(QString("http://www.digikam.org/ns/kipi/1.0/"), QString("kipi"));
registerXmpNameSpace(QString("http://ns.microsoft.com/photo/1.2/"), QString("MP"));
#endif // _XMP_SUPPORT_
return true;
}
bool KExiv2::cleanupExiv2()
{
// Fix memory leak if Exiv2 support XMP.
#ifdef _XMP_SUPPORT_
unregisterXmpNameSpace(QString("http://ns.adobe.com/lightroom/1.0/"));
unregisterXmpNameSpace(QString("http://www.digikam.org/ns/kipi/1.0/"));
unregisterXmpNameSpace(QString("http://ns.microsoft.com/photo/1.2/"));
Exiv2::XmpParser::terminate();
#endif // _XMP_SUPPORT_
return true;
}
bool KExiv2::supportXmp()
{
#ifdef _XMP_SUPPORT_
return true;
#else
return false;
#endif // _XMP_SUPPORT_
}
bool KExiv2::supportMetadataWritting(const QString& typeMime)
{
if (typeMime == QString("image/jpeg"))
{
return true;
}
else if (typeMime == QString("image/tiff"))
{
return true;
}
else if (typeMime == QString("image/png"))
{
return true;
}
else if (typeMime == QString("image/jp2"))
{
return true;
}
else if (typeMime == QString("image/x-raw"))
{
return true;
}
else if (typeMime == QString("image/pgf"))
{
return true;
}
return false;
}
QString KExiv2::Exiv2Version()
{
// Since 0.14.0 release, we can extract run-time version of Exiv2.
// else we return make version.
return QString(Exiv2::version());
}
QString KExiv2::version()
{
return QString(kexiv2_version);
}
QString KExiv2::sidecarFilePathForFile(const QString& path)
{
QString ret;
if (!path.isEmpty())
{
ret = path + QString(".xmp");
}
return ret;
}
KUrl KExiv2::sidecarUrl(const KUrl& url)
{
QString sidecarPath = sidecarFilePathForFile(url.path());
KUrl sidecarUrl(url);
sidecarUrl.setPath(sidecarPath);
return sidecarUrl;
}
KUrl KExiv2::sidecarUrl(const QString& path)
{
return KUrl::fromPath(sidecarFilePathForFile(path));
}
QString KExiv2::sidecarPath(const QString& path)
{
return sidecarFilePathForFile(path);
}
bool KExiv2::hasSidecar(const QString& path)
{
return QFileInfo(sidecarFilePathForFile(path)).exists();
}
//-- General methods ----------------------------------------------
KExiv2Data KExiv2::data() const
{
KExiv2Data data;
data.d = d->data;
return data;
}
void KExiv2::setData(const KExiv2Data& data)
{
if (data.d)
{
d->data = data.d;
}
else
{
// KExiv2Data can have a null pointer,
// but we never want a null pointer in Private.
d->data->clear();
}
}
bool KExiv2::loadFromData(const QByteArray& imgData) const
{
if (imgData.isEmpty())
return false;
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
d->filePath.clear();
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = image->mimeType().c_str();
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot load metadata using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::load(const QString& filePath) const
{
if (filePath.isEmpty())
{
return false;
}
d->filePath = filePath;
bool hasLoaded = false;
try
{
Exiv2::Image::AutoPtr image;
image = Exiv2::ImageFactory::open((const char*)(QFile::encodeName(filePath)));
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = image->mimeType().c_str();
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
hasLoaded = true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot load metadata from file ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
#ifdef _XMP_SUPPORT_
try
{
if (d->useXMPSidecar4Reading)
{
QString xmpSidecarPath = sidecarFilePathForFile(filePath);
QFileInfo xmpSidecarFileInfo(xmpSidecarPath);
Exiv2::Image::AutoPtr xmpsidecar;
if (xmpSidecarFileInfo.exists() && xmpSidecarFileInfo.isReadable())
{
// Read sidecar data
xmpsidecar = Exiv2::ImageFactory::open((const char*)QFile::encodeName(xmpSidecarPath));
xmpsidecar->readMetadata();
// Merge
d->loadSidecarData(xmpsidecar);
hasLoaded = true;
}
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot load XMP sidecar", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
#endif // _XMP_SUPPORT_
return hasLoaded;
}
bool KExiv2::save(const QString& imageFilePath) const
{
// If our image is really a symlink, we should follow the symlink so that
// when we delete the file and rewrite it, we are honoring the symlink
// (rather than just deleting it and putting a file there).
// However, this may be surprising to the user when they are writing sidecar
// files. They might expect them to show up where the symlink is. So, we
// shouldn't follow the link when figuring out what the filename for the
// sidecar should be.
// Note, we are not yet handling the case where the sidecar itself is a
// symlink.
QString regularFilePath = imageFilePath; // imageFilePath might be a
// symlink. Below we will change
// regularFile to the pointed to
// file if so.
QFileInfo givenFileInfo(imageFilePath);
if (givenFileInfo.isSymLink())
{
kDebug() << "filePath" << imageFilePath << "is a symlink."
<< "Using target" << givenFileInfo.canonicalPath();
regularFilePath = givenFileInfo.canonicalPath();// Walk all the symlinks
}
// NOTE: see B.K.O #137770 & #138540 : never touch the file if is read only.
QFileInfo finfo(regularFilePath);
QFileInfo dinfo(finfo.path());
if (!dinfo.isWritable())
{
kDebug() << "Dir '" << dinfo.filePath() << "' is read-only. Metadata not saved.";
return false;
}
bool writeToFile = false;
bool writeToSidecar = false;
bool writeToSidecarIfFileNotPossible = false;
bool writtenToFile = false;
bool writtenToSidecar = false;
kDebug() << "KExiv2::metadataWritingMode" << d->metadataWritingMode;
switch(d->metadataWritingMode)
{
case WRITETOSIDECARONLY:
writeToSidecar = true;
break;
case WRITETOIMAGEONLY:
writeToFile = true;
break;
case WRITETOSIDECARANDIMAGE:
writeToFile = true;
writeToSidecar = true;
break;
case WRITETOSIDECARONLY4READONLYFILES:
writeToFile = true;
writeToSidecarIfFileNotPossible = true;
break;
}
if (writeToFile)
{
kDebug() << "Will write Metadata to file" << finfo.fileName();
writtenToFile = d->saveToFile(finfo);
if (writeToFile)
{
kDebug() << "Metadata for file" << finfo.fileName() << "written to file.";
}
}
if (writeToSidecar || (writeToSidecarIfFileNotPossible && !writtenToFile))
{
kDebug() << "Will write XMP sidecar for file" << givenFileInfo.fileName();
writtenToSidecar = d->saveToXMPSidecar(imageFilePath);
if (writtenToSidecar)
{
kDebug() << "Metadata for file '" << givenFileInfo.fileName() << "' written to XMP sidecar.";
}
}
return writtenToFile || writtenToSidecar;
}
bool KExiv2::applyChanges() const
{
if (d->filePath.isEmpty())
{
kDebug() << "Failed to apply changes: file path is empty!";
return false;
}
return save(d->filePath);
}
bool KExiv2::isEmpty() const
{
if (!hasComments() && !hasExif() && !hasIptc() && !hasXmp())
return true;
return false;
}
void KExiv2::setFilePath(const QString& path)
{
d->filePath = path;
}
QString KExiv2::getFilePath() const
{
return d->filePath;
}
QSize KExiv2::getPixelSize() const
{
return d->pixelSize;
}
QString KExiv2::getMimeType() const
{
return d->mimeType;
}
void KExiv2::setWriteRawFiles(const bool on)
{
d->writeRawFiles = on;
}
bool KExiv2::writeRawFiles() const
{
return d->writeRawFiles;
}
void KExiv2::setUseXMPSidecar4Reading(const bool on)
{
d->useXMPSidecar4Reading = on;
}
bool KExiv2::useXMPSidecar4Reading() const
{
return d->useXMPSidecar4Reading;
}
void KExiv2::setMetadataWritingMode(const int mode)
{
d->metadataWritingMode = mode;
}
int KExiv2::metadataWritingMode() const
{
return d->metadataWritingMode;
}
void KExiv2::setUpdateFileTimeStamp(bool on)
{
d->updateFileTimeStamp = on;
}
bool KExiv2::updateFileTimeStamp() const
{
return d->updateFileTimeStamp;
}
bool KExiv2::setProgramId(bool /*on*/) const
{
return true;
}
} // NameSpace KExiv2Iface

1109
libkexiv2/libkexiv2/kexiv2.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,538 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-09-03
* @brief Exiv2 library interface for KDE
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2_p.h"
// C ANSI includes
extern "C"
{
#include <sys/stat.h>
#include <utime.h>
}
namespace KExiv2Iface
{
KExiv2::Private::Private()
: data(new KExiv2Data::Private)
{
writeRawFiles = false;
updateFileTimeStamp = false;
useXMPSidecar4Reading = false;
metadataWritingMode = WRITETOIMAGEONLY;
loadedFromSidecar = false;
Exiv2::LogMsg::setHandler(KExiv2::Private::printExiv2MessageHandler);
}
KExiv2::Private::~Private()
{
}
void KExiv2::Private::copyPrivateData(const Private* const other)
{
data = other->data;
filePath = other->filePath;
writeRawFiles = other->writeRawFiles;
updateFileTimeStamp = other->updateFileTimeStamp;
useXMPSidecar4Reading = other->useXMPSidecar4Reading;
metadataWritingMode = other->metadataWritingMode;
}
bool KExiv2::Private::saveToXMPSidecar(const QFileInfo& finfo) const
{
QString filePath = KExiv2::sidecarFilePathForFile(finfo.filePath());
if (filePath.isEmpty())
{
return false;
}
try
{
Exiv2::Image::AutoPtr image;
image = Exiv2::ImageFactory::create(Exiv2::ImageType::xmp, (const char*)(QFile::encodeName(filePath)));
return saveOperations(finfo, image);
}
catch( Exiv2::Error& e )
{
printExiv2ExceptionError("Cannot save metadata to XMP sidecar using Exiv2 ", e);
return false;
}
catch(...)
{
kError() << "Default exception from Exiv2";
return false;
}
}
bool KExiv2::Private::saveToFile(const QFileInfo& finfo) const
{
if (!finfo.isWritable())
{
kDebug() << "File '" << finfo.fileName().toAscii().constData() << "' is read only. Metadata not written.";
return false;
}
QStringList rawTiffBasedSupported, rawTiffBasedNotSupported;
// Raw files supported by Exiv2 0.21
rawTiffBasedSupported << "dng" << "nef" << "pef" << "orf" << "srw";
if (Exiv2::testVersion(0,23,0))
{
rawTiffBasedSupported << "cr2";
}
// Raw files not supported by Exiv2 0.21
rawTiffBasedNotSupported
<< "3fr" << "arw" << "dcr" << "erf" << "k25" << "kdc"
<< "mos" << "raw" << "sr2" << "srf" << "rw2";
if (!Exiv2::testVersion(0,23,0))
{
rawTiffBasedNotSupported << "cr2";
}
QString ext = finfo.suffix().toLower();
if (!writeRawFiles && (rawTiffBasedSupported.contains(ext) || rawTiffBasedNotSupported.contains(ext)) )
{
kDebug() << finfo.fileName()
<< "is a TIFF based RAW file, writing to such a file is disabled by current settings.";
return false;
}
/*
if (rawTiffBasedNotSupported.contains(ext))
{
kDebug() << finfo.fileName()
<< "is TIFF based RAW file not yet supported. Metadata not saved.";
return false;
}
if (rawTiffBasedSupported.contains(ext) && !writeRawFiles)
{
kDebug() << finfo.fileName()
<< "is TIFF based RAW file supported but writing mode is disabled. "
<< "Metadata not saved.";
return false;
}
kDebug() << "File Extension: " << ext << " is supported for writing mode";
bool ret = false;
*/
try
{
Exiv2::Image::AutoPtr image;
image = Exiv2::ImageFactory::open((const char*)(QFile::encodeName(finfo.filePath())));
return saveOperations(finfo, image);
}
catch( Exiv2::Error& e )
{
printExiv2ExceptionError("Cannot save metadata to image using Exiv2 ", e);
return false;
}
catch(...)
{
kError() << "Default exception from Exiv2";
return false;
}
}
bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoPtr image) const
{
try
{
Exiv2::AccessMode mode;
bool wroteComment = false, wroteEXIF = false, wroteIPTC = false, wroteXMP = false;
// We need to load target file metadata to merge with new one. It's mandatory with TIFF format:
// like all tiff file structure is based on Exif.
image->readMetadata();
// Image Comments ---------------------------------
mode = image->checkMode(Exiv2::mdComment);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
image->setComment(imageComments());
wroteComment = true;
}
// Exif metadata ----------------------------------
mode = image->checkMode(Exiv2::mdExif);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
if (image->mimeType() == "image/tiff")
{
Exiv2::ExifData orgExif = image->exifData();
Exiv2::ExifData newExif;
QStringList untouchedTags;
// With tiff image we cannot overwrite whole Exif data as well, because
// image data are stored in Exif container. We need to take a care about
// to not lost image data.
untouchedTags << "Exif.Image.ImageWidth";
untouchedTags << "Exif.Image.ImageLength";
untouchedTags << "Exif.Image.BitsPerSample";
untouchedTags << "Exif.Image.Compression";
untouchedTags << "Exif.Image.PhotometricInterpretation";
untouchedTags << "Exif.Image.FillOrder";
untouchedTags << "Exif.Image.SamplesPerPixel";
untouchedTags << "Exif.Image.StripOffsets";
untouchedTags << "Exif.Image.RowsPerStrip";
untouchedTags << "Exif.Image.StripByteCounts";
untouchedTags << "Exif.Image.XResolution";
untouchedTags << "Exif.Image.YResolution";
untouchedTags << "Exif.Image.PlanarConfiguration";
untouchedTags << "Exif.Image.ResolutionUnit";
for (Exiv2::ExifData::iterator it = orgExif.begin(); it != orgExif.end(); ++it)
{
if (untouchedTags.contains(it->key().c_str()))
{
newExif[it->key().c_str()] = orgExif[it->key().c_str()];
}
}
Exiv2::ExifData readedExif = exifMetadata();
for (Exiv2::ExifData::iterator it = readedExif.begin(); it != readedExif.end(); ++it)
{
if (!untouchedTags.contains(it->key().c_str()))
{
newExif[it->key().c_str()] = readedExif[it->key().c_str()];
}
}
image->setExifData(newExif);
}
else
{
image->setExifData(exifMetadata());
}
wroteEXIF = true;
}
// Iptc metadata ----------------------------------
mode = image->checkMode(Exiv2::mdIptc);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
image->setIptcData(iptcMetadata());
wroteIPTC = true;
}
// Xmp metadata -----------------------------------
mode = image->checkMode(Exiv2::mdXmp);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
#ifdef _XMP_SUPPORT_
image->setXmpData(xmpMetadata());
wroteXMP = true;
#endif
}
if (!wroteComment && !wroteEXIF && !wroteIPTC && !wroteXMP)
{
kDebug() << "Writing metadata is not supported for file" << finfo.fileName();
return false;
}
else if (!wroteEXIF || !wroteIPTC || !wroteXMP)
{
kDebug() << "Support for writing metadata is limited for file" << finfo.fileName()
<< "EXIF" << wroteEXIF << "IPTC" << wroteIPTC << "XMP" << wroteXMP;
}
if (!updateFileTimeStamp)
{
// Don't touch access and modification timestamp of file.
struct stat st;
struct utimbuf ut;
int ret = ::stat(QFile::encodeName(filePath), &st);
if (ret == 0)
{
ut.modtime = st.st_mtime;
ut.actime = st.st_atime;
}
image->writeMetadata();
if (ret == 0)
{
::utime(QFile::encodeName(filePath), &ut);
}
}
else
{
image->writeMetadata();
}
return true;
}
catch( Exiv2::Error& e )
{
printExiv2ExceptionError("Cannot save metadata using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
void KExiv2Data::Private::clear()
{
imageComments.clear();
exifMetadata.clear();
iptcMetadata.clear();
#ifdef _XMP_SUPPORT_
xmpMetadata.clear();
#endif
}
void KExiv2::Private::printExiv2ExceptionError(const QString& msg, Exiv2::Error& e)
{
std::string s(e.what());
kError() << msg.toAscii().constData() << " (Error #"
<< e.code() << ": " << s.c_str();
}
void KExiv2::Private::printExiv2MessageHandler(int lvl, const char* msg)
{
kDebug() << "Exiv2 (" << lvl << ") : " << msg;
}
QString KExiv2::Private::convertCommentValue(const Exiv2::Exifdatum& exifDatum) const
{
try
{
std::string comment;
std::string charset;
comment = exifDatum.toString();
// libexiv2 will prepend "charset=\"SomeCharset\" " if charset is specified
// Before conversion to QString, we must know the charset, so we stay with std::string for a while
if (comment.length() > 8 && comment.substr(0, 8) == "charset=")
{
// the prepended charset specification is followed by a blank
std::string::size_type pos = comment.find_first_of(' ');
if (pos != std::string::npos)
{
// extract string between the = and the blank
charset = comment.substr(8, pos-8);
// get the rest of the string after the charset specification
comment = comment.substr(pos+1);
}
}
if (charset == "\"Unicode\"")
{
return QString::fromUtf8(comment.data());
}
else if (charset == "\"Jis\"")
{
QTextCodec* codec = QTextCodec::codecForName("JIS7");
return codec->toUnicode(comment.c_str());
}
else if (charset == "\"Ascii\"")
{
return QString::fromLatin1(comment.c_str());
}
else
{
return detectEncodingAndDecode(comment);
}
}
catch( Exiv2::Error& e )
{
printExiv2ExceptionError("Cannot convert Comment using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QString();
}
QString KExiv2::Private::detectEncodingAndDecode(const std::string& value) const
{
// For charset autodetection, we could use sophisticated code
// (Mozilla chardet, KHTML's autodetection, QTextCodec::codecForContent),
// but that is probably too much.
// We check for UTF8, Local encoding and ASCII.
// TODO: Gilles ==> Marcel : Look like KEncodingDetector class can provide a full implementation for encoding detection.
if (value.empty())
{
return QString();
}
if (KStringHandler::isUtf8(value.c_str()))
{
return QString::fromUtf8(value.c_str());
}
// Utf8 has a pretty unique byte pattern.
// Thats not true for ASCII, it is not possible
// to reliably autodetect different ISO-8859 charsets.
// So we can use either local encoding, or latin1.
//TODO: KDE4PORT: check for regression of #134999 (very probably no regression!)
return QString::fromLocal8Bit(value.c_str());
//return QString::fromLatin1(value.c_str());
}
int KExiv2::Private::getXMPTagsListFromPrefix(const QString& pf, KExiv2::TagsMap& tagsMap) const
{
QList<const Exiv2::XmpPropertyInfo*> tags;
tags << Exiv2::XmpProperties::propertyList(pf.toAscii().data());
int i = 0;
for (QList<const Exiv2::XmpPropertyInfo*>::iterator it = tags.begin(); it != tags.end(); ++it)
{
while ( (*it) && !QString((*it)->name_).isNull() )
{
QString key = QLatin1String( Exiv2::XmpKey( pf.toAscii().data(), (*it)->name_ ).key().c_str() );
QStringList values;
values << (*it)->name_ << (*it)->title_ << (*it)->desc_;
tagsMap.insert(key, values);
++(*it);
i++;
}
}
return i;
}
#ifdef _XMP_SUPPORT_
void KExiv2::Private::loadSidecarData(Exiv2::Image::AutoPtr xmpsidecar)
{
// Having a sidecar is a special situation.
// The sidecar data often "dominates", see in particular bug 309058 for important aspects:
// If a field is removed from the sidecar, we must ignore (older) data for this field in the file.
// First: Ignore file XMP, only use sidecar XMP
xmpMetadata() = xmpsidecar->xmpData();
loadedFromSidecar = true;
// EXIF
// Four groups of properties are mapped between EXIF and XMP:
// Date/Time, Description, Copyright, Creator
// A few more tags are defined "writeback" tags in the XMP specification, the sidecar value therefore overrides the Exif value.
// The rest is kept side-by-side.
// (to understand, remember that the xmpsidecar's Exif data is actually XMP data mapped back to Exif)
// Description, Copyright and Creator is dominated by the sidecar: Remove file Exif fields, if field not in XMP.
ExifMergeHelper exifDominatedHelper;
exifDominatedHelper << QLatin1String("Exif.Image.ImageDescription")
<< QLatin1String("Exif.Photo.UserComment")
<< QLatin1String("Exif.Image.Copyright")
<< QLatin1String("Exif.Image.Artist");
exifDominatedHelper.exclusiveMerge(xmpsidecar->exifData(), exifMetadata());
// Date/Time and "the few more" from the XMP spec are handled as writeback
// Note that Date/Time mapping is slightly contradictory in latest specs.
ExifMergeHelper exifWritebackHelper;
exifWritebackHelper << QLatin1String("Exif.Image.DateTime")
<< QLatin1String("Exif.Image.DateTime")
<< QLatin1String("Exif.Photo.DateTimeOriginal")
<< QLatin1String("Exif.Photo.DateTimeDigitized")
<< QLatin1String("Exif.Image.Orientation")
<< QLatin1String("Exif.Image.XResolution")
<< QLatin1String("Exif.Image.YResolution")
<< QLatin1String("Exif.Image.ResolutionUnit")
<< QLatin1String("Exif.Image.Software")
<< QLatin1String("Exif.Photo.RelatedSoundFile");
exifWritebackHelper.mergeFields(xmpsidecar->exifData(), exifMetadata());
// IPTC
// These fields cover almost all relevant IPTC data and are defined in the XMP specification for reconciliation.
IptcMergeHelper iptcDominatedHelper;
iptcDominatedHelper << QLatin1String("Iptc.Application2.ObjectName")
<< QLatin1String("Iptc.Application2.Urgency")
<< QLatin1String("Iptc.Application2.Category")
<< QLatin1String("Iptc.Application2.SuppCategory")
<< QLatin1String("Iptc.Application2.Keywords")
<< QLatin1String("Iptc.Application2.SubLocation")
<< QLatin1String("Iptc.Application2.SpecialInstructions")
<< QLatin1String("Iptc.Application2.Byline")
<< QLatin1String("Iptc.Application2.BylineTitle")
<< QLatin1String("Iptc.Application2.City")
<< QLatin1String("Iptc.Application2.ProvinceState")
<< QLatin1String("Iptc.Application2.CountryCode")
<< QLatin1String("Iptc.Application2.CountryName")
<< QLatin1String("Iptc.Application2.TransmissionReference")
<< QLatin1String("Iptc.Application2.Headline")
<< QLatin1String("Iptc.Application2.Credit")
<< QLatin1String("Iptc.Application2.Source")
<< QLatin1String("Iptc.Application2.Copyright")
<< QLatin1String("Iptc.Application2.Caption")
<< QLatin1String("Iptc.Application2.Writer");
iptcDominatedHelper.exclusiveMerge(xmpsidecar->iptcData(), iptcMetadata());
IptcMergeHelper iptcWritebackHelper;
iptcWritebackHelper << QLatin1String("Iptc.Application2.DateCreated")
<< QLatin1String("Iptc.Application2.TimeCreated")
<< QLatin1String("Iptc.Application2.DigitizationDate")
<< QLatin1String("Iptc.Application2.DigitizationTime");
iptcWritebackHelper.mergeFields(xmpsidecar->iptcData(), iptcMetadata());
/*
* TODO: Exiv2 (referring to 0.23) does not correctly synchronize all times values as given below.
* Time values and their synchronization:
* Original Date/Time Creation date of the intellectual content (e.g. the photograph),
rather than the creatio*n date of the content being shown
Exif DateTimeOriginal (36867, 0x9003) and SubSecTimeOriginal (37521, 0x9291)
IPTC DateCreated (IIM 2:55, 0x0237) and TimeCreated (IIM 2:60, 0x023C)
XMP (photoshop:DateCreated)
* Digitized Date/Time Creation date of the digital representation
Exif DateTimeDigitized (36868, 0x9004) and SubSecTimeDigitized (37522, 0x9292)
IPTC DigitalCreationDate (IIM 2:62, 0x023E) and DigitalCreationTime (IIM 2:63, 0x023F)
XMP (xmp:CreateDate)
* Modification Date/Time Modification date of the digital image file
Exif DateTime (306, 0x132) and SubSecTime (37520, 0x9290)
XMP (xmp:ModifyDate)
*/
}
#endif // _XMP_SUPPORT_
} // NameSpace KExiv2Iface

View file

@ -0,0 +1,328 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-09-03
* @brief Exiv2 library interface for KDE
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KEXIV2PRIVATE_H
#define KEXIV2PRIVATE_H
#include "kexiv2.h"
// C++ includes
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cfloat>
#include <iostream>
#include <iomanip>
#include <string>
// Qt includes
#include <QBuffer>
#include <QFile>
#include <QImage>
#include <QSize>
#include <QLatin1String>
#include <QTextCodec>
#include <QMatrix>
#include <QFileInfo>
#include <QDataStream>
#include <QSharedData>
// KDE includes
#include <ktemporaryfile.h>
#include <kencodingdetector.h>
#include <kstringhandler.h>
#include <kdeversion.h>
#include <kdebug.h>
// Exiv2 includes -------------------------------------------------------
// NOTE: All Exiv2 header must be stay there to not expose external source code to Exiv2 API
// and reduce Exiv2 dependency to client code.
// The pragmas are required to be able to catch exceptions thrown by libexiv2:
// See http://gcc.gnu.org/wiki/Visibility, the section about c++ exceptions.
// They are needed for all libexiv2 versions that do not care about visibility.
#ifdef __GNUC__
#pragma GCC visibility push(default)
#endif
#include <exiv2/exv_conf.h>
#include <exiv2/error.hpp>
#include <exiv2/image.hpp>
#include <exiv2/jpgimage.hpp>
#include <exiv2/datasets.hpp>
#include <exiv2/tags.hpp>
#include <exiv2/preview.hpp>
#include <exiv2/properties.hpp>
#include <exiv2/types.hpp>
#include <exiv2/exif.hpp>
#include <exiv2/xmpsidecar.hpp>
// Check if Exiv2 support XMP
#ifdef EXV_HAVE_XMP_TOOLKIT
# define _XMP_SUPPORT_ 1
#endif
// Make sure an EXIV2_TEST_VERSION macro exists:
#ifdef EXIV2_VERSION
# ifndef EXIV2_TEST_VERSION
# define EXIV2_TEST_VERSION(major,minor,patch) \
( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) )
# endif
#else
# define EXIV2_TEST_VERSION(major,minor,patch) (false)
#endif
// With exiv2 > 0.20.0, all makernote header files have been removed to increase binary compatibility.
// See Exiv2 bugzilla entry http://dev.exiv2.org/issues/719
// and wiki topic http://dev.exiv2.org/boards/3/topics/583
#ifdef __GNUC__
#pragma GCC visibility pop
#endif
// End of Exiv2 headers ------------------------------------------------------
namespace KExiv2Iface
{
class KExiv2Data::Private : public QSharedData
{
public:
void clear();
public:
std::string imageComments;
Exiv2::ExifData exifMetadata;
Exiv2::IptcData iptcMetadata;
#ifdef _XMP_SUPPORT_
Exiv2::XmpData xmpMetadata;
#endif
};
// --------------------------------------------------------------------------
class KExiv2::Private
{
public:
Private();
~Private();
void copyPrivateData(const Private* const other);
bool saveToXMPSidecar(const QFileInfo& finfo) const;
bool saveToFile(const QFileInfo& finfo) const;
bool saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoPtr image) const;
/** Wrapper method to convert a Comments content to a QString.
*/
QString convertCommentValue(const Exiv2::Exifdatum& exifDatum) const;
/** Charset autodetection to convert a string to a QString.
*/
QString detectEncodingAndDecode(const std::string& value) const;
int getXMPTagsListFromPrefix(const QString& pf, KExiv2::TagsMap& tagsMap) const;
const Exiv2::ExifData& exifMetadata() const { return data.constData()->exifMetadata; }
const Exiv2::IptcData& iptcMetadata() const { return data.constData()->iptcMetadata; }
const std::string& imageComments() const { return data.constData()->imageComments; }
#ifdef _XMP_SUPPORT_
const Exiv2::XmpData& xmpMetadata() const { return data.constData()->xmpMetadata; }
#endif
Exiv2::ExifData& exifMetadata() { return data.data()->exifMetadata; }
Exiv2::IptcData& iptcMetadata() { return data.data()->iptcMetadata; }
std::string& imageComments() { return data.data()->imageComments; }
#ifdef _XMP_SUPPORT_
Exiv2::XmpData& xmpMetadata() { return data.data()->xmpMetadata; }
void loadSidecarData(Exiv2::Image::AutoPtr xmpsidecar);
#endif
public:
/** Generic method to print the Exiv2 C++ Exception error message from 'e'.
* 'msg' string is printed using kDebug rules..
*/
static void printExiv2ExceptionError(const QString& msg, Exiv2::Error& e);
/** Generic method to print debug message from Exiv2.
* 'msg' string is printed using kDebug rules. 'lvl' is the debug level of Exiv2 message.
*/
static void printExiv2MessageHandler(int lvl, const char* msg);
public:
bool writeRawFiles;
bool updateFileTimeStamp;
bool useXMPSidecar4Reading;
/// A mode from #MetadataWritingMode enum.
int metadataWritingMode;
/// XMP, and parts of EXIF/IPTC, were loaded from an XMP sidecar file
bool loadedFromSidecar;
QString filePath;
QSize pixelSize;
QString mimeType;
QSharedDataPointer<KExiv2Data::Private> data;
};
template <class Data, class Key, class KeyString, class KeyStringList = QList<KeyString> >
class MergeHelper
{
public:
KeyStringList keys;
MergeHelper& operator<<(const KeyString& key)
{
keys << key;
return *this;
}
/**
* Merge two (Exif,IPTC,Xmp)Data packages, where the result is stored in dest
* and fields from src take precedence over existing data from dest.
*/
void mergeAll(const Data& src, Data& dest)
{
for (typename Data::const_iterator it = src.begin(); it != src.end(); ++it)
{
typename Data::iterator destIt = dest.findKey(Key(it->key()));
if (destIt == dest.end())
{
dest.add(*it);
}
else
{
*destIt = *it;
}
}
}
/**
* Merge two (Exif,IPTC,Xmp)Data packages, the result is stored in dest.
* Only keys in keys are considered for merging.
* Fields from src take precedence over existing data from dest.
*/
void mergeFields(const Data& src, Data& dest)
{
foreach (const KeyString& keyString, keys)
{
Key key(keyString.latin1());
typename Data::const_iterator it = src.findKey(key);
if (it == src.end())
{
continue;
}
typename Data::iterator destIt = dest.findKey(key);
if (destIt == dest.end())
{
dest.add(*it);
}
else
{
*destIt = *it;
}
}
}
/**
* Merge two (Exif,IPTC,Xmp)Data packages, the result is stored in dest.
* The following steps apply only to keys in "keys":
* The result is determined by src.
* Keys must exist in src to kept in dest.
* Fields from src take precedence over existing data from dest.
*/
void exclusiveMerge(const Data& src, Data& dest)
{
foreach (const KeyString& keyString, keys)
{
Key key(keyString.latin1());
typename Data::const_iterator it = src.findKey(key);
typename Data::iterator destIt = dest.findKey(key);
if (destIt == dest.end())
{
if (it != src.end())
{
dest.add(*it);
}
}
else
{
if (it == src.end())
{
dest.erase(destIt);
}
else
{
*destIt = *it;
}
}
}
}
};
class ExifMergeHelper : public MergeHelper<Exiv2::ExifData, Exiv2::ExifKey, QLatin1String>
{
};
class IptcMergeHelper : public MergeHelper<Exiv2::IptcData, Exiv2::IptcKey, QLatin1String>
{
};
#ifdef _XMP_SUPPORT_
class XmpMergeHelper : public MergeHelper<Exiv2::XmpData, Exiv2::XmpKey, QLatin1String>
{
};
#endif
} // NameSpace KExiv2Iface
#endif // KEXIV2PRIVATE_H

View file

@ -0,0 +1,104 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-15
* @brief Comments manipulation methods
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Local includes
#include "kexiv2_p.h"
#include "kexiv2.h"
namespace KExiv2Iface
{
bool KExiv2::canWriteComment(const QString& filePath)
{
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(QFile::encodeName(filePath)));
Exiv2::AccessMode mode = image->checkMode(Exiv2::mdComment);
return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
}
catch( Exiv2::Error& e )
{
std::string s(e.what());
kError() << "Cannot check Comment access mode using Exiv2 (Error #"
<< e.code() << ": " << s.c_str() << ")";
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::hasComments() const
{
return !d->imageComments().empty();
}
bool KExiv2::clearComments() const
{
return setComments(QByteArray());
}
QByteArray KExiv2::getComments() const
{
return QByteArray(d->imageComments().data(), d->imageComments().size());
}
QString KExiv2::getCommentsDecoded() const
{
return d->detectEncodingAndDecode(d->imageComments());
}
bool KExiv2::setComments(const QByteArray& data) const
{
d->imageComments() = std::string(data.data(), data.size());
return true;
}
QString KExiv2::detectLanguageAlt(const QString& value, QString& lang)
{
// Ex. from an Xmp tag Xmp.tiff.copyright: "lang="x-default" (c) Gilles Caulier 2007"
if (value.size() > 6 && value.startsWith(QString("lang=\"")))
{
int pos = value.indexOf(QString("\""), 6);
if (pos != -1)
{
lang = value.mid(6, pos-6);
return (value.mid(pos+2));
}
}
lang.clear();
return value;
}
} // NameSpace KExiv2Iface

View file

@ -0,0 +1,66 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-11-15
* @brief Exiv2 library interface for KDE
*
* @author Copyright (C) 2009-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2009-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KEXIV2DATA_H
#define KEXIV2DATA_H
// QT includes
#include <QtCore/QSharedDataPointer>
// Local includes
#include "libkexiv2_export.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT KExiv2Data
{
public:
KExiv2Data();
KExiv2Data(const KExiv2Data&);
~KExiv2Data();
KExiv2Data& operator=(const KExiv2Data&);
public:
// Declared as public due to use in KExiv2Priv class
class Private;
private:
QSharedDataPointer<Private> d;
friend class KExiv2;
};
} // NameSpace KExiv2Iface
#endif /* KEXIV2_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,989 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-15
* @brief GPS manipulation methods
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
* @author Copyright (C) 2010-2012 by Michael G. Hansen
* <a href="mailto:mike at mghansen dot de">mike at mghansen dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2.h"
#include "kexiv2_p.h"
// C++ includes
#include <climits>
#include <cmath>
#include <math.h>
namespace KExiv2Iface
{
bool KExiv2::getGPSInfo(double& altitude, double& latitude, double& longitude) const
{
// Some GPS device do not set Altitude. So a valid GPS position can be with a zero value.
// No need to check return value.
getGPSAltitude(&altitude);
if (!getGPSLatitudeNumber(&latitude))
return false;
if (!getGPSLongitudeNumber(&longitude))
return false;
return true;
}
bool KExiv2::getGPSLatitudeNumber(double* const latitude) const
{
try
{
*latitude=0.0;
// Try XMP first. Reason: XMP in sidecar may be more up-to-date than EXIF in original image.
if ( convertFromGPSCoordinateString(getXmpTagString("Xmp.exif.GPSLatitude"), latitude) )
return true;
// Now try to get the reference from Exif.
const QByteArray latRef = getExifTagData("Exif.GPSInfo.GPSLatitudeRef");
if (!latRef.isEmpty())
{
Exiv2::ExifKey exifKey("Exif.GPSInfo.GPSLatitude");
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifData::iterator it = exifData.findKey(exifKey);
if (it != exifData.end() && (*it).count() == 3)
{
// Latitude decoding from Exif.
double num, den, min, sec;
num = (double)((*it).toRational(0).first);
den = (double)((*it).toRational(0).second);
if (den == 0)
return false;
*latitude = num/den;
num = (double)((*it).toRational(1).first);
den = (double)((*it).toRational(1).second);
if (den == 0)
return false;
min = num/den;
if (min != -1.0)
*latitude = *latitude + min/60.0;
num = (double)((*it).toRational(2).first);
den = (double)((*it).toRational(2).second);
if (den == 0)
{
// be relaxed and accept 0/0 seconds. See #246077.
if (num == 0)
den = 1;
else
return false;
}
sec = num/den;
if (sec != -1.0)
*latitude = *latitude + sec/3600.0;
}
else
{
return false;
}
if (latRef[0] == 'S')
*latitude *= -1.0;
return true;
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get GPS tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::getGPSLongitudeNumber(double* const longitude) const
{
try
{
*longitude=0.0;
// Try XMP first. Reason: XMP in sidecar may be more up-to-date than EXIF in original image.
if ( convertFromGPSCoordinateString(getXmpTagString("Xmp.exif.GPSLongitude"), longitude) )
return true;
// Now try to get the reference from Exif.
const QByteArray lngRef = getExifTagData("Exif.GPSInfo.GPSLongitudeRef");
if (!lngRef.isEmpty())
{
// Longitude decoding from Exif.
Exiv2::ExifKey exifKey2("Exif.GPSInfo.GPSLongitude");
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifData::iterator it = exifData.findKey(exifKey2);
if (it != exifData.end() && (*it).count() == 3)
{
/// @todo Decoding of latitude and longitude works in the same way,
/// code here can be put in a separate function
double num, den;
num = (double)((*it).toRational(0).first);
den = (double)((*it).toRational(0).second);
if (den == 0)
{
return false;
}
*longitude = num/den;
num = (double)((*it).toRational(1).first);
den = (double)((*it).toRational(1).second);
if (den == 0)
{
return false;
}
const double min = num/den;
if (min != -1.0)
{
*longitude = *longitude + min/60.0;
}
num = (double)((*it).toRational(2).first);
den = (double)((*it).toRational(2).second);
if (den == 0)
{
// be relaxed and accept 0/0 seconds. See #246077.
if (num == 0)
den = 1;
else
return false;
}
const double sec = num/den;
if (sec != -1.0)
{
*longitude = *longitude + sec/3600.0;
}
}
else
{
return false;
}
if (lngRef[0] == 'W')
{
*longitude *= -1.0;
}
return true;
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get GPS tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::getGPSAltitude(double* const altitude) const
{
try
{
double num, den;
*altitude=0.0;
// Try XMP first. Reason: XMP in sidecar may be more up-to-date than EXIF in original image.
const QString altRefXmp = getXmpTagString("Xmp.exif.GPSAltitudeRef");
if (!altRefXmp.isEmpty())
{
const QString altXmp = getXmpTagString("Xmp.exif.GPSAltitude");
if (!altXmp.isEmpty())
{
num = altXmp.section('/', 0, 0).toDouble();
den = altXmp.section('/', 1, 1).toDouble();
if (den == 0)
return false;
*altitude = num/den;
if (altRefXmp == QString("1"))
*altitude *= -1.0;
return true;
}
}
// Get the reference from Exif (above/below sea level)
const QByteArray altRef = getExifTagData("Exif.GPSInfo.GPSAltitudeRef");
if (!altRef.isEmpty())
{
// Altitude decoding from Exif.
Exiv2::ExifKey exifKey3("Exif.GPSInfo.GPSAltitude");
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifData::iterator it = exifData.findKey(exifKey3);
if (it != exifData.end() && (*it).count())
{
num = (double)((*it).toRational(0).first);
den = (double)((*it).toRational(0).second);
if (den == 0)
return false;
*altitude = num/den;
}
else
{
return false;
}
if (altRef[0] == '1')
*altitude *= -1.0;
return true;
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get GPS tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QString KExiv2::getGPSLatitudeString() const
{
double latitude;
if (!getGPSLatitudeNumber(&latitude))
return QString();
return convertToGPSCoordinateString(true, latitude);
}
QString KExiv2::getGPSLongitudeString() const
{
double longitude;
if (!getGPSLongitudeNumber(&longitude))
return QString();
return convertToGPSCoordinateString(false, longitude);
}
bool KExiv2::initializeGPSInfo(const bool setProgramName)
{
if (!setProgramId(setProgramName))
return false;
try
{
// TODO: what happens if these already exist?
// Do all the easy constant ones first.
// GPSVersionID tag: standard says is should be four bytes: 02 00 00 00
// (and, must be present).
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::unsignedByte);
value->read("2 0 0 0");
d->exifMetadata().add(Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID"), value.get());
// Datum: the datum of the measured data. If not given, we insert WGS-84.
d->exifMetadata()["Exif.GPSInfo.GPSMapDatum"] = "WGS-84";
#ifdef _XMP_SUPPORT_
setXmpTagString("Xmp.exif.GPSVersionID", QString("2.0.0.0"), false);
setXmpTagString("Xmp.exif.GPSMapDatum", QString("WGS-84"), false);
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot initialize GPS data using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::setGPSInfo(const double altitude, const double latitude, const double longitude, const bool setProgramName)
{
return setGPSInfo(&altitude, latitude, longitude, setProgramName);
}
bool KExiv2::setGPSInfo(const double* const altitude, const double latitude, const double longitude, const bool setProgramName)
{
if (!setProgramId(setProgramName))
return false;
try
{
// In first, we need to clean up all existing GPS info.
removeGPSInfo();
// now re-initialize the GPS info:
if (!initializeGPSInfo(setProgramName))
return false;
char scratchBuf[100];
long int nom, denom;
long int deg, min;
// Now start adding data.
// ALTITUDE.
if (altitude)
{
// Altitude reference: byte "00" meaning "above sea level", "01" mening "behing sea level".
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::unsignedByte);
if ((*altitude) >= 0) value->read("0");
else value->read("1");
d->exifMetadata().add(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitudeRef"), value.get());
// And the actual altitude, as absolute value..
convertToRational(fabs(*altitude), &nom, &denom, 4);
snprintf(scratchBuf, 100, "%ld/%ld", nom, denom);
d->exifMetadata()["Exif.GPSInfo.GPSAltitude"] = scratchBuf;
#ifdef _XMP_SUPPORT_
setXmpTagString("Xmp.exif.GPSAltitudeRef", ((*altitude) >= 0) ? QString("0") : QString("1"), false);
setXmpTagString("Xmp.exif.GPSAltitude", QString(scratchBuf), false);
#endif // _XMP_SUPPORT_
}
// LATITUDE
// Latitude reference:
// latitude < 0 : "S"
// latitude > 0 : "N"
//
d->exifMetadata()["Exif.GPSInfo.GPSLatitudeRef"] = (latitude < 0 ) ? "S" : "N";
// Now the actual latitude itself.
// This is done as three rationals.
// I choose to do it as:
// dd/1 - degrees.
// mmmm/100 - minutes
// 0/1 - seconds
// Exif standard says you can do it with minutes
// as mm/1 and then seconds as ss/1, but its
// (slightly) more accurate to do it as
// mmmm/100 than to split it.
// We also absolute the value (with fabs())
// as the sign is encoded in LatRef.
// Further note: original code did not translate between
// dd.dddddd to dd mm.mm - that's why we now multiply
// by 6000 - x60 to get minutes, x1000000 to get to mmmm/1000000.
deg = (int)floor(fabs(latitude)); // Slice off after decimal.
min = (int)floor((fabs(latitude) - floor(fabs(latitude))) * 60000000);
snprintf(scratchBuf, 100, "%ld/1 %ld/1000000 0/1", deg, min);
d->exifMetadata()["Exif.GPSInfo.GPSLatitude"] = scratchBuf;
#ifdef _XMP_SUPPORT_
/** @todo The XMP spec does not mention Xmp.exif.GPSLatitudeRef,
* because the reference is included in Xmp.exif.GPSLatitude.
* Is there a historic reason for writing it anyway?
*/
setXmpTagString("Xmp.exif.GPSLatitudeRef", (latitude < 0) ? QString("S") : QString("N"), false);
setXmpTagString("Xmp.exif.GPSLatitude", convertToGPSCoordinateString(true, latitude), false);
#endif // _XMP_SUPPORT_
// LONGITUDE
// Longitude reference:
// longitude < 0 : "W"
// longitude > 0 : "E"
d->exifMetadata()["Exif.GPSInfo.GPSLongitudeRef"] = (longitude < 0 ) ? "W" : "E";
// Now the actual longitude itself.
// This is done as three rationals.
// I choose to do it as:
// dd/1 - degrees.
// mmmm/100 - minutes
// 0/1 - seconds
// Exif standard says you can do it with minutes
// as mm/1 and then seconds as ss/1, but its
// (slightly) more accurate to do it as
// mmmm/100 than to split it.
// We also absolute the value (with fabs())
// as the sign is encoded in LongRef.
// Further note: original code did not translate between
// dd.dddddd to dd mm.mm - that's why we now multiply
// by 6000 - x60 to get minutes, x1000000 to get to mmmm/1000000.
deg = (int)floor(fabs(longitude)); // Slice off after decimal.
min = (int)floor((fabs(longitude) - floor(fabs(longitude))) * 60000000);
snprintf(scratchBuf, 100, "%ld/1 %ld/1000000 0/1", deg, min);
d->exifMetadata()["Exif.GPSInfo.GPSLongitude"] = scratchBuf;
#ifdef _XMP_SUPPORT_
/** @todo The XMP spec does not mention Xmp.exif.GPSLongitudeRef,
* because the reference is included in Xmp.exif.GPSLongitude.
* Is there a historic reason for writing it anyway?
*/
setXmpTagString("Xmp.exif.GPSLongitudeRef", (longitude < 0) ? QString("W") : QString("E"), false);
setXmpTagString("Xmp.exif.GPSLongitude", convertToGPSCoordinateString(false, longitude), false);
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set Exif GPS tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::setGPSInfo(const double altitude, const QString& latitude, const QString& longitude, const bool setProgramName)
{
double longitudeValue, latitudeValue;
if (!convertFromGPSCoordinateString(latitude, &latitudeValue))
return false;
if (!convertFromGPSCoordinateString(longitude, &longitudeValue))
return false;
return setGPSInfo(&altitude, latitudeValue, longitudeValue, setProgramName);
}
bool KExiv2::removeGPSInfo(const bool setProgramName)
{
if (!setProgramId(setProgramName))
return false;
try
{
QStringList gpsTagsKeys;
for (Exiv2::ExifData::iterator it = d->exifMetadata().begin();
it != d->exifMetadata().end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key.section('.', 1, 1) == QString("GPSInfo"))
gpsTagsKeys.append(key);
}
for(QStringList::const_iterator it2 = gpsTagsKeys.constBegin(); it2 != gpsTagsKeys.constEnd(); ++it2)
{
Exiv2::ExifKey gpsKey((*it2).toAscii().constData());
Exiv2::ExifData::iterator it3 = d->exifMetadata().findKey(gpsKey);
if (it3 != d->exifMetadata().end())
d->exifMetadata().erase(it3);
}
#ifdef _XMP_SUPPORT_
/** @todo The XMP spec does not mention Xmp.exif.GPSLongitudeRef,
* and Xmp.exif.GPSLatitudeRef. But because we write them in setGPSInfo(),
* we should also remove them here.
*/
removeXmpTag("Xmp.exif.GPSLatitudeRef", false);
removeXmpTag("Xmp.exif.GPSLongitudeRef", false);
removeXmpTag("Xmp.exif.GPSVersionID", false);
removeXmpTag("Xmp.exif.GPSLatitude", false);
removeXmpTag("Xmp.exif.GPSLongitude", false);
removeXmpTag("Xmp.exif.GPSAltitudeRef", false);
removeXmpTag("Xmp.exif.GPSAltitude", false);
removeXmpTag("Xmp.exif.GPSTimeStamp", false);
removeXmpTag("Xmp.exif.GPSSatellites", false);
removeXmpTag("Xmp.exif.GPSStatus", false);
removeXmpTag("Xmp.exif.GPSMeasureMode", false);
removeXmpTag("Xmp.exif.GPSDOP", false);
removeXmpTag("Xmp.exif.GPSSpeedRef", false);
removeXmpTag("Xmp.exif.GPSSpeed", false);
removeXmpTag("Xmp.exif.GPSTrackRef", false);
removeXmpTag("Xmp.exif.GPSTrack", false);
removeXmpTag("Xmp.exif.GPSImgDirectionRef", false);
removeXmpTag("Xmp.exif.GPSImgDirection", false);
removeXmpTag("Xmp.exif.GPSMapDatum", false);
removeXmpTag("Xmp.exif.GPSDestLatitude", false);
removeXmpTag("Xmp.exif.GPSDestLongitude", false);
removeXmpTag("Xmp.exif.GPSDestBearingRef", false);
removeXmpTag("Xmp.exif.GPSDestBearing", false);
removeXmpTag("Xmp.exif.GPSDestDistanceRef", false);
removeXmpTag("Xmp.exif.GPSDestDistance", false);
removeXmpTag("Xmp.exif.GPSProcessingMethod", false);
removeXmpTag("Xmp.exif.GPSAreaInformation", false);
removeXmpTag("Xmp.exif.GPSDifferential", false);
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot remove Exif GPS tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
void KExiv2::convertToRational(const double number, long int* const numerator,
long int* const denominator, const int rounding)
{
// This function converts the given decimal number
// to a rational (fractional) number.
//
// Examples in comments use Number as 25.12345, Rounding as 4.
// Split up the number.
double whole = trunc(number);
double fractional = number - whole;
// Calculate the "number" used for rounding.
// This is 10^Digits - ie, 4 places gives us 10000.
double rounder = pow(10.0, rounding);
// Round the fractional part, and leave the number
// as greater than 1.
// To do this we: (for example)
// 0.12345 * 10000 = 1234.5
// floor(1234.5) = 1234 - now bigger than 1 - ready...
fractional = round(fractional * rounder);
// Convert the whole thing to a fraction.
// Fraction is:
// (25 * 10000) + 1234 251234
// ------------------- = ------ = 25.1234
// 10000 10000
double numTemp = (whole * rounder) + fractional;
double denTemp = rounder;
// Now we should reduce until we can reduce no more.
// Try simple reduction...
// if Num
// ----- = integer out then....
// Den
if (trunc(numTemp / denTemp) == (numTemp / denTemp))
{
// Divide both by Denominator.
numTemp /= denTemp;
denTemp /= denTemp;
}
// And, if that fails, brute force it.
while (1)
{
// Jump out if we can't integer divide one.
if ((numTemp / 2) != trunc(numTemp / 2)) break;
if ((denTemp / 2) != trunc(denTemp / 2)) break;
// Otherwise, divide away.
numTemp /= 2;
denTemp /= 2;
}
// Copy out the numbers.
*numerator = (int)numTemp;
*denominator = (int)denTemp;
}
void KExiv2::convertToRationalSmallDenominator(const double number, long int* const numerator, long int* const denominator)
{
// This function converts the given decimal number
// to a rational (fractional) number.
//
// This method, in contrast to the method above, will retrieve the smallest possible
// denominator. It is tested to retrieve the correct value for 1/x, with 0 < x <= 1000000.
// Note: This requires double precision, storing in float breaks some numbers (49, 59, 86,...)
// Split up the number.
double whole = trunc(number);
double fractional = number - whole;
/*
* Find best rational approximation to a double
* by C.B. Falconer, 2006-09-07. Released to public domain.
*
* Newsgroups: comp.lang.c, comp.programming
* From: CBFalconer <cbfalconer@yahoo.com>
* Date: Thu, 07 Sep 2006 17:35:30 -0400
* Subject: Rational approximations
*/
int lastnum = 500; // this is _not_ the largest possible denominator
long int num, approx, bestnum=0, bestdenom=1;
double value, error, leasterr, criterion;
value = fractional;
if (value == 0.0)
{
*numerator = (long int)whole;
*denominator = 1;
return;
}
criterion = 2 * value * DBL_EPSILON;
for (leasterr = value, num = 1; num < lastnum; ++num)
{
approx = (int)(num / value + 0.5);
error = fabs((double)num / approx - value);
if (error < leasterr)
{
bestnum = num;
bestdenom = approx;
leasterr = error;
if (leasterr <= criterion) break;
}
}
// add whole number part
if (bestdenom * whole > (double)INT_MAX)
{
// In some cases, we would generate an integer overflow.
// Fall back to Gilles's code which is better suited for such numbers.
convertToRational(number, numerator, denominator, 5);
}
else
{
bestnum += bestdenom * (long int)whole;
*numerator = bestnum;
*denominator = bestdenom;
}
}
QString KExiv2::convertToGPSCoordinateString(const long int numeratorDegrees, const long int denominatorDegrees,
const long int numeratorMinutes, const long int denominatorMinutes,
const long int numeratorSeconds, long int denominatorSeconds,
const char directionReference)
{
/**
* Precision:
* A second at sea level measures 30m for our purposes, a minute 1800m.
* (for more details, see http://en.wikipedia.org/wiki/Geographic_coordinate_system)
* This means with a decimal precision of 8 for minutes we get +/-0,018mm.
* (if I calculated correctly)
*/
QString coordinate;
// be relaxed with seconds of 0/0
if (denominatorSeconds == 0 && numeratorSeconds == 0)
denominatorSeconds = 1;
if (denominatorDegrees == 1 &&
denominatorMinutes == 1 &&
denominatorSeconds == 1)
{
// use form DDD,MM,SSk
coordinate = "%1,%2,%3%4";
coordinate = coordinate.arg(numeratorDegrees).arg(numeratorMinutes).arg(numeratorSeconds).arg(directionReference);
}
else if (denominatorDegrees == 1 &&
denominatorMinutes == 100 &&
denominatorSeconds == 1)
{
// use form DDD,MM.mmk
coordinate = "%1,%2%3";
double minutes = (double)numeratorMinutes / (double)denominatorMinutes;
minutes += (double)numeratorSeconds / 60.0;
QString minutesString = QString::number(minutes, 'f', 8);
while (minutesString.endsWith('0') && !minutesString.endsWith(".0"))
{
minutesString.chop(1);
}
coordinate = coordinate.arg(numeratorDegrees).arg(minutesString).arg(directionReference);
}
else if (denominatorDegrees == 0 ||
denominatorMinutes == 0 ||
denominatorSeconds == 0)
{
// Invalid. 1/0 is everything but 0. As is 0/0.
return QString();
}
else
{
// use form DDD,MM.mmk
coordinate = "%1,%2%3";
double degrees = (double)numeratorDegrees / (double)denominatorDegrees;
double wholeDegrees = trunc(degrees);
double minutes = (double)numeratorMinutes / (double)denominatorMinutes;
minutes += (degrees - wholeDegrees) * 60.0;
minutes += ((double)numeratorSeconds / (double)denominatorSeconds) / 60.0;
QString minutesString = QString::number(minutes, 'f', 8);
while (minutesString.endsWith('0') && !minutesString.endsWith(".0"))
{
minutesString.chop(1);
}
coordinate = coordinate.arg((int)wholeDegrees).arg(minutesString).arg(directionReference);
}
return coordinate;
}
QString KExiv2::convertToGPSCoordinateString(const bool isLatitude, double coordinate)
{
if (coordinate < -360.0 || coordinate > 360.0)
return QString();
QString coordinateString;
char directionReference;
if (isLatitude)
{
if (coordinate < 0)
directionReference = 'S';
else
directionReference = 'N';
}
else
{
if (coordinate < 0)
directionReference = 'W';
else
directionReference = 'E';
}
// remove sign
coordinate = fabs(coordinate);
int degrees = (int)floor(coordinate);
// get fractional part
coordinate = coordinate - (double)(degrees);
// To minutes
double minutes = coordinate * 60.0;
// use form DDD,MM.mmk
coordinateString = "%1,%2%3";
coordinateString = coordinateString.arg(degrees);
coordinateString = coordinateString.arg(minutes, 0, 'f', 8).arg(directionReference);
return coordinateString;
}
bool KExiv2::convertFromGPSCoordinateString(const QString& gpsString,
long int* const numeratorDegrees, long int* const denominatorDegrees,
long int* const numeratorMinutes, long int* const denominatorMinutes,
long int* const numeratorSeconds, long int* const denominatorSeconds,
char* const directionReference)
{
if (gpsString.isEmpty())
return false;
*directionReference = gpsString.at(gpsString.length() - 1).toUpper().toLatin1();
QString coordinate = gpsString.left(gpsString.length() - 1);
QStringList parts = coordinate.split(',');
if (parts.size() == 2)
{
// form DDD,MM.mmk
*denominatorDegrees = 1;
*denominatorMinutes = 1000000;
*denominatorSeconds = 1;
*numeratorDegrees = parts[0].toLong();
double minutes = parts[1].toDouble();
minutes *= 1000000;
*numeratorMinutes = (long)round(minutes);
*numeratorSeconds = 0;
return true;
}
else if (parts.size() == 3)
{
// use form DDD,MM,SSk
*denominatorDegrees = 1;
*denominatorMinutes = 1;
*denominatorSeconds = 1;
*numeratorDegrees = parts[0].toLong();
*numeratorMinutes = parts[1].toLong();
*numeratorSeconds = parts[2].toLong();
return true;
}
else
{
return false;
}
}
bool KExiv2::convertFromGPSCoordinateString(const QString& gpsString, double* const degrees)
{
if (gpsString.isEmpty())
return false;
char directionReference = gpsString.at(gpsString.length() - 1).toUpper().toLatin1();
QString coordinate = gpsString.left(gpsString.length() - 1);
QStringList parts = coordinate.split(',');
if (parts.size() == 2)
{
// form DDD,MM.mmk
*degrees = parts[0].toLong();
*degrees += parts[1].toDouble() / 60.0;
if (directionReference == 'W' || directionReference == 'S')
*degrees *= -1.0;
return true;
}
else if (parts.size() == 3)
{
// use form DDD,MM,SSk
*degrees = parts[0].toLong();
*degrees += parts[1].toLong() / 60.0;
*degrees += parts[2].toLong() / 3600.0;
if (directionReference == 'W' || directionReference == 'S')
*degrees *= -1.0;
return true;
}
else
{
return false;
}
}
bool KExiv2::convertToUserPresentableNumbers(const QString& gpsString,
int* const degrees, int* const minutes,
double* const seconds, char* const directionReference)
{
if (gpsString.isEmpty())
return false;
*directionReference = gpsString.at(gpsString.length() - 1).toUpper().toLatin1();
QString coordinate = gpsString.left(gpsString.length() - 1);
QStringList parts = coordinate.split(',');
if (parts.size() == 2)
{
// form DDD,MM.mmk
*degrees = parts[0].toInt();
double fractionalMinutes = parts[1].toDouble();
*minutes = (int)trunc(fractionalMinutes);
*seconds = (fractionalMinutes - (double)(*minutes)) * 60.0;
return true;
}
else if (parts.size() == 3)
{
// use form DDD,MM,SSk
*degrees = parts[0].toInt();
*minutes = parts[1].toInt();
*seconds = (double)parts[2].toInt();
return true;
}
else
{
return false;
}
}
void KExiv2::convertToUserPresentableNumbers(const bool isLatitude, double coordinate,
int* const degrees, int* const minutes,
double* const seconds, char* const directionReference)
{
if (isLatitude)
{
if (coordinate < 0)
*directionReference = 'S';
else
*directionReference = 'N';
}
else
{
if (coordinate < 0)
*directionReference = 'W';
else
*directionReference = 'E';
}
// remove sign
coordinate = fabs(coordinate);
*degrees = (int)floor(coordinate);
// get fractional part
coordinate = coordinate - (double)(*degrees);
// To minutes
coordinate *= 60.0;
*minutes = (int)floor(coordinate);
// get fractional part
coordinate = coordinate - (double)(*minutes);
// To seconds
coordinate *= 60.0;
*seconds = coordinate;
}
} // NameSpace KExiv2Iface

View file

@ -0,0 +1,967 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-15
* @brief Common metadata image information manipulation methods
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2.h"
#include "kexiv2_p.h"
// Local includes
#include "rotationmatrix.h"
namespace KExiv2Iface
{
bool KExiv2::setImageProgramId(const QString& program, const QString& version) const
{
try
{
QString software(program);
software.append("-");
software.append(version);
// Set program info into Exif.Image.ProcessingSoftware tag (only available with Exiv2 >= 0.14.0).
d->exifMetadata()["Exif.Image.ProcessingSoftware"] = std::string(software.toAscii().constData());
// See B.K.O #142564: Check if Exif.Image.Software already exist. If yes, do not touch this tag.
if (!d->exifMetadata().empty())
{
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifKey key("Exif.Image.Software");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it == exifData.end())
d->exifMetadata()["Exif.Image.Software"] = std::string(software.toAscii().constData());
}
// set program info into XMP tags.
#ifdef _XMP_SUPPORT_
if (!d->xmpMetadata().empty())
{
// Only create Xmp.xmp.CreatorTool if it do not exist.
Exiv2::XmpData xmpData(d->xmpMetadata());
Exiv2::XmpKey key("Xmp.xmp.CreatorTool");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it == xmpData.end())
setXmpTagString("Xmp.xmp.CreatorTool", software, false);
}
setXmpTagString("Xmp.tiff.Software", software, false);
#endif // _XMP_SUPPORT_
// Set program info into IPTC tags.
d->iptcMetadata()["Iptc.Application2.Program"] = std::string(program.toAscii().constData());
d->iptcMetadata()["Iptc.Application2.ProgramVersion"] = std::string(version.toAscii().constData());
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set Program identity into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QSize KExiv2::getImageDimensions() const
{
try
{
long width=-1, height=-1;
// Try to get Exif.Photo tags
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifKey key("Exif.Photo.PixelXDimension");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end() && it->count())
width = it->toLong();
Exiv2::ExifKey key2("Exif.Photo.PixelYDimension");
Exiv2::ExifData::iterator it2 = exifData.findKey(key2);
if (it2 != exifData.end() && it2->count())
height = it2->toLong();
if (width != -1 && height != -1)
return QSize(width, height);
// Try to get Exif.Image tags
width = -1;
height = -1;
Exiv2::ExifKey key3("Exif.Image.ImageWidth");
Exiv2::ExifData::iterator it3 = exifData.findKey(key3);
if (it3 != exifData.end() && it3->count())
width = it3->toLong();
Exiv2::ExifKey key4("Exif.Image.ImageLength");
Exiv2::ExifData::iterator it4 = exifData.findKey(key4);
if (it4 != exifData.end() && it4->count())
height = it4->toLong();
if (width != -1 && height != -1)
return QSize(width, height);
#ifdef _XMP_SUPPORT_
// Try to get Xmp.tiff tags
width = -1;
height = -1;
bool wOk = false;
bool hOk = false;
QString str = getXmpTagString("Xmp.tiff.ImageWidth");
if (!str.isEmpty())
width = str.toInt(&wOk);
str = getXmpTagString("Xmp.tiff.ImageLength");
if (!str.isEmpty())
height = str.toInt(&hOk);
if (wOk && hOk)
return QSize(width, height);
// Try to get Xmp.exif tags
width = -1;
height = -1;
wOk = false;
hOk = false;
str = getXmpTagString("Xmp.exif.PixelXDimension");
if (!str.isEmpty())
width = str.toInt(&wOk);
str = getXmpTagString("Xmp.exif.PixelYDimension");
if (!str.isEmpty())
height = str.toInt(&hOk);
if (wOk && hOk)
return QSize(width, height);
#endif // _XMP_SUPPORT_
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot parse image dimensions tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QSize();
}
bool KExiv2::setImageDimensions(const QSize& size, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
// Set Exif values.
// NOTE: see B.K.O #144604: need to cast to record an unsigned integer value.
d->exifMetadata()["Exif.Image.ImageWidth"] = static_cast<uint32_t>(size.width());
d->exifMetadata()["Exif.Image.ImageLength"] = static_cast<uint32_t>(size.height());
d->exifMetadata()["Exif.Photo.PixelXDimension"] = static_cast<uint32_t>(size.width());
d->exifMetadata()["Exif.Photo.PixelYDimension"] = static_cast<uint32_t>(size.height());
// Set Xmp values.
#ifdef _XMP_SUPPORT_
setXmpTagString("Xmp.tiff.ImageWidth", QString::number(size.width()), false);
setXmpTagString("Xmp.tiff.ImageLength", QString::number(size.height()), false);
setXmpTagString("Xmp.exif.PixelXDimension", QString::number(size.width()), false);
setXmpTagString("Xmp.exif.PixelYDimension", QString::number(size.height()), false);
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set image dimensions using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
KExiv2::ImageOrientation KExiv2::getImageOrientation() const
{
try
{
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifData::iterator it;
long orientation;
ImageOrientation imageOrient = ORIENTATION_NORMAL;
// -- Standard Xmp tag --------------------------------
#ifdef _XMP_SUPPORT_
bool ok = false;
QString str = getXmpTagString("Xmp.tiff.Orientation");
if (!str.isEmpty())
{
orientation = str.toLong(&ok);
if (ok)
{
kDebug() << "Orientation => Xmp.tiff.Orientation => " << (int)orientation;
return (ImageOrientation)orientation;
}
}
#endif // _XMP_SUPPORT_
// Because some camera set a wrong standard exif orientation tag,
// We need to check makernote tags in first!
// -- Minolta Cameras ----------------------------------
Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
it = exifData.findKey(minoltaKey1);
if (it != exifData.end() && it->count())
{
orientation = it->toLong();
kDebug() << "Orientation => Exif.MinoltaCs7D.Rotation => " << (int)orientation;
switch(orientation)
{
case 76:
imageOrient = ORIENTATION_ROT_90;
break;
case 82:
imageOrient = ORIENTATION_ROT_270;
break;
}
return imageOrient;
}
Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
it = exifData.findKey(minoltaKey2);
if (it != exifData.end() && it->count())
{
orientation = it->toLong();
kDebug() << "Orientation => Exif.MinoltaCs5D.Rotation => " << (int)orientation;
switch(orientation)
{
case 76:
imageOrient = ORIENTATION_ROT_90;
break;
case 82:
imageOrient = ORIENTATION_ROT_270;
break;
}
return imageOrient;
}
// -- Standard Exif tag --------------------------------
Exiv2::ExifKey keyStd("Exif.Image.Orientation");
it = exifData.findKey(keyStd);
if (it != exifData.end() && it->count())
{
orientation = it->toLong();
kDebug() << "Orientation => Exif.Image.Orientation => " << (int)orientation;
return (ImageOrientation)orientation;
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot parse Exif Orientation tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return ORIENTATION_UNSPECIFIED;
}
bool KExiv2::setImageOrientation(ImageOrientation orientation, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
if (orientation < ORIENTATION_UNSPECIFIED || orientation > ORIENTATION_ROT_270)
{
kDebug() << "Image orientation value is not correct!";
return false;
}
// Set Exif values.
d->exifMetadata()["Exif.Image.Orientation"] = static_cast<uint16_t>(orientation);
kDebug() << "Exif.Image.Orientation tag set to: " << (int)orientation;
// Set Xmp values.
#ifdef _XMP_SUPPORT_
setXmpTagString("Xmp.tiff.Orientation", QString::number((int)orientation), false);
#endif // _XMP_SUPPORT_
// -- Minolta/Sony Cameras ----------------------------------
// Minolta and Sony camera store image rotation in Makernote.
// We remove these information to prevent duplicate values.
Exiv2::ExifData::iterator it;
Exiv2::ExifKey minoltaKey1("Exif.MinoltaCs7D.Rotation");
it = d->exifMetadata().findKey(minoltaKey1);
if (it != d->exifMetadata().end())
{
d->exifMetadata().erase(it);
kDebug() << "Removing Exif.MinoltaCs7D.Rotation tag";
}
Exiv2::ExifKey minoltaKey2("Exif.MinoltaCs5D.Rotation");
it = d->exifMetadata().findKey(minoltaKey2);
if (it != d->exifMetadata().end())
{
d->exifMetadata().erase(it);
kDebug() << "Removing Exif.MinoltaCs5D.Rotation tag";
}
// -- Exif embedded thumbnail ----------------------------------
Exiv2::ExifKey thumbKey("Exif.Thumbnail.Orientation");
it = d->exifMetadata().findKey(thumbKey);
if (it != d->exifMetadata().end() && it->count())
{
RotationMatrix operation((KExiv2Iface::KExiv2::ImageOrientation)it->toLong());
operation *= orientation;
(*it) = static_cast<uint16_t>(operation.exifOrientation());
}
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set Exif Orientation tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
KExiv2::ImageColorWorkSpace KExiv2::getImageColorWorkSpace() const
{
// Check Exif values.
long exifColorSpace = -1;
if (!getExifTagLong("Exif.Photo.ColorSpace", exifColorSpace))
{
#ifdef _XMP_SUPPORT_
QVariant var = getXmpTagVariant("Xmp.exif.ColorSpace");
if (!var.isNull())
exifColorSpace = var.toInt();
#endif // _XMP_SUPPORT_
}
if (exifColorSpace == 1)
{
return WORKSPACE_SRGB; // as specified by standard
}
else if (exifColorSpace == 2)
{
return WORKSPACE_ADOBERGB; // not in the standard!
}
else
{
if (exifColorSpace == 65535)
{
// A lot of cameras set the Exif.Iop.InteroperabilityIndex,
// as documented for ExifTool
QString interopIndex = getExifTagString("Exif.Iop.InteroperabilityIndex");
if (!interopIndex.isNull())
{
if (interopIndex == "R03")
return WORKSPACE_ADOBERGB;
else if (interopIndex == "R98")
return WORKSPACE_SRGB;
}
}
// Note: Text EXIF ColorSpace tag may just not be present (NEF files)
// Nikon camera set Exif.Photo.ColorSpace to uncalibrated or just skip this field,
// then add additional information into the makernotes.
// Exif.Nikon3.ColorSpace: 1 => sRGB, 2 => AdobeRGB
long nikonColorSpace;
if (getExifTagLong("Exif.Nikon3.ColorSpace", nikonColorSpace))
{
if (nikonColorSpace == 1)
return WORKSPACE_SRGB;
else if (nikonColorSpace == 2)
return WORKSPACE_ADOBERGB;
}
// Exif.Nikon3.ColorMode is set to "MODE2" for AdobeRGB, but there are sometimes two ColorMode fields
// in a NEF, with the first one "COLOR" and the second one "MODE2"; but in this case, ColorSpace (above) was set.
if (getExifTagString("Exif.Nikon3.ColorMode").contains("MODE2"))
return WORKSPACE_ADOBERGB;
//TODO: This makernote tag (0x00b4) must be added to libexiv2
/*
long canonColorSpace;
if (getExifTagLong("Exif.Canon.ColorSpace", canonColorSpace))
{
if (canonColorSpace == 1)
return WORKSPACE_SRGB;
else if (canonColorSpace == 2)
return WORKSPACE_ADOBERGB;
}
*/
// TODO : add more Makernote parsing here ...
if (exifColorSpace == 65535)
return WORKSPACE_UNCALIBRATED;
}
return WORKSPACE_UNSPECIFIED;
}
bool KExiv2::setImageColorWorkSpace(ImageColorWorkSpace workspace, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
// Set Exif value.
d->exifMetadata()["Exif.Photo.ColorSpace"] = static_cast<uint16_t>(workspace);
// Set Xmp value.
#ifdef _XMP_SUPPORT_
setXmpTagString("Xmp.exif.ColorSpace", QString::number((int)workspace), false);
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set Exif color workspace tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QDateTime KExiv2::getImageDateTime() const
{
try
{
// In first, trying to get Date & time from Exif tags.
if (!d->exifMetadata().empty())
{
Exiv2::ExifData exifData(d->exifMetadata());
{
Exiv2::ExifKey key("Exif.Photo.DateTimeOriginal");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Exif.Photo.DateTimeOriginal => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::ExifKey key("Exif.Photo.DateTimeDigitized");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Exif.Photo.DateTimeDigitized => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::ExifKey key("Exif.Image.DateTime");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Exif.Image.DateTime => " << dateTime;
return dateTime;
}
}
}
}
// In second, trying to get Date & time from Xmp tags.
#ifdef _XMP_SUPPORT_
if (!d->xmpMetadata().empty())
{
Exiv2::XmpData xmpData(d->xmpMetadata());
{
Exiv2::XmpKey key("Xmp.exif.DateTimeOriginal");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.exif.DateTimeOriginal => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.exif.DateTimeDigitized");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.exif.DateTimeDigitized => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.photoshop.DateCreated");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.photoshop.DateCreated => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.xmp.CreateDate");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.xmp.CreateDate => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.tiff.DateTime");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.tiff.DateTime => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.xmp.ModifyDate");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.xmp.ModifyDate => " << dateTime;
return dateTime;
}
}
}
{
Exiv2::XmpKey key("Xmp.xmp.MetadataDate");
Exiv2::XmpData::iterator it = xmpData.findKey(key);
if (it != xmpData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime => Xmp.xmp.MetadataDate => " << dateTime;
return dateTime;
}
}
}
}
#endif // _XMP_SUPPORT_
// In third, trying to get Date & time from Iptc tags.
if (!d->iptcMetadata().empty())
{
Exiv2::IptcData iptcData(d->iptcMetadata());
// Try creation Iptc date & time entries.
Exiv2::IptcKey keyDateCreated("Iptc.Application2.DateCreated");
Exiv2::IptcData::iterator it = iptcData.findKey(keyDateCreated);
if (it != iptcData.end())
{
QString IptcDateCreated(it->toString().c_str());
Exiv2::IptcKey keyTimeCreated("Iptc.Application2.TimeCreated");
Exiv2::IptcData::iterator it2 = iptcData.findKey(keyTimeCreated);
if (it2 != iptcData.end())
{
QString IptcTimeCreated(it2->toString().c_str());
QDate date = QDate::fromString(IptcDateCreated, Qt::ISODate);
QTime time = QTime::fromString(IptcTimeCreated, Qt::ISODate);
QDateTime dateTime = QDateTime(date, time);
if (dateTime.isValid())
{
kDebug() << "DateTime => Iptc.Application2.DateCreated => " << dateTime;
return dateTime;
}
}
}
// Try digitization Iptc date & time entries.
Exiv2::IptcKey keyDigitizationDate("Iptc.Application2.DigitizationDate");
Exiv2::IptcData::iterator it3 = iptcData.findKey(keyDigitizationDate);
if (it3 != iptcData.end())
{
QString IptcDateDigitization(it3->toString().c_str());
Exiv2::IptcKey keyDigitizationTime("Iptc.Application2.DigitizationTime");
Exiv2::IptcData::iterator it4 = iptcData.findKey(keyDigitizationTime);
if (it4 != iptcData.end())
{
QString IptcTimeDigitization(it4->toString().c_str());
QDate date = QDate::fromString(IptcDateDigitization, Qt::ISODate);
QTime time = QTime::fromString(IptcTimeDigitization, Qt::ISODate);
QDateTime dateTime = QDateTime(date, time);
if (dateTime.isValid())
{
kDebug() << "DateTime => Iptc.Application2.DigitizationDate => " << dateTime;
return dateTime;
}
}
}
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot parse Exif date & time tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QDateTime();
}
bool KExiv2::setImageDateTime(const QDateTime& dateTime, bool setDateTimeDigitized, bool setProgramName) const
{
if(!dateTime.isValid())
return false;
if (!setProgramId(setProgramName))
return false;
try
{
// In first we write date & time into Exif.
// DateTimeDigitized is set by slide scanners etc. when a picture is digitized.
// DateTimeOriginal specifies the date/time when the picture was taken.
// For digital cameras, these dates should be both set, and identical.
// Reference: http://www.exif.org/Exif2-2.PDF, chapter 4.6.5, table 4, section F.
const std::string &exifdatetime(dateTime.toString(QString("yyyy:MM:dd hh:mm:ss")).toAscii().constData());
d->exifMetadata()["Exif.Image.DateTime"] = exifdatetime;
d->exifMetadata()["Exif.Photo.DateTimeOriginal"] = exifdatetime;
if(setDateTimeDigitized)
d->exifMetadata()["Exif.Photo.DateTimeDigitized"] = exifdatetime;
#ifdef _XMP_SUPPORT_
// In second we write date & time into Xmp.
const std::string &xmpdatetime(dateTime.toString(Qt::ISODate).toAscii().constData());
Exiv2::Value::AutoPtr xmpTxtVal = Exiv2::Value::create(Exiv2::xmpText);
xmpTxtVal->read(xmpdatetime);
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.exif.DateTimeOriginal"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.photoshop.DateCreated"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.tiff.DateTime"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.CreateDate"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.MetadataDate"), xmpTxtVal.get());
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.xmp.ModifyDate"), xmpTxtVal.get());
if(setDateTimeDigitized)
d->xmpMetadata().add(Exiv2::XmpKey("Xmp.exif.DateTimeDigitized"), xmpTxtVal.get());
// Tag not updated:
// "Xmp.dc.DateTime" is a sequence of date relevant of dublin core change.
// This is not the picture date as well
#endif // _XMP_SUPPORT_
// In third we write date & time into Iptc.
const std::string &iptcdate(dateTime.date().toString(Qt::ISODate).toAscii().constData());
const std::string &iptctime(dateTime.time().toString(Qt::ISODate).toAscii().constData());
d->iptcMetadata()["Iptc.Application2.DateCreated"] = iptcdate;
d->iptcMetadata()["Iptc.Application2.TimeCreated"] = iptctime;
if(setDateTimeDigitized)
{
d->iptcMetadata()["Iptc.Application2.DigitizationDate"] = iptcdate;
d->iptcMetadata()["Iptc.Application2.DigitizationTime"] = iptctime;
}
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot set Date & Time into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QDateTime KExiv2::getDigitizationDateTime(bool fallbackToCreationTime) const
{
try
{
// In first, trying to get Date & time from Exif tags.
if (!d->exifMetadata().empty())
{
// Try Exif date time digitized.
Exiv2::ExifData exifData(d->exifMetadata());
Exiv2::ExifKey key("Exif.Photo.DateTimeDigitized");
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end())
{
QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
if (dateTime.isValid())
{
kDebug() << "DateTime (Exif digitalized): " << dateTime.toString().toAscii().constData();
return dateTime;
}
}
}
// In second, trying to get Date & time from Iptc tags.
if (!d->iptcMetadata().empty())
{
// Try digitization Iptc date time entries.
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcKey keyDigitizationDate("Iptc.Application2.DigitizationDate");
Exiv2::IptcData::iterator it = iptcData.findKey(keyDigitizationDate);
if (it != iptcData.end())
{
QString IptcDateDigitization(it->toString().c_str());
Exiv2::IptcKey keyDigitizationTime("Iptc.Application2.DigitizationTime");
Exiv2::IptcData::iterator it2 = iptcData.findKey(keyDigitizationTime);
if (it2 != iptcData.end())
{
QString IptcTimeDigitization(it2->toString().c_str());
QDate date = QDate::fromString(IptcDateDigitization, Qt::ISODate);
QTime time = QTime::fromString(IptcTimeDigitization, Qt::ISODate);
QDateTime dateTime = QDateTime(date, time);
if (dateTime.isValid())
{
kDebug() << "Date (IPTC digitalized): " << dateTime.toString().toAscii().constData();
return dateTime;
}
}
}
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot parse Exif digitization date & time tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
if (fallbackToCreationTime)
return getImageDateTime();
else
return QDateTime();
}
bool KExiv2::getImagePreview(QImage& preview) const
{
try
{
// In first we trying to get from Iptc preview tag.
if (preview.loadFromData(getIptcTagData("Iptc.Application2.Preview")) )
return true;
// TODO : Added here Makernotes preview extraction when Exiv2 will be fixed for that.
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get image preview using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::setImagePreview(const QImage& preview, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
if (preview.isNull())
{
removeIptcTag("Iptc.Application2.Preview");
removeIptcTag("Iptc.Application2.PreviewFormat");
removeIptcTag("Iptc.Application2.PreviewVersion");
return true;
}
try
{
QByteArray data;
QBuffer buffer(&data);
buffer.open(QIODevice::WriteOnly);
// A little bit compressed preview jpeg image to limit IPTC size.
preview.save(&buffer, "JPEG");
kDebug() << "JPEG image preview size: (" << preview.width() << " x "
<< preview.height() << ") pixels - " << data.size() << " bytes";
Exiv2::DataValue val;
val.read((Exiv2::byte *)data.data(), data.size());
d->iptcMetadata()["Iptc.Application2.Preview"] = val;
// See http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf Appendix A for details.
d->iptcMetadata()["Iptc.Application2.PreviewFormat"] = 11; // JPEG
d->iptcMetadata()["Iptc.Application2.PreviewVersion"] = 1;
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get image preview using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
} // NameSpace KExiv2Iface

View file

@ -0,0 +1,883 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-09-15
* @brief Iptc manipulation methods
*
* @author Copyright (C) 2006-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2006-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2.h"
#include "kexiv2_p.h"
namespace KExiv2Iface
{
bool KExiv2::canWriteIptc(const QString& filePath)
{
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)
(QFile::encodeName(filePath)));
Exiv2::AccessMode mode = image->checkMode(Exiv2::mdIptc);
return (mode == Exiv2::amWrite || mode == Exiv2::amReadWrite);
}
catch(Exiv2::Error& e)
{
std::string s(e.what());
kError() << "Cannot check Iptc access mode using Exiv2 (Error #"
<< e.code() << ": " << s.c_str() << ")";
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::hasIptc() const
{
return !d->iptcMetadata().empty();
}
bool KExiv2::clearIptc() const
{
try
{
d->iptcMetadata().clear();
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot clear Iptc data using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QByteArray KExiv2::getIptc(bool addIrbHeader) const
{
try
{
if (!d->iptcMetadata().empty())
{
Exiv2::IptcData& iptc = d->iptcMetadata();
Exiv2::DataBuf c2;
if (addIrbHeader)
{
c2 = Exiv2::Photoshop::setIptcIrb(0, 0, iptc);
}
else
{
c2 = Exiv2::IptcParser::encode(d->iptcMetadata());
}
QByteArray data((const char*)c2.pData_, c2.size_);
return data;
}
}
catch(Exiv2::Error& e)
{
if (!d->filePath.isEmpty())
{
kError() << "From file " << d->filePath.toAscii().constData();
}
d->printExiv2ExceptionError("Cannot get Iptc data using Exiv2 ",e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QByteArray();
}
bool KExiv2::setIptc(const QByteArray& data) const
{
try
{
if (!data.isEmpty())
{
Exiv2::IptcParser::decode(d->iptcMetadata(), (const Exiv2::byte*)data.data(), data.size());
return (!d->iptcMetadata().empty());
}
}
catch(Exiv2::Error& e)
{
if (!d->filePath.isEmpty())
{
kError() << "From file " << d->filePath.toAscii().constData();
}
d->printExiv2ExceptionError("Cannot set Iptc data using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
KExiv2::MetaDataMap KExiv2::getIptcTagsDataList(const QStringList& iptcKeysFilter, bool invertSelection) const
{
if (d->iptcMetadata().empty())
return MetaDataMap();
try
{
Exiv2::IptcData iptcData = d->iptcMetadata();
iptcData.sortByKey();
QString ifDItemName;
MetaDataMap metaDataMap;
for (Exiv2::IptcData::iterator md = iptcData.begin(); md != iptcData.end(); ++md)
{
QString key = QString::fromLocal8Bit(md->key().c_str());
// Decode the tag value with a user friendly output.
std::ostringstream os;
os << *md;
QString value;
if (key == QString("Iptc.Envelope.CharacterSet"))
{
value = iptcData.detectCharset();
}
else
{
value = QString::fromUtf8(os.str().c_str());
}
// To make a string just on one line.
value.replace('\n', ' ');
// Some Iptc key are redondancy. check if already one exist...
MetaDataMap::iterator it = metaDataMap.find(key);
// We apply a filter to get only the Iptc tags that we need.
if (!iptcKeysFilter.isEmpty())
{
if (!invertSelection)
{
if (iptcKeysFilter.contains(key.section('.', 1, 1)))
{
if (it == metaDataMap.end())
{
metaDataMap.insert(key, value);
}
else
{
QString v = *it;
v.append(", ");
v.append(value);
metaDataMap.insert(key, v);
}
}
}
else
{
if (!iptcKeysFilter.contains(key.section('.', 1, 1)))
{
if (it == metaDataMap.end())
{
metaDataMap.insert(key, value);
}
else
{
QString v = *it;
v.append(", ");
v.append(value);
metaDataMap.insert(key, v);
}
}
}
}
else // else no filter at all.
{
if (it == metaDataMap.end())
{
metaDataMap.insert(key, value);
}
else
{
QString v = *it;
v.append(", ");
v.append(value);
metaDataMap.insert(key, v);
}
}
}
return metaDataMap;
}
catch (Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot parse Iptc metadata using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return MetaDataMap();
}
QString KExiv2::getIptcTagTitle(const char* iptcTagName)
{
try
{
std::string iptckey(iptcTagName);
Exiv2::IptcKey ik(iptckey);
return QString::fromLocal8Bit( Exiv2::IptcDataSets::dataSetTitle(ik.tag(), ik.record()) );
}
catch (Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get metadata tag title using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QString();
}
QString KExiv2::getIptcTagDescription(const char* iptcTagName)
{
try
{
std::string iptckey(iptcTagName);
Exiv2::IptcKey ik(iptckey);
return QString::fromLocal8Bit( Exiv2::IptcDataSets::dataSetDesc(ik.tag(), ik.record()) );
}
catch (Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get metadata tag description using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QString();
}
bool KExiv2::removeIptcTag(const char* iptcTagName, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
Exiv2::IptcData::iterator it = d->iptcMetadata().begin();
int i = 0;
while(it != d->iptcMetadata().end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString(iptcTagName))
{
it = d->iptcMetadata().erase(it);
++i;
}
else
{
++it;
}
};
if (i > 0)
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot remove Iptc tag using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
bool KExiv2::setIptcTagData(const char* iptcTagName, const QByteArray& data, bool setProgramName) const
{
if (data.isEmpty())
return false;
if (!setProgramId(setProgramName))
return false;
try
{
Exiv2::DataValue val((Exiv2::byte *)data.data(), data.size());
d->iptcMetadata()[iptcTagName] = val;
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot set Iptc tag data into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QByteArray KExiv2::getIptcTagData(const char* iptcTagName) const
{
try
{
Exiv2::IptcKey iptcKey(iptcTagName);
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.findKey(iptcKey);
if (it != iptcData.end())
{
char* const s = new char[(*it).size()];
(*it).copy((Exiv2::byte*)s, Exiv2::bigEndian);
QByteArray data(s, (*it).size());
delete [] s;
return data;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
.arg(iptcTagName), e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QByteArray();
}
QString KExiv2::getIptcTagString(const char* iptcTagName, bool escapeCR) const
{
try
{
Exiv2::IptcKey iptcKey(iptcTagName);
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.findKey(iptcKey);
if (it != iptcData.end())
{
std::ostringstream os;
os << *it;
QString tagValue(os.str().c_str());
if (escapeCR)
tagValue.replace('\n', ' ');
return tagValue;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
.arg(iptcTagName), e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QString();
}
bool KExiv2::setIptcTagString(const char* iptcTagName, const QString& value, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
d->iptcMetadata()[iptcTagName] = std::string(value.toUtf8().constData());
// Make sure we have set the charset to UTF-8
d->iptcMetadata()["Iptc.Envelope.CharacterSet"] = "\33%G";
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot set Iptc tag string into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QStringList KExiv2::getIptcTagsStringList(const char* iptcTagName, bool escapeCR) const
{
try
{
if (!d->iptcMetadata().empty())
{
QStringList values;
Exiv2::IptcData iptcData(d->iptcMetadata());
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString(iptcTagName))
{
QString tagValue = QString::fromUtf8(it->toString().c_str());
if (escapeCR)
tagValue.replace('\n', ' ');
values.append(tagValue);
}
}
return values;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError(QString("Cannot find Iptc key '%1' into image using Exiv2 ")
.arg(iptcTagName), e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QStringList();
}
bool KExiv2::setIptcTagsStringList(const char* iptcTagName, int maxSize,
const QStringList& oldValues, const QStringList& newValues,
bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
QStringList oldvals = oldValues;
QStringList newvals = newValues;
kDebug() << d->filePath.toAscii().constData() << " : " << iptcTagName
<< " => " << newvals.join(",").toAscii().constData();
// Remove all old values.
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.begin();
while(it != iptcData.end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
QString val = QString::fromUtf8(it->toString().c_str());
// Also remove new values to avoid duplicates. They will be added again below.
if ( key == QString(iptcTagName) &&
(oldvals.contains(val) || newvals.contains(val))
)
it = iptcData.erase(it);
else
++it;
};
// Add new values.
Exiv2::IptcKey iptcTag(iptcTagName);
for (QStringList::iterator it = newvals.begin(); it != newvals.end(); ++it)
{
QString key = *it;
key.truncate(maxSize);
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
val->read(key.toUtf8().constData());
iptcData.add(iptcTag, val.get());
}
d->iptcMetadata() = iptcData;
// Make sure character set is UTF-8
setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError(QString("Cannot set Iptc key '%1' into image using Exiv2 ")
.arg(iptcTagName), e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QStringList KExiv2::getIptcKeywords() const
{
try
{
if (!d->iptcMetadata().empty())
{
QStringList keywords;
Exiv2::IptcData iptcData(d->iptcMetadata());
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString("Iptc.Application2.Keywords"))
{
QString val = QString::fromUtf8(it->toString().c_str());
keywords.append(val);
}
}
kDebug() << d->filePath << " ==> Read Iptc Keywords: " << keywords;
return keywords;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get Iptc Keywords from image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QStringList();
}
bool KExiv2::setIptcKeywords(const QStringList& oldKeywords, const QStringList& newKeywords,
bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
QStringList oldkeys = oldKeywords;
QStringList newkeys = newKeywords;
kDebug() << d->filePath << " ==> New Iptc Keywords: " << newkeys;
// Remove all old keywords.
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.begin();
while(it != iptcData.end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
QString val = QString::fromUtf8(it->toString().c_str());
// Also remove new keywords to avoid duplicates. They will be added again below.
if ( key == QString("Iptc.Application2.Keywords") &&
(oldKeywords.contains(val) || newKeywords.contains(val))
)
it = iptcData.erase(it);
else
++it;
};
// Add new keywords. Note that Keywords Iptc tag is limited to 64 char but can be redondant.
Exiv2::IptcKey iptcTag("Iptc.Application2.Keywords");
for (QStringList::iterator it = newkeys.begin(); it != newkeys.end(); ++it)
{
QString key = *it;
key.truncate(64);
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
val->read(key.toUtf8().constData());
iptcData.add(iptcTag, val.get());
}
d->iptcMetadata() = iptcData;
// Make sure character set is UTF-8
setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot set Iptc Keywords into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QStringList KExiv2::getIptcSubjects() const
{
try
{
if (!d->iptcMetadata().empty())
{
QStringList subjects;
Exiv2::IptcData iptcData(d->iptcMetadata());
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString("Iptc.Application2.Subject"))
{
QString val(it->toString().c_str());
subjects.append(val);
}
}
return subjects;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get Iptc Subjects from image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QStringList();
}
bool KExiv2::setIptcSubjects(const QStringList& oldSubjects, const QStringList& newSubjects,
bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
QStringList oldDef = oldSubjects;
QStringList newDef = newSubjects;
// Remove all old subjects.
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.begin();
while(it != iptcData.end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
QString val = QString::fromUtf8(it->toString().c_str());
if (key == QString("Iptc.Application2.Subject") && oldDef.contains(val))
it = iptcData.erase(it);
else
++it;
};
// Add new subjects. Note that Keywords Iptc tag is limited to 236 char but can be redondant.
Exiv2::IptcKey iptcTag("Iptc.Application2.Subject");
for (QStringList::iterator it = newDef.begin(); it != newDef.end(); ++it)
{
QString key = *it;
key.truncate(236);
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
val->read(key.toUtf8().constData());
iptcData.add(iptcTag, val.get());
}
d->iptcMetadata() = iptcData;
// Make sure character set is UTF-8
setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot set Iptc Subjects into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
QStringList KExiv2::getIptcSubCategories() const
{
try
{
if (!d->iptcMetadata().empty())
{
QStringList subCategories;
Exiv2::IptcData iptcData(d->iptcMetadata());
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString("Iptc.Application2.SuppCategory"))
{
QString val(it->toString().c_str());
subCategories.append(val);
}
}
return subCategories;
}
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get Iptc Sub Categories from image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return QStringList();
}
bool KExiv2::setIptcSubCategories(const QStringList& oldSubCategories, const QStringList& newSubCategories,
bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
QStringList oldkeys = oldSubCategories;
QStringList newkeys = newSubCategories;
// Remove all old Sub Categories.
Exiv2::IptcData iptcData(d->iptcMetadata());
Exiv2::IptcData::iterator it = iptcData.begin();
while(it != iptcData.end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
QString val = QString::fromUtf8(it->toString().c_str());
if (key == QString("Iptc.Application2.SuppCategory") && oldSubCategories.contains(val))
it = iptcData.erase(it);
else
++it;
};
// Add new Sub Categories. Note that SubCategories Iptc tag is limited to 32
// characters but can be redondant.
Exiv2::IptcKey iptcTag("Iptc.Application2.SuppCategory");
for (QStringList::iterator it = newkeys.begin(); it != newkeys.end(); ++it)
{
QString key = *it;
key.truncate(32);
Exiv2::Value::AutoPtr val = Exiv2::Value::create(Exiv2::string);
val->read(key.toUtf8().constData());
iptcData.add(iptcTag, val.get());
}
d->iptcMetadata() = iptcData;
// Make sure character set is UTF-8
setIptcTagString("Iptc.Envelope.CharacterSet", "\33%G", false);
return true;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot set Iptc Sub Categories into image using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return false;
}
KExiv2::TagsMap KExiv2::getIptcTagsList() const
{
try
{
QList<const Exiv2::DataSet*> tags;
tags << Exiv2::IptcDataSets::envelopeRecordList()
<< Exiv2::IptcDataSets::application2RecordList();
TagsMap tagsMap;
for (QList<const Exiv2::DataSet*>::iterator it = tags.begin(); it != tags.end(); ++it)
{
do
{
QString key = QLatin1String( Exiv2::IptcKey( (*it)->number_, (*it)->recordId_ ).key().c_str() );
QStringList values;
values << (*it)->name_ << (*it)->title_ << (*it)->desc_;
tagsMap.insert(key, values);
++(*it);
}
while((*it)->number_ != 0xffff);
}
return tagsMap;
}
catch(Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot get Iptc Tags list using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
return TagsMap();
}
} // NameSpace KExiv2Iface

View file

@ -0,0 +1,214 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-11-14
* @brief Embedded preview loading
*
* @author Copyright (C) 2009-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2009-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "kexiv2previews.h"
// Local includes
#include "kexiv2_p.h"
#include "kexiv2.h"
namespace KExiv2Iface
{
class KExiv2Previews::Private
{
public:
Private()
{
manager = 0;
}
~Private()
{
delete manager;
}
void load(Exiv2::Image::AutoPtr image_)
{
image = image_;
image->readMetadata();
manager = new Exiv2::PreviewManager(*image);
Exiv2::PreviewPropertiesList props = manager->getPreviewProperties();
// reverse order of list, which is smallest-first
Exiv2::PreviewPropertiesList::reverse_iterator it;
for (it = props.rbegin() ; it != props.rend() ; ++it)
{
properties << *it;
}
}
public:
Exiv2::Image::AutoPtr image;
Exiv2::PreviewManager* manager;
QList<Exiv2::PreviewProperties> properties;
};
KExiv2Previews::KExiv2Previews(const QString& filePath)
: d(new Private)
{
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((const char*)(QFile::encodeName(filePath)));
d->load(image);
}
catch( Exiv2::Error& e )
{
KExiv2::Private::printExiv2ExceptionError("Cannot load metadata using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
}
KExiv2Previews::KExiv2Previews(const QByteArray& imgData)
: d(new Private)
{
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
d->load(image);
}
catch( Exiv2::Error& e )
{
KExiv2::Private::printExiv2ExceptionError("Cannot load metadata using Exiv2 ", e);
}
catch(...)
{
kError() << "Default exception from Exiv2";
}
}
KExiv2Previews::~KExiv2Previews()
{
delete d;
}
bool KExiv2Previews::isEmpty()
{
return d->properties.isEmpty();
}
QSize KExiv2Previews::originalSize() const
{
if (d->image.get())
return QSize(d->image->pixelWidth(), d->image->pixelHeight());
return QSize();
}
QString KExiv2Previews::originalMimeType() const
{
if (d->image.get())
return d->image->mimeType().c_str();
return QString();
}
int KExiv2Previews::count()
{
return d->properties.size();
}
int KExiv2Previews::dataSize(int index)
{
if (index < 0 || index >= size()) return 0;
return d->properties[index].size_;
}
int KExiv2Previews::width(int index)
{
if (index < 0 || index >= size()) return 0;
return d->properties[index].width_;
}
int KExiv2Previews::height(int index)
{
if (index < 0 || index >= size()) return 0;
return d->properties[index].height_;
}
QString KExiv2Previews::mimeType(int index)
{
if (index < 0 || index >= size()) return 0;
return QString::fromLatin1(d->properties[index].mimeType_.c_str());
}
QString KExiv2Previews::fileExtension(int index)
{
if (index < 0 || index >= size()) return 0;
return QString::fromLatin1(d->properties[index].extension_.c_str());
}
QByteArray KExiv2Previews::data(int index)
{
if (index < 0 || index >= size()) return QByteArray();
kDebug() << "index: " << index;
kDebug() << "d->properties: " << count();
try
{
Exiv2::PreviewImage image = d->manager->getPreviewImage(d->properties[index]);
return QByteArray((const char*)image.pData(), image.size());
}
catch( Exiv2::Error& e )
{
KExiv2::Private::printExiv2ExceptionError("Cannot load metadata using Exiv2 ", e);
return QByteArray();
}
catch(...)
{
kError() << "Default exception from Exiv2";
return QByteArray();
}
}
QImage KExiv2Previews::image(int index)
{
QByteArray previewData = data(index);
QImage image;
if (!image.loadFromData(previewData))
return QImage();
return image;
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,106 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-11-14
* @brief Embedded preview loading
*
* @author Copyright (C) 2009-2014 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2009-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KEXIV2PREVIEWS
#define KEXIV2PREVIEWS
// Qt includes
#include <QtCore/QByteArray>
#include <QtCore/QSize>
#include <QtCore/QString>
// Local includes
#include "libkexiv2_export.h"
class QImage;
namespace KExiv2Iface
{
class KEXIV2_EXPORT KExiv2Previews
{
public:
/**
* Open the given file and scan for embedded preview images
*/
KExiv2Previews(const QString& filePath);
/**
* Open the given image data and scan the image for embedded preview images.
*/
KExiv2Previews(const QByteArray& imgData);
~KExiv2Previews();
/// Returns the pixel size of the original image, as read from the file (not the metadata).
QSize originalSize() const;
/// Returns the mimeType of the original image, detected from the file's content.
QString originalMimeType() const;
/// Returns if there are any preview images available
bool isEmpty();
/// Returns how many embedded previews are available
int count();
int size() { return count(); }
/**
* For each contained preview image, return the size
* of the image data in bytes, width and height of the preview,
* the mimeType and the file extension.
* Ensure that index < count().
* Previews are sorted by width*height, largest first.
*/
int dataSize(int index = 0);
int width(int index = 0);
int height(int index = 0);
QString mimeType(int index = 0);
QString fileExtension(int index = 0);
/**
* Retrieve the image data for the specified embedded preview image
*/
QByteArray data(int index = 0);
/**
* Loads the data of the specified preview and creates a QImage
* from this data. Returns a null QImage if the loading failed.
*/
QImage image(int index = 0);
private:
class Private;
Private* const d;
};
} // namespace KExiv2Iface
#endif // KEXIV2PREVIEWS

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
/** ===========================================================
* @file
*
* This file is part of the KDE project
*
* @brief Helper for exporting functions/classes from the shared library
*
* @author Copyright (C) 2007 David Faure <faure@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* ============================================================ */
#ifndef LIBKEXIV2_EXPORT_H
#define LIBKEXIV2_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <kdemacros.h>
#ifndef KEXIV2_EXPORT
# if defined(MAKE_KEXIV2_LIB)
/* We are building this library */
# define KEXIV2_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define KEXIV2_EXPORT KDE_IMPORT
# endif
#endif
# ifndef KEXIV2_EXPORT_DEPRECATED
# define KEXIV2_EXPORT_DEPRECATED KDE_DEPRECATED KEXIV2_EXPORT
# endif
#endif

View file

@ -0,0 +1,109 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-07-15
* @brief a text edit widget with click message.
*
* @author Copyright (C) 2009-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Qt includes
#include <QColor>
#include <QPalette>
#include <QPainter>
// Local includes
#include "moc_msgtextedit.cpp"
namespace KExiv2Iface
{
class MsgTextEdit::Private
{
public:
Private(){}
QString message;
};
MsgTextEdit::MsgTextEdit(QWidget* parent)
: KTextEdit(parent), d(new Private)
{
setAcceptRichText(false);
}
MsgTextEdit::~MsgTextEdit()
{
delete d;
}
QString MsgTextEdit::clickMessage() const
{
return d->message;
}
void MsgTextEdit::setClickMessage(const QString& msg)
{
d->message = msg;
viewport()->update();
}
void MsgTextEdit::setText(const QString& txt)
{
KTextEdit::setText(txt);
viewport()->update();
}
void MsgTextEdit::paintEvent(QPaintEvent* e)
{
KTextEdit::paintEvent(e);
if (toPlainText().isEmpty() && !hasFocus())
{
QPainter p(viewport());
QPen tmp = p.pen();
p.setPen(palette().color(QPalette::Disabled, QPalette::Text));
QRect cr = contentsRect();
p.drawText(cr, Qt::AlignTop, d->message);
p.setPen(tmp);
}
}
void MsgTextEdit::dropEvent(QDropEvent* e)
{
viewport()->update();
KTextEdit::dropEvent(e);
}
void MsgTextEdit::focusInEvent(QFocusEvent* e)
{
viewport()->update();
KTextEdit::focusInEvent(e);
}
void MsgTextEdit::focusOutEvent(QFocusEvent* e)
{
viewport()->update();
KTextEdit::focusOutEvent(e);
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,74 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-07-15
* @brief a text edit widget with click message.
*
* @author Copyright (C) 2009-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef MSGTEXTEDIT_H
#define MSGTEXTEDIT_H
// Qt includes
#include <QtGui/QWidget>
#include <QtCore/QString>
// KDE includes
#include <ktextedit.h>
// Local includes
#include "libkexiv2_export.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT MsgTextEdit : public KTextEdit
{
Q_OBJECT
public:
MsgTextEdit(QWidget* parent);
~MsgTextEdit();
void setClickMessage(const QString& msg);
QString clickMessage() const;
void setText(const QString& txt);
protected:
void paintEvent(QPaintEvent*);
void dropEvent(QDropEvent*);
void focusInEvent(QFocusEvent*);
void focusOutEvent(QFocusEvent*);
private:
class Private;
Private* const d;
};
} // namespace KExiv2Iface
#endif /* MSGTEXTEDIT_H */

View file

@ -0,0 +1,340 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-08-03
* @brief Tools for combining rotation operations
*
* @author Copyright (C) 2006-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2004-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "rotationmatrix.h"
// KDE includes
#include <kdebug.h>
// local includes
#include "version.h"
namespace KExiv2Iface
{
/**
If the picture is displayed according to the exif orientation tag,
the user will request rotating operations relative to what he sees,
and that is the picture rotated according to the EXIF tag.
So the operation requested and the given EXIF angle must be combined.
E.g. if orientation is "6" (rotate 90 clockwiseto show correctly)
and the user selects 180 clockwise, the operation is 270.
If the user selected 270, the operation would be None (and clearing the exif tag).
This requires to describe the transformations in a model which
cares for both composing (180+90=270) and eliminating (180+180=no action),
as well as the non-commutative nature of the operations (vflip+90 is not 90+vflip)
All 2D transformations can be described by a 2x3 matrix, see QWRotationMatrix.
All transformations needed here - rotate 90, 180, 270, flipV, flipH -
can be described in a 2x2 matrix with the values 0,1,-1
(because flipping is expressed by changing the sign only,
and sine and cosine of 90, 180 and 270 are either 0,1 or -1).
x' = m11 x + m12 y
y' = m21 x + m22 y
Moreover, all combinations of these rotate/flip operations result in one of the eight
matrices defined below.
(I did not proof that mathematically, but empirically)
static const RotationMatrix identity; //( 1, 0, 0, 1)
static const RotationMatrix rotate90; //( 0, -1, 1, 0)
static const RotationMatrix rotate180; //(-1, 0, 0, -1)
static const RotationMatrix rotate270; //( 0, 1, -1, 0)
static const RotationMatrix flipHorizontal; //(-1, 0, 0, 1)
static const RotationMatrix flipVertical; //( 1, 0, 0, -1)
static const RotationMatrix rotate90flipHorizontal; //( 0, 1, 1, 0), first rotate, then flip
static const RotationMatrix rotate90flipVertical; //( 0, -1, -1, 0), first rotate, then flip
*/
namespace Matrix
{
static const RotationMatrix identity ( 1, 0, 0, 1);
static const RotationMatrix rotate90 ( 0, -1, 1, 0);
static const RotationMatrix rotate180 (-1, 0, 0, -1);
static const RotationMatrix rotate270 ( 0, 1, -1, 0);
static const RotationMatrix flipHorizontal (-1, 0, 0, 1);
static const RotationMatrix flipVertical ( 1, 0, 0, -1);
static const RotationMatrix rotate90flipHorizontal ( 0, 1, 1, 0);
static const RotationMatrix rotate90flipVertical ( 0, -1, -1, 0);
RotationMatrix matrix(RotationMatrix::TransformationAction action)
{
switch (action)
{
case RotationMatrix::NoTransformation:
return identity;
case RotationMatrix::FlipHorizontal:
return flipHorizontal;
case RotationMatrix::FlipVertical:
return flipVertical;
case RotationMatrix::Rotate90:
return rotate90;
case RotationMatrix::Rotate180:
return rotate180;
case RotationMatrix::Rotate270:
return rotate270;
}
return identity;
}
RotationMatrix matrix(KExiv2::ImageOrientation exifOrientation)
{
switch (exifOrientation)
{
case KExiv2::ORIENTATION_NORMAL:
return identity;
case KExiv2::ORIENTATION_HFLIP:
return flipHorizontal;
case KExiv2::ORIENTATION_ROT_180:
return rotate180;
case KExiv2::ORIENTATION_VFLIP:
return flipVertical;
case KExiv2::ORIENTATION_ROT_90_HFLIP:
return rotate90flipHorizontal;
case KExiv2::ORIENTATION_ROT_90:
return rotate90;
case KExiv2::ORIENTATION_ROT_90_VFLIP:
return rotate90flipVertical;
case KExiv2::ORIENTATION_ROT_270:
return rotate270;
case KExiv2::ORIENTATION_UNSPECIFIED:
return identity;
}
return identity;
}
} // namespace Matrix
RotationMatrix::RotationMatrix()
{
set( 1, 0, 0, 1 );
}
RotationMatrix::RotationMatrix(TransformationAction action)
{
*this = Matrix::matrix(action);
}
RotationMatrix::RotationMatrix(KExiv2::ImageOrientation exifOrientation)
{
*this = Matrix::matrix(exifOrientation);
}
RotationMatrix::RotationMatrix(int m11, int m12, int m21, int m22)
{
set(m11, m12, m21, m22);
}
void RotationMatrix::set(int m11, int m12, int m21, int m22)
{
m[0][0]=m11;
m[0][1]=m12;
m[1][0]=m21;
m[1][1]=m22;
}
bool RotationMatrix::isNoTransform() const
{
return *this == Matrix::identity;
}
RotationMatrix& RotationMatrix::operator*=(const RotationMatrix& ma)
{
set( ma.m[0][0]*m[0][0] + ma.m[0][1]*m[1][0], ma.m[0][0]*m[0][1] + ma.m[0][1]*m[1][1],
ma.m[1][0]*m[0][0] + ma.m[1][1]*m[1][0], ma.m[1][0]*m[0][1] + ma.m[1][1]*m[1][1] );
return *this;
}
bool RotationMatrix::operator==(const RotationMatrix& ma) const
{
return m[0][0]==ma.m[0][0] &&
m[0][1]==ma.m[0][1] &&
m[1][0]==ma.m[1][0] &&
m[1][1]==ma.m[1][1];
}
bool RotationMatrix::operator!=(const RotationMatrix& ma) const
{
return !(*this==ma);
}
RotationMatrix& RotationMatrix::operator*=(TransformationAction action)
{
return (*this *= Matrix::matrix(action));
}
RotationMatrix& RotationMatrix::operator*=(QList<TransformationAction> actions)
{
foreach(const TransformationAction& action, actions)
{
*this *= Matrix::matrix(action);
}
return *this;
}
RotationMatrix& RotationMatrix::operator*=(KExiv2::ImageOrientation exifOrientation)
{
return (*this *= Matrix::matrix(exifOrientation));
}
/** Converts the mathematically correct description
into the primitive operations that can be carried out losslessly.
*/
QList<RotationMatrix::TransformationAction> RotationMatrix::transformations() const
{
QList<TransformationAction> transforms;
if (*this == Matrix::rotate90)
{
transforms << Rotate90;
}
else if (*this == Matrix::rotate180)
{
transforms << Rotate180;
}
else if (*this == Matrix::rotate270)
{
transforms << Rotate270;
}
else if (*this == Matrix::flipHorizontal)
{
transforms << FlipHorizontal;
}
else if (*this == Matrix::flipVertical)
{
transforms << FlipVertical;
}
else if (*this == Matrix::rotate90flipHorizontal)
{
//first rotate, then flip!
transforms << Rotate90;
transforms << FlipHorizontal;
}
else if (*this == Matrix::rotate90flipVertical)
{
//first rotate, then flip!
transforms << Rotate90;
transforms << FlipVertical;
}
return transforms;
}
KExiv2::ImageOrientation RotationMatrix::exifOrientation() const
{
if (*this == Matrix::identity)
{
return KExiv2::ORIENTATION_NORMAL;
}
if (*this == Matrix::rotate90)
{
return KExiv2::ORIENTATION_ROT_90;
}
else if (*this == Matrix::rotate180)
{
return KExiv2::ORIENTATION_ROT_180;
}
else if (*this == Matrix::rotate270)
{
return KExiv2::ORIENTATION_ROT_270;
}
else if (*this == Matrix::flipHorizontal)
{
return KExiv2::ORIENTATION_HFLIP;
}
else if (*this == Matrix::flipVertical)
{
return KExiv2::ORIENTATION_VFLIP;
}
else if (*this == Matrix::rotate90flipHorizontal)
{
return KExiv2::ORIENTATION_ROT_90_HFLIP;
}
else if (*this == Matrix::rotate90flipVertical)
{
return KExiv2::ORIENTATION_ROT_90_VFLIP;
}
return KExiv2::ORIENTATION_UNSPECIFIED;
}
QMatrix RotationMatrix::toMatrix() const
{
return toMatrix(exifOrientation());
}
QMatrix RotationMatrix::toMatrix(KExiv2::ImageOrientation orientation)
{
QMatrix matrix;
switch (orientation)
{
case KExiv2::ORIENTATION_NORMAL:
case KExiv2::ORIENTATION_UNSPECIFIED:
break;
case KExiv2::ORIENTATION_HFLIP:
matrix.scale(-1, 1);
break;
case KExiv2::ORIENTATION_ROT_180:
matrix.rotate(180);
break;
case KExiv2::ORIENTATION_VFLIP:
matrix.scale(1, -1);
break;
case KExiv2::ORIENTATION_ROT_90_HFLIP:
matrix.scale(-1, 1);
matrix.rotate(90);
break;
case KExiv2::ORIENTATION_ROT_90:
matrix.rotate(90);
break;
case KExiv2::ORIENTATION_ROT_90_VFLIP:
matrix.scale(1, -1);
matrix.rotate(90);
break;
case KExiv2::ORIENTATION_ROT_270:
matrix.rotate(270);
break;
}
return matrix;
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,118 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2009-08-03
* @brief Tools for combining rotation operations
*
* @author Copyright (C) 2006-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2004-2012 by Marcel Wiesweg
* <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef LIBKEXIV2_ROTATIONMATRIX_H
#define LIBKEXIV2_ROTATIONMATRIX_H
// Qt includes
#include <QtGui/QMatrix>
// Local includes
#include "kexiv2.h"
#include "libkexiv2_export.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT RotationMatrix
{
public:
/** This describes single transform primitives.
* Note some of the defined Exif rotation flags combine
* two of these actions.
* The enum values correspond to those defined
* as JXFORM_CODE in the often used the JPEG tool transupp.h.
*/
enum TransformationAction
{
NoTransformation = 0, /// no transformation
FlipHorizontal = 1, /// horizontal flip
FlipVertical = 2, /// vertical flip
Rotate90 = 5, /// 90-degree clockwise rotation
Rotate180 = 6, /// 180-degree rotation
Rotate270 = 7 /// 270-degree clockwise (or 90 ccw)
};
/// Constructs the identity matrix (the matrix describing no transformation)
RotationMatrix();
/// Returns the matrix corresponding to the given TransformationAction
RotationMatrix(TransformationAction action);
/// Returns the matrix corresponding to the given TransformationAction
RotationMatrix(KExiv2::ImageOrientation exifOrientation);
bool operator==(const RotationMatrix& ma) const;
bool operator!=(const RotationMatrix& ma) const;
/// Returns true of this matrix describes no transformation (is the identity matrix)
bool isNoTransform() const;
RotationMatrix& operator*=(const RotationMatrix& ma);
/// Applies the given transform to this matrix
RotationMatrix& operator*=(TransformationAction action);
/// Applies the given transform actions to this matrix
RotationMatrix& operator*=(QList<TransformationAction> actions);
/// Applies the given Exif orientation flag to this matrix
RotationMatrix& operator*=(KExiv2::ImageOrientation exifOrientation);
/** Returns the actions described by this matrix. The order matters.
* Not all possible matrices are supported, but all those that can be combined
* by Exif rotation flags and the transform actions above.
* If isNoTransform() or the matrix is not supported returns an empty list. */
QList<TransformationAction> transformations() const;
/** Returns the Exif orienation flag describing this matrix.
* Returns ORIENTATION_UNSPECIFIED if no flag matches this matrix.
*/
KExiv2::ImageOrientation exifOrientation() const;
/// Returns a QMatrix representing this matrix
QMatrix toMatrix() const;
/// Returns a QMatrix for the given Exif orientation
static QMatrix toMatrix(KExiv2::ImageOrientation orientation);
RotationMatrix(int m11, int m12, int m21, int m22);
protected:
void set(int m11, int m12, int m21, int m22);
protected:
int m[2][2];
};
} // namespace KExiv2Iface
#endif // LIBKEXIV2_ROTATIONMATRIX_H

View file

@ -0,0 +1,601 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-10-15
* @brief IPTC subjects editor.
*
* @author Copyright (C) 2006-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2009-2012 by Andi Clemens
* <a href="mailto:andi dot clemens at googlemail dot com">andi dot clemens at googlemail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "moc_subjectwidget.cpp"
// Qt includes
#include <QCheckBox>
#include <QDomDocument>
#include <QDomElement>
#include <QFile>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QValidator>
// KDE includes
#include <kcombobox.h>
#include <kdialog.h>
#include <kglobal.h>
#include <khbox.h>
#include <kiconloader.h>
#include <klineedit.h>
#include <klistwidget.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kdebug.h>
namespace KExiv2Iface
{
class SubjectWidget::Private
{
public:
enum EditionMode
{
STANDARD = 0,
CUSTOM
};
Private()
{
addSubjectButton = 0;
delSubjectButton = 0;
repSubjectButton = 0;
subjectsBox = 0;
iprLabel = 0;
refLabel = 0;
nameLabel = 0;
matterLabel = 0;
detailLabel = 0;
btnGroup = 0;
stdBtn = 0;
customBtn = 0;
refCB = 0;
optionsBox = 0;
}
typedef QMap<QString, SubjectData> SubjectCodesMap;
SubjectCodesMap subMap;
QStringList subjectsList;
QWidget* optionsBox;
QPushButton* addSubjectButton;
QPushButton* delSubjectButton;
QPushButton* repSubjectButton;
QLabel* iprLabel;
QLabel* refLabel;
QLabel* nameLabel;
QLabel* matterLabel;
QLabel* detailLabel;
QButtonGroup* btnGroup;
QRadioButton* stdBtn;
QRadioButton* customBtn;
KComboBox* refCB;
KListWidget* subjectsBox;
};
// --------------------------------------------------------------------------------
SubjectWidget::SubjectWidget(QWidget* parent)
: QWidget(parent), d(new Private)
{
// Load subject codes provided by IPTC/NAA as xml file.
// See http://iptc.cms.apa.at/std/topicset/topicset.iptc-subjectcode.xml for details.
KGlobal::dirs()->addResourceDir("iptcschema", KStandardDirs::installPath("data") +
QString("libkexiv2/data"));
QString path = KGlobal::dirs()->findResource("iptcschema", "topicset.iptc-subjectcode.xml");
if (!loadSubjectCodesFromXML(KUrl(path)))
kDebug() << "Cannot load IPTC/NAA subject codes XML database";
// --------------------------------------------------------
// Subject Reference Number only accept digit.
QRegExp refDigitRx("^[0-9]{8}$");
QValidator *refValidator = new QRegExpValidator(refDigitRx, this);
// --------------------------------------------------------
m_subjectsCheck = new QCheckBox(i18n("Use structured definition of the subject matter:"), this);
d->optionsBox = new QWidget;
d->btnGroup = new QButtonGroup(this);
d->stdBtn = new QRadioButton;
d->customBtn = new QRadioButton;
d->refCB = new KComboBox;
QLabel* codeLink = new QLabel(i18n("Use standard "
"<b><a href='http://www.iptc.org/site/NewsCodes'>"
"reference code</a></b>"));
codeLink->setOpenExternalLinks(true);
codeLink->setWordWrap(false);
// By default, check box is not visible. (digiKam do not use it, kipi-plugins yes).
m_subjectsCheck->setVisible(false);
QLabel* customLabel = new QLabel(i18n("Use custom definition"));
d->btnGroup->addButton(d->stdBtn, Private::STANDARD);
d->btnGroup->addButton(d->customBtn, Private::CUSTOM);
d->btnGroup->setExclusive(true);
d->stdBtn->setChecked(true);
for (Private::SubjectCodesMap::Iterator it = d->subMap.begin();
it != d->subMap.end(); ++it)
d->refCB->addItem(it.key());
// --------------------------------------------------------
m_iprEdit = new KLineEdit;
m_iprEdit->setClearButtonShown(true);
m_iprEdit->setMaxLength(32);
// --------------------------------------------------------
m_refEdit = new KLineEdit;
m_refEdit->setClearButtonShown(true);
m_refEdit->setValidator(refValidator);
m_refEdit->setMaxLength(8);
// --------------------------------------------------------
m_nameEdit = new KLineEdit;
m_nameEdit->setClearButtonShown(true);
m_nameEdit->setMaxLength(64);
// --------------------------------------------------------
m_matterEdit = new KLineEdit;
m_matterEdit->setClearButtonShown(true);
m_matterEdit->setMaxLength(64);
// --------------------------------------------------------
m_detailEdit = new KLineEdit;
m_detailEdit->setClearButtonShown(true);
m_detailEdit->setMaxLength(64);
// --------------------------------------------------------
d->iprLabel = new QLabel(i18nc("Information Provider Reference: "
"A name, registered with the IPTC/NAA, "
"identifying the provider that guarantees "
"the uniqueness of the UNO", "I.P.R:"));
d->refLabel = new QLabel(i18n("Reference:"));
d->nameLabel = new QLabel(i18n("Name:"));
d->matterLabel = new QLabel(i18n("Matter:"));
d->detailLabel = new QLabel(i18n("Detail:"));
// --------------------------------------------------------
d->subjectsBox = new KListWidget;
d->subjectsBox->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
d->addSubjectButton = new QPushButton(i18n("&Add"));
d->delSubjectButton = new QPushButton(i18n("&Delete"));
d->repSubjectButton = new QPushButton(i18n("&Replace"));
d->addSubjectButton->setIcon(SmallIcon("list-add"));
d->delSubjectButton->setIcon(SmallIcon("edit-delete"));
d->repSubjectButton->setIcon(SmallIcon("view-refresh"));
d->delSubjectButton->setEnabled(false);
d->repSubjectButton->setEnabled(false);
// --------------------------------------------------------
m_note = new QLabel;
m_note->setMaximumWidth(150);
m_note->setOpenExternalLinks(true);
m_note->setWordWrap(true);
m_note->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
// --------------------------------------------------------
QGridLayout* optionsBoxLayout = new QGridLayout;
optionsBoxLayout->addWidget(d->stdBtn, 0, 0, 1, 1);
optionsBoxLayout->addWidget(codeLink, 0, 1, 1, 2);
optionsBoxLayout->addWidget(d->refCB, 0, 3, 1, 1);
optionsBoxLayout->addWidget(d->customBtn, 1, 0, 1, 4);
optionsBoxLayout->addWidget(customLabel, 1, 1, 1, 4);
optionsBoxLayout->addWidget(d->iprLabel, 2, 0, 1, 1);
optionsBoxLayout->addWidget(m_iprEdit, 2, 1, 1, 4);
optionsBoxLayout->addWidget(d->refLabel, 3, 0, 1, 1);
optionsBoxLayout->addWidget(m_refEdit, 3, 1, 1, 1);
optionsBoxLayout->addWidget(d->nameLabel, 4, 0, 1, 1);
optionsBoxLayout->addWidget(m_nameEdit, 4, 1, 1, 4);
optionsBoxLayout->addWidget(d->matterLabel, 5, 0, 1, 1);
optionsBoxLayout->addWidget(m_matterEdit, 5, 1, 1, 4);
optionsBoxLayout->addWidget(d->detailLabel, 6, 0, 1, 1);
optionsBoxLayout->addWidget(m_detailEdit, 6, 1, 1, 4);
optionsBoxLayout->setColumnStretch(4, 10);
optionsBoxLayout->setMargin(0);
optionsBoxLayout->setSpacing(KDialog::spacingHint());
d->optionsBox->setLayout(optionsBoxLayout);
// --------------------------------------------------------
QGridLayout* mainLayout = new QGridLayout;
mainLayout->setAlignment( Qt::AlignTop );
mainLayout->addWidget(m_subjectsCheck, 0, 0, 1, 4);
mainLayout->addWidget(d->optionsBox, 1, 0, 1, 4);
mainLayout->addWidget(d->subjectsBox, 2, 0, 5, 3);
mainLayout->addWidget(d->addSubjectButton, 2, 3, 1, 1);
mainLayout->addWidget(d->delSubjectButton, 3, 3, 1, 1);
mainLayout->addWidget(d->repSubjectButton, 4, 3, 1, 1);
mainLayout->addWidget(m_note, 5, 3, 1, 1);
mainLayout->setRowStretch(6, 10);
mainLayout->setColumnStretch(2, 1);
mainLayout->setMargin(0);
mainLayout->setSpacing(KDialog::spacingHint());
setLayout(mainLayout);
// --------------------------------------------------------
connect(d->subjectsBox, SIGNAL(itemSelectionChanged()),
this, SLOT(slotSubjectSelectionChanged()));
connect(d->addSubjectButton, SIGNAL(clicked()),
this, SLOT(slotAddSubject()));
connect(d->delSubjectButton, SIGNAL(clicked()),
this, SLOT(slotDelSubject()));
connect(d->repSubjectButton, SIGNAL(clicked()),
this, SLOT(slotRepSubject()));
connect(d->btnGroup, SIGNAL(buttonReleased(int)),
this, SLOT(slotEditOptionChanged(int)));
connect(d->refCB, SIGNAL(activated(int)),
this, SLOT(slotRefChanged()));
// --------------------------------------------------------
connect(m_subjectsCheck, SIGNAL(toggled(bool)),
this, SLOT(slotSubjectsToggled(bool)));
// --------------------------------------------------------
connect(m_subjectsCheck, SIGNAL(toggled(bool)),
this, SIGNAL(signalModified()));
connect(d->addSubjectButton, SIGNAL(clicked()),
this, SIGNAL(signalModified()));
connect(d->delSubjectButton, SIGNAL(clicked()),
this, SIGNAL(signalModified()));
connect(d->repSubjectButton, SIGNAL(clicked()),
this, SIGNAL(signalModified()));
// --------------------------------------------------------
slotEditOptionChanged(d->btnGroup->id(d->btnGroup->checkedButton()));
}
SubjectWidget::~SubjectWidget()
{
delete d;
}
void SubjectWidget::slotSubjectsToggled(bool b)
{
d->optionsBox->setEnabled(b);
d->subjectsBox->setEnabled(b);
d->addSubjectButton->setEnabled(b);
d->delSubjectButton->setEnabled(b);
d->repSubjectButton->setEnabled(b);
slotEditOptionChanged(d->btnGroup->id(d->btnGroup->checkedButton()));
}
void SubjectWidget::slotEditOptionChanged(int b)
{
if (b == Private::CUSTOM)
{
d->refCB->setEnabled(false);
m_iprEdit->setEnabled(true);
m_refEdit->setEnabled(true);
m_nameEdit->setEnabled(true);
m_matterEdit->setEnabled(true);
m_detailEdit->setEnabled(true);
}
else
{
d->refCB->setEnabled(true);
m_iprEdit->setEnabled(false);
m_refEdit->setEnabled(false);
m_nameEdit->setEnabled(false);
m_matterEdit->setEnabled(false);
m_detailEdit->setEnabled(false);
slotRefChanged();
}
}
void SubjectWidget::slotRefChanged()
{
QString key = d->refCB->currentText();
QString name, matter, detail;
for (Private::SubjectCodesMap::Iterator it = d->subMap.begin();
it != d->subMap.end(); ++it)
{
if (key == it.key())
{
name = it.value().name;
matter = it.value().matter;
detail = it.value().detail;
}
}
m_refEdit->setText(key);
m_nameEdit->setText(name);
m_matterEdit->setText(matter);
m_detailEdit->setText(detail);
}
QString SubjectWidget::buildSubject() const
{
QString subject = m_iprEdit->text();
subject.append(":");
subject.append(m_refEdit->text());
subject.append(":");
subject.append(m_nameEdit->text());
subject.append(":");
subject.append(m_matterEdit->text());
subject.append(":");
subject.append(m_detailEdit->text());
return subject;
}
void SubjectWidget::slotDelSubject()
{
QListWidgetItem* item = d->subjectsBox->currentItem();
if (!item) return;
d->subjectsBox->takeItem(d->subjectsBox->row(item));
delete item;
}
void SubjectWidget::slotRepSubject()
{
QString newSubject = buildSubject();
if (newSubject.isEmpty()) return;
if (!d->subjectsBox->selectedItems().isEmpty())
{
d->subjectsBox->selectedItems()[0]->setText(newSubject);
m_iprEdit->clear();
m_refEdit->clear();
m_nameEdit->clear();
m_matterEdit->clear();
m_detailEdit->clear();
}
}
void SubjectWidget::slotSubjectSelectionChanged()
{
if (!d->subjectsBox->selectedItems().isEmpty())
{
QString subject = d->subjectsBox->selectedItems()[0]->text();
m_iprEdit->setText(subject.section(':', 0, 0));
m_refEdit->setText(subject.section(':', 1, 1));
m_nameEdit->setText(subject.section(':', 2, 2));
m_matterEdit->setText(subject.section(':', 3, 3));
m_detailEdit->setText(subject.section(':', 4, 4));
d->delSubjectButton->setEnabled(true);
d->repSubjectButton->setEnabled(true);
}
else
{
d->delSubjectButton->setEnabled(false);
d->repSubjectButton->setEnabled(false);
}
}
void SubjectWidget::slotAddSubject()
{
QString newSubject = buildSubject();
if (newSubject.isEmpty()) return;
bool found = false;
for (int i = 0 ; i < d->subjectsBox->count(); i++)
{
QListWidgetItem* item = d->subjectsBox->item(i);
if (newSubject == item->text())
{
found = true;
break;
}
}
if (!found)
{
d->subjectsBox->insertItem(d->subjectsBox->count(), newSubject);
m_iprEdit->clear();
m_refEdit->clear();
m_nameEdit->clear();
m_matterEdit->clear();
m_detailEdit->clear();
}
}
bool SubjectWidget::loadSubjectCodesFromXML(const KUrl& url)
{
QFile xmlfile(url.toLocalFile());
if (!xmlfile.open(QIODevice::ReadOnly))
return false;
QDomDocument xmlDoc("NewsML");
if (!xmlDoc.setContent(&xmlfile))
return false;
QDomElement xmlDocElem = xmlDoc.documentElement();
if (xmlDocElem.tagName()!="NewsML")
return false;
for (QDomNode nbE1 = xmlDocElem.firstChild();
!nbE1.isNull(); nbE1 = nbE1.nextSibling())
{
QDomElement newsItemElement = nbE1.toElement();
if (newsItemElement.isNull()) continue;
if (newsItemElement.tagName() != "NewsItem") continue;
for (QDomNode nbE2 = newsItemElement.firstChild();
!nbE2.isNull(); nbE2 = nbE2.nextSibling())
{
QDomElement topicSetElement = nbE2.toElement();
if (topicSetElement.isNull()) continue;
if (topicSetElement.tagName() != "TopicSet") continue;
for (QDomNode nbE3 = topicSetElement.firstChild();
!nbE3.isNull(); nbE3 = nbE3.nextSibling())
{
QDomElement topicElement = nbE3.toElement();
if (topicElement.isNull()) continue;
if (topicElement.tagName() != "Topic") continue;
QString type, name, matter, detail, ref;
for (QDomNode nbE4 = topicElement.firstChild();
!nbE4.isNull(); nbE4 = nbE4.nextSibling())
{
QDomElement topicSubElement = nbE4.toElement();
if (topicSubElement.isNull()) continue;
if (topicSubElement.tagName() == "TopicType")
type = topicSubElement.attribute("FormalName");
if (topicSubElement.tagName() == "FormalName")
ref = topicSubElement.text();
if (topicSubElement.tagName() == "Description" &&
topicSubElement.attribute("Variant") == "Name")
{
if (type == "Subject")
name = topicSubElement.text();
else if (type == "SubjectMatter")
matter = topicSubElement.text();
else if (type == "SubjectDetail")
detail = topicSubElement.text();
}
}
d->subMap.insert(ref, SubjectData(name, matter, detail));
}
}
}
// Set the Subject Name everywhere on the map.
for (Private::SubjectCodesMap::Iterator it = d->subMap.begin();
it != d->subMap.end(); ++it)
{
QString name, keyPrefix;
if (it.key().endsWith(QLatin1String("00000")))
{
keyPrefix = it.key().left(3);
name = it.value().name;
for (Private::SubjectCodesMap::Iterator it2 = d->subMap.begin();
it2 != d->subMap.end(); ++it2)
{
if (it2.key().startsWith(keyPrefix) &&
!it2.key().endsWith(QLatin1String("00000")))
{
it2.value().name = name;
}
}
}
}
// Set the Subject Matter Name everywhere on the map.
for (Private::SubjectCodesMap::Iterator it = d->subMap.begin();
it != d->subMap.end(); ++it)
{
QString matter, keyPrefix;
if (it.key().endsWith(QLatin1String("000")))
{
keyPrefix = it.key().left(5);
matter = it.value().matter;
for (Private::SubjectCodesMap::Iterator it2 = d->subMap.begin();
it2 != d->subMap.end(); ++it2)
{
if (it2.key().startsWith(keyPrefix) &&
!it2.key().endsWith(QLatin1String("000")))
{
it2.value().matter = matter;
}
}
}
}
return true;
}
void SubjectWidget::setSubjectsList(const QStringList& list)
{
d->subjectsList = list;
blockSignals(true);
d->subjectsBox->clear();
m_subjectsCheck->setChecked(false);
if (!d->subjectsList.isEmpty())
{
d->subjectsBox->insertItems(0, d->subjectsList);
m_subjectsCheck->setChecked(true);
}
blockSignals(false);
slotSubjectsToggled(m_subjectsCheck->isChecked());
}
QStringList SubjectWidget::subjectsList() const
{
QStringList newSubjects;
for (int i = 0 ; i < d->subjectsBox->count(); i++)
{
QListWidgetItem* item = d->subjectsBox->item(i);
newSubjects.append(item->text());
}
return newSubjects;
}
} // namespace KExiv2Iface

View file

@ -0,0 +1,122 @@
/** ===========================================================
* @file
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2006-10-15
* @brief IPTC subjects editor.
*
* @author Copyright (C) 2006-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
* @author Copyright (C) 2009-2012 by Andi Clemens
* <a href="mailto:andi dot clemens at googlemail dot com">andi dot clemens at googlemail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef SUBJECTWIDGET_H
#define SUBJECTWIDGET_H
// Qt includes
#include <QtGui/QButtonGroup>
#include <QtCore/QByteArray>
#include <QtCore/QMap>
#include <QtCore/QStringList>
#include <QtGui/QWidget>
#include <QtGui/QCheckBox>
#include <QtGui/QLabel>
// KDE includes
#include <kurl.h>
#include <klineedit.h>
// Local includes
#include "libkexiv2_export.h"
namespace KExiv2Iface
{
class KEXIV2_EXPORT SubjectData
{
public:
SubjectData(const QString& n, const QString& m, const QString& d)
{
name = n;
matter = m;
detail = d;
}
QString name; // English and Ascii Name of subject.
QString matter; // English and Ascii Matter Name of subject.
QString detail; // English and Ascii Detail Name of subject.
};
// --------------------------------------------------------------------------------
class KEXIV2_EXPORT SubjectWidget : public QWidget
{
Q_OBJECT
public:
SubjectWidget(QWidget* parent);
~SubjectWidget();
void setSubjectsList(const QStringList& list);
QStringList subjectsList() const;
Q_SIGNALS:
void signalModified();
protected Q_SLOTS:
virtual void slotSubjectsToggled(bool);
virtual void slotRefChanged();
virtual void slotEditOptionChanged(int);
virtual void slotSubjectSelectionChanged();
virtual void slotAddSubject();
virtual void slotDelSubject();
virtual void slotRepSubject();
protected:
virtual bool loadSubjectCodesFromXML(const KUrl& url);
virtual QString buildSubject() const;
protected:
QLabel* m_note;
QCheckBox* m_subjectsCheck;
KLineEdit* m_iprEdit;
KLineEdit* m_refEdit;
KLineEdit* m_nameEdit;
KLineEdit* m_matterEdit;
KLineEdit* m_detailEdit;
private:
class Private;
Private* const d;
};
} // namespace KExiv2Iface
#endif // SUBJECTWIDGET_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
/** ===========================================================
*
* This file is a part of digiKam project
* <a href="http://www.digikam.org">http://www.digikam.org</a>
*
* @date 2007-02-06
* @brief Exiv2 library interface for KDE
*
* @author Copyright (C) 2007-2012 by Gilles Caulier
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef KEXIV2_VERSION_H
#define KEXIV2_VERSION_H
static const char kexiv2_version[] = "${KEXIV2_LIB_VERSION_STRING}";
#define KEXIV2_VERSION ${KEXIV2_LIB_VERSION_ID}
#endif // KEXIV2_VERSION_H

View file

@ -0,0 +1,53 @@
# ===========================================================
#
# This file is a part of digiKam project
# <a href="http://www.digikam.org">http://www.digikam.org</a>
#
# @date 2006-09-15
# @brief Exiv2 library interface for KDE
#
# @author Copyright (C) 2006-2012 by Gilles Caulier
# <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
#
# This program is free software; you can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ============================================================
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libkexiv2)
SET(setiptcpreview_SRCS setiptcpreview.cpp)
KDE4_ADD_EXECUTABLE(setiptcpreview NOGUI ${setiptcpreview_SRCS})
TARGET_LINK_LIBRARIES(setiptcpreview kexiv2 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
SET(loadfromba_SRCS loadfromba.cpp)
KDE4_ADD_EXECUTABLE(loadfromba NOGUI ${loadfromba_SRCS})
TARGET_LINK_LIBRARIES(loadfromba kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
SET(erasetag_SRCS erasetag.cpp)
KDE4_ADD_EXECUTABLE(erasetag NOGUI ${erasetag_SRCS})
TARGET_LINK_LIBRARIES(erasetag kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
SET(printtagslist_SRCS printtagslist.cpp)
KDE4_ADD_EXECUTABLE(printtagslist NOGUI ${printtagslist_SRCS})
TARGET_LINK_LIBRARIES(printtagslist kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
SET(usexmpsidecar_SRCS usexmpsidecar.cpp)
KDE4_ADD_EXECUTABLE(usexmpsidecar NOGUI ${usexmpsidecar_SRCS})
TARGET_LINK_LIBRARIES(usexmpsidecar kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
SET(readimagewritexmpsidecar_SRCS readimagewritexmpsidecar.cpp)
KDE4_ADD_EXECUTABLE(readimagewritexmpsidecar NOGUI ${readimagewritexmpsidecar_SRCS})
TARGET_LINK_LIBRARIES(readimagewritexmpsidecar kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
SET(setxmpface_SRCS setxmpface.cpp)
KDE4_ADD_EXECUTABLE(setxmpface NOGUI ${setxmpface_SRCS})
TARGET_LINK_LIBRARIES(setxmpface kexiv2 ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})

Some files were not shown because too many files have changed in this diff Show more