#include <../source/TAL/objbase.h>
#include <../source/PAL/dataman.h>

/*
 *	Utility function to produce screenshots.
 */
vboolean	V_GLOBAL
vglSaveFramebuffer(char *file_name,u32_t mmWidth,u32_t mmHeight)
{
	u8_t *pixels;
	u32_t rw, rh;
	if(!file_name || !file_name[0])
	{
#ifdef	CHECKED_BUILD
		conlPrintf(LOG_ERROR,"vglSaveFramebuffer(%s,%u,%u): "
			"incorrect parameter.\n",
			strSafe(file_name),mmWidth,mmHeight);
#endif	/* CHECKED_BUILD */
		return false;
	}
	pixels = vglReadPixels(&rw,&rh);
	if(!pixels)
	{
#ifdef	CHECKED_BUILD
		conlPrintf(LOG_ERROR,"vglSaveFramebuffer(%s,%u,%u): "
			"vglReadPixels() failed.\n",
			strSafe(file_name),mmWidth,mmHeight);
#endif	/* CHECKED_BUILD */
		return false;
	}
	return rgbaSaveEx(file_name,rw,rh,pixels,mmWidth,mmHeight);
}
