Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PNGRead.hpp « libslic3r « src - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e7311f2e510e756073bbc0409e9a1110e57e2fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef PNGREAD_HPP
#define PNGREAD_HPP

#include <vector>
#include <string>

namespace Slic3r { namespace png {

struct ReadBuf { const void *buf = nullptr; const size_t sz = 0; };

template<class PxT> struct Image {
    std::vector<PxT> buf;
    size_t rows, cols;
    PxT get(size_t row, size_t col) const { return buf[row * cols + col]; }
};

struct RGB { uint8_t r, g, b; };

using ImageRGB = Image<RGB>;
using ImageGreyscale = Image<uint8_t>;

bool is_png(const ReadBuf &pngbuf);

// Only decodes true 8 bit grayscale png images. Returns false for other formats
// TODO: implement transformation of rgb images into grayscale...
bool decode_png(const ReadBuf &pngbuf, ImageGreyscale &img);

// TODO
// bool decode_png(Buffer &&pngbuf, ImageRGB &img);

}}
#endif // PNGREAD_HPP