You are not logged in.
Because of Redshade's help I was able to make a screenshot function for GRRLIB 3.0.
First you need to include this:
#include <fat.h>
Add this function to GRRLIB.c:
/** * 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); if(!fatUnmount(PI_INTERNAL_SD)) { // I can only hope it's better than nothing fatUnsafeUnmount(PI_INTERNAL_SD); } } return !ErrorCode; }
Add the definition to GRRLIB.h:
bool GRRLIB_ScrShot(const char*);
Called it like that in your program:
if(GRRLIB_ScrShot("Screenshot.png")) strcpy(text, "A screenshot was taken!!!"); else strcpy(text, "Screenshot did not work!!!");
Offline
Nice one Crayon I was just about to look at this so you saved me a job, cheers!
Offline
You are mounting and unmounting fat throughout the application?
Offline
RedShade wrote:
You are mounting and unmounting fat throughout the application?
That's part of the code by feesh on this page:
http://wiibrew.org/wiki/Talk:Developmen … Shot.28.29
Because without the fatUnmount I think you can't make multiple screenshot, it only work once.
The solution would be to initialize fat outside GRRLIB. Anyway GGRLIB is a video library.
Offline
this is a very good function Crayon, thanks !!
Offline
what about making this compatible with PAL by using the rmode to get the size of the screen rather than hard coding it to 640x480?
Offline
With the new version of libfat the unmount command is not necessary anymore (I think), so the function should look like this:
/** * 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; }
The new unmount function is:
/* Unmount the partition specified by name. If there are open files, it will attempt to synchronise them to disc. */ extern void fatUnmount (const char* name);
Last edited by Crayon (2008-12-11 07:05:53)
Offline