[CHG] Add ScreenShot function and 16:9 correction

This commit is contained in:
N0NameN0 2009-03-05 23:40:10 +00:00
parent 346889e86b
commit 989faaabcc
2 changed files with 30 additions and 0 deletions

View file

@ -13,6 +13,7 @@
#include "../lib/libpng/pngu/pngu.h" #include "../lib/libpng/pngu/pngu.h"
#include "../lib/libjpeg/jpeglib.h" #include "../lib/libjpeg/jpeglib.h"
#include "GRRLIB.h" #include "GRRLIB.h"
#include <fat.h>
#define DEFAULT_FIFO_SIZE (256 * 1024) /**< GX fifo buffer size. */ #define DEFAULT_FIFO_SIZE (256 * 1024) /**< GX fifo buffer size. */
@ -898,6 +899,14 @@ void GRRLIB_Init() {
rmode = VIDEO_GetPreferredMode(NULL); rmode = VIDEO_GetPreferredMode(NULL);
if(rmode == NULL) if(rmode == NULL)
return; return;
/* Widescreen patch by CashMan's Productions (http://www.CashMan-Productions.fr.nf) */
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
{
rmode->viWidth = 678;
rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678)/2;
}
VIDEO_Configure(rmode); VIDEO_Configure(rmode);
xfb[0] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[0] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
xfb[1] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[1] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
@ -1008,3 +1017,21 @@ void GRRLIB_Exit() {
gp_fifo = NULL; gp_fifo = NULL;
} }
} }
/**
* Make a PNG screenshot on the SD card.
* @param File Name of the file to write.
* @return True if every thing worked, false otherwise.
*/
bool GRRLIB_ScrShot(const char* File)
{
IMGCTX pngContext;
int ErrorCode = -1;
if(fatInitDefault() && (pngContext = PNGU_SelectImageFromDevice(File)))
{
ErrorCode = PNGU_EncodeFromYCbYCr(pngContext, 640, 480, xfb[fb], 0);
PNGU_ReleaseImageContext(pngContext);
}
return !ErrorCode;
}

View file

@ -14,6 +14,7 @@
*/ */
#include <gccore.h> #include <gccore.h>
#include <ogc/conf.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -113,6 +114,8 @@ void GRRLIB_Render();
void GRRLIB_Exit(); void GRRLIB_Exit();
bool GRRLIB_ScrShot(const char*);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */