Mercurial > hg > orthanc
comparison Core/PngWriter.cpp @ 453:30086c1aca30
endianness
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jul 2013 14:29:44 +0200 |
parents | bdd72233b105 |
children |
comparison
equal
deleted
inserted
replaced
452:80f7539147a2 | 453:30086c1aca30 |
---|---|
35 #include <vector> | 35 #include <vector> |
36 #include <stdint.h> | 36 #include <stdint.h> |
37 #include <png.h> | 37 #include <png.h> |
38 #include "OrthancException.h" | 38 #include "OrthancException.h" |
39 #include "ChunkedBuffer.h" | 39 #include "ChunkedBuffer.h" |
40 #include "Toolbox.h" | |
40 | 41 |
41 | 42 |
42 // http://www.libpng.org/pub/png/libpng-1.2.5-manual.html#section-4 | 43 // http://www.libpng.org/pub/png/libpng-1.2.5-manual.html#section-4 |
43 // http://zarb.org/~gc/html/libpng.html | 44 // http://zarb.org/~gc/html/libpng.html |
44 /* | 45 /* |
169 if (height > 0) | 170 if (height > 0) |
170 { | 171 { |
171 switch (format) | 172 switch (format) |
172 { | 173 { |
173 case PixelFormat_Grayscale16: | 174 case PixelFormat_Grayscale16: |
174 // Must swap the endianness!! | |
175 png_set_rows(pimpl_->png_, pimpl_->info_, &pimpl_->rows_[0]); | 175 png_set_rows(pimpl_->png_, pimpl_->info_, &pimpl_->rows_[0]); |
176 png_write_png(pimpl_->png_, pimpl_->info_, PNG_TRANSFORM_SWAP_ENDIAN, NULL); | 176 |
177 if (Toolbox::DetectEndianness() == Endianness_Little) | |
178 { | |
179 // Must swap the endianness!! | |
180 png_write_png(pimpl_->png_, pimpl_->info_, PNG_TRANSFORM_SWAP_ENDIAN, NULL); | |
181 } | |
182 | |
177 break; | 183 break; |
178 | 184 |
179 default: | 185 default: |
180 png_write_image(pimpl_->png_, &pimpl_->rows_[0]); | 186 png_write_image(pimpl_->png_, &pimpl_->rows_[0]); |
181 } | 187 } |