diff --git a/rtengine/iimage.h b/rtengine/iimage.h index cd8aa9a9e..65c3a641e 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -1809,9 +1809,6 @@ public: * @return The mutex */ virtual MyMutex& getMutex () = 0; virtual cmsHPROFILE getProfile () const = 0; - /** @brief Returns the bits per pixel of the image. - * @return The bits per pixel of the image */ - virtual int getBitsPerPixel () const = 0; /** @brief Saves the image to file. It autodetects the format (jpg, tif, png are supported). * @param fname is the name of the file @return the error code, 0 if none */ @@ -1837,7 +1834,7 @@ public: * @param pl is the pointer to the class implementing the ProgressListener interface */ virtual void setSaveProgressListener (ProgressListener* pl) = 0; /** @brief Free the image */ - virtual void free () = 0; +// virtual void free () = 0; }; /** @brief This class represents an image having a float pixel planar representation. diff --git a/rtengine/image16.cc b/rtengine/image16.cc index 07fc66fad..1a9130b5d 100644 --- a/rtengine/image16.cc +++ b/rtengine/image16.cc @@ -258,10 +258,10 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P lineB[dst_x] = CLIP(bm * btot); } else { // computing a special factor for this incomplete sub-region - float area = src_sub_width * src_sub_height; - lineR[dst_x] = CLIP(rm2 * rtot / area); - lineG[dst_x] = CLIP(gm2 * gtot / area); - lineB[dst_x] = CLIP(bm2 * btot / area); + float larea = src_sub_width * src_sub_height; + lineR[dst_x] = CLIP(rm2 * rtot / larea); + lineG[dst_x] = CLIP(gm2 * gtot / larea); + lineB[dst_x] = CLIP(bm2 * btot / larea); } } } @@ -295,21 +295,6 @@ void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, P #undef GCLIP } -Image8* Image16::to8() const -{ - Image8* img8 = new Image8(width, height); - - for (int h = 0; h < height; ++h) { - for (int w = 0; w < width; ++w) { - img8->r(h, w) = uint16ToUint8Rounded(r(h, w)); - img8->g(h, w) = uint16ToUint8Rounded(g(h, w)); - img8->b(h, w) = uint16ToUint8Rounded(b(h, w)); - } - } - - return img8; -} - // Parallelized transformation; create transform with cmsFLAGS_NOCACHE! void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform) { diff --git a/rtengine/image16.h b/rtengine/image16.h index de9288f2d..de9718708 100644 --- a/rtengine/image16.h +++ b/rtengine/image16.h @@ -40,8 +40,6 @@ public: Image16* copy() const; - Image8* to8() const; - void getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, PreviewProps pp) const override; const char* getType() const override @@ -67,11 +65,6 @@ public: return getEmbeddedProfile(); } - int getBitsPerPixel() const override - { - return 8 * sizeof(unsigned short); - } - int saveToFile(const Glib::ustring &fname) const override { return save(fname); @@ -97,10 +90,6 @@ public: setProgressListener(pl); } - void free() override - { - delete this; - } void ExecCMSTransform(cmsHTRANSFORM hTransform); /* void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy); */ diff --git a/rtengine/image8.h b/rtengine/image8.h index c11d9d7fc..dd3be5d9b 100644 --- a/rtengine/image8.h +++ b/rtengine/image8.h @@ -64,11 +64,6 @@ public: return getEmbeddedProfile (); } - int getBitsPerPixel () const override - { - return 8 * sizeof(unsigned char); - } - int saveToFile (const Glib::ustring &fname) const override { return save (fname); @@ -94,11 +89,6 @@ public: setProgressListener (pl); } - void free () override - { - delete this; - } - }; } diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index f905134a0..d9ac841eb 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -288,10 +288,10 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag lineB[dst_x] = CLIP0(bm * btot); } else { // computing a special factor for this incomplete sub-region - float area = src_sub_width * src_sub_height; - lineR[dst_x] = CLIP0(rm2 * rtot / area); - lineG[dst_x] = CLIP0(gm2 * gtot / area); - lineB[dst_x] = CLIP0(bm2 * btot / area); + float larea = src_sub_width * src_sub_height; + lineR[dst_x] = CLIP0(rm2 * rtot / larea); + lineG[dst_x] = CLIP0(gm2 * gtot / larea); + lineB[dst_x] = CLIP0(bm2 * btot / larea); } } } @@ -327,53 +327,15 @@ void Imagefloat::getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* imag #endif } -Image8* -Imagefloat::to8() const -{ - Image8* img8 = new Image8(width, height); -#ifdef _OPENMP - #pragma omp parallel for schedule(static) -#endif - - for (int h = 0; h < height; ++h) { - for (int w = 0; w < width; ++w) { - img8->r(h, w) = uint16ToUint8Rounded(CLIP(r(h, w))); - img8->g(h, w) = uint16ToUint8Rounded(CLIP(g(h, w))); - img8->b(h, w) = uint16ToUint8Rounded(CLIP(b(h, w))); - } - } - - return img8; -} - -Image16* -Imagefloat::to16() const -{ - Image16* img16 = new Image16(width, height); -#ifdef _OPENMP - #pragma omp parallel for schedule(static) -#endif - - for (int h = 0; h < height; ++h) { - for (int w = 0; w < width; ++w) { - img16->r(h, w) = CLIP(r(h, w)); - img16->g(h, w) = CLIP(g(h, w)); - img16->b(h, w) = CLIP(b(h, w)); - } - } - - return img16; -} - void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal) { - float scale = MAXVALF / (srcMaxVal - srcMinVal); - int w = width; - int h = height; + const float scale = MAXVALF / (srcMaxVal - srcMinVal); + const int w = width; + const int h = height; #ifdef _OPENMP - #pragma omp parallel for firstprivate(w, h, srcMinVal, scale) schedule(dynamic, 5) + #pragma omp parallel for schedule(dynamic, 5) #endif for (int y = 0; y < h; y++) { @@ -389,11 +351,11 @@ void Imagefloat::normalizeFloat(float srcMinVal, float srcMaxVal) void Imagefloat::normalizeFloatTo1() { - int w = width; - int h = height; + const int w = width; + const int h = height; #ifdef _OPENMP - #pragma omp parallel for firstprivate(w, h) schedule(dynamic, 5) + #pragma omp parallel for schedule(dynamic, 5) #endif for (int y = 0; y < h; y++) { @@ -409,11 +371,11 @@ void Imagefloat::normalizeFloatTo1() void Imagefloat::normalizeFloatTo65535() { - int w = width; - int h = height; + const int w = width; + const int h = height; #ifdef _OPENMP - #pragma omp parallel for firstprivate(w, h) schedule(dynamic, 5) + #pragma omp parallel for schedule(dynamic, 5) #endif for (int y = 0; y < h; y++) { @@ -425,59 +387,6 @@ void Imagefloat::normalizeFloatTo65535() } } -void Imagefloat::calcCroppedHistogram(const ProcParams ¶ms, float scale, LUTu & hist) -{ - - hist.clear(); - - // Set up factors to calc the lightness - TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix (params.icm.workingProfile); - - float facRed = wprof[1][0]; - float facGreen = wprof[1][1]; - float facBlue = wprof[1][2]; - - - // calc pixel size - int x1, x2, y1, y2; - params.crop.mapToResized(width, height, scale, x1, x2, y1, y2); - -#ifdef _OPENMP - #pragma omp parallel -#endif - { - LUTu histThr(65536); - histThr.clear(); -#ifdef _OPENMP - #pragma omp for nowait -#endif - - for (int y = y1; y < y2; y++) { - for (int x = x1; x < x2; x++) { - int i = (int)(facRed * r(y, x) + facGreen * g(y, x) + facBlue * b(y, x)); - - if (i < 0) { - i = 0; - } else if (i > 65535) { - i = 65535; - } - - histThr[i]++; - } - } - -#ifdef _OPENMP - #pragma omp critical -#endif - { - for(int i = 0; i <= 0xffff; i++) { - hist[i] += histThr[i]; - } - } - } - -} - // Parallelized transformation; create transform with cmsFLAGS_NOCACHE! void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform) { diff --git a/rtengine/imagefloat.h b/rtengine/imagefloat.h index c7000d4b8..3362afcda 100644 --- a/rtengine/imagefloat.h +++ b/rtengine/imagefloat.h @@ -45,9 +45,6 @@ public: Imagefloat* copy () const; - Image8* to8() const; - Image16* to16() const; - void getStdImage (const ColorTemp &ctemp, int tran, Imagefloat* image, PreviewProps pp) const override; const char* getType () const override @@ -72,10 +69,6 @@ public: { return getEmbeddedProfile (); } - int getBitsPerPixel () const override - { - return 8 * sizeof(float); - } int saveToFile (const Glib::ustring &fname) const override { return save (fname); @@ -96,10 +89,6 @@ public: { setProgressListener (pl); } - void free () override - { - delete this; - } inline uint16_t DNG_FloatToHalf(float f) const { @@ -220,7 +209,6 @@ public: void normalizeFloat(float srcMinVal, float srcMaxVal) override; void normalizeFloatTo1(); void normalizeFloatTo65535(); - void calcCroppedHistogram(const ProcParams ¶ms, float scale, LUTu & hist); void ExecCMSTransform(cmsHTRANSFORM hTransform); void ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy); }; diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index aa8770504..fc9d215b7 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -852,8 +852,6 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) if ((todo & M_RGBCURVE) || (todo & M_CROP)) { - // if (hListener) oprevi->calcCroppedHistogram(params, scale, histCropped); - //complexCurve also calculated pre-curves histogram depending on crop CurveFactory::complexCurve(params->toneCurve.expcomp, params->toneCurve.black / 65535.0, params->toneCurve.hlcompr, params->toneCurve.hlcomprthresh, diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 8b4583877..3b6bb73ed 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -699,7 +699,7 @@ rtengine::ProcessingJob* BatchQueue::imageReady(rtengine::IImagefloat* img) err = img->saveAsJPEG (fname, saveFormat.jpegQuality, saveFormat.jpegSubSamp); } - img->free (); + delete img; if (err) { throw Glib::FileError(Glib::FileError::FAILED, M("MAIN_MSG_CANNOTSAVE") + "\n" + fname); diff --git a/rtgui/bqentryupdater.cc b/rtgui/bqentryupdater.cc index 61683e158..7115447c2 100644 --- a/rtgui/bqentryupdater.cc +++ b/rtgui/bqentryupdater.cc @@ -146,7 +146,7 @@ void BatchQueueEntryUpdater::processThread () } memcpy(current.oimg, img->getData(), prevw * prevh * 3); - img->free(); + delete img; } } diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 669dd491a..9d6860e0f 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1795,7 +1795,7 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, bool EditorPanel::idle_imageSaved (ProgressConnector *pc, rtengine::IImagefloat* img, Glib::ustring fname, SaveFormat sf, rtengine::procparams::ProcParams &pparams) { - img->free (); + delete img; if (! pc->returnValue() ) { openThm->imageDeveloped (); @@ -1995,7 +1995,7 @@ bool EditorPanel::saveImmediately (const Glib::ustring &filename, const SaveForm err = 1; } - img->free(); + delete img; return !err; } @@ -2057,7 +2057,7 @@ bool EditorPanel::idle_sendToGimp ( ProgressConnector *p } if (tries == 1000) { - img->free (); + delete img; return false; } @@ -2078,7 +2078,7 @@ bool EditorPanel::idle_sendToGimp ( ProgressConnector *p bool EditorPanel::idle_sentToGimp (ProgressConnector *pc, rtengine::IImagefloat* img, Glib::ustring filename) { - img->free (); + delete img; int errore = pc->returnValue(); setProgressState(false); delete pc; diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index 3129e93e2..cbe31726d 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -230,7 +230,7 @@ void FileBrowserEntry::updateImage(rtengine::IImage8* img, double scale, const r --feih->pending; } - img->free(); + delete img; return false; } @@ -276,7 +276,7 @@ void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rten landscape = newLandscape; - img->free(); + delete img; if (parent) { if (rotated) { diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index c60cba070..feef93564 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -832,7 +832,7 @@ int processLineParams ( int argc, char **argv ) } ii->decreaseRef(); - resultImage->free(); + delete resultImage; } if (imgParams) { diff --git a/rtgui/previewhandler.cc b/rtgui/previewhandler.cc index 1dad0676e..76def26b4 100644 --- a/rtgui/previewhandler.cc +++ b/rtgui/previewhandler.cc @@ -110,7 +110,7 @@ void PreviewHandler::delImage(IImage8* i) oldImg->getMutex().unlock(); } - i->free(); + delete i; pih->phandler->previewImgMutex.lock(); pih->phandler->previewImg.clear(); pih->phandler->previewImgMutex.unlock();