diff --git a/rtengine/image16.cc b/rtengine/image16.cc index 5f03ede9b..937e2d19d 100644 --- a/rtengine/image16.cc +++ b/rtengine/image16.cc @@ -19,14 +19,13 @@ #include "image16.h" #include "imagefloat.h" #include "image8.h" -#include #include #include "rtengine.h" namespace { -void getScanline8 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, unsigned char* buffer) +void getScanline8 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned char* buffer) { for (int i = 0, ix = 0; i < width; i++) { buffer[ix++] = red[i] >> 8; @@ -35,7 +34,7 @@ void getScanline8 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, un } } -void getScanline16 (uint16_t *red, uint16_t *green, uint16_t *blue, int width, unsigned short* buffer) +void getScanline16 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned short* buffer) { for (int i = 0, ix = 0; i < width; i++) { buffer[ix++] = red[i]; @@ -64,14 +63,14 @@ Image16::~Image16 () void Image16::getScanline (int row, unsigned char* buffer, int bps) { - if (data == NULL) { + if (data == nullptr) { return; } if (bps == 16) { - getScanline16 (&r(row, 0), &g(row, 0), &b(row, 0), width, (unsigned short*)buffer); + getScanline16 (r(row), g(row), b(row), width, (unsigned short*)buffer); } else if (bps == 8) { - getScanline8 (&r(row, 0), &g(row, 0), &b(row, 0), width, buffer); + getScanline8 (r(row), g(row), b(row), width, buffer); } } @@ -82,11 +81,11 @@ void Image16::getScanline (int row, unsigned char* buffer, int bps) void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue) { - if (data == NULL) { + if (data == nullptr) { return; } - // For optimization purpose, we're assuming that this class never have to provide min/max bound + // For optimization purpose, we're assuming that this class never has to provide min/max bounds assert(!minValue); switch (sampleFormat) { @@ -116,7 +115,7 @@ void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minVa } default: - // Other type are ignored, but could be implemented if necessary + // Other types are ignored, but could be implemented if necessary break; } diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index 2c779a99b..3ad8faee0 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -41,8 +41,7 @@ #include "color.h" #include "jpeg.h" -#define BENCHMARK -#include "StopWatch.h" + using namespace std; using namespace rtengine; using namespace rtengine::procparams; @@ -62,6 +61,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname) std::unique_ptr wfname (reinterpret_cast(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free); HANDLE hFile = CreateFileW ( wfname.get (), GENERIC_READ | GENERIC_WRITE, 0 /* no sharing allowed */, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile != INVALID_HANDLE_VALUE) { f = _fdopen (_open_osfhandle ((intptr_t)hFile, 0), "wb"); } @@ -918,7 +918,7 @@ int ImageIO::loadPPMFromMemory(const char* buffer, int width, int height, bool s int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps) { -BENCHFUN + FILE *file = g_fopen_withBinaryAndLock (fname); if (!file) { @@ -1012,7 +1012,7 @@ BENCHFUN // Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp) { -BENCHFUN + FILE *file = g_fopen_withBinaryAndLock (fname); if (!file) { @@ -1199,7 +1199,7 @@ BENCHFUN int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) { -BENCHFUN + //TODO: Handling 32 bits floating point output images! bool writeOk = true; int width = getW (); @@ -1228,9 +1228,11 @@ BENCHFUN // buffer for the exif and iptc int bufferSize = 165535; //TODO: Is it really 165535... or 65535 ? - if(profileData) + + if(profileData) { bufferSize += profileLength; - + } + unsigned char* buffer = new unsigned char[bufferSize]; unsigned char* iptcdata = NULL; unsigned int iptclen = 0;