mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 10:17:55 -06:00
PNG image read with libpng
This commit is contained in:
parent
19e1d877aa
commit
2bcd36d155
6 changed files with 164 additions and 15 deletions
30
src/libslic3r/PNGRead.hpp
Normal file
30
src/libslic3r/PNGRead.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#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>;
|
||||
|
||||
// TODO
|
||||
// bool decode_png(Buffer &&pngbuf, ImageRGB &img);
|
||||
|
||||
bool is_png(const ReadBuf &pngbuf);
|
||||
|
||||
bool decode_png(const ReadBuf &pngbuf, ImageGreyscale &img);
|
||||
|
||||
}}
|
||||
#endif // PNGREAD_HPP
|
Loading…
Add table
Add a link
Reference in a new issue