Fix #3619 and some minor clean-ups

This commit is contained in:
Flössie 2017-01-22 19:28:46 +01:00
parent 3f62b14703
commit 4649e1306f
6 changed files with 25 additions and 20 deletions

View File

@ -909,8 +909,11 @@ int ImageIO::loadPPMFromMemory(const char* buffer, int width, int height, bool s
int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps) int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps)
{ {
if (getW() < 1 || getH() < 1) {
return IMIO_HEADERERROR;
}
FILE *file = g_fopen_withBinaryAndLock (fname); FILE* const file = g_fopen_withBinaryAndLock (fname);
if (!file) { if (!file) {
return IMIO_CANNOTWRITEFILE; return IMIO_CANNOTWRITEFILE;
@ -1003,8 +1006,11 @@ int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps)
// Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high // Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high
int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp) int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
{ {
if (getW() < 1 || getH() < 1) {
return IMIO_HEADERERROR;
}
FILE *file = g_fopen_withBinaryAndLock (fname); FILE* const file = g_fopen_withBinaryAndLock (fname);
if (!file) { if (!file) {
return IMIO_CANNOTWRITEFILE; return IMIO_CANNOTWRITEFILE;
@ -1190,6 +1196,9 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp)
int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed)
{ {
if (getW() < 1 || getH() < 1) {
return IMIO_HEADERERROR;
}
//TODO: Handling 32 bits floating point output images! //TODO: Handling 32 bits floating point output images!
bool writeOk = true; bool writeOk = true;

View File

@ -5332,7 +5332,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited)
} }
if (keyFile.has_key ("Crop", "W")) { if (keyFile.has_key ("Crop", "W")) {
crop.w = std::max(keyFile.get_integer ("Crop", "W"),1); crop.w = std::max(keyFile.get_integer("Crop", "W"), 1);
if (pedited) { if (pedited) {
pedited->crop.w = true; pedited->crop.w = true;
@ -5340,7 +5340,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited)
} }
if (keyFile.has_key ("Crop", "H")) { if (keyFile.has_key ("Crop", "H")) {
crop.h = std::max(keyFile.get_integer ("Crop", "H"),1); crop.h = std::max(keyFile.get_integer("Crop", "H"), 1);
if (pedited) { if (pedited) {
pedited->crop.h = true; pedited->crop.h = true;

View File

@ -117,22 +117,19 @@ int StdImageSource::load (const Glib::ustring &fname, bool batch)
switch (sFormat) { switch (sFormat) {
case (IIOSF_UNSIGNED_CHAR): { case (IIOSF_UNSIGNED_CHAR): {
Image8 *img_8 = new Image8 (); img = new Image8;
img = img_8;
break; break;
} }
case (IIOSF_UNSIGNED_SHORT): { case (IIOSF_UNSIGNED_SHORT): {
Image16 *img_16 = new Image16 (); img = new Image16;
img = img_16;
break; break;
} }
case (IIOSF_LOGLUV24): case (IIOSF_LOGLUV24):
case (IIOSF_LOGLUV32): case (IIOSF_LOGLUV32):
case (IIOSF_FLOAT): { case (IIOSF_FLOAT): {
Imagefloat *img_float = new Imagefloat (); img = new Imagefloat;
img = img_float;
break; break;
} }

View File

@ -326,10 +326,10 @@ void Crop::read (const ProcParams* pp, const ParamsEdited* pedited)
guide->set_active (8); guide->set_active (8);
} }
x->set_value (pp->crop.x); x->set_value(pp->crop.x);
y->set_value (pp->crop.y); y->set_value(pp->crop.y);
w->set_value (std::max(pp->crop.w,1)); w->set_value(std::max(pp->crop.w, 1));
h->set_value (std::max(pp->crop.h,1)); h->set_value(std::max(pp->crop.h, 1));
nx = pp->crop.x; nx = pp->crop.x;
ny = pp->crop.y; ny = pp->crop.y;

View File

@ -27,9 +27,10 @@
class CropPanelListener class CropPanelListener
{ {
public: public:
virtual void cropSelectRequested () {} virtual ~CropPanelListener() = default;
virtual void cropSelectRequested() = 0;
}; };
class CropRatio class CropRatio
@ -42,7 +43,6 @@ public:
class Crop : public ToolParamBlock, public CropGUIListener, public FoldableToolPanel, public rtengine::SizeListener class Crop : public ToolParamBlock, public CropGUIListener, public FoldableToolPanel, public rtengine::SizeListener
{ {
protected: protected:
Gtk::CheckButton* fixr; Gtk::CheckButton* fixr;
MyComboBoxText* ratio; MyComboBoxText* ratio;
@ -70,7 +70,6 @@ protected:
std::vector<CropRatio> cropratio; std::vector<CropRatio> cropratio;
public: public:
Crop (); Crop ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr); void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);

View File

@ -284,8 +284,8 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
if ( if (
lastdot_pos != Glib::ustring::npos lastdot_pos != Glib::ustring::npos
&& lastdot_pos <= casefolded_path.size() - 4 && lastdot_pos <= casefolded_path.size() - 4
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension)) && !casefolded_path.compare(lastdot_pos, 4, paramFileExtension)
{ ) {
// removing the extension // removing the extension
// now use dot position without casefold() // now use dot position without casefold()
path = path.substr(0, path.find_last_of('.')); path = path.substr(0, path.find_last_of('.'));