# screenshot.cpp File Reference

The creation of screenshots! More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "fileio_func.h"`
`#include "viewport_func.h"`
`#include "gfx_func.h"`
`#include "screenshot.h"`
`#include "blitter/factory.hpp"`
`#include "zoom_func.h"`
`#include "core/endian_func.hpp"`
`#include "map_func.h"`
`#include "saveload/saveload.h"`
`#include "company_func.h"`
`#include "strings_func.h"`
`#include "gui.h"`
`#include "table/strings.h"`
`#include <png.h>`

Go to the source code of this file.

## Data Structures
struct | ScreenshotFormat
struct | BitmapFileHeader
| BMP File Header (stored in little endian). More...
struct | BitmapInfoHeader
| BMP Info Header (stored in little endian). More...
struct | RgbQuad
| Format of palette data in BMP header. More...
struct | PcxHeader
## Typedefs
typedef void | ScreenshotCallback (void *userdata, void *buf, uint y, uint pitch, uint n)
typedef bool | ScreenshotHandlerProc (const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
## Functions
| assert_compile (sizeof(BitmapFileHeader)==14)
| assert_compile (sizeof(BitmapInfoHeader)==40)
| assert_compile (sizeof(RgbQuad)==4)
static bool | MakeBMPImage (const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
| Generic .BMP writer.
static void PNGAPI | png_my_error (png_structp png_ptr, png_const_charp message)
static void PNGAPI | png_my_warning (png_structp png_ptr, png_const_charp message)
static bool | MakePNGImage (const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
| assert_compile (sizeof(PcxHeader)==128)
static bool | MakePCXImage (const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
void | InitializeScreenshotFormats ()
const char * | GetScreenshotFormatDesc (int i)
void | SetScreenshotFormat (int i)
static void | CurrentScreenCallback (void *userdata, void *buf, uint y, uint pitch, uint n)
static void | LargeWorldCallback (void *userdata, void *buf, uint y, uint pitch, uint n)
| generate a large piece of the world
static const char * | MakeScreenshotName (const char *ext)
static bool | MakeSmallScreenshot ()
static bool | MakeWorldScreenshot ()
bool | MakeScreenshot (ScreenshotType t, const char *name)
| Make an actual screenshot.
## Variables
char | _screenshot_format_name [8]
uint | _num_screenshot_formats
uint | _cur_screenshot_format
static char | _screenshot_name [128]
char | _full_screenshot_name [MAX_PATH]
struct BitmapFileHeader | GCC_PACK
| BMP File Header (stored in little endian).
static const ScreenshotFormat | _screenshot_formats []

## Detailed Description

The creation of screenshots!

Definition in file screenshot.cpp.

## Function Documentation

static void LargeWorldCallback | ( | void * | userdata,
|  | void * | buf,
|  | uint | y,
|  | uint | pitch,
|  | uint | n |
| ) |  |  | `[static]`

generate a large piece of the world

Parameters:

  | userdata | Viewport area to draw
  | buf | Videobuffer with same bitdepth as current blitter
  | y | First line to render
  | pitch | Pitch of the videobuffer
  | n | Number of lines to render

Definition at line 521 of file screenshot.cpp.

References _screen_disable_anim, ViewPort::left, min(), ScaleByZoom(), ViewPort::top, ViewPort::virtual_left, ViewPort::virtual_top, and ViewPort::width.

static bool MakeBMPImage | ( | const char * | name,
|  | ScreenshotCallback * | callb,
|  | void * | userdata,
|  | uint | w,
|  | uint | h,
|  | int | pixelformat,
|  | const Colour * | palette |
| ) |  |  | `[static]`

Generic .BMP writer.

Parameters:

  | name | file name including extension
  | callb | callback used for gathering rendered image
  | userdata | parameters forwarded to callb
  | w | width in pixels
  | h | height in pixels
  | pixelformat | bits per pixel
  | palette | colour palette (for 8bpp mode)

Returns:
  was everything ok?

Definition at line 92 of file screenshot.cpp.

References Align(), AllocaM, Clamp(), and min().

bool MakeScreenshot | ( | ScreenshotType | t,
|  | const char * | name |
| ) |  |  |

Make an actual screenshot.

Parameters:

  | t | the type of screenshot to make.
  | name | the name to give to the screenshot.

Returns:
  true iff the screenshow was made succesfully

Definition at line 631 of file screenshot.cpp.

References DrawDirtyBlocks(), INVALID_STRING_ID, lastof, SC_RAW, SC_VIEWPORT, SC_WORLD, SetDParamStr(), ShowErrorMessage(), and strecpy().

Referenced by CrashLog::WriteScreenshot().

## Variable Documentation

const ScreenshotFormat _screenshot_formats[]`[static]`

Initial value:

     {

      {"PNG", "png", &MakePNGImage},

      {"BMP", "bmp", &MakeBMPImage},
      {"PCX", "pcx", &MakePCXImage},
    }

Definition at line 475 of file screenshot.cpp.