VTK - Convert image format

#include <iostream>
#include <vtkSmartPointer.h>
#include <vtkJPEGReader.h>
#include <vtkPNGWriter.h>

#pragma comment(lib, "vtkCommonCore-8.2.lib")
#pragma comment(lib, "vtkIOImage-8.2.lib")
#pragma comment(lib, "vtkCommonExecutionModel-8.2.lib")

void jpeg_to_png(const char* jpegFileName, const char* pngFileName)
{
    auto reader = vtkSmartPointer<vtkJPEGReader>::New();
    reader->SetFileName(jpegFileName);
    auto writer = vtkSmartPointer<vtkPNGWriter>::New();
    writer->SetFileName(pngFileName);
    writer->SetInputConnection(reader->GetOutputPort());
    writer->Write();
}

int main()
{
    jpeg_to_png("a.jpg", "b.png");
    return 0;
}