diff --git a/src/PNGDumper.cpp b/src/PNGDumper.cpp index 8cf9ad9..92fb330 100644 --- a/src/PNGDumper.cpp +++ b/src/PNGDumper.cpp @@ -54,6 +54,8 @@ void PNGDumper::dumpImageSeries(const LayerData &layer) auto data = layer.data(); + png::image image(shape[2], shape[3]); + for (int i = 0; i < shape[0]; ++i) { for (int j = 0; j < shape[1]; ++j) { memcpy(buffer.data(), data, imagePixels * sizeof(DType)); @@ -63,8 +65,6 @@ void PNGDumper::dumpImageSeries(const LayerData &layer) clamp(buffer.begin(), buffer.end(), 0.0, 255.0); - png::image image(shape[2], shape[3]); - for (int y = 0; y < shape[2]; ++y) { for (int x = 0; x < shape[3]; ++x) { image[x][y] = png::gray_pixel((int) buffer[x + y * shape[3]]);