diff -Nru ddroom-1.0.5.2/CHANGELOG.txt ddroom-1.0.5.3/CHANGELOG.txt --- ddroom-1.0.5.2/CHANGELOG.txt 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/CHANGELOG.txt 2017-04-23 09:11:23.000000000 +0000 @@ -1,4 +1,5 @@ +1.0.5.3 - Fixed incorrect GP wrapper for resampling insertion. 1.0.5.2 - Fixed edges on demosaic CA correction. 1.0.5.1 - Fixed 'missing resize event' on photo open bug. 1.0.5.0 - Added description on the distortion profiling, rearranges processing sequence. diff -Nru ddroom-1.0.5.2/ddroom.pro ddroom-1.0.5.3/ddroom.pro --- ddroom-1.0.5.2/ddroom.pro 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/ddroom.pro 2017-04-23 09:11:23.000000000 +0000 @@ -184,7 +184,8 @@ LIBS += -lOpenCL # suppress 'unused-result' for dcraw.cpp -QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-sign-compare -Wno-unused-result +#QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-sign-compare -Wno-unused-result +QMAKE_CXXFLAGS_WARN_ON = -Wall -Wextra -Wno-unused-parameter QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE += -O3 @@ -224,7 +225,6 @@ QMAKE_CXXFLAGS_RELEASE += -O2 } -#QT += widgets svg xml opengl QT += widgets svg xml debug:DESTDIR = debug diff -Nru ddroom-1.0.5.2/debian/changelog ddroom-1.0.5.3/debian/changelog --- ddroom-1.0.5.2/debian/changelog 2017-04-19 05:18:33.000000000 +0000 +++ ddroom-1.0.5.3/debian/changelog 2017-12-05 12:27:49.000000000 +0000 @@ -1,3 +1,11 @@ +ddroom (1.0.5.3-1dhor~zesty) zesty; urgency=medium + + * Code clean-ups. + * Removed PNG export parameter 'compression level' - used with the best… + * 1.0.5.3 - Fixed incorrect GP wrapper for resampling insertion. + + -- Dariusz Duma Tue, 05 Dec 2017 13:12:26 +0100 + ddroom (1.0.5.2-1dhor~zesty) zesty; urgency=medium * 1.0.5.2 - Fixed edges on demosaic CA correction. diff -Nru ddroom-1.0.5.2/src/area_helper.cpp ddroom-1.0.5.3/src/area_helper.cpp --- ddroom-1.0.5.2/src/area_helper.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/area_helper.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -17,7 +17,7 @@ //------------------------------------------------------------------------------ std::unique_ptr AreaHelper::convert(Area *area_in, Area::format_t out_format, int rotation) { -//cerr << "AreaHelper::convert(): rotation == " << rotation << endl; +cerr << "AreaHelper::convert(): rotation == " << rotation << endl; Area::t_dimensions d_out; d_out.size.w = area_in->dimensions()->width(); d_out.size.h = area_in->dimensions()->height(); @@ -238,7 +238,7 @@ if(out_is_16) out_16[k + index_table[c]] = v; else - out_8[k + index_table[c]] = v >> 8; + out_8[k + index_table[c]] = (v >> 8); } } } diff -Nru ddroom-1.0.5.2/src/batch.cpp ddroom-1.0.5.3/src/batch.cpp --- ddroom-1.0.5.2/src/batch.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/batch.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -389,14 +389,13 @@ //------------------------------------------------------------------------------ void Batch::load_default_ep(export_parameters_t *ep) { Config::instance()->get(CONFIG_SECTION_BATCH, "process_asap", ep->process_asap); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_iq", ep->t_jpeg_iq); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_color_subsampling", ep->t_jpeg_color_subsampling_1x1); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_color_space", ep->t_jpeg_color_space_rgb); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_png_compression", ep->t_png_compression); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_png_alpha", ep->t_png_alpha); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_png_bits", ep->t_png_bits); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_tiff_alpha", ep->t_tiff_alpha); - Config::instance()->get(CONFIG_SECTION_BATCH, "type_tiff_bits", ep->t_tiff_bits); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_image_quality", ep->options_jpeg.image_quality); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_color_subsampling", ep->options_jpeg.color_subsampling_1x1); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_jpeg_color_space", ep->options_jpeg.color_space_rgb); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_png_alpha", ep->options_png.alpha); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_png_bits", ep->options_png.bits); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_tiff_alpha", ep->options_tiff.alpha); + Config::instance()->get(CONFIG_SECTION_BATCH, "type_tiff_bits", ep->options_tiff.bits); string type_name = ep->image_type_to_name(ep->image_type); Config::instance()->get(CONFIG_SECTION_BATCH, "image_type", type_name); ep->image_type = ep->image_name_to_type(type_name); @@ -408,14 +407,13 @@ void Batch::save_default_ep(export_parameters_t *ep) { Config::instance()->set(CONFIG_SECTION_BATCH, "process_asap", ep->process_asap); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_iq", ep->t_jpeg_iq); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_color_subsampling", ep->t_jpeg_color_subsampling_1x1); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_color_space", ep->t_jpeg_color_space_rgb); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_png_compression", ep->t_png_compression); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_png_alpha", ep->t_png_alpha); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_png_bits", ep->t_png_bits); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_tiff_alpha", ep->t_tiff_alpha); - Config::instance()->set(CONFIG_SECTION_BATCH, "type_tiff_bits", ep->t_tiff_bits); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_image_quality", ep->options_jpeg.image_quality); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_color_subsampling", ep->options_jpeg.color_subsampling_1x1); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_jpeg_color_space", ep->options_jpeg.color_space_rgb); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_png_alpha", ep->options_png.alpha); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_png_bits", ep->options_png.bits); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_tiff_alpha", ep->options_tiff.alpha); + Config::instance()->set(CONFIG_SECTION_BATCH, "type_tiff_bits", ep->options_tiff.bits); Config::instance()->set(CONFIG_SECTION_BATCH, "scaling_force", ep->scaling_force); Config::instance()->set(CONFIG_SECTION_BATCH, "scaling_to_fill", ep->scaling_to_fill); Config::instance()->set(CONFIG_SECTION_BATCH, "scaling_width", ep->scaling_width); diff -Nru ddroom-1.0.5.2/src/batch_dialog.cpp ddroom-1.0.5.3/src/batch_dialog.cpp --- ddroom-1.0.5.2/src/batch_dialog.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/batch_dialog.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -107,7 +107,7 @@ QLabel *label_jpeg_iq = new QLabel(); label_jpeg_iq->setText(tr("Image quality:")); hb_jpeg_iq->addWidget(label_jpeg_iq); - GuiSlider *slider_jpeg_iq = new GuiSlider(0.0, 100.0, ep->t_jpeg_iq, 1, 1, 5); + GuiSlider *slider_jpeg_iq = new GuiSlider(0.0, 100.0, ep->options_jpeg.image_quality, 1, 1, 5); hb_jpeg_iq->addWidget(slider_jpeg_iq); QLabel *label_jpeg_iq_percent = new QLabel(); label_jpeg_iq_percent->setText(tr("%")); @@ -134,8 +134,8 @@ lb_color_space->addStretch(); gl_jpeg_color->addWidget(label_color_space, gl_jpeg_color_row, 0, Qt::AlignRight | Qt::AlignTop); gl_jpeg_color->addLayout(lb_color_space, gl_jpeg_color_row++, 1); - if(ep->t_jpeg_color_space_rgb == 0) radio_color_space_ycbcr->setChecked(true); - if(ep->t_jpeg_color_space_rgb == 1) radio_color_space_rgb->setChecked(true); + if(ep->options_jpeg.color_space_rgb == 0) radio_color_space_ycbcr->setChecked(true); + if(ep->options_jpeg.color_space_rgb == 1) radio_color_space_rgb->setChecked(true); // color subsampling: 2x2 or 1x1 QHBoxLayout *lb_jpeg_subsampling = new QHBoxLayout(); @@ -150,8 +150,8 @@ lb_jpeg_subsampling->addStretch(); gl_jpeg_color->addWidget(label_jpeg_subsampling, gl_jpeg_color_row, 0, Qt::AlignRight | Qt::AlignTop); gl_jpeg_color->addLayout(lb_jpeg_subsampling, gl_jpeg_color_row++, 1); - if(ep->t_jpeg_color_subsampling_1x1 == 0) rb_jpeg_subsampling_22->setChecked(true); - if(ep->t_jpeg_color_subsampling_1x1 == 1) rb_jpeg_subsampling_11->setChecked(true); + if(ep->options_jpeg.color_subsampling_1x1 == 0) rb_jpeg_subsampling_22->setChecked(true); + if(ep->options_jpeg.color_subsampling_1x1 == 1) rb_jpeg_subsampling_11->setChecked(true); l_jpeg->addStretch(); stack_type->addWidget(tab_jpeg); @@ -163,15 +163,6 @@ QVBoxLayout *l_png = new QVBoxLayout(tab_png); l_png->setSizeConstraint(QLayout::SetMinimumSize); - // compression - QHBoxLayout *hb_png_compression = new QHBoxLayout(); - QLabel *label_png_compression = new QLabel(); - label_png_compression->setText(tr("Compression ratio: ")); - hb_png_compression->addWidget(label_png_compression); - GuiSlider *slider_png_compression = new GuiSlider(0.0, Z_BEST_COMPRESSION, ep->t_png_compression, 1, 1, 1); - hb_png_compression->addWidget(slider_png_compression); - l_png->addLayout(hb_png_compression); - // alpha QCheckBox *check_png_alpha = new QCheckBox(tr("Save alpha channel")); l_png->addWidget(check_png_alpha); @@ -301,13 +292,13 @@ } // tab_type->setCurrentIndex(ep->image_type); - if(ep->t_png_bits == 8) radio_png_bits_8->setChecked(true); - if(ep->t_png_bits == 16) radio_png_bits_16->setChecked(true); + if(ep->options_png.bits == 8) radio_png_bits_8->setChecked(true); + if(ep->options_png.bits == 16) radio_png_bits_16->setChecked(true); - if(ep->t_tiff_bits == 8) radio_tiff_bits_8->setChecked(true); - if(ep->t_tiff_bits == 16) radio_tiff_bits_16->setChecked(true); - check_png_alpha->setCheckState(ep->t_png_alpha ? Qt::Checked : Qt::Unchecked); - check_tiff_alpha->setCheckState(ep->t_tiff_alpha ? Qt::Checked : Qt::Unchecked); + if(ep->options_tiff.bits == 8) radio_tiff_bits_8->setChecked(true); + if(ep->options_tiff.bits == 16) radio_tiff_bits_16->setChecked(true); + check_png_alpha->setCheckState(ep->options_png.alpha ? Qt::Checked : Qt::Unchecked); + check_tiff_alpha->setCheckState(ep->options_tiff.alpha ? Qt::Checked : Qt::Unchecked); set_folder(ep->folder); QString name = QString::fromStdString(ep->get_file_name()); @@ -345,7 +336,6 @@ connect(slider_jpeg_iq, SIGNAL(signal_changed(double)), this, SLOT(slot_jpeg_iq(double))); connect(radio_jpeg_color_space, SIGNAL(buttonClicked(int)), this, SLOT(slot_jpeg_color_space(int))); connect(rb_jpeg_subsampling, SIGNAL(buttonClicked(int)), this, SLOT(slot_jpeg_subsampling(int))); - connect(slider_png_compression, SIGNAL(signal_changed(double)), this, SLOT(slot_png_compression(double))); if(line_file_name != nullptr) connect(line_file_name, SIGNAL(editingFinished(void)), this, SLOT(slot_line_file_name(void))); connect(check_process_asap, SIGNAL(stateChanged(int)), this, SLOT(slot_process_asap(int))); @@ -392,35 +382,35 @@ } void Batch_Dialog::slot_png_bits(int id) { - ep->t_png_bits = id; + ep->options_png.bits = id; } void Batch_Dialog::slot_tiff_bits(int id) { - ep->t_tiff_bits = id; + ep->options_tiff.bits = id; } void Batch_Dialog::slot_png_alpha(int checked) { - ep->t_png_alpha = (checked == Qt::Checked); + ep->options_png.alpha = (checked == Qt::Checked); } void Batch_Dialog::slot_tiff_alpha(int checked) { - ep->t_tiff_alpha = (checked == Qt::Checked); + ep->options_tiff.alpha = (checked == Qt::Checked); } void Batch_Dialog::slot_jpeg_iq(double _value) { - ep->t_jpeg_iq = _value + 0.05; + ep->options_jpeg.image_quality = _value + 0.05; } void Batch_Dialog::normalize_jpeg_subsampling(void) { disconnect(rb_jpeg_subsampling, SIGNAL(buttonClicked(int)), this, SLOT(slot_jpeg_subsampling(int))); - if(ep->t_jpeg_color_space_rgb == 1) { + if(ep->options_jpeg.color_space_rgb == true) { rb_jpeg_subsampling_11->setChecked(true); rb_jpeg_subsampling_22->setEnabled(false); rb_jpeg_subsampling_11->setEnabled(false); label_jpeg_subsampling->setEnabled(false); } else { - if(ep->t_jpeg_color_subsampling_1x1 == 0) rb_jpeg_subsampling_22->setChecked(true); - if(ep->t_jpeg_color_subsampling_1x1 == 1) rb_jpeg_subsampling_11->setChecked(true); + if(ep->options_jpeg.color_subsampling_1x1 == false) rb_jpeg_subsampling_22->setChecked(true); + if(ep->options_jpeg.color_subsampling_1x1 == true) rb_jpeg_subsampling_11->setChecked(true); rb_jpeg_subsampling_22->setEnabled(true); rb_jpeg_subsampling_11->setEnabled(true); label_jpeg_subsampling->setEnabled(true); @@ -429,18 +419,14 @@ } void Batch_Dialog::slot_jpeg_subsampling(int id) { - ep->t_jpeg_color_subsampling_1x1 = id; + ep->options_jpeg.color_subsampling_1x1 = id; } void Batch_Dialog::slot_jpeg_color_space(int id) { - ep->t_jpeg_color_space_rgb = id; + ep->options_jpeg.color_space_rgb = id; normalize_jpeg_subsampling(); } -void Batch_Dialog::slot_png_compression(double _value) { - ep->t_png_compression = _value + 0.05; -} - void Batch_Dialog::slot_line_file_name(void) { QString text = line_file_name->text(); ep->cut_and_set_file_name(text.toStdString()); diff -Nru ddroom-1.0.5.2/src/batch_dialog.h ddroom-1.0.5.3/src/batch_dialog.h --- ddroom-1.0.5.2/src/batch_dialog.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/batch_dialog.h 2017-04-23 09:11:23.000000000 +0000 @@ -29,7 +29,6 @@ void slot_jpeg_iq(double _value); void slot_jpeg_subsampling(int id); void slot_jpeg_color_space(int id); - void slot_png_compression(double _value); void slot_png_bits(int id); void slot_png_alpha(int checked); void slot_tiff_bits(int id); diff -Nru ddroom-1.0.5.2/src/cm.h ddroom-1.0.5.3/src/cm.h --- ddroom-1.0.5.2/src/cm.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/cm.h 2017-04-23 09:11:23.000000000 +0000 @@ -26,7 +26,7 @@ class CM_Convert { public: virtual ~CM_Convert(void) {}; - virtual void convert(float *to, const float *from) {}; + virtual void convert(float *to, const float *from) = 0; virtual float get_C_from_Jsh(const float *Jsh) {return Jsh[1];} virtual float get_s_from_JCh(const float *JCh) {return JCh[1];} }; diff -Nru ddroom-1.0.5.2/src/ddr_math.cpp ddroom-1.0.5.3/src/ddr_math.cpp --- ddroom-1.0.5.2/src/ddr_math.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/ddr_math.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -149,11 +149,11 @@ throw("wrong points vector in Spline_Calc constructor"); } // normalize points - use middle Y for all points with the same X - for(int i = 0; i < _points.size(); ++i) { + for(size_t i = 0; i < _points.size(); ++i) { int c = 1; float x = _points[i].first; float y = _points[i].second; - for(int j = i + 1; j < _points.size(); ++j) { + for(size_t j = i + 1; j < _points.size(); ++j) { if(_points[i].first != _points[j].first) { break; } else { diff -Nru ddroom-1.0.5.2/src/edit.cpp ddroom-1.0.5.3/src/edit.cpp --- ddroom-1.0.5.2/src/edit.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/edit.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -403,7 +403,7 @@ delete process_runner; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i]->photo) { cerr << "close photo " << sessions[i]->photo->photo_id.get_export_file_name() << endl; photo_close(i); @@ -661,7 +661,7 @@ //------------------------------------------------------------------------------ bool Edit::version_is_open(Photo_ID photo_id) { - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i] != nullptr) if(sessions[i]->photo) if(sessions[i]->photo->photo_id == photo_id) @@ -684,7 +684,7 @@ void Edit::slot_view_close(void *data) { View *view = (View *)data; int session_id = -1; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i]->view == view) { session_id = i; break; @@ -708,7 +708,7 @@ void Edit::slot_view_browser_reopen(void *data) { View *view = (View *)data; std::shared_ptr open_photo; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i]->view == view) { open_photo = sessions[i]->photo; break; @@ -725,7 +725,7 @@ View *view = (View *)data; bool update = false; std::shared_ptr photo_prev = sessions[session_active]->photo; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i]->view == view) { set_session_active(i); update = true; @@ -795,8 +795,8 @@ //------------------------------------------------------------------------------ void Edit::slot_update_opened_photo_ids(QList ids_list, int versions_count) { - int c = ids_list.size() / 2; - for(int i = 0; i < c; ++i) { + size_t c = ids_list.size() / 2; + for(size_t i = 0; i < c; ++i) { Photo_ID id_before = ids_list.at(i * 2 + 0); Photo_ID id_after = ids_list.at(i * 2 + 1); #if 0 @@ -968,7 +968,7 @@ bool Edit::flush_current_ps(void) { bool was_changed = false; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i] != nullptr) { if(sessions[i]->photo) was_changed = flush_current_ps(sessions[i]->photo); @@ -1104,7 +1104,7 @@ } void Edit::slot_controls_enable(bool state) { - for(int i = 0; i < filters_pages.size(); ++i) + for(size_t i = 0; i < filters_pages.size(); ++i) filters_pages[i]->setEnabled(state); for(QAction *action : filters_actions_list) if(action != nullptr) @@ -1210,7 +1210,7 @@ Edit::EditSession_t *Edit::session_of_view(View *view) { EditSession_t *session = nullptr; - for(int i = 0; i < sessions.size(); ++i) { + for(size_t i = 0; i < sessions.size(); ++i) { if(sessions[i]->view == view) { session = sessions[i]; break; diff -Nru ddroom-1.0.5.2/src/export.cpp ddroom-1.0.5.3/src/export.cpp --- ddroom-1.0.5.2/src/export.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/export.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -7,14 +7,6 @@ * */ -/* - * NOTES: - - looks like noone use embedded thumbs nowadays, so just skip creation of them - - in PNG - 16 bit byte order on PC is swapped, but looks like noone take care about - order information from header. Bad, so do real bytes swap - can be slow... - -*/ - #include #include @@ -59,14 +51,6 @@ folder = ""; image_type = export_parameters_t::image_type_jpeg; process_asap = true; - t_jpeg_iq = 95; - t_jpeg_color_subsampling_1x1 = true; - t_jpeg_color_space_rgb = false; - t_png_compression = 3; - t_png_alpha = false; - t_png_bits = 8; - t_tiff_alpha = false; - t_tiff_bits = 8; scaling_force = false; scaling_to_fill = false; // true - allow cut to fill size; false - use smallest size to fit scaling_width = 1280; @@ -154,31 +138,75 @@ } bool export_parameters_t::alpha(void) { - bool r = false; - if(image_type == image_type_png && t_png_alpha) - r = true; - if(image_type == image_type_tiff && t_tiff_alpha) - r = true; - return r; + bool alpha = false; + if(image_type == image_type_png && options_png.alpha) + alpha = true; + if(image_type == image_type_tiff && options_tiff.alpha) + alpha = true; + return alpha; } int export_parameters_t::bits(void) { - int b = 8; - if(image_type == image_type_png && t_png_bits == 16) - b = 16; - if(image_type == image_type_tiff && t_tiff_bits == 16) - b = 16; - return b; + int bits = 8; + if(image_type == image_type_png && options_png.bits == 16) + bits = 16; + if(image_type == image_type_tiff && options_tiff.bits == 16) + bits = 16; + return bits; } //------------------------------------------------------------------------------ -void Export::export_tiff(string file_name, Area *area_image, Area *area_thumb, export_parameters_t *ep, int rotation, Metadata *metadata) { +static void write_exif(string fname, int rotation, Metadata *metadata, int width, int height, Area *area_thumb) { + int orientation = 1; + if(rotation == 90) orientation = 6; + if(rotation == 180) orientation = 3; + if(rotation == 270) orientation = 8; + + // NOTE: rewrite fields with real values - width and height, possibly other too... + Exiv2::Image::AutoPtr exif_image = Exiv2::ImageFactory::open(fname); + exif_image->readMetadata(); + if(metadata != nullptr) + exif_image->setExifData(metadata->_exif_image->exifData()); + Exiv2::ExifData& exif_data = exif_image->exifData(); + + // store thumbnail + if(area_thumb != nullptr) { + Exiv2::ExifThumb exif_thumb(exif_data); + exif_thumb.erase(); + QImage image = area_thumb->to_qimage(); + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + image.save(&buffer, "JPEG", 85); + Exiv2::URational r(72, 1); + exif_thumb.setJpegThumbnail((const Exiv2::byte *)buffer.data().data(), buffer.size(), r, r, RESUNIT_INCH); + } + + string software = APP_NAME; + software += " "; + software += APP_VERSION; + exif_data["Exif.Image.Software"] = software.c_str(); + exif_data["Exif.Image.Orientation"] = uint16_t(orientation); + // update geometry of photo + exif_data["Exif.Iop.RelatedImageWidth"] = (uint16_t)width; + exif_data["Exif.Iop.RelatedImageLength"] = (uint16_t)height; + exif_data["Exif.Photo.PixelXDimension"] = (uint16_t)width; + exif_data["Exif.Photo.PixelYDimension"] = (uint16_t)height; + try { + exif_image->writeMetadata(); + } catch (Exiv2::AnyError& e) { + cerr << "Exiv2: FATAL ERROR TO WRITE: \"" << e << "\"" << endl; + } +} + +//------------------------------------------------------------------------------ +static void export_tiff(string file_name, Area *area_image, Area *area_thumb, encoding_options_tiff options, int rotation, Metadata *metadata) { int width = area_image->mem_width(); int height = area_image->mem_height(); void *image = (void *)area_image->ptr(); - int bits = ep->t_tiff_bits; - bool alpha = ep->t_tiff_alpha; + const int bits = options.bits; + const bool alpha = options.alpha; TIFF *tiff; // Open the TIFF file @@ -191,7 +219,15 @@ TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, (bits == 16) ? 16 : 8); TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, alpha ? 4 : 3); // RGBA + +#ifdef LZW_SUPPORT + const bool compression_lzw = true; + TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_LZW); +#else + const bool compression_lzw = false; TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_NONE); +#endif + TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, height); int bytes = (alpha ? 4 : 3) * ((bits == 8) ? 1 : 2); TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); @@ -237,7 +273,6 @@ Exif.Photo.PixelYDimension Short 1 1536 */ - // write EXIF Exiv2::Image::AutoPtr exif_image = Exiv2::ImageFactory::open(file_name); exif_image->readMetadata(); @@ -271,9 +306,9 @@ if(alpha) sv->value_.push_back(bits); exif_data["Exif.Image.BitsPerSample"].setValue(sv.get()); -// if(compression_lzw) -// exif_data["Exif.Image.Compression"] = (uint16_t)COMPRESSION_LZW; -// else + if(compression_lzw) + exif_data["Exif.Image.Compression"] = (uint16_t)COMPRESSION_LZW; + else exif_data["Exif.Image.Compression"] = (uint16_t)COMPRESSION_NONE; exif_data["Exif.Image.PhotometricInterpretation"] = (uint16_t)PHOTOMETRIC_RGB; #if __BYTE_ORDER == __BIG_ENDIAN @@ -301,7 +336,7 @@ } //------------------------------------------------------------------------------ -void Export::export_jpeg(string fname, Area *area_image, Area *area_thumb, export_parameters_t *ep, int rotation, Metadata *metadata) { +static void export_jpeg(string fname, Area *area_image, Area *area_thumb, encoding_options_jpeg options, int rotation, Metadata *metadata) { //cerr << endl << "export_jpeg: fname == " << fname << endl << endl; int width = area_image->mem_width(); int height = area_image->mem_height(); @@ -310,7 +345,7 @@ //cerr << "area_image->mem_size() == " << area_image->mem_width() << "x" << area_image->mem_height() << endl; //cerr << "area_image->size() == " << area_image->dimensions()->width() << "x" << area_image->dimensions()->height() << endl; - int quality = ep->t_jpeg_iq; + int quality = options.image_quality; if(quality < 0) quality = 0; if(quality > 100) @@ -342,7 +377,7 @@ cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); - if(ep->t_jpeg_color_space_rgb) { + if(options.color_space_rgb) { // for best colors, useful for anaglyph images jpeg_set_colorspace(&cinfo, JCS_RGB); } else { @@ -358,9 +393,9 @@ // TODO: check error handling via force incorrect factor value to '0' // with JCS_RGB is 1x1 (about x4 larger file); with JCS_YCbCr can be 2x2 (as default) or 1x1 (about x2 larger file) int colors_subsample = 2; - if(ep->t_jpeg_color_subsampling_1x1) + if(options.color_subsampling_1x1) colors_subsample = 1; - if(ep->t_jpeg_color_space_rgb) + if(options.color_space_rgb) colors_subsample = 1; cinfo.comp_info[0].v_samp_factor = colors_subsample; cinfo.comp_info[0].h_samp_factor = colors_subsample; @@ -388,20 +423,20 @@ } //------------------------------------------------------------------------------ -void Export::export_png(string file_name, Area *area_image, Area *area_thumb, export_parameters_t *ep, int rotation, Metadata *metadata) { +static void export_png(string file_name, Area *area_image, Area *area_thumb, encoding_options_png options, int rotation, Metadata *metadata) { int width = area_image->mem_width(); int height = area_image->mem_height(); void *image = (void *)area_image->ptr(); - int compression_ratio = ep->t_png_compression; - if(compression_ratio < 0) - compression_ratio = 0; - if(compression_ratio > Z_BEST_COMPRESSION) - compression_ratio = Z_BEST_COMPRESSION; - int bits = ep->t_png_bits; + // zlib compression level + // Z_NO_COMPRESSION unreasonably huge + // Z_BEST_COMPRESSION unreasonably slow + int compression_ratio = Z_BEST_SPEED; + + int bits = options.bits; if(bits != 8 && bits != 16) bits = 8; - bool alpha = ep->t_png_alpha; + bool alpha = options.alpha; //cerr << "alpha == " << alpha << "; bits == " << bits << endl; //cerr << "file_name == " << file_name << endl; @@ -437,6 +472,7 @@ /* set the zlib compression level */ png_set_compression_level(png_ptr, compression_ratio); +// png_set_filter(png_ptr, 0, PNG_FILTER_AVG); /* set other zlib parameters - better do not change that */ png_set_compression_mem_level(png_ptr, 8); png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); @@ -454,7 +490,6 @@ // !!! png_set_tIME(png_ptr, info_ptr, mod_time); // !!! png_set_text(png_ptr, info_ptr, text_ptr, num_text); // - set 'Title', 'Author', 'Descripthion', 'Copyright', 'Creation Time', 'Software' etc... - png_write_info(png_ptr, info_ptr); int row_stride = 0; /* JSAMPLEs per row in image_buffer */ @@ -497,60 +532,17 @@ } //------------------------------------------------------------------------------ -void Export::write_exif(string fname, int rotation, Metadata *metadata, int width, int height, Area *area_thumb) { - int orientation = 1; - if(rotation == 90) orientation = 6; - if(rotation == 180) orientation = 3; - if(rotation == 270) orientation = 8; - - // NOTE: rewrite fields with real values - width and height, possibly other too... - Exiv2::Image::AutoPtr exif_image = Exiv2::ImageFactory::open(fname); - exif_image->readMetadata(); - if(metadata != nullptr) - exif_image->setExifData(metadata->_exif_image->exifData()); - Exiv2::ExifData& exif_data = exif_image->exifData(); - - // store thumbnail - if(area_thumb != nullptr) { - Exiv2::ExifThumb exif_thumb(exif_data); - exif_thumb.erase(); - QImage image = area_thumb->to_qimage(); - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - image.save(&buffer, "JPEG", 85); - Exiv2::URational r(72, 1); - exif_thumb.setJpegThumbnail((const Exiv2::byte *)buffer.data().data(), buffer.size(), r, r, RESUNIT_INCH); - } - - string software = APP_NAME; - software += " "; - software += APP_VERSION; - exif_data["Exif.Image.Software"] = software.c_str(); - exif_data["Exif.Image.Orientation"] = uint16_t(orientation); - // update geometry of photo - exif_data["Exif.Iop.RelatedImageWidth"] = (uint16_t)width; - exif_data["Exif.Iop.RelatedImageLength"] = (uint16_t)height; - exif_data["Exif.Photo.PixelXDimension"] = (uint16_t)width; - exif_data["Exif.Photo.PixelYDimension"] = (uint16_t)height; - try { - exif_image->writeMetadata(); - } catch (Exiv2::AnyError& e) { - cerr << "Exiv2: FATAL ERROR TO WRITE: \"" << e << "\"" << endl; - } -} - void Export::export_photo(std::string file_name, Area *area_image, Area *area_thumb, export_parameters_t *ep, int rotation, Metadata *metadata) { if(area_image == nullptr || area_thumb == nullptr) return; if(area_image->ptr() == nullptr || area_thumb->ptr() == nullptr) return; if(ep->image_type == export_parameters_t::image_type_jpeg) - export_jpeg(file_name, area_image, area_thumb, ep, rotation, metadata); + export_jpeg(file_name, area_image, area_thumb, ep->options_jpeg, rotation, metadata); if(ep->image_type == export_parameters_t::image_type_png) - export_png(file_name, area_image, area_thumb, ep, rotation, metadata); + export_png(file_name, area_image, area_thumb, ep->options_png, rotation, metadata); if(ep->image_type == export_parameters_t::image_type_tiff) - export_tiff(file_name, area_image, area_thumb, ep, rotation, metadata); + export_tiff(file_name, area_image, area_thumb, ep->options_tiff, rotation, metadata); } //------------------------------------------------------------------------------ diff -Nru ddroom-1.0.5.2/src/export.h ddroom-1.0.5.3/src/export.h --- ddroom-1.0.5.2/src/export.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/export.h 2017-04-23 09:11:23.000000000 +0000 @@ -9,11 +9,29 @@ * */ - #include #include "metadata.h" //------------------------------------------------------------------------------ +class encoding_options_jpeg { +public: + int image_quality = 95; // 0 - 100% + bool color_subsampling_1x1 = true; // 'true' == 1x1, 'false' == 2x2 + bool color_space_rgb = false; // 'true' == RGB, 'false' == YCbCr +}; + +class encoding_options_png { +public: + bool alpha = false; + int bits = 8; // 8 | 16 +}; + +class encoding_options_tiff { +public: + bool alpha = false; + int bits = 8; // 8 | 16 +}; + class export_parameters_t { public: enum image_type_t { @@ -39,16 +57,12 @@ std::string _file_name_wo_ext; std::string folder; - image_type_t image_type; bool process_asap; - int t_jpeg_iq; // 0 - 100 % - bool t_jpeg_color_subsampling_1x1; // 'true' == 1x1, 'false' == 2x2 - bool t_jpeg_color_space_rgb; // 'true' == RGB, 'false' == YCbCr - int t_png_compression; // 0 - 9 - check zlib.h - bool t_png_alpha; - int t_png_bits; // 8 | 16 - bool t_tiff_alpha; - int t_tiff_bits; // 8 | 16 + + image_type_t image_type; + encoding_options_jpeg options_jpeg; + encoding_options_png options_png; + encoding_options_tiff options_tiff; // scaling bool scaling_force; bool scaling_to_fill; @@ -60,12 +74,6 @@ class Export { public: static void export_photo(std::string file_name, class Area *area_image, class Area *area_thumb, export_parameters_t *ep, int rotation, class Metadata *metadata); - -protected: - static void export_jpeg(std::string fname, class Area *area_image, class Area *area_thumb, export_parameters_t *ep, int rotation, class Metadata *metadata); - static void export_png(std::string file_name, class Area *area_image, class Area *area_thumb, export_parameters_t *ep, int rotation, class Metadata *metadata); - static void export_tiff(std::string fname, class Area *area_image, class Area *area_thumb, export_parameters_t *ep, int rotation, class Metadata *metadata); - static void write_exif(std::string fname, int rotation, class Metadata *metadata, int width, int height, class Area *area_thumb); }; //------------------------------------------------------------------------------ diff -Nru ddroom-1.0.5.2/src/f_cm_colors.cpp ddroom-1.0.5.3/src/f_cm_colors.cpp --- ddroom-1.0.5.2/src/f_cm_colors.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/f_cm_colors.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -333,7 +333,7 @@ public: TF_JS_Spline(const QVector *_points) { std::vector> points(_points->size()); - for(int i = 0; i < points.size(); ++i) + for(size_t i = 0; i < points.size(); ++i) points[i] = std::pair{(*_points)[i].x(), (*_points)[i].y()}; spline = new Spline_Calc(points); _init(0.0, 1.0, 1024); @@ -607,12 +607,19 @@ out[out_index + 1] = pixel[1] * scale; */ #if 1 - float pixel[3]; + float pixel[4]; pixel[0] = in[in_index + 0]; pixel[1] = in[in_index + 1]; pixel[2] = in[in_index + 2]; + pixel[3] = in[in_index + 3]; filter(pixel, task); out[out_index + 1] = pixel[1]; +/* + out[out_index + 0] = pixel[0]; + out[out_index + 1] = pixel[1]; + out[out_index + 2] = pixel[2]; + out[out_index + 3] = pixel[3]; +*/ #else float *pixel = &in[in_index]; float scale = task->saturation; diff -Nru ddroom-1.0.5.2/src/f_cm_lightness.cpp ddroom-1.0.5.3/src/f_cm_lightness.cpp --- ddroom-1.0.5.2/src/f_cm_lightness.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/f_cm_lightness.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -610,7 +610,7 @@ public: TF_Spline(const QVector *_points) { std::vector> points(_points->size()); - for(int i = 0; i < points.size(); ++i) + for(size_t i = 0; i < points.size(); ++i) points[i] = std::pair((*_points)[i].x(), (*_points)[i].y()); spline = new Spline_Calc(points); _init(0.0, 1.0, 4096); diff -Nru ddroom-1.0.5.2/src/f_cm_to_cs.cpp ddroom-1.0.5.3/src/f_cm_to_cs.cpp --- ddroom-1.0.5.2/src/f_cm_to_cs.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/f_cm_to_cs.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -223,7 +223,7 @@ void FP_CM_to_CS::filter_post(fp_cp_args_t *args) { std::vector tasks(args->vector_private.size()); - for(int i = 0; i < args->vector_private.size(); ++i) + for(size_t i = 0; i < args->vector_private.size(); ++i) tasks[i] = (task_t *)(args->vector_private[i].get()); task_release(tasks, args->threads_count, args->mutators_multipass, false, (FP_CM_to_CS_Cache_t *)args->cache); } diff -Nru ddroom-1.0.5.2/src/filter_gp.cpp ddroom-1.0.5.3/src/filter_gp.cpp --- ddroom-1.0.5.2/src/filter_gp.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/filter_gp.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -87,7 +87,7 @@ FilterProcess_GP_Wrapper::~FilterProcess_GP_Wrapper(void) { //cerr << "_____________________________________________ FilterProcess_GP_Wrapper::~FilterProcess_GP_Wrapper(void)" << endl; - for(int i = 0; i < gp_vector.size(); ++i) + for(size_t i = 0; i < gp_vector.size(); ++i) delete gp_vector[i]; } @@ -97,7 +97,7 @@ void FilterProcess_GP_Wrapper::init_gp(class Metadata *metadata) { if(gp_vector.size() == 0) { - for(int i = 0; i < fp_gp_vector.size(); ++i) { + for(size_t i = 0; i < fp_gp_vector.size(); ++i) { FP_GP_data_t data; data.metadata = metadata; data.filter = fp_gp_vector[i].filter; @@ -119,9 +119,9 @@ in[3] = in[1]; in[4] = in[0]; in[5] = in[1]; - for(int i = 0; i < 6; ++i) + for(size_t i = 0; i < 6; ++i) out[i] = in[i]; - for(int i = 0; i < gp_vector.size(); ++i) { + for(size_t i = 0; i < gp_vector.size(); ++i) { gp_vector[i]->process_forward_rgb(in, out); for(int k = 0; k < 6; ++k) in[k] = out[k]; @@ -236,7 +236,7 @@ //cerr << "px == " << px << endl; //cerr << "py == " << py << endl; // process sizes for each filter and fold accordingly - for(int i = 0; i < gp_vector.size(); ++i) { + for(size_t i = 0; i < gp_vector.size(); ++i) { bool to_clip = gp_vector[i]->to_clip(); float p_min_in[6]; float p_min_out[6]; @@ -348,11 +348,11 @@ out[3] = out[1]; out[4] = out[0]; out[5] = out[1]; - for(int i = 0; i < 6; ++i) + for(size_t i = 0; i < 6; ++i) in[i] = out[i]; - for(int i = gp_vector.size() - 1; i >= 0; i--) { + for(int i = gp_vector.size() - 1; i >= 0; --i) { gp_vector[i]->process_backward_rgb(in, out); - for(int k = 0; k < 6; ++k) + for(size_t k = 0; k < 6; ++k) out[k] = in[k]; } if(flag_min_max[c]) { @@ -585,8 +585,8 @@ out[0] = in[0] * task->wb_a[0] + task->wb_b[0]; out[1] = in[1] * task->wb_a[1] + task->wb_b[1]; out[2] = in[2] * task->wb_a[2] + task->wb_b[2]; - out[3] = 1.0f; -// out[3] = in[3]; +// out[3] = 1.0f; + out[3] = in[3]; } #ifdef MARK_CORNERS // mark corners @@ -742,7 +742,7 @@ d_out.position.px_size_y = px_size_out_y; d_out.edges.reset(); - for(int i = 0; i < gp_vector.size(); ++i) + for(size_t i = 0; i < gp_vector.size(); ++i) coordinates_rgb |= gp_vector[i]->is_rgb(); Area::type_t area_type = coordinates_rgb ? Area::type_t::float_p6 : Area::type_t::float_p2; area_out_coordinates = std::unique_ptr(new Area(&d_out, area_type)); @@ -961,30 +961,20 @@ const int in_x2 = area_in->dimensions()->width() + in_x1;// - 4; const int in_y2 = area_in->dimensions()->height() + in_y1;// - 4; +//cerr << "in_x1 == " << in_x1 << endl; +//cerr << "in_y1 == " << in_y1 << endl; + const int _w = area_in->mem_width(); float *_in = (float *)area_in->ptr(); float *_out = (float *)area_out->ptr(); float *_coordinates = (float *)area_coordinates->ptr(); - float color_pixel[12]; - color_pixel[ 0] = 0.5; - color_pixel[ 1] = 0.5; - color_pixel[ 2] = 0.5; - // WARNING: keep that alpha at zero !!! - color_pixel[ 3] = 0.0; - color_pixel[ 4] = 1.0; - color_pixel[ 5] = 0.0; - color_pixel[ 6] = 0.0; - color_pixel[ 7] = 0.75; - color_pixel[ 8] = 0.0; - color_pixel[ 9] = 1.0; - color_pixel[10] = 0.0; - color_pixel[11] = 0.75; + float empty_pixel[4] = {0.5, 0.5, 0.5, 0.0}; +// float empty_pixel[4] = {1.0, 1.0, 1.0, 0.5}; - float *empty_pixel = &color_pixel[0]; #ifdef MARK_CORNERS - float *mark_lt_pixel = &color_pixel[4]; - float *mark_rb_pixel = &color_pixel[8]; + float mark_lt_pixel[4] = {1.0, 0.0, 0.0, 0.75}; + float mark_rb_pixel[4] = {0.0, 1.0, 0.0, 0.75}; #endif int it_y; @@ -998,9 +988,7 @@ while((it_y = y_flow->fetch_add(1)) < out_y_max) { for(int it_x = 0; it_x < out_x_max; ++it_x) { float *rez = &_out[(it_y * out_width + it_x) * 4]; - float px_sum[4]; - for(int i = 0; i < 4; ++i) - px_sum[i] = 0.0; + float px_sum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; for(int k = 0; k < rgb_count; ++k) { int rgb_offset = 2 * k; // use coordinates for green channel for alpha channel for now @@ -1015,10 +1003,10 @@ float py1 = _coordinates[((cit_y - 1) * coords_width + cit_x) * rgb_size + rgb_offset + 1]; float _py = _coordinates[((cit_y ) * coords_width + cit_x) * rgb_size + rgb_offset + 1]; float py2 = _coordinates[((cit_y + 1) * coords_width + cit_x) * rgb_size + rgb_offset + 1]; - px1 = (px1 + _px) * 0.5; - px2 = (_px + px2) * 0.5; - py1 = (py1 + _py) * 0.5; - py2 = (_py + py2) * 0.5; + px1 = (px1 + _px) * 0.5f; + px2 = (_px + px2) * 0.5f; + py1 = (py1 + _py) * 0.5f; + py2 = (_py + py2) * 0.5f; float x1 = (px1 - offset_x) / px_size_x; float x2 = (px2 - offset_x) / px_size_x; float y1 = (py1 - offset_y) / px_size_y; @@ -1027,20 +1015,11 @@ float ly = y2 - y1; float xst = x1; float yst = y1; -#if 0 -if(it_x == 0 && it_y == 0) { -cerr << "_px == " << _px << endl; -cerr << "px1 == " << px1 << "; px2 == " << px2 << "; lx == " << lx << endl; -cerr << " x1 == " << x1 << "; x2 == " << x2 << "; xst == " << xst << endl; -cerr << " offset_x == " << offset_x << endl; -cerr << "px_size_x == " << px_size_x << endl; -} -#endif bool flag_to_skip = false; // X - float wx = 1.0 - (xst - floor(xst)); - if(lx < 1.0) - lx = 1.0; + float wx = 1.0f - (xst - floor(xst)); + if(lx < 1.0f) + lx = 1.0f; int ix1 = floor(xst); int ix2 = floor(xst + lx); ix1 += in_x_offset; @@ -1048,9 +1027,9 @@ if(ix2 < in_x1 || ix1 >= in_x2) flag_to_skip = true; // Y - float wy = 1.0 - (yst - floor(yst)); - if(ly < 1.0) - ly = 1.0; + float wy = 1.0f - (yst - floor(yst)); + if(ly < 1.0f) + ly = 1.0f; int iy1 = int(yst); int iy2 = int(yst + ly); iy1 += in_y_offset; @@ -1065,95 +1044,46 @@ continue; } // supersampling - float w_sum = 0.0; - float w_sum_alpha = 0.0; + float w_sum = 0.0f; + float w_sum_alpha = 0.0f; float w_y = wy; - if(w_y < 0.0) + if(w_y < 0.0f) w_y = -w_y; float l_y = ly; for(int y = iy1; y <= iy2; ++y) { float w_x = wx; - if(w_x < 0.0) + if(w_x < 0.0f) w_x = -w_x; float l_x = lx; for(int x = ix1; x <= ix2; ++x) { float w = w_x * w_y; -#if 0 -if(it_x == 0 && it_y == 0 && y == iy1) { -cerr << "w_x == " << w_x << "; l_x = " << l_x << "; x == " << x << endl; -cerr << "x == " << x << "; in_x1 == " << in_x1 << "; y == " << y << "; in_y1 == " << in_y1 << endl; -} -#endif l_x -= w_x; - w_x = (l_x > 1.0) ? 1.0 : l_x; + w_x = (l_x > 1.0f) ? 1.0f : l_x; if(x >= in_x1 && x < in_x2 && y >= in_y1 && y < in_y2) { w_sum += w; -#if 0 -if(it_x == 0 && it_y == 0 && y == iy1) -cerr << "..." << endl; -#endif if(task->coordinates_rgb) { - if(k == 3) - px_sum[3] += 1.0 * w; - else { - // apply WB and [0.0, 1.0] clip -// px_sum[k] += ddr::clip(_in[((y) * _w + x) * 4 + k] * task->wb_a[k] + task->wb_b[k]) * w; - px_sum[k] += _in[((y) * _w + x) * 4 + k] * w; + if(k == 3) { + px_sum[3] += 1.0f * w; + } else { + px_sum[k] += _in[(y * _w + x) * 4 + k] * w; } } else { -#if 0 - float in_r = _in[((y) * _w + x) * 4 + 0]; - float in_g = _in[((y) * _w + x) * 4 + 1]; - float in_b = _in[((y) * _w + x) * 4 + 2]; - float r = in_r * task->wb_a[0] + task->wb_b[0]; - float g = in_g * task->wb_a[1] + task->wb_b[1]; - float b = in_b * task->wb_a[2] + task->wb_b[2]; - if((in_r < 1.0f && in_g < 1.0f && in_b < 1.0f) && (r >= 1.0f || g >= 1.0f || b >= 1.0f)) { - float max = (r > g) ? r : g; - max = (max > b) ? max : b; - r /= max; - g /= max; - b /= max; - } -// if((in_r < 1.0f && in_g < 1.0f && in_b < 1.0f) && (r >= 1.0f || g >= 1.0f || b >= 1.0f)) { - if((in_r >= 1.0f || in_g >= 1.0f || in_b >= 1.0f) && (r >= 1.0f || g >= 1.0f || b >= 1.0f)) { -// if(in_r >= 1.0f || in_g >= 1.0f || in_b >= 1.0f) { - r = 1.0f; - g = 1.0f; - b = 1.0f; - } - px_sum[0] += ddr::clip(r) * w; - px_sum[1] += ddr::clip(g) * w; - px_sum[2] += ddr::clip(b) * w; -// px_sum[0] += r * w; -// px_sum[1] += g * w; -// px_sum[2] += b * w; - for(int i = 0; i < 3; ++i) { - // apply WB and [0.0, 1.0] clip - px_sum[i] += ddr::clip(_in[((y) * _w + x) * 4 + i] * task->wb_a[i] + task->wb_b[i]) * w; -// px_sum[i] += _in[((y) * _w + x) * 4 + i] * w; - } -#endif for(int i = 0; i < 3; ++i) - px_sum[i] += _in[((y) * _w + x) * 4 + i] * w; - px_sum[3] += 1.0 * w; + px_sum[i] += _in[(y * _w + x) * 4 + i] * w; + px_sum[3] += 1.0f * w; } } w_sum_alpha += w; } l_y -= w_y; - w_y = (l_y > 1.0) ? 1.0 : l_y; + w_y = (l_y > 1.0f) ? 1.0f : l_y; } -#if 0 -if(it_x == 0 && it_y == 0) -cerr << "w_sum == " << w_sum << "; w_sum_alpha == " << w_sum_alpha << endl; -#endif - // --==-- if(task->coordinates_rgb) { - if(k == 3) + if(k == 3) { rez[k] = px_sum[k] / w_sum_alpha; - else + } else { rez[k] = px_sum[k] / w_sum; + } } else { for(int i = 0; i < 3; ++i) rez[i] = px_sum[i] / w_sum; @@ -1183,15 +1113,15 @@ for(int i = 0; i < 4; ++i) rez[i] = mark_rb_pixel[i]; #endif -// rez[3] = 1.0; - if(rez[3] > 0.99) - rez[3] = 1.0; - if(rez[3] < 0.01) { // avoid 'isnan' for unprocessed transparent pixels - rez[0] = 0.0; - rez[1] = 0.0; - rez[2] = 0.0; - rez[3] = 0.0; + if(rez[3] > 0.99f) + rez[3] = 1.0f; + if(rez[3] < 0.01f) { // avoid 'isnan' for unprocessed transparent pixels + rez[0] = 0.0f; + rez[1] = 0.0f; + rez[2] = 0.0f; + rez[3] = 0.0f; } +// rez[3] = 0.5; } } } diff -Nru ddroom-1.0.5.2/src/f_unsharp.cpp ddroom-1.0.5.3/src/f_unsharp.cpp --- ddroom-1.0.5.2/src/f_unsharp.cpp 2017-04-19 05:15:27.000000000 +0000 +++ ddroom-1.0.5.3/src/f_unsharp.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -29,7 +29,7 @@ #include "misc.h" #define CL_USE_DEPRECATED_OPENCL_1_2_APIS -#include "CL/cl.h" +#include using namespace std; @@ -62,7 +62,7 @@ context = NULL; cl_platform_id ocl_platform_id = NULL; cl_device_id ocl_device_id = NULL; - for(int i = 0; i < numPlatforms; ++i) { + for(unsigned i = 0; i < numPlatforms; ++i) { ocl_platform_id = platforms[i]; cl_context_properties ctx_props[3] = { CL_CONTEXT_PLATFORM, @@ -77,7 +77,7 @@ continue; cl_device_id *devices = new cl_device_id[numDevices]; clGetDeviceIDs(ocl_platform_id, CL_DEVICE_TYPE_ALL, numDevices, devices, NULL); - for(int j = 0; j < numDevices; ++j) { + for(unsigned j = 0; j < numDevices; ++j) { ocl_device_id = devices[j]; // check features - > `OpenCL 1.2` and images support cl_bool image_support = CL_FALSE; diff -Nru ddroom-1.0.5.2/src/f_wb.cpp ddroom-1.0.5.3/src/f_wb.cpp --- ddroom-1.0.5.2/src/f_wb.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/f_wb.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -320,7 +320,7 @@ } // load presets - int tb_index = 0; + size_t tb_index = 0; for(; tb_index < wb_presets.size(); ++tb_index) if(wb_presets[tb_index].id == ps->wb_id) break; @@ -677,7 +677,7 @@ wb_tb["fluorescent"] = _wb_tb_t(":/resources/wb_fluorescent.svg", tr("White fluorescent (~4000K)"), true); radio_wb = new QButtonGroup(wb_rwbh); - for(int i = 0; i < wb_presets.size(); ++i) { + for(size_t i = 0; i < wb_presets.size(); ++i) { _wb_tb_t &rec = wb_tb[wb_presets[i].id]; QToolButton *tb = new QToolButton(parent); tb->setCheckable(true); diff -Nru ddroom-1.0.5.2/src/gui_curve.cpp ddroom-1.0.5.3/src/gui_curve.cpp --- ddroom-1.0.5.2/src/gui_curve.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/gui_curve.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -776,7 +776,7 @@ painter->setPen(pen); // spline std::vector> points(cpoints.size()); - for(int i = 0; i < points.size(); ++i) + for(size_t i = 0; i < points.size(); ++i) points[i] = std::pair{cpoints[i].x(), cpoints[i].y()}; Spline_Calc spline(points, 1.0, true, left_type, left_df, right_type, right_df); float _px = cpoints[0].x(); diff -Nru ddroom-1.0.5.2/src/import.h ddroom-1.0.5.3/src/import.h --- ddroom-1.0.5.2/src/import.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/import.h 2017-04-23 09:11:23.000000000 +0000 @@ -14,8 +14,6 @@ #include #include -#include -#include #include "photo.h" diff -Nru ddroom-1.0.5.2/src/import_jpeg.cpp ddroom-1.0.5.3/src/import_jpeg.cpp --- ddroom-1.0.5.2/src/import_jpeg.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/import_jpeg.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -24,7 +24,7 @@ //------------------------------------------------------------------------------ std::list Import_Jpeg::extensions(void) { return std::list { - "jpeg", "jpg" + "jpeg", "jpg", "jpe" }; } diff -Nru ddroom-1.0.5.2/src/import_png.cpp ddroom-1.0.5.3/src/import_png.cpp --- ddroom-1.0.5.2/src/import_png.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/import_png.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -26,13 +26,6 @@ #include #else #include -/* - #ifdef Q_OS_MAC - #include - #else - #include - #endif -*/ #endif using namespace std; @@ -99,7 +92,6 @@ std::unique_ptr Import_PNG::load_image(Metadata *metadata, bool is_thumb) { png_struct *ptr_png_struct = nullptr; png_info *ptr_png_info = nullptr; - png_byte *png_row = nullptr; metadata->rotation = 0; // get real rotation with Exiv2 for(int i = 0; i < 3; ++i) @@ -159,7 +151,7 @@ png_uint_32 row_bytes; row_bytes = png_get_rowbytes(ptr_png_struct, ptr_png_info); - png_row = (png_byte *)new char[row_bytes * sizeof(png_byte)]; + png_byte *png_row = (png_byte *)new char[row_bytes * sizeof(png_byte)]; if(png_row == nullptr) throw(std::string("out of memory")); @@ -182,9 +174,9 @@ scale = 0xFFFF; bc = 2; } - for(int y = 0; y < height; ++y) { + for(decltype(height) y = 0; y < height; ++y) { png_read_row(ptr_png_struct, png_row, nullptr); - for(int i = 0; i < width; ++i) { + for(decltype(width) i = 0; i < width; ++i) { for(int j = 0; j < 3; ++j) { // unsigned v = png_row[i * channels + j]; int in_channel = (channels < 3) ? 0 : j; @@ -229,6 +221,8 @@ png_read_end(ptr_png_struct, ptr_png_info); // clean up after the read, and free any memory allocated - REQUIRED png_destroy_read_struct(&ptr_png_struct, &ptr_png_info, (png_infopp)nullptr); + + delete[] (char *)png_row; } catch(const char *msg) { if(area != nullptr) area.reset(); @@ -242,8 +236,6 @@ png_destroy_read_struct(&ptr_png_struct, &ptr_png_info, nullptr); } fclose(infile); - if(png_row != nullptr) - delete[] (char *)png_row; #if 0 if(is_thumb == false) { diff -Nru ddroom-1.0.5.2/src/import_tiff.cpp ddroom-1.0.5.3/src/import_tiff.cpp --- ddroom-1.0.5.2/src/import_tiff.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/import_tiff.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -126,7 +126,7 @@ cms_matrix->get_matrix_CS_to_XYZ(color_space, metadata->cRGB_to_XYZ); TableFunction *gamma = cms_matrix->get_inverse_gamma(color_space); uint8_t *raster_8 = (uint8_t *)raster; - for(int y = 0; y < height; ++y) { + for(decltype(height) y = 0; y < height; ++y) { int pos_in = (height - 1 - y) * width * 4; if(!use_read_rgba) { // read next scanline @@ -135,7 +135,7 @@ // error pos_in = 0; } - for(int x = 0; x < width; ++x) { + for(decltype(width) x = 0; x < width; ++x) { float fv; if(!is_thumb) ptr[pos + 3] = 1.0; diff -Nru ddroom-1.0.5.2/src/misc.h ddroom-1.0.5.3/src/misc.h --- ddroom-1.0.5.2/src/misc.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/misc.h 2017-04-23 09:11:23.000000000 +0000 @@ -63,7 +63,7 @@ inline std::string to_lower(const std::string &in) { const size_t l = in.length(); std::string out(l, ' '); - for(int i = 0; i < l; ++i) + for(size_t i = 0; i < l; ++i) out[i] = std::tolower(in[i]); return out; } diff -Nru ddroom-1.0.5.2/src/photo_storage.cpp ddroom-1.0.5.3/src/photo_storage.cpp --- ddroom-1.0.5.2/src/photo_storage.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/photo_storage.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -247,7 +247,7 @@ string file_name = photo_id.get_file_name(); std::unique_lock locker(ps_lock, std::defer_lock); lock(file_name, locker); - int v_index = photo_id.get_version_index(); + unsigned v_index = photo_id.get_version_index(); //cerr << "PS_loader::version_rearrange(), v_index == " << v_index << endl; if(v_index < 1) v_index = 1; // load all versions @@ -257,7 +257,7 @@ // copy versions and add map ps_map; PS_Loader *ps_base = _ps_map[v_index]; - for(int i = 1; i <= _ps_map.size(); ++i) { + for(unsigned i = 1; i <= _ps_map.size(); ++i) { if(remove_not_create) { if(i < v_index) ps_map.insert(std::pair(i, _ps_map[i])); diff -Nru ddroom-1.0.5.2/src/process.cpp ddroom-1.0.5.3/src/process.cpp --- ddroom-1.0.5.2/src/process.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/process.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -208,33 +208,40 @@ for(int pass = 0; pass < 2; ++pass) { vector gp_wrapper_records; vector cp_wrapper_records; - bool gp_wrapper_resampling = false; - bool gp_wrapper_force = false; -// bool flag_crgb = false; - bool flag_crgb = true; - for(vector::const_iterator it = filters.cbegin(); true; ++it) { - if(it != filters.cend()) { + + // create a vector of enabled filters only + std::vector enabled_filters; + enabled_filters.reserve(filters.size()); + for(auto el : filters) { + if(el.fp->is_enabled(el.ps_base.get())) + enabled_filters.push_back(el); + } + + bool gp_wrapper_resampling_check = true; + bool gp_wrapper_resampling_force = false; + for(vector::const_iterator it = enabled_filters.cbegin(); true; ++it) { + if(it != enabled_filters.cend()) { if(!(*it).use_tiling) { //cerr << "skip FP: " << (*it).fp->name() << endl; continue; } } FilterProcess::fp_type_en filter_type = FilterProcess::fp_type_unknown; - if(it != filters.cend()) + if(it != enabled_filters.cend()) filter_type = (*it).fp->fp_type(pass == 0); // check if we need to add GP_Wrapper for resampling - if(!gp_wrapper_resampling) { -// if(flag_crgb && filter_type != FilterProcess::fp_type_gp && filter_type != FilterProcess::fp_type_2d) { - if(flag_crgb && filter_type != FilterProcess::fp_type_gp) { - gp_wrapper_force = true; - gp_wrapper_resampling = true; + if(gp_wrapper_resampling_check) { + if((*it).use_tiling == true) { + if(filter_type != FilterProcess::fp_type_gp) + gp_wrapper_resampling_force = true; + gp_wrapper_resampling_check = false; } } // create a new GP wrapper - if(gp_wrapper_force || (gp_wrapper_records.size() > 0 && filter_type != FilterProcess::fp_type_gp)) { -//cerr << "!!! gp_wrapper_force !!! " << endl; - gp_wrapper_force = false; + if(gp_wrapper_resampling_force || (gp_wrapper_records.size() > 0 && filter_type != FilterProcess::fp_type_gp)) { +//cerr << "create a new GP wrapper" << endl; + gp_wrapper_resampling_force = false; filter_record_t r; r.wrapper_holder.reset(new FilterProcess_GP_Wrapper(gp_wrapper_records)); gp_wrapper_records.clear(); @@ -256,11 +263,8 @@ } // analyze next filter if any - if(it == filters.end()) + if(it == enabled_filters.end()) break; - bool enabled = (*it).fp->is_enabled((*it).ps_base.get()); - if(!enabled) - continue; // add record for GP filter for wrapper if(filter_type == FilterProcess::fp_type_gp) { FilterProcess_GP *fp_gp = (FilterProcess_GP *)(*it).fp->get_ptr(pass == 0); @@ -289,7 +293,6 @@ r.fp_2d = (FilterProcess_2D *)r.fp->get_ptr(pass == 0); task->filter_records[pass].push_back(r); } -// flag_crgb = ((*it).filter->id() == std::string("F_WB")); } } } @@ -460,9 +463,6 @@ if(task.photo->metadata == nullptr) task.photo->metadata = new Metadata; task.photo->area_raw = std::unique_ptr(Import::image(task.photo->photo_id.get_file_name(), task.photo->metadata)); - - Area *a = task.photo->area_raw.get(); - Area::t_dimensions *d = a->dimensions(); } catch(Area::bad_alloc) { bad_alloc = true; } catch(std::bad_alloc) { @@ -570,7 +570,7 @@ // remove deprecated caches if any bool remove_cache = false; int index_tiling = task_filter_records.size() - 1; - for(int i = 0; i < task_filter_records.size(); ++i) { + for(unsigned i = 0; i < task_filter_records.size(); ++i) { if(task_filter_records[i].use_tiling) { index_tiling = i; break; @@ -618,7 +618,7 @@ // prepare list of filters to process if(index != 0) - for(int i = index; i < task_filter_records.size(); ++i) + for(unsigned i = index; i < task_filter_records.size(); ++i) filters_to_process.push_back(task_filter_records[i]); else filters_to_process = task_filter_records; @@ -823,7 +823,7 @@ cerr << " px_size: " << tiles_request->scale_factor_x << "-" << tiles_request->scale_factor_y << endl; cerr << " position: " << target_dimensions.position.x << "-" << target_dimensions.position.y << endl; */ - for(int i = 0; i < tiles_request->tiles.size() + 1; ++i) { + for(unsigned i = 0; i < tiles_request->tiles.size() + 1; ++i) { // actually, tiles coordinates and edges flags (outer|inner) was prepared in tiles_request, nothing to do here //cerr << endl << "....................................................................." << "process_size_backward(); iteration == " << i << endl; if(i == 0) { diff -Nru ddroom-1.0.5.2/src/version.h ddroom-1.0.5.3/src/version.h --- ddroom-1.0.5.2/src/version.h 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/version.h 2017-04-23 09:11:23.000000000 +0000 @@ -11,6 +11,6 @@ #define APP_NAME "DDRoom" #define APP_NAME_FULL "Digital Dark Room" -#define APP_VERSION "1.0.5.2" +#define APP_VERSION "1.0.5.3" #endif //__H_VERSION__ diff -Nru ddroom-1.0.5.2/src/view.cpp ddroom-1.0.5.3/src/view.cpp --- ddroom-1.0.5.2/src/view.cpp 2017-04-18 20:25:17.000000000 +0000 +++ ddroom-1.0.5.3/src/view.cpp 2017-04-23 09:11:23.000000000 +0000 @@ -223,16 +223,16 @@ tiles_len_y = std::vector(0); tiles_d_len_x = std::vector(0); tiles_d_len_y = std::vector(0); - for(int i = 0; i < tiles_areas.size(); ++i) + for(size_t i = 0; i < tiles_areas.size(); ++i) if(tiles_areas[i] != nullptr) delete tiles_areas[i]; tiles_areas = std::vector(0); if(deferred == false) { - for(int i = 0; i < tiles_pixmaps.size(); ++i) + for(size_t i = 0; i < tiles_pixmaps.size(); ++i) if(tiles_pixmaps[i] != nullptr) delete tiles_pixmaps[i]; } else { - for(int i = 0; i < tiles_pixmaps.size(); ++i) + for(size_t i = 0; i < tiles_pixmaps.size(); ++i) tiles_pixmaps_to_delete.push_back(tiles_pixmaps[i]); } tiles_pixmaps = std::vector(0); @@ -284,7 +284,7 @@ std::vector tv = tiles_d_len_y; tiles_d_len_y = tiles_d_len_x; tiles_d_len_x = tv; - for(int i = 0; i < tv.size(); ++i) + for(size_t i = 0; i < tv.size(); ++i) tiles_d_len_x[i] = tv[tv.size() - i - 1]; std::vector tv_i(w_out * h_out); std::vector tv_t; @@ -804,7 +804,7 @@ image->thumb_scaled = QPixmap(); // if 'image->scale == false' - rotate tiles and update center position; // reset tiles and emit update as whith resize otherwise. - for(int i = 0; i < image->tiles_pixmaps.size(); ++i) { + for(size_t i = 0; i < image->tiles_pixmaps.size(); ++i) { if(image->tiles_pixmaps[i] != nullptr) { *image->tiles_pixmaps[i] = rotate_pixmap(image->tiles_pixmaps[i], angle); // image->tiles_pixmaps[i]->swap(rotate_pixmap(image->tiles_pixmaps[i], angle)); @@ -900,7 +900,7 @@ to_update = true; } // check tiles - for(int i = 0; i < image->tiles_areas.size(); ++i) { + for(size_t i = 0; i < image->tiles_areas.size(); ++i) { if(image->tiles_areas[i] != nullptr) { if(image->tiles_pixmaps[i] != nullptr) delete image->tiles_pixmaps[i]; @@ -1317,7 +1317,7 @@ } std::vector tiles_i = image->arrange_tiles_indexes(raw_index_vector); tiles_descriptor.index_list_lock.lock(); - for(int i = 0; i < tiles_i.size(); ++i) { + for(size_t i = 0; i < tiles_i.size(); ++i) { int index = tiles_i[i]; // if(!tiles_descriptor.index_list.contains(index)) { auto &ref = tiles_descriptor.index_list; @@ -1569,7 +1569,7 @@ // update thumbnail in browser edit->update_thumbnail((void *)this, thumbnail); } else { - bool update = (tile->index >= 0 && tile->index < image->tiles_areas.size()); + bool update = (tile->index >= 0 && tile->index < (signed)image->tiles_areas.size()); if(update) { image->tiles_areas[tile->index] = tile->area; tile->area = nullptr; @@ -1876,7 +1876,7 @@ std::vector arranged_index_list = image->arrange_tiles_indexes(raw_index_vector); t->index_list_lock.lock(); - for(int i = 0; i < arranged_index_list.size(); ++i) + for(size_t i = 0; i < arranged_index_list.size(); ++i) t->index_list.push_back(arranged_index_list[i]); t->index_list_lock.unlock(); //cerr << "GET_TILES; image->rotation == " << image->rotation << endl;