vtk-m/vtkm/io/DecodePNG.cxx

43 lines
1.2 KiB
C++
Raw Normal View History

2019-04-15 23:24:21 +00:00
//============================================================================
2016-08-26 19:30:52 +00:00
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
2019-04-15 23:24:21 +00:00
//============================================================================
2016-08-26 19:30:52 +00:00
#include <vtkm/io/DecodePNG.h>
2016-08-26 19:30:52 +00:00
#include <vtkm/cont/Logging.h>
#include <vtkm/internal/Configure.h>
VTKM_THIRDPARTY_PRE_INCLUDE
2020-04-08 20:29:40 +00:00
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
VTKM_THIRDPARTY_POST_INCLUDE
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace io
2017-05-18 14:29:41 +00:00
{
2016-08-26 19:30:52 +00:00
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)
2016-08-26 19:30:52 +00:00
{
using namespace vtkm::png;
constexpr std::size_t bitdepth = 8;
vtkm::UInt32 iw = 0;
vtkm::UInt32 ih = 0;
auto retcode = lodepng::decode(out_image, iw, ih, in_png, in_size, LCT_RGBA, bitdepth);
image_width = iw;
image_height = ih;
return retcode;
2016-08-26 19:30:52 +00:00
}
}
} // namespace vtkm::io