// // WritePNGfile // void WritePNGfile (FILE *file, const BYTE *buffer, const PalEntry *palette, ESSType color_type, int width, int height, int pitch) { if (!M_CreatePNG (file, buffer, palette, color_type, width, height, pitch) || !M_AppendPNGText (file, "Software", GAMENAME DOTVERSIONSTR) || !M_FinishPNG (file)) { Printf ("Could not create screenshot.\n"); } }
// // WritePNGfile // void WritePNGfile (FileWriter *file, const BYTE *buffer, const PalEntry *palette, ESSType color_type, int width, int height, int pitch) { char software[100]; mysnprintf(software, countof(software), GAMENAME " %s", GetVersionString()); if (!M_CreatePNG (file, buffer, palette, color_type, width, height, pitch) || !M_AppendPNGText (file, "Software", software) || !M_FinishPNG (file)) { Printf ("Could not create screenshot.\n"); } }
void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) { DCanvas *pic = new DSimpleCanvas (width, height); PalEntry palette[256]; // Take a snapshot of the player's view pic->ObjectFlags |= OF_Fixed; pic->Lock (); R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); screen->GetFlashedPalette (palette); M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch()); pic->Unlock (); pic->Destroy(); pic->ObjectFlags |= OF_YesReallyDelete; delete pic; }
void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height) { GL_IRECT bounds; bounds.left=0; bounds.top=0; bounds.width=width; bounds.height=height; glFlush(); SetFixedColormap(player); gl_RenderState.SetVertexBuffer(mVBO); GLRenderer->mVBO->Reset(); if (!gl.legacyMode) GLRenderer->mLights->Clear(); // Check if there's some lights. If not some code can be skipped. TThinkerIterator<ADynamicLight> it(STAT_DLIGHT); GLRenderer->mLightCount = ((it.Next()) != NULL); sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, FieldOfView.Degrees, 1.6f, 1.6f, true, false); glDisable(GL_STENCIL_TEST); gl_RenderState.SetFixedColormap(CM_DEFAULT); gl_RenderState.SetSoftLightLevel(-1); screen->Begin2D(false); if (!FGLRenderBuffers::IsEnabled()) { DrawBlend(viewsector); } CopyToBackbuffer(&bounds, false); glFlush(); byte * scr = (byte *)M_Malloc(width * height * 3); glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3); M_Free(scr); }