mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
First stab at building a vtkm_io library target.
This commit is contained in:
parent
87470a89b7
commit
981f0ed0d9
@ -10,10 +10,24 @@
|
||||
|
||||
set(headers
|
||||
ErrorIO.h
|
||||
DecodePNG.h
|
||||
EncodePNG.h
|
||||
)
|
||||
|
||||
set(sources
|
||||
DecodePNG.cxx
|
||||
EncodePNG.cxx
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
||||
vtkm_library( NAME vtkm_io
|
||||
SOURCES ${sources}
|
||||
HEADERS ${headers}
|
||||
)
|
||||
|
||||
target_link_libraries(vtkm_io PRIVATE vtkm_lodepng)
|
||||
|
||||
add_subdirectory(internal)
|
||||
add_subdirectory(reader)
|
||||
add_subdirectory(writer)
|
||||
|
@ -8,18 +8,19 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/rendering/DecodePNG.h>
|
||||
#include <vtkm/io/DecodePNG.h>
|
||||
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/internal/Configure.h>
|
||||
|
||||
|
||||
VTKM_THIRDPARTY_PRE_INCLUDE
|
||||
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
|
||||
VTKM_THIRDPARTY_POST_INCLUDE
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
namespace io
|
||||
{
|
||||
|
||||
vtkm::UInt32 DecodePNG(std::vector<unsigned char>& out_image,
|
||||
@ -39,4 +40,4 @@ vtkm::UInt32 DecodePNG(std::vector<unsigned char>& out_image,
|
||||
return retcode;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::rendering
|
||||
} // namespace vtkm::io
|
@ -7,17 +7,16 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_rendering_DecodePNG_h
|
||||
#define vtk_m_rendering_DecodePNG_h
|
||||
#ifndef vtk_m_io_DecodePNG_h
|
||||
#define vtk_m_io_DecodePNG_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/rendering/vtkm_rendering_export.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
namespace io
|
||||
{
|
||||
|
||||
/// Decodes a PNG file buffer in memory, into a raw pixel buffer
|
||||
@ -25,13 +24,13 @@ namespace rendering
|
||||
/// no matter what color type the original PNG image had. This gives predictable,
|
||||
/// usable data from any random input PNG.
|
||||
///
|
||||
VTKM_RENDERING_EXPORT
|
||||
VTKM_ALWAYS_EXPORT
|
||||
vtkm::UInt32 DecodePNG(std::vector<unsigned char>& out_image,
|
||||
unsigned long& image_width,
|
||||
unsigned long& image_height,
|
||||
const unsigned char* in_png,
|
||||
std::size_t in_size);
|
||||
}
|
||||
} // vtkm::rendering
|
||||
} // vtkm::io
|
||||
|
||||
#endif //vtk_m_rendering_DecodePNG_h
|
||||
#endif //vtk_m_io_DecodePNG_h
|
@ -8,7 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#include <algorithm> // for std::equal
|
||||
#include <vtkm/rendering/EncodePNG.h>
|
||||
#include <vtkm/io/EncodePNG.h>
|
||||
|
||||
#include <vtkm/cont/Logging.h>
|
||||
#include <vtkm/internal/Configure.h>
|
||||
@ -19,7 +19,7 @@ VTKM_THIRDPARTY_POST_INCLUDE
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
namespace io
|
||||
{
|
||||
|
||||
vtkm::UInt32 EncodePNG(std::vector<unsigned char> const& image,
|
||||
@ -68,4 +68,4 @@ vtkm::UInt32 SavePNG(std::string const& filename,
|
||||
return error;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::rendering
|
||||
} // namespace vtkm::io
|
@ -7,32 +7,31 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_rendering_EncodePNG_h
|
||||
#define vtk_m_rendering_EncodePNG_h
|
||||
#ifndef vtk_m_io_EncodePNG_h
|
||||
#define vtk_m_io_EncodePNG_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/rendering/vtkm_rendering_export.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
namespace io
|
||||
{
|
||||
|
||||
VTKM_RENDERING_EXPORT
|
||||
VTKM_ALWAYS_EXPORT
|
||||
vtkm::UInt32 EncodePNG(std::vector<unsigned char> const& image,
|
||||
unsigned long width,
|
||||
unsigned long height,
|
||||
unsigned char* out_png,
|
||||
std::size_t out_size);
|
||||
|
||||
VTKM_RENDERING_EXPORT
|
||||
VTKM_ALWAYS_EXPORT
|
||||
vtkm::UInt32 SavePNG(std::string const& filename,
|
||||
std::vector<unsigned char> const& image,
|
||||
unsigned long width,
|
||||
unsigned long height);
|
||||
}
|
||||
} // vtkm::rendering
|
||||
} // vtkm::io
|
||||
|
||||
#endif //vtk_m_rendering_EncodePNG_h
|
||||
#endif //vtk_m_io_EncodePNG_h
|
@ -50,8 +50,6 @@ set(headers
|
||||
ColorLegendAnnotation.h
|
||||
ConnectivityProxy.h
|
||||
Cylinderizer.h
|
||||
DecodePNG.h
|
||||
EncodePNG.h
|
||||
LineRenderer.h
|
||||
MatrixHelpers.h
|
||||
Scene.h
|
||||
@ -85,8 +83,6 @@ set(sources
|
||||
|
||||
Camera.cxx
|
||||
Color.cxx
|
||||
DecodePNG.cxx
|
||||
EncodePNG.cxx
|
||||
raytracing/Logger.cxx
|
||||
)
|
||||
|
||||
@ -200,8 +196,7 @@ elseif(VTKm_ENABLE_EGL_CONTEXT)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
target_link_libraries(vtkm_rendering PUBLIC vtkm_filter
|
||||
PRIVATE vtkm_lodepng)
|
||||
target_link_libraries(vtkm_rendering PUBLIC vtkm_filter vtkm_io)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(vtkm_rendering PRIVATE rt)
|
||||
endif()
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
#include <vtkm/io/DecodePNG.h>
|
||||
#include <vtkm/io/EncodePNG.h>
|
||||
#include <vtkm/rendering/BitmapFontFactory.h>
|
||||
#include <vtkm/rendering/DecodePNG.h>
|
||||
#include <vtkm/rendering/EncodePNG.h>
|
||||
#include <vtkm/rendering/LineRenderer.h>
|
||||
#include <vtkm/rendering/TextRenderer.h>
|
||||
#include <vtkm/rendering/WorldAnnotator.h>
|
||||
@ -523,7 +523,7 @@ bool Canvas::LoadFont() const
|
||||
const std::vector<unsigned char>& rawPNG = Internals->Font.GetRawImageData();
|
||||
std::vector<unsigned char> rgba;
|
||||
unsigned long textureWidth, textureHeight;
|
||||
auto error = DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size());
|
||||
auto error = io::DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size());
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
@ -598,7 +598,8 @@ void Canvas::SaveAs(const std::string& fileName) const
|
||||
}
|
||||
}
|
||||
|
||||
SavePNG(fileName, img, static_cast<unsigned long>(width), static_cast<unsigned long>(height));
|
||||
vtkm::io::SavePNG(
|
||||
fileName, img, static_cast<unsigned long>(width), static_cast<unsigned long>(height));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user