#include "util.h"

void salvaImagem( char* nome  , int width , int height , unsigned char *data )
{
	int erro;

	imFile* ifile;

	ifile = imFileNew(nome, "JPEG", &erro);

	erro = imFileWriteImageInfo(ifile, width, height, IM_GRAY , IM_BYTE );

	erro = imFileWriteImageData(ifile, data);

	imFileClose(ifile); 
}

void salvaImagemRGB( char* nome  , int width , int height , imImage *data )
{
	int erro;

	imFile* ifile;

	ifile = imFileNew(nome, "JPEG", &erro);

	erro = imFileWriteImageInfo(ifile, width, height, IM_RGB , IM_BYTE );

	//erro = imFileWriteImageData(ifile, data->data);
	imSaveRGB( width , height , IM_JPG , data->data[0] , data->data[1] , data->data[2] , nome );

	imFileClose(ifile); 
}
