Reuse PNG buffer between exports.

This commit is contained in:
2017-10-13 13:34:23 +02:00
parent 492d84fab0
commit 172949eda8

View File

@@ -54,6 +54,8 @@ void PNGDumper::dumpImageSeries(const LayerData &layer)
auto data = layer.data(); auto data = layer.data();
png::image<png::gray_pixel> image(shape[2], shape[3]);
for (int i = 0; i < shape[0]; ++i) { for (int i = 0; i < shape[0]; ++i) {
for (int j = 0; j < shape[1]; ++j) { for (int j = 0; j < shape[1]; ++j) {
memcpy(buffer.data(), data, imagePixels * sizeof(DType)); 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); clamp(buffer.begin(), buffer.end(), 0.0, 255.0);
png::image<png::gray_pixel> image(shape[2], shape[3]);
for (int y = 0; y < shape[2]; ++y) { for (int y = 0; y < shape[2]; ++y) {
for (int x = 0; x < shape[3]; ++x) { for (int x = 0; x < shape[3]; ++x) {
image[x][y] = png::gray_pixel((int) buffer[x + y * shape[3]]); image[x][y] = png::gray_pixel((int) buffer[x + y * shape[3]]);