2013-10-28 21:15:08 +02:00
|
|
|
#ifndef _library__png__hpp__included__
|
|
|
|
#define _library__png__hpp__included__
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-12-20 12:07:07 +02:00
|
|
|
namespace png
|
2013-10-28 21:15:08 +02:00
|
|
|
{
|
2013-12-20 12:07:07 +02:00
|
|
|
struct decoder
|
|
|
|
{
|
|
|
|
decoder();
|
|
|
|
decoder(std::istream& file);
|
|
|
|
decoder(const std::string& file);
|
2013-10-28 21:15:08 +02:00
|
|
|
size_t width;
|
|
|
|
size_t height;
|
|
|
|
bool has_palette;
|
|
|
|
std::vector<uint32_t> data;
|
|
|
|
std::vector<uint32_t> palette;
|
|
|
|
private:
|
|
|
|
void decode_png(std::istream& file);
|
|
|
|
};
|
|
|
|
|
2013-12-20 12:07:07 +02:00
|
|
|
struct encoder
|
2013-10-28 21:15:08 +02:00
|
|
|
{
|
2013-12-20 12:07:07 +02:00
|
|
|
encoder();
|
2013-10-28 21:15:08 +02:00
|
|
|
size_t width;
|
|
|
|
size_t height;
|
|
|
|
bool has_palette;
|
|
|
|
bool has_alpha;
|
|
|
|
uint32_t colorkey;
|
|
|
|
std::vector<uint32_t> data;
|
|
|
|
std::vector<uint32_t> palette;
|
|
|
|
void encode(const std::string& file) const;
|
|
|
|
void encode(std::ostream& file) const;
|
|
|
|
};
|
2013-12-20 12:07:07 +02:00
|
|
|
}
|
2013-10-28 21:15:08 +02:00
|
|
|
|
|
|
|
#endif
|