dumb
This commit is contained in:
parent
e765b9400c
commit
892e650712
|
@ -1082,14 +1082,14 @@ UINT8 *HWR_GetScreenshot(void)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean HWR_Screenshot(const char *pathname, char **error)
|
boolean HWR_Screenshot(const char *pathname)
|
||||||
{
|
{
|
||||||
boolean ret;
|
boolean ret;
|
||||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
*error = "Failed to allocate memory for HWR_Screenshot";
|
CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,7 +1097,7 @@ boolean HWR_Screenshot(const char *pathname, char **error)
|
||||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
||||||
|
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL, &*error); // c_irl
|
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||||
#else
|
#else
|
||||||
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
ret = saveTGA(pathname, buf, vid.width, vid.height);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,7 +53,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
|
||||||
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
|
||||||
|
|
||||||
UINT8 *HWR_GetScreenshot(void);
|
UINT8 *HWR_GetScreenshot(void);
|
||||||
boolean HWR_Screenshot(const char *pathname, char **error);
|
boolean HWR_Screenshot(const char *pathname);
|
||||||
|
|
||||||
void HWR_AddCommands(void);
|
void HWR_AddCommands(void);
|
||||||
void HWR_CorrectSWTricks(void);
|
void HWR_CorrectSWTricks(void);
|
||||||
|
|
18
src/m_misc.c
18
src/m_misc.c
|
@ -1285,9 +1285,8 @@ void M_StopMovie(void)
|
||||||
* \param height Height of the picture.
|
* \param height Height of the picture.
|
||||||
* \param palette Palette of image data.
|
* \param palette Palette of image data.
|
||||||
* \note if palette is NULL, BGR888 format
|
* \note if palette is NULL, BGR888 format
|
||||||
* \param error Error string to return, if screenshot failed.
|
|
||||||
*/
|
*/
|
||||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error)
|
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette)
|
||||||
{
|
{
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop png_info_ptr;
|
png_infop png_info_ptr;
|
||||||
|
@ -1302,14 +1301,14 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
||||||
png_FILE = fopen(filename,"wb");
|
png_FILE = fopen(filename,"wb");
|
||||||
if (!png_FILE)
|
if (!png_FILE)
|
||||||
{
|
{
|
||||||
*error = "Failed to open file for write";
|
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for write\n", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
{
|
{
|
||||||
*error = "Failed to initialize libpng";
|
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n");
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
remove(filename);
|
remove(filename);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1318,7 +1317,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
||||||
png_info_ptr = png_create_info_struct(png_ptr);
|
png_info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (!png_info_ptr)
|
if (!png_info_ptr)
|
||||||
{
|
{
|
||||||
*error = "Failed to allocate memory for libpng";
|
CONS_Debug(DBG_RENDER, "M_SavePNG: Error on allocate for libpng\n");
|
||||||
png_destroy_write_struct(&png_ptr, NULL);
|
png_destroy_write_struct(&png_ptr, NULL);
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
remove(filename);
|
remove(filename);
|
||||||
|
@ -1331,7 +1330,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const
|
||||||
if (setjmp(png_jmpbuf(png_ptr)))
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
*error = "libpng write error";
|
//CONS_Debug(DBG_RENDER, "libpng write error on %s\n", filename);
|
||||||
png_destroy_write_struct(&png_ptr, &png_info_ptr);
|
png_destroy_write_struct(&png_ptr, &png_info_ptr);
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
remove(filename);
|
remove(filename);
|
||||||
|
@ -1470,7 +1469,6 @@ void M_DoScreenShot(void)
|
||||||
#if NUMSCREENS > 2
|
#if NUMSCREENS > 2
|
||||||
const char *freename = NULL, *pathname = ".";
|
const char *freename = NULL, *pathname = ".";
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
char *error = "Unknown error";
|
|
||||||
UINT8 *linear = NULL;
|
UINT8 *linear = NULL;
|
||||||
|
|
||||||
// Don't take multiple screenshots, obviously
|
// Don't take multiple screenshots, obviously
|
||||||
|
@ -1511,13 +1509,13 @@ void M_DoScreenShot(void)
|
||||||
// save the pcx file
|
// save the pcx file
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
ret = HWR_Screenshot(va(pandf,pathname,freename), &error);
|
ret = HWR_Screenshot(va(pandf,pathname,freename));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
M_CreateScreenShotPalette();
|
M_CreateScreenShotPalette();
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette, &error);
|
ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||||
#else
|
#else
|
||||||
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1532,7 +1530,7 @@ failure:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (freename)
|
if (freename)
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s (%s)\n"), freename, pathname, error);
|
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname);
|
||||||
else
|
else
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname);
|
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void FIL_ForceExtension(char *path, const char *extension);
|
||||||
boolean FIL_CheckExtension(const char *in);
|
boolean FIL_CheckExtension(const char *in);
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette, char **error);
|
boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern boolean takescreenshot;
|
extern boolean takescreenshot;
|
||||||
|
|
Loading…
Reference in New Issue