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 (?)

http://www.openframeworks.cc/files/0057-…-ithGui.zip

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(){  
	fakeFromFlickrImage.loadImage("fromFlickr.jpg");  
	fakeFromFlickrImage.resize(1024,768);  
}  
  
void testApp::draw(){	  
	fakeFromFlickrImage.draw(0,0);  
}  
  

Can anyone else replicate this problem?

Cheers,

JGL

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

cya!

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);  
	  
	#ifdef TARGET_LITTLE_ENDIAN  
		//if (pix.bytesPerPixel != 1) swapRgb(pix);  
	#endif  
  
	  
	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.

JGL

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…