mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 10:52:49 +00:00
generic: adjust to OpenEXR v3.0+ changes
the image I/O plugin will likely break again due to use of deprecated API Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0f7656719e
commit
5d024e5a0e
2 changed files with 53 additions and 93 deletions
|
@ -1,102 +1,55 @@
|
||||||
# Try to find the OpenEXR libraries, once done this will define:
|
# Try to find OpenEXR, once done this will define:
|
||||||
#
|
#
|
||||||
# OPENEXR_FOUND - system has OpenEXR
|
# OPENEXR_FOUND - system has OpenEXR
|
||||||
# OPENEXR_INCLUDE_DIR - OpenEXR include directory
|
# OPENEXR_INCLUDE_DIR - the OpenEXR include directory
|
||||||
# OPENEXR_LIBRARIES - Libraries needed to use OpenEXR
|
# OPENEXR_LIBRARIES - the libraries needed to use OpenEXR
|
||||||
# OPENEXR_DEFINITIONS - definitions required to use OpenEXR
|
# OPENEXR_DEFINITIONS - compiler switches required for using OpenEXR
|
||||||
|
#
|
||||||
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
|
# Copyright (c) 2021 Ivailo Monev <xakepa10@gmail.com>
|
||||||
#
|
#
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
if (OPENEXR_INCLUDE_DIR AND OPENEXR_LIBRARIES)
|
include(FindPkgConfig)
|
||||||
# in cache already
|
|
||||||
set(OPENEXR_FOUND TRUE)
|
|
||||||
|
|
||||||
else (OPENEXR_INCLUDE_DIR AND OPENEXR_LIBRARIES)
|
|
||||||
|
|
||||||
# use pkg-config to get the directories and then use these values
|
|
||||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
|
||||||
find_package(PkgConfig)
|
|
||||||
pkg_check_modules(PC_OPENEXR QUIET OpenEXR)
|
pkg_check_modules(PC_OPENEXR QUIET OpenEXR)
|
||||||
|
|
||||||
FIND_PATH(OPENEXR_INCLUDE_DIR ImfRgbaFile.h
|
set(OPENEXR_INCLUDE_DIR ${PC_OPENEXR_INCLUDE_DIRS})
|
||||||
HINTS
|
set(OPENEXR_LIBRARIES ${PC_OPENEXR_LIBRARIES})
|
||||||
${PC_OPENEXR_INCLUDEDIR}
|
endif()
|
||||||
${PC_OPENEXR_INCLUDE_DIRS}
|
|
||||||
|
set(OPENEXR_VERSION ${PC_OPENEXR_VERSION})
|
||||||
|
set(OPENEXR_DEFINITIONS ${PC_OPENEXR_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
if(NOT OPENEXR_INCLUDE_DIR OR NOT OPENEXR_LIBRARIES)
|
||||||
|
find_path(OPENEXR_INCLUDE_DIR
|
||||||
|
NAMES ImfRgbaFile.h
|
||||||
PATH_SUFFIXES OpenEXR
|
PATH_SUFFIXES OpenEXR
|
||||||
|
HINTS $ENV{OPENEXRDIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
FIND_LIBRARY(OPENEXR_HALF_LIBRARY NAMES Half
|
find_library(OPENEXR_LIBRARIES
|
||||||
HINTS
|
NAMES OpenEXR
|
||||||
${PC_OPENEXR_LIBDIR}
|
HINTS $ENV{OPENEXRDIR}/lib
|
||||||
${PC_OPENEXR_LIBRARY_DIRS}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# fallback for versions older than 3.0
|
||||||
FIND_LIBRARY(OPENEXR_IEX_LIBRARY NAMES Iex
|
if(NOT OPENEXR_LIBRARIES)
|
||||||
PATHS
|
set(OPENEXR_NAMES Imath IlmImf Half Iex IlmThread)
|
||||||
${PC_OPENEXR_LIBDIR}
|
foreach(lib ${OPENEXR_NAMES})
|
||||||
${PC_OPENEXR_LIBRARY_DIRS}
|
find_library(OPENEXR_${lib}_PATH
|
||||||
|
NAMES ${lib}
|
||||||
|
HINTS $ENV{OPENEXRDIR}/lib
|
||||||
)
|
)
|
||||||
|
set(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES} ${OPENEXR_${lib}_PATH})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
FIND_LIBRARY(OPENEXR_IMATH_LIBRARY NAMES Imath
|
include(FindPackageHandleStandardArgs)
|
||||||
HINTS
|
find_package_handle_standard_args(OpenEXR
|
||||||
${PC_OPENEXR_LIBDIR}
|
VERSION_VAR OPENEXR_VERSION
|
||||||
${PC_OPENEXR_LIBRARY_DIRS}
|
REQUIRED_VARS OPENEXR_LIBRARIES OPENEXR_INCLUDE_DIR
|
||||||
)
|
)
|
||||||
|
|
||||||
FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY NAMES IlmImf
|
mark_as_advanced(OPENEXR_INCLUDE_DIR OPENEXR_LIBRARIES)
|
||||||
HINTS
|
|
||||||
${PC_OPENEXR_LIBDIR}
|
|
||||||
${PC_OPENEXR_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY NAMES IlmThread
|
|
||||||
HINTS
|
|
||||||
${PC_OPENEXR_LIBDIR}
|
|
||||||
${PC_OPENEXR_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (OPENEXR_INCLUDE_DIR AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
|
||||||
set(OPENEXR_FOUND TRUE)
|
|
||||||
if (OPENEXR_ILMTHREAD_LIBRARY)
|
|
||||||
set(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} )
|
|
||||||
else (OPENEXR_ILMTHREAD_LIBRARY)
|
|
||||||
set(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} )
|
|
||||||
endif (OPENEXR_ILMTHREAD_LIBRARY)
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
set(_OPENEXR_DEFINITIONS -DOPENEXR_DLL)
|
|
||||||
else (WIN32)
|
|
||||||
set(_OPENEXR_DEFINITIONS)
|
|
||||||
endif (WIN32)
|
|
||||||
|
|
||||||
set(OPENEXR_DEFINITIONS ${_OPENEXR_DEFINITIONS})
|
|
||||||
|
|
||||||
endif (OPENEXR_INCLUDE_DIR AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY)
|
|
||||||
|
|
||||||
|
|
||||||
if (OPENEXR_FOUND)
|
|
||||||
if (NOT OpenEXR_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found OPENEXR: ${OPENEXR_LIBRARIES}")
|
|
||||||
endif (NOT OpenEXR_FIND_QUIETLY)
|
|
||||||
else (OPENEXR_FOUND)
|
|
||||||
if (OpenEXR_FIND_REQUIRED)
|
|
||||||
message(FATAL_ERROR "Could NOT find OPENEXR")
|
|
||||||
endif (OpenEXR_FIND_REQUIRED)
|
|
||||||
endif (OPENEXR_FOUND)
|
|
||||||
|
|
||||||
mark_as_advanced(
|
|
||||||
OPENEXR_INCLUDE_DIR
|
|
||||||
OPENEXR_LIBRARIES
|
|
||||||
OPENEXR_ILMIMF_LIBRARY
|
|
||||||
OPENEXR_ILMTHREAD_LIBRARY
|
|
||||||
OPENEXR_IMATH_LIBRARY
|
|
||||||
OPENEXR_IEX_LIBRARY
|
|
||||||
OPENEXR_HALF_LIBRARY
|
|
||||||
OPENEXR_DEFINITIONS )
|
|
||||||
|
|
||||||
endif (OPENEXR_INCLUDE_DIR AND OPENEXR_LIBRARIES)
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <ImfConvert.h>
|
#include <ImfConvert.h>
|
||||||
#include <ImfVersion.h>
|
#include <ImfVersion.h>
|
||||||
#include <IexThrowErrnoExc.h>
|
#include <IexThrowErrnoExc.h>
|
||||||
|
#include <OpenEXRConfig.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -38,6 +39,12 @@
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QtGui/qimageiohandler.h>
|
#include <QtGui/qimageiohandler.h>
|
||||||
|
|
||||||
|
#if defined(OPENEXR_VERSION_MAJOR) && OPENEXR_VERSION_MAJOR >= 3
|
||||||
|
# define K_OE_INT_TYPE uint64_t
|
||||||
|
#else
|
||||||
|
# define K_OE_INT_TYPE Imf::Int64
|
||||||
|
#endif
|
||||||
|
|
||||||
class K_IStream: public Imf::IStream
|
class K_IStream: public Imf::IStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -46,8 +53,8 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual bool read( char c[], int n );
|
virtual bool read( char c[], int n );
|
||||||
virtual Imf::Int64 tellg( );
|
virtual K_OE_INT_TYPE tellg( );
|
||||||
virtual void seekg( Imf::Int64 pos );
|
virtual void seekg( K_OE_INT_TYPE pos );
|
||||||
virtual void clear( );
|
virtual void clear( );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -66,12 +73,12 @@ bool K_IStream::read( char c[], int n )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Imf::Int64 K_IStream::tellg( )
|
K_OE_INT_TYPE K_IStream::tellg( )
|
||||||
{
|
{
|
||||||
return m_dev->pos();
|
return m_dev->pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_IStream::seekg( Imf::Int64 pos )
|
void K_IStream::seekg( K_OE_INT_TYPE pos )
|
||||||
{
|
{
|
||||||
m_dev->seek( pos );
|
m_dev->seek( pos );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue