Merge topic 'lodepng-in-lib'

b380e702d only include the lodepng header when installing
c9cbd9693 fix type warnings
62fe68acd fixes to match old files
abf569288 Merge branch 'upstream-lodepng' into lodepng-in-lib
957568e36 lodepng 2020-04-16 (b51302e1)
e925d6d54 turn lodepng into a library

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland <kmorel@sandia.gov>
Merge-request: !2034
This commit is contained in:
Nickolas Davis 2020-04-23 18:01:55 +00:00 committed by Kitware Robot
commit d22b658c3a
5 changed files with 52 additions and 23 deletions

@ -14,8 +14,8 @@
#include <vtkm/internal/Configure.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.cpp>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm
{

@ -15,7 +15,7 @@
VTKM_THIRDPARTY_PRE_INCLUDE
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
VTKM_THIRDPARTY_PRE_INCLUDE
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm
{
@ -29,7 +29,8 @@ vtkm::UInt32 EncodePNG(std::vector<unsigned char> const& image,
{
// The default is 8 bit RGBA; does anyone care to have more options?
// We can certainly add them in a backwards-compatible way if need be.
vtkm::UInt32 error = vtkm::png::lodepng::encode(output_png, image, width, height);
vtkm::UInt32 error = vtkm::png::lodepng::encode(
output_png, image, static_cast<unsigned int>(width), static_cast<unsigned int>(height));
if (error)
{
VTKM_LOG_S(vtkm::cont::LogLevel::Error,

@ -7,19 +7,47 @@
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
add_library(vtkm_lodepng INTERFACE)
set(headers
vtkmlodepng/lodepng.h
)
set(sources
vtkmlodepng/lodepng.cpp
)
vtkm_get_kit_name(kit_name kit_dir)
# Mark this lib as STATIC for usage in Windows without requiring dll_export
# if a SHARED lib is ever required you will need to generate the export
# headers and add them to the lodepng functions that should be shared
add_library(vtkm_lodepng STATIC ${headers} ${sources})
if(DEFINED VTKm_CUSTOM_LIBRARY_SUFFIX)
set(_lib_suffix "${VTKm_CUSTOM_LIBRARY_SUFFIX}")
else()
set(_lib_suffix "-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}")
endif()
set_target_properties(vtkm_lodepng
PROPERTIES
OUTPUT_NAME "vtkm_lodepng${_lib_suffix}"
LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
VERSION 1
SOVERSION 1
)
target_include_directories(vtkm_lodepng INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng>)
$<INSTALL_INTERFACE:${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng>
)
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(FILES ${headers}
DESTINATION "${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng/vtkmlodepng/"
)
endif()
install(TARGETS vtkm_lodepng
EXPORT ${VTKm_EXPORT_NAME})
## Install headers
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(DIRECTORY vtkmlodepng
DESTINATION ${VTKm_INSTALL_INCLUDE_DIR}/${kit_dir}/)
endif()
EXPORT ${VTKm_EXPORT_NAME}
LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR}
COMPONENT libraries
)

@ -3325,7 +3325,7 @@ void lodepng_compute_color_stats(LodePNGColorStats* stats,
if(!numcolors_done) {
for(i = 0; i < stats->numcolors; i++) {
const unsigned char* color = &stats->palette[i * 4];
color_tree_add(&tree, color[0], color[1], color[2], color[3], i);
color_tree_add(&tree, color[0], color[1], color[2], color[3], (unsigned int)i);
}
}
@ -4243,7 +4243,7 @@ static unsigned readChunk_iCCP(LodePNGInfo* info, const LodePNGDecompressSetting
&data[string2_begin],
length, zlibsettings);
if(!error) {
info->iccp_profile_size = decoded.size;
info->iccp_profile_size = (unsigned int)decoded.size;
info->iccp_profile = (unsigned char*)lodepng_malloc(decoded.size);
if(info->iccp_profile) {
memcpy(info->iccp_profile, decoded.data, decoded.size);

@ -28,13 +28,6 @@ freely, subject to the following restrictions:
#include <string.h> /*for size_t*/
namespace vtkm
{
namespace png
{
extern const char* LODEPNG_VERSION_STRING;
/*
The following #defines are used to create code sections. They can be disabled
to disable code sections, which can give faster compile time and smaller binary.
@ -99,6 +92,13 @@ source files with custom allocators.*/
#include <string>
#endif /*LODEPNG_COMPILE_CPP*/
namespace vtkm
{
namespace png
{
extern const char* LODEPNG_VERSION_STRING;
#ifdef LODEPNG_COMPILE_PNG
/*The PNG color types (also used for raw).*/
typedef enum LodePNGColorType {