OpenTTD Source  20241109-master-g5e4f8db7d6
screenshot.h File Reference

Functions to make screenshots. More...

Go to the source code of this file.

Enumerations

enum  ScreenshotType {
  SC_VIEWPORT , SC_CRASHLOG , SC_ZOOMEDIN , SC_DEFAULTZOOM ,
  SC_WORLD , SC_HEIGHTMAP , SC_MINIMAP
}
 Type of requested screenshot. More...
 

Functions

void InitializeScreenshotFormats ()
 Initialize screenshot format information on startup, with _screenshot_format_name filled from the loadsave code.
 
const char * GetCurrentScreenshotExtension ()
 Get filename extension of current screenshot file format.
 
void SetupScreenshotViewport (ScreenshotType t, struct Viewport *vp, uint32_t width=0, uint32_t height=0)
 Configure a Viewport for rendering (a part of) the map into a screenshot. More...
 
bool MakeHeightmapScreenshot (const char *filename)
 Make a heightmap of the current map. More...
 
void MakeScreenshotWithConfirm (ScreenshotType t)
 Make a screenshot. More...
 
bool MakeScreenshot (ScreenshotType t, std::string name, uint32_t width=0, uint32_t height=0)
 Schedule making a screenshot. More...
 
bool MakeMinimapWorldScreenshot ()
 Make a minimap screenshot.
 

Variables

std::string _screenshot_format_name
 Extension of the current screenshot format (corresponds with #_cur_screenshot_format).
 
std::string _full_screenshot_path
 Pathname of the screenshot file.
 

Detailed Description

Functions to make screenshots.

Definition in file screenshot.h.

Enumeration Type Documentation

◆ ScreenshotType

Type of requested screenshot.

Enumerator
SC_VIEWPORT 

Screenshot of viewport.

SC_CRASHLOG 

Raw screenshot from blitter buffer.

SC_ZOOMEDIN 

Fully zoomed in screenshot of the visible area.

SC_DEFAULTZOOM 

Zoomed to default zoom level screenshot of the visible area.

SC_WORLD 

World screenshot.

SC_HEIGHTMAP 

Heightmap of the world.

SC_MINIMAP 

Minimap screenshot.

Definition at line 18 of file screenshot.h.

Function Documentation

◆ MakeHeightmapScreenshot()

bool MakeHeightmapScreenshot ( const char *  filename)

Make a heightmap of the current map.

Parameters
filenameFilename to use for saving.

Definition at line 811 of file screenshot.cpp.

References _heightmap_highest_peak, Colour::a, lengthof, Map::Size(), and TileHeight().

◆ MakeScreenshot()

bool MakeScreenshot ( ScreenshotType  t,
std::string  name,
uint32_t  width,
uint32_t  height 
)

Schedule making a screenshot.

Unconditionally take a screenshot of the requested type.

Parameters
tthe type of screenshot to make.
namethe name to give to the screenshot.
widththe width of the screenshot of, or 0 for current viewport width (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
heightthe height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
Returns
true iff the screenshot was successfully made.
See also
MakeScreenshotWithConfirm

Definition at line 949 of file screenshot.cpp.

References VideoDriver::GetInstance(), lock, VideoDriver::QueueOnMainThread(), RealMakeScreenshot(), and SC_CRASHLOG.

Referenced by MakeScreenshotWithConfirm(), and ScreenshotConfirmationCallback().

◆ MakeScreenshotWithConfirm()

void MakeScreenshotWithConfirm ( ScreenshotType  t)

Make a screenshot.

Ask for confirmation first if the screenshot will be huge.

Parameters
tScreenshot type: World, defaultzoom, heightmap or viewport screenshot
See also
MakeScreenshot

Definition at line 847 of file screenshot.cpp.

References _confirmed_screenshot_type, Viewport::height, MakeScreenshot(), SC_HEIGHTMAP, SC_MINIMAP, ScreenshotConfirmationCallback(), SetDParam(), SetupScreenshotViewport(), ShowQuery(), Map::SizeX(), Map::SizeY(), and Viewport::width.

◆ SetupScreenshotViewport()

void SetupScreenshotViewport ( ScreenshotType  t,
Viewport vp,
uint32_t  width,
uint32_t  height 
)

Configure a Viewport for rendering (a part of) the map into a screenshot.

Parameters
tScreenshot type
widththe width of the screenshot, or 0 for current viewport width (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD).
heightthe height of the screenshot, or 0 for current viewport height (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD).
[out]vpResult viewport

Definition at line 694 of file screenshot.cpp.

References GetMainWindow(), Viewport::left, SC_CRASHLOG, SC_VIEWPORT, Viewport::top, Window::viewport, Viewport::virtual_height, Viewport::virtual_left, Viewport::virtual_top, Viewport::virtual_width, and Viewport::width.

Referenced by MakeLargeWorldScreenshot(), and MakeScreenshotWithConfirm().