OFImage Resize Bug in 00573-Xcode-Fat-YCAM

Hey All,

I have been using the 00573-Xcode-Fat-YCAM version of oF which is up at the slightly secret (?)


As it has Poco included. I am aiming to query Flickr using its API and then display a series of images. Just to test the bug that I have found I have created a very simple app, which loads an RGB JPG from a local file. It then resizes it.

I have found that with the resize call, the channels get mixed up, resulting in an image with a blue cast.

void testApp::setup(){  
void testApp::draw(){	  

Can anyone else replicate this problem?



Hey Joel, yea I had this problem too…
You need to comment out the line:

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

in ofImage.cpp in resizePixels()

maybe there is a more ‘correct’ fix, but that worked for me


Hey Memo,

That works great for me.

void ofImage::resizePixels(ofPixels &pix, int newWidth, int newHeight){  
	FIBITMAP * bmp					= getBmpFromPixels(pix);  
	FIBITMAP * convertedBmp			= NULL;  
	convertedBmp = FreeImage_Rescale(bmp, newWidth, newHeight, FILTER_BICUBIC);  
	putBmpIntoPixels(convertedBmp, pix);  
		//if (pix.bytesPerPixel != 1) swapRgb(pix);  
	if (bmp != NULL)				FreeImage_Unload(bmp);  
	if (convertedBmp != NULL)		FreeImage_Unload(convertedBmp);  

Is that an Intel Mac/PPC issue? Surely that compiler flag for endian-ness must be set right in XCode by default. I am poking around the wiki for the OF0.06 fix list to see if it’s still in the latest dev build.


Hey Joel, yea the flag is set by XCode and is most probably set correctly, as Intel is Little endian (Least Signicifant Byte is stored at the lower address) - but I didn’t really look into why that swap there is incorrect cos I was in a rush at the time, and completely forgot about it later…

I guess the question is do powerpc users (big endian by default) see swapped channels when they resize? If so, the check should be for big endian instead of little. If they see correct channels when resized, then the check (and swap) doesn’t need to be there at all I guess…