Allocate ofImage

I initialize an ofImages using allocate. Doing this and printing the values before and after the allocate, i probably found where is my problem. I initialize the ofImage with correct value but, after the allocate function, the images has different values of height and width.
Example:
print(“height%d\n”, mat.cols);–>Correct value
print(“width%d\n”, mat.rows);–>Correct value
image.allocate(mat.cols,mat.rows,OF_IMAGE_GRAYSCALE)
print(“height%d\n”, image.gethight);–>Wrong value
print(“width%d\n”, image.getwidth);–>Wrong value
Why allocate create the image taking the correct height and width value and the final image as different height and width?

you seem to be swapping cols/rows width/height when allocating or really when printing in the first place. cols is width not height and rows is height

@arturo
I checked, the ofImage is allocated correctly(i made a mistake on the example code inside the post). After checking the allocation of the image, what could be the problem of the wrong value assignement?(after the ofImage allocation, width and height are both zero)

The problem must be somewhere else, this:

		ofImage img;
		img.allocate(640, 480, OF_IMAGE_GRAYSCALE);
		std::cout << img.getWidth() << ", " << img.getHeight() << std::endl;

works fine printing:

640, 480