You are not logged in.
I don't know how to access pixel on-screen so if someone could please help me. Now that the library support PNG it could be nice to have screenshots directly in PNG format.
Offline
I need to check on what exactly is involved, but I believe that that is what PNGU_EncodeFromYCbYCr is for.
YCbYCr is the format of the screen buffer.
For those interested, that's a good start. I haven't tested the following, but it seems the general idea of how a screenshot should work, since the Encode does filewriting based on its source.
On TehSkeen there was the following code:
if ( (pngContext = PNGU_SelectImageFromDevice ("/scrnsht.png")) ) { PNGU_EncodeFromYCbYCr (pngContext, 640, 480, frameBuffer[fb], 0); PNGU_ReleaseImageContext (pngContext); }
Offline
Thanks RedShade, I will try that later, I just want to specified that:
IMGCTX pngContext;
Offline
Oh yeah, and frameBuffer is xfb in GRRLIB, so the function should look like this:
void GRRLIB_ScrShot() { IMGCTX pngContext; if( (pngContext = PNGU_SelectImageFromDevice ("/scrnsht.png")) ) { PNGU_EncodeFromYCbYCr(pngContext, 640, 480, xfb[fb], 0); PNGU_ReleaseImageContext(pngContext); } }
Offline
I added the complete code in the contribution section of the forum: http://grrlib.santo.fr/forum/viewtopic.php?pid=125
Have fun
Offline
Does anyone have any idea how to use something like this to grab the screen into a texture that could then be redrawn?
Offline
Add this function to GRRLIB:
u8 *GRRLIB_Screen2Texture();
/** * Make a snapshot of the sreen in a texture. * @return A texture representing the screen. */ u8 *GRRLIB_Screen2Texture() { void *my_texture; GX_SetTexCopySrc(0, 0, 640, 480); GX_SetTexCopyDst(640, 480, GX_TF_RGBA8, GX_FALSE); my_texture = memalign(32, 640 * 480 * 4); // GX_GetTexBufferSize(640, 480, GX_TF_RGBA8, GX_FALSE, 1) GX_CopyTex(my_texture, GX_FALSE); GX_PixModeSync(); return my_texture; }
In your code you put something like:
u8 *CopiedImg; CopiedImg = GRRLIB_Screen2Texture(); ... GRRLIB_DrawImg(0, 0, 640, 480, CopiedImg, 0, 1, 1, 255);
Offline
Wow, thanks for the fast response! Unfortunately, I can't get this to work and just end up with a black screen.
Offline
If you want download the source of my game and check how I use it:
http://wiibrew.org/wiki/Wii-Tac-Toe
Offline
If you don't want look at all my code check this post: http://grrlib.santo.fr/forum/viewtopic.php?pid=376#p376
See the last message, I corrected my function.
Offline