Remove pixel type selection from PNG reader

Selecting the pixel type just means that lodepng casts it to that type
for it then to be cast to the type VTK-m uses. Since VTK-m always uses
the same type, there is little value for changing the intermediate cast.
This commit is contained in:
Kenneth Moreland 2020-05-28 23:27:16 -06:00
parent 6c97054b7f
commit e8c5ee5e69
2 changed files with 2 additions and 42 deletions

@ -64,38 +64,12 @@ ImageReaderPNG::~ImageReaderPNG() noexcept
{
}
const vtkm::cont::DataSet& ImageReaderPNG::ReadDataSet(PixelType pixelType)
{
this->Read(pixelType);
return this->GetDataSet();
}
void ImageReaderPNG::Read()
{
this->Read(PixelType::RGB_16);
}
void ImageReaderPNG::Read(PixelType pixelType)
{
vtkm::io::ImageReaderBase::ColorArrayType pixelArray;
vtkm::Id width;
vtkm::Id height;
switch (pixelType)
{
case PixelType::RGB_8:
pixelArray = ReadFromPNG<vtkm::io::RGBPixel_8>(this->FileName, width, height);
break;
case PixelType::RGB_16:
pixelArray = ReadFromPNG<vtkm::io::RGBPixel_16>(this->FileName, width, height);
break;
case PixelType::GREY_8:
pixelArray = ReadFromPNG<vtkm::io::GreyPixel_8>(this->FileName, width, height);
break;
case PixelType::GREY_16:
pixelArray = ReadFromPNG<vtkm::io::GreyPixel_16>(this->FileName, width, height);
break;
}
vtkm::io::ImageReaderBase::ColorArrayType pixelArray =
ReadFromPNG<vtkm::io::RGBPixel_16>(this->FileName, width, height);
this->InitializeImageDataSet(width, height, pixelArray);
}

@ -37,22 +37,8 @@ public:
ImageReaderPNG(const ImageReaderPNG&) = delete;
ImageReaderPNG& operator=(const ImageReaderPNG&) = delete;
enum class PixelType
{
RGB_8,
RGB_16,
GREY_8,
GREY_16
};
/// Reads PNG data from the provided file and stores it
/// according to the provided `PixelType`.
///
VTKM_CONT const vtkm::cont::DataSet& ReadDataSet(PixelType pixelType = PixelType::RGB_16);
protected:
VTKM_CONT void Read() override;
VTKM_CONT void Read(PixelType pixelType);
};
}
} // namespace vtkm::io