ofImage - saveImage return value

hey, I was hoping that the ofImage::saveImage method could return a bool of if it was saved successfuly or not. Looking at the code, there is a possibility of the save failing and with a void return value there is no way of checking if it was successful or not.

Cheers,
-plong0

here’s my modified version of the saveImageFromPixels that I’ve implemented into my ofxImage addon…

  
  
//----------------------------------------------------------------  
// copied directly from core ofImage::saveImageFromPixels  
// added bool return value  
bool ofxImage::saveImageFromPixels(string fileName, ofPixels &pix){  
	bool result = false;  
	if (pix.bAllocated == false){  
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");  
		return result;  
	}  
	  
#ifdef TARGET_LITTLE_ENDIAN  
	if (pix.bytesPerPixel != 1) swapRgb(pix);  
#endif  
	  
	FIBITMAP * bmp	= getBmpFromPixels(pix);  
	  
#ifdef TARGET_LITTLE_ENDIAN  
	if (pix.bytesPerPixel != 1) swapRgb(pix);  
#endif  
	  
	fileName = ofToDataPath(fileName);  
	if (pix.bAllocated == true){  
		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;  
		fif = FreeImage_GetFileType(fileName.c_str(), 0);  
		if(fif == FIF_UNKNOWN) {  
			// or guess via filename  
			fif = FreeImage_GetFIFFromFilename(fileName.c_str());  
		}  
		if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {  
			result = FreeImage_Save(fif, bmp, fileName.c_str(), 0);  
		}  
	}  
	  
	if (bmp != NULL){  
		FreeImage_Unload(bmp);  
	}  
	return result;  
}  
  

I am getting an error when compiling to Release mode with Xcode. Debug works fine.

If I comment out both instances of

  
   if (pix.bytesPerPixel != 1) swapRgb(pix);  

It goes through ok as well. Any ideas?