FreeImage doesn't work

Hey guys.
I have a big problem and I don’t know how to solve this.
I am loading an image file with this function:

bool LoadTexture(const char* filename, GLenum imageFormat, GLint internalFormat, BYTE *imageData)
{
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
//pointer to the image, once loaded
FIBITMAP *dib(0);
//check the file signature and deduce its format
fif = FreeImage_GetFileType(filename, 0);
//if still unknown, try to guess the file format from the file extension
if(fif == FIF_UNKNOWN)
fif = FreeImage_GetFIFFromFilename(filename);
//if still unkown, return failure
if(fif == FIF_UNKNOWN)
return false;

  	//check that the plugin has reading capabilities and load the file
  	if(FreeImage_FIFSupportsReading(fif))
  		dib = FreeImage_Load(fif, filename);
  	//if the image failed to load, return failure
  	if(!dib)
  		return false;
  	//retrieve the image data
  	imageData = FreeImage_GetBits(dib);
  	//if this somehow one of these failed (they shouldn't), return failure
  	if(imageData == 0)
  		return false;
  	//Free FreeImage's copy of the data
  	FreeImage_Unload(dib);
  	//return success
  	return true;

}

When I try to render this Image Data with

glRasterPos2i(50,0);
glDrawPixels(64, 64, GL_RGB, GL_BYTE, iData);

I only see a black rectangle on the screen and I don’t know why. Please can anyone help?

FreeImage_GetBits returns pointer that is valid until you call FreeImage_Unload. So you are calling glDrawPixels with point to unallocated memory.

Ok thank you. But there is another problem. The picture should be red but it is still green. Why?
I tried to change GL_RGB to GL_BGR but now it is blue.

I found out that I need to use GL_UNSIGNED_BYTE instead of GL_BYTE but please can anyone tell me why?

GL_UNSIGNED_BYTE means that values are in range 0…255
GL_BYTE is signed number from -128 to 127.
Images are usually stored using unsigned numbers.

beware that FreeImage loads the image in pixel format defined by the image. It could be 8bit, 16bit, float, rgb, rgba, …