//==============================================================================
//
// pgmcreate.c
//
// use:
// pgmcreate nWidth nHeight nBright filename.pgm 
//
//==============================================================================

#include <stdio.h>
#include "pgm.h"

int main(int nArg, char** ppArg)
{
	int i;
	int nW, nH;  // image width and height
	int nBr;     // image brightness
	byte* pIm;
	
	int nSize;
	
	if(nArg==1) 
	{
		puts("create uniform grey scale image and save it in .pgm files");
		puts("pgmcreate nWidth nHeight nBright filename.pgm ");
		exit(1);
	}
	
	nW  = atoi(ppArg[1]);
	nH  = atoi(ppArg[2]);
	nBr = atoi(ppArg[3]); 
	
	nSize = nW * nH;
	
	pIm = (byte*) malloc(nSize);
	
	for(i=0; i<nSize; i++)
	{
		pIm[i] = nBr;
	}
	
	WritePGM(ppArg[4], pIm, nW, nH);
	
	return 0;
}