110 if(imgIdx >=
int(
data.size())){
111 std::cout <<
"Bad index " << imgIdx <<
std::endl;
116 std::lock_guard<std::mutex> guard(*
fMIPLocks[imgIdx]);
126 if(src + 4*dim*dim - 1 > &(*
data[imgIdx]).back()){
127 std::cout <<
"Bad mipmap size " << dim <<
std::endl;
131 png_struct_def* png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
133 auto info_ptr = png_create_info_struct(png_ptr);
138 png_set_compression_level(png_ptr, 1);
139 png_set_compression_strategy(png_ptr, Z_RLE);
141 png_set_IHDR(png_ptr, info_ptr, dim, dim,
142 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE,
143 PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
145 std::vector<png_byte*> pdatas(dim);
146 for(
int i = 0; i < dim; ++i) pdatas[i] = src + i*dim*4;
148 png_set_rows(png_ptr, info_ptr, pdatas.data());
158 png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
160 png_destroy_write_struct(&png_ptr, &info_ptr);
void webevd_png_write_fn(png_struct_def *png_ptr, png_byte *buffer, long unsigned int nbytes)
void webevd_png_flush_fn(png_struct_def *png_ptr)
std::vector< std::unique_ptr< std::array< png_byte, kTotBytes > > > data
static constexpr int MipMapOffset(int dim, int maxdim)
std::vector< bool > fHasMIP
std::vector< std::mutex * > fMIPLocks
QTextStream & endl(QTextStream &s)