cannot make a clone of a grayscale ofImage

cannot make a clone of a grayscale ofImage.
please help me!

i am using the following version.—latest-fixes/638/0

void testApp::setup() {	   
	ofBackground(255, 255, 255);  
	orig.allocate(400, 400, OF_IMAGE_GRAYSCALE);  
	unsigned char *pix = new unsigned char[400*400];   
	for (int i = 0; i < 400*400; i++) {   
		pix[i] = (unsigned char)(ofRandomuf() * 255);   
	orig.setFromPixels(pix, 400, 400, OF_IMAGE_GRAYSCALE);  
	delete[] pix;  
	copy = orig;  
void testApp::draw(){  
	//this result is a black image.  
	//however, if it is a color image, it is duplicated without trouble.   
	copy.draw(10, 10);  

You might already have this somewhere in your code but just to be thorough, do you have this somewhere before the copy:

copy.allocate(400, 400, OF_IMAGE_GRAYSCALE);


Thank you for your advice.
I tried allocating before clone. But, the result did not change…

two fixes fix this problem

a) is in svn –…-D=%2F@HEAD

change in update():

bool bNoPallette = (FreeImage_GetColorType(bmp) != FIC_PALETTE);  


bool bNoPallette = (FreeImage_GetColorType(bmp) != FIC_PALETTE) || type == OF_IMAGE_GRAYSCALE;  

b) is not in svn, but will be shortly…

adding one line to clone:

void ofImage::clone(const ofImage &mom){  
	// this *not* optimal if mom.w, mom.h = our w/h  
	// we shouldn't delete and recreate....  
	// delete everything if we exist:  
	// clone:  
	bmp = FreeImage_Clone(mom.bmp);  
	type = mom.type;   // zach -- added this, to avoid palette mistake  
	// update:  

that should do the trick - both orig and copy work for me

thanks for pointing it out!!


Thank you for quick fix!!

I am developing Ruby language bridge of openFrameworks now.
Therefore, I want the latest version.
Where can I get it? I have svn client.

sounds interesting! I know some serious ruby fans that’d be into this. I can put you in touch if you want to bounce ideas off of them. (or start a thread, I’ll forward them that way)

there is info here about the latest versions / svn here:—latest-fixes/638/0

take care!

  • zach

thanks for info about svn. i had overlooked it.

now, about 50% in oF-core has been exported to ruby.
if translation goes well, i will report again!