You are not logged in.

#1 2008-06-30 20:46:37

Crayon
Bad Mother Fucker

I miss the screenshot function

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

 

#2 2008-06-30 22:14:07

RedShade
Member

Re: I miss the screenshot function

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:

Code:

            if ( (pngContext = PNGU_SelectImageFromDevice ("/scrnsht.png")) )  {
            PNGU_EncodeFromYCbYCr (pngContext, 640, 480, frameBuffer[fb], 0);
            PNGU_ReleaseImageContext (pngContext);
            }

Offline

 

#3 2008-06-30 22:50:20

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

Thanks RedShade, I will try that later, I just  want to specified that:

Code:

IMGCTX pngContext;

Offline

 

#4 2008-06-30 22:58:58

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

Oh yeah, and frameBuffer is xfb in GRRLIB, so the function should look like this:

Code:

void GRRLIB_ScrShot()
{
    IMGCTX pngContext;
    if( (pngContext = PNGU_SelectImageFromDevice ("/scrnsht.png")) )
    {
        PNGU_EncodeFromYCbYCr(pngContext, 640, 480, xfb[fb], 0);
        PNGU_ReleaseImageContext(pngContext);
    }
}

Offline

 

#5 2008-07-01 04:45:16

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

I added the complete code in the contribution section of the forum: http://grrlib.santo.fr/forum/viewtopic.php?pid=125

Have fun smile

Offline

 

#6 2008-11-22 17:11:48

chris
Member

Re: I miss the screenshot function

Does anyone have any idea how to use something like this to grab the screen into a texture that could then be redrawn?

Offline

 

#7 2008-11-22 17:48:06

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

Add this function to GRRLIB:

Code:

u8 *GRRLIB_Screen2Texture();

Code:

/**
 * 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:

Code:

u8 *CopiedImg;
CopiedImg = GRRLIB_Screen2Texture();
...
GRRLIB_DrawImg(0, 0, 640, 480, CopiedImg, 0, 1, 1, 255);

Offline

 

#8 2008-11-22 19:32:27

chris
Member

Re: I miss the screenshot function

Wow, thanks for the fast response!  Unfortunately, I can't get this to work and just end up with a black screen.

Offline

 

#9 2008-11-22 20:16:53

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

If you want download the source of my game and check how I use it:
http://wiibrew.org/wiki/Wii-Tac-Toe

Offline

 

#10 2008-11-22 20:54:14

Crayon
Bad Mother Fucker

Re: I miss the screenshot function

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

 

Board footer

Powered by FluxBB