MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / SaveScreenshot

Method SaveScreenshot

Source/SysPSP/Graphics/GraphicsContext.cpp:481–523  ·  view source on GitHub ↗

Save current visible screen as PNG From Shazz/71M - thanks guys!

Source from the content-addressed store, hash-verified

479// From Shazz/71M - thanks guys!
480//*****************************************************************************
481void IGraphicsContext::SaveScreenshot( const char* filename, s32 x, s32 y, u32 width, u32 height )
482{
483 void * buffer;
484 int bufferwidth;
485 int pixelformat;
486 int unknown = 0;
487
488 sceDisplayWaitVblankStart(); // if framebuf was set with PSP_DISPLAY_SETBUF_NEXTFRAME, wait until it is changed
489 sceDisplayGetFrameBuf( &buffer, &bufferwidth, &pixelformat, unknown );
490
491 ETextureFormat texture_format;
492 u32 bpp;
493
494 switch( pixelformat )
495 {
496 case PSP_DISPLAY_PIXEL_FORMAT_565:
497 texture_format = TexFmt_5650;
498 bpp = 2;
499 break;
500 case PSP_DISPLAY_PIXEL_FORMAT_5551:
501 texture_format = TexFmt_5551;
502 bpp = 2;
503 break;
504 case PSP_DISPLAY_PIXEL_FORMAT_4444:
505 texture_format = TexFmt_4444;
506 bpp = 2;
507 break;
508 case PSP_DISPLAY_PIXEL_FORMAT_8888:
509 texture_format = TexFmt_8888;
510 bpp = 4;
511 break;
512 default:
513 texture_format = TexFmt_8888;
514 bpp = 4;
515 break;
516 }
517
518 u32 pitch( bufferwidth * bpp );
519
520 buffer = reinterpret_cast< u8 * >( buffer ) + (y * pitch) + (x * bpp);
521
522 PngSaveImage( filename, buffer, nullptr, texture_format, pitch, width, height, false );
523}
524
525//*****************************************************************************
526//

Callers

nothing calls this directly

Calls 1

PngSaveImageFunction · 0.85

Tested by

no test coverage detected