|
OpenTTD Source
1.10.0-RC1
|
The creation of screenshots! More...
#include "stdafx.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 "saveload/saveload.h"#include "company_base.h"#include "company_func.h"#include "strings_func.h"#include "error.h"#include "window_gui.h"#include "window_func.h"#include "tile_map.h"#include "landscape.h"#include "table/strings.h"#include "safeguards.h"#include <png.h>Go to the source code of this file.
Data Structures | |
| struct | ScreenshotFormat |
| Screenshot format information. More... | |
| struct | BitmapInfoHeader |
| BMP Info Header (stored in little endian) More... | |
| struct | RgbQuad |
| Format of palette data in BMP header. More... | |
| struct | PcxHeader |
| Definition of a PCX file header. More... | |
Macros | |
| #define | MKCOLOUR(x) TO_LE32X(x) |
Typedefs | |
| typedef void | ScreenshotCallback(void *userdata, void *buf, uint y, uint pitch, uint n) |
| Callback function signature for generating lines of pixel data to be written to the screenshot file. More... | |
| typedef bool | ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
| Function signature for a screenshot generation routine for one of the available formats. More... | |
Functions | |
| PACK (struct BitmapFileHeader { uint16 type;uint32 size;uint32 reserved;uint32 off_bits;}) | |
| BMP File Header (stored in little endian) | |
| 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. More... | |
| 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) |
| Generic .PNG file image writer. More... | |
| assert_compile (sizeof(PcxHeader)==128) | |
| static bool | MakePCXImage (const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
| Generic .PCX file image writer. More... | |
| const char * | GetCurrentScreenshotExtension () |
| Get filename extension of current screenshot file format. More... | |
| void | InitializeScreenshotFormats () |
| Initialize screenshot format information on startup, with _screenshot_format_name filled from the loadsave code. More... | |
| static void | CurrentScreenCallback (void *userdata, void *buf, uint y, uint pitch, uint n) |
| Callback of the screenshot generator that dumps the current video buffer. More... | |
| static void | LargeWorldCallback (void *userdata, void *buf, uint y, uint pitch, uint n) |
| generate a large piece of the world More... | |
| static const char * | MakeScreenshotName (const char *default_fn, const char *ext, bool crashlog=false) |
| Construct a pathname for a screenshot file. More... | |
| static bool | MakeSmallScreenshot (bool crashlog) |
| Make a screenshot of the current screen. More... | |
| void | SetupScreenshotViewport (ScreenshotType t, ViewPort *vp) |
| Configure a ViewPort for rendering (a part of) the map into a screenshot. More... | |
| static bool | MakeLargeWorldScreenshot (ScreenshotType t) |
| Make a screenshot of the map. More... | |
| static void | HeightmapCallback (void *userdata, void *buffer, uint y, uint pitch, uint n) |
| Callback for generating a heightmap. More... | |
| bool | MakeHeightmapScreenshot (const char *filename) |
| Make a heightmap of the current map. More... | |
| bool | MakeScreenshot (ScreenshotType t, const char *name) |
| Make an actual screenshot. More... | |
| static Owner | GetMinimapOwner (TileIndex tile) |
| Return the owner of a tile to display it with in the small map in mode "Owner". More... | |
| static void | MinimapScreenCallback (void *userdata, void *buf, uint y, uint pitch, uint n) |
| bool | MakeMinimapWorldScreenshot () |
| Make a minimap screenshot. | |
Variables | |
| static const char *const | SCREENSHOT_NAME = "screenshot" |
| Default filename of a saved screenshot. | |
| static const char *const | HEIGHTMAP_NAME = "heightmap" |
| Default filename of a saved heightmap. | |
| char | _screenshot_format_name [8] |
| Extension of the current screenshot format (corresponds with _cur_screenshot_format). | |
| uint | _num_screenshot_formats |
| Number of available screenshot formats. | |
| uint | _cur_screenshot_format |
| Index of the currently selected screenshot format in _screenshot_formats. | |
| static char | _screenshot_name [128] |
| Filename of the screenshot file. | |
| char | _full_screenshot_name [MAX_PATH] |
| Pathname of the screenshot file. | |
| static const ScreenshotFormat | _screenshot_formats [] |
| Available screenshot formats. More... | |
The creation of screenshots!
Definition in file screenshot.cpp.
| typedef void ScreenshotCallback(void *userdata, void *buf, uint y, uint pitch, uint n) |
Callback function signature for generating lines of pixel data to be written to the screenshot file.
| userdata | Pointer to user data. |
| buf | Destination buffer. |
| y | Line number of the first line to write. |
| pitch | Number of pixels to write (1 byte for 8bpp, 4 bytes for 32bpp). |
| n | Number of lines to write. |
Definition at line 49 of file screenshot.cpp.
| typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) |
Function signature for a screenshot generation routine for one of the available formats.
| name | Filename, including extension. |
| callb | Callback function for generating lines of pixels. |
| userdata | User data, passed on to callb. |
| w | Width of the image in pixels. |
| h | Height of the image in pixels. |
| pixelformat | Bits per pixel (bpp), either 8 or 32. |
| palette | Colour palette (for 8bpp images). |
Definition at line 62 of file screenshot.cpp.
|
static |
Callback of the screenshot generator that dumps the current video buffer.
Definition at line 597 of file screenshot.cpp.
Referenced by MakeSmallScreenshot().
| const char* GetCurrentScreenshotExtension | ( | ) |
Get filename extension of current screenshot file format.
Definition at line 574 of file screenshot.cpp.
References _cur_screenshot_format, and ScreenshotFormat::extension.
Referenced by FiosMakeHeightmapName().
Return the owner of a tile to display it with in the small map in mode "Owner".
| tile | The tile of which we would like to get the colour. |
Definition at line 901 of file screenshot.cpp.
References GetTileOwner(), GetTileType(), IsTileType(), MP_HOUSE, MP_INDUSTRY, MP_VOID, OWNER_DEITY, OWNER_END, and OWNER_TOWN.
|
static |
Callback for generating a heightmap.
Supports 8bpp grayscale only.
| userdata | Pointer to user data. |
| buffer | Destination buffer. |
| y | Line number of the first line to write. |
| pitch | Number of pixels to write (1 byte for 8bpp, 4 bytes for 32bpp). |
| n | Number of lines to write. |
Definition at line 801 of file screenshot.cpp.
Referenced by MakeHeightmapScreenshot().
| void InitializeScreenshotFormats | ( | ) |
Initialize screenshot format information on startup, with _screenshot_format_name filled from the loadsave code.
Definition at line 580 of file screenshot.cpp.
References _cur_screenshot_format, _num_screenshot_formats, _screenshot_format_name, ScreenshotFormat::extension, and lengthof.
|
static |
generate a large piece of the world
| 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 612 of file screenshot.cpp.
Referenced by MakeLargeWorldScreenshot().
|
static |
Generic .BMP writer.
| 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) |
Definition at line 112 of file screenshot.cpp.
| bool MakeHeightmapScreenshot | ( | const char * | filename | ) |
Make a heightmap of the current map.
| filename | Filename to use for saving. |
Definition at line 821 of file screenshot.cpp.
References _cur_screenshot_format, Colour::a, HeightmapCallback(), lengthof, MapSizeX(), MapSizeY(), and ScreenshotFormat::proc.
|
static |
Make a screenshot of the map.
| t | Screenshot type: World or viewport screenshot |
Definition at line 782 of file screenshot.cpp.
References _cur_palette, _cur_screenshot_format, ScreenshotFormat::extension, BlitterFactory::GetCurrentBlitter(), Blitter::GetScreenDepth(), ViewPort::height, LargeWorldCallback(), MakeScreenshotName(), Palette::palette, ScreenshotFormat::proc, SCREENSHOT_NAME, SetupScreenshotViewport(), and ViewPort::width.
|
static |
Generic .PCX file image writer.
| name | Filename, including extension. |
| callb | Callback function for generating lines of pixels. |
| userdata | User data, passed on to callb. |
| w | Width of the image in pixels. |
| h | Height of the image in pixels. |
| pixelformat | Bits per pixel (bpp), either 8 or 32. |
| palette | Colour palette (for 8bpp images). |
Definition at line 435 of file screenshot.cpp.
|
static |
Generic .PNG file image writer.
| name | Filename, including extension. |
| callb | Callback function for generating lines of pixels. |
| userdata | User data, passed on to callb. |
| w | Width of the image in pixels. |
| h | Height of the image in pixels. |
| pixelformat | Bits per pixel (bpp), either 8 or 32. |
| palette | Colour palette (for 8bpp images). |
Definition at line 258 of file screenshot.cpp.
| bool MakeScreenshot | ( | ScreenshotType | t, |
| const char * | name | ||
| ) |
Make an actual screenshot.
| t | the type of screenshot to make. |
| name | the name to give to the screenshot. |
Definition at line 840 of file screenshot.cpp.
References SC_VIEWPORT.
Referenced by MenuClickScreenshot(), ScreenshotWindow::ScreenshotConfirmationCallback(), and ScreenshotConfirmCallback().
|
static |
Construct a pathname for a screenshot file.
| default_fn | Default filename. |
| ext | Extension to use. |
| crashlog | Create path for crash.png |
Definition at line 667 of file screenshot.cpp.
References _screenshot_name, and StrEmpty().
Referenced by MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), and MakeSmallScreenshot().
|
static |
Make a screenshot of the current screen.
Definition at line 701 of file screenshot.cpp.
References _cur_screenshot_format, CurrentScreenCallback(), ScreenshotFormat::extension, MakeScreenshotName(), ScreenshotFormat::proc, and SCREENSHOT_NAME.
| void SetupScreenshotViewport | ( | ScreenshotType | t, |
| ViewPort * | vp | ||
| ) |
Configure a ViewPort for rendering (a part of) the map into a screenshot.
| t | Screenshot type | |
| [out] | vp | Result viewport |
Definition at line 713 of file screenshot.cpp.
References FindWindowById(), ViewPort::left, SC_CRASHLOG, SC_VIEWPORT, ViewPort::top, Window::viewport, ViewPort::virtual_height, ViewPort::virtual_left, ViewPort::virtual_top, ViewPort::virtual_width, WC_MAIN_WINDOW, and ViewPort::width.
Referenced by MakeLargeWorldScreenshot(), MenuClickScreenshot(), and ScreenshotWindow::TakeScreenshot().
|
static |
Available screenshot formats.
Definition at line 565 of file screenshot.cpp.