-#include <png.h>
#include "pngloader.h"
+#include <png.h>
using namespace std;
struct PngLoader::Private
{
- std::string message;
- png_struct *png;
- png_info *info;
- int interlace;
+ string message;
+ png_struct *png = nullptr;
+ png_info *info = nullptr;
+ int interlace = PNG_INTERLACE_NONE;
};
PngLoader::PngLoader(IO::Base &io, unsigned sig_bytes):
priv(new Private)
{
- priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, 0);
+ priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, nullptr);
priv->info = png_create_info_struct(priv->png);
// These probably won't give any errors
PngLoader::~PngLoader()
{
- png_destroy_read_struct(&priv->png, &priv->info, 0);
+ png_destroy_read_struct(&priv->png, &priv->info, nullptr);
delete priv;
}
-bool PngLoader::detect(const std::string &sig)
+bool PngLoader::detect(const string &sig)
{
return !png_sig_cmp(reinterpret_cast<png_byte *>(const_cast<char*>(sig.data())), 0, sig.size());
}
png_uint_32 height;
int depth;
int color;
- png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, 0, 0);
+ png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, nullptr, nullptr);
unsigned nchans = png_get_channels(priv->png, priv->info);
if(depth!=8)
void PngLoader::load_pixels_(Image::Data &data)
{
- png_byte **rows = 0;
+ png_byte **rows = nullptr;
if(setjmp(png_jmpbuf(priv->png)))
{
rows[y] = reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y));
for(unsigned i=0; i<n_passes; ++i)
- png_read_rows(priv->png, rows, 0, data.height);
+ png_read_rows(priv->png, rows, nullptr, data.height);
delete[] rows;
- rows = 0;
}
else
{
for(unsigned y=0; y<data.height; ++y)
- png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), 0);
+ png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), nullptr);
}
- png_read_end(priv->png, 0);
+ png_read_end(priv->png, nullptr);
}
} // namespace Graphics