From 989faaabcc8bf3e148447cef55df2f9dafb52b8e Mon Sep 17 00:00:00 2001 From: N0NameN0 Date: Thu, 5 Mar 2009 23:40:10 +0000 Subject: [PATCH] [CHG] Add ScreenShot function and 16:9 correction --- GRRLIB/GRRLIB/GRRLIB.c | 27 +++++++++++++++++++++++++++ GRRLIB/GRRLIB/GRRLIB.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/GRRLIB/GRRLIB/GRRLIB.c b/GRRLIB/GRRLIB/GRRLIB.c index 405422a..45441c7 100644 --- a/GRRLIB/GRRLIB/GRRLIB.c +++ b/GRRLIB/GRRLIB/GRRLIB.c @@ -13,6 +13,7 @@ #include "../lib/libpng/pngu/pngu.h" #include "../lib/libjpeg/jpeglib.h" #include "GRRLIB.h" +#include #define DEFAULT_FIFO_SIZE (256 * 1024) /**< GX fifo buffer size. */ @@ -898,6 +899,14 @@ void GRRLIB_Init() { rmode = VIDEO_GetPreferredMode(NULL); if(rmode == NULL) 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); xfb[0] = (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; } } + +/** + * 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; +} diff --git a/GRRLIB/GRRLIB/GRRLIB.h b/GRRLIB/GRRLIB/GRRLIB.h index bc19c02..fe765e0 100644 --- a/GRRLIB/GRRLIB/GRRLIB.h +++ b/GRRLIB/GRRLIB/GRRLIB.h @@ -14,6 +14,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -113,6 +114,8 @@ void GRRLIB_Render(); void GRRLIB_Exit(); +bool GRRLIB_ScrShot(const char*); + #ifdef __cplusplus } #endif /* __cplusplus */