Mercurial > hg > orthanc
comparison Core/Images/PngWriter.cpp @ 1916:5bcf721bde4f
IImageWriter
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Feb 2016 15:26:37 +0100 |
parents | b1291df2f780 |
children | 08ce34cfacad |
comparison
equal
deleted
inserted
replaced
1915:7454019be8f3 | 1916:5bcf721bde4f |
---|---|
200 | 200 |
201 png_write_end(pimpl_->png_, NULL); | 201 png_write_end(pimpl_->png_, NULL); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 void PngWriter::WriteToFile(const char* filename, | 205 void PngWriter::WriteToFileInternal(const std::string& filename, |
206 unsigned int width, | 206 unsigned int width, |
207 unsigned int height, | 207 unsigned int height, |
208 unsigned int pitch, | 208 unsigned int pitch, |
209 PixelFormat format, | 209 PixelFormat format, |
210 const void* buffer) | 210 const void* buffer) |
211 { | 211 { |
212 Prepare(width, height, pitch, format, buffer); | 212 Prepare(width, height, pitch, format, buffer); |
213 | 213 |
214 FILE* fp = fopen(filename, "wb"); | 214 // TODO This will not work on Windows system if the path contains non-ASCII characters |
215 FILE* fp = fopen(filename.c_str(), "wb"); | |
215 if (!fp) | 216 if (!fp) |
216 { | 217 { |
217 throw OrthancException(ErrorCode_CannotWriteFile); | 218 throw OrthancException(ErrorCode_CannotWriteFile); |
218 } | 219 } |
219 | 220 |
227 | 228 |
228 Compress(width, height, pitch, format); | 229 Compress(width, height, pitch, format); |
229 | 230 |
230 fclose(fp); | 231 fclose(fp); |
231 } | 232 } |
232 | |
233 | 233 |
234 | 234 |
235 | 235 |
236 static void MemoryCallback(png_structp png_ptr, | 236 static void MemoryCallback(png_structp png_ptr, |
237 png_bytep data, | 237 png_bytep data, |
241 buffer->AddChunk(reinterpret_cast<const char*>(data), size); | 241 buffer->AddChunk(reinterpret_cast<const char*>(data), size); |
242 } | 242 } |
243 | 243 |
244 | 244 |
245 | 245 |
246 void PngWriter::WriteToMemory(std::string& png, | 246 void PngWriter::WriteToMemoryInternal(std::string& png, |
247 unsigned int width, | 247 unsigned int width, |
248 unsigned int height, | 248 unsigned int height, |
249 unsigned int pitch, | 249 unsigned int pitch, |
250 PixelFormat format, | 250 PixelFormat format, |
251 const void* buffer) | 251 const void* buffer) |
252 { | 252 { |
253 ChunkedBuffer chunks; | 253 ChunkedBuffer chunks; |
254 | 254 |
255 Prepare(width, height, pitch, format, buffer); | 255 Prepare(width, height, pitch, format, buffer); |
256 | 256 |