@@ -93,19 +93,19 @@ struct ScreenshotFormat {
|
||||
|
||||
/** BMP File Header (stored in little endian) */
|
||||
PACK(struct BitmapFileHeader {
|
||||
uint16 type;
|
||||
uint32 size;
|
||||
uint32 reserved;
|
||||
uint32 off_bits;
|
||||
uint16_t type;
|
||||
uint32_t size;
|
||||
uint32_t reserved;
|
||||
uint32_t off_bits;
|
||||
});
|
||||
static_assert(sizeof(BitmapFileHeader) == 14);
|
||||
|
||||
/** BMP Info Header (stored in little endian) */
|
||||
struct BitmapInfoHeader {
|
||||
uint32 size;
|
||||
int32 width, height;
|
||||
uint16 planes, bitcount;
|
||||
uint32 compression, sizeimage, xpels, ypels, clrused, clrimp;
|
||||
uint32_t size;
|
||||
int32_t width, height;
|
||||
uint16_t planes, bitcount;
|
||||
uint32_t compression, sizeimage, xpels, ypels, clrused, clrimp;
|
||||
};
|
||||
static_assert(sizeof(BitmapInfoHeader) == 40);
|
||||
|
||||
@@ -193,8 +193,8 @@ static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *user
|
||||
/* Try to use 64k of memory, store between 16 and 128 lines */
|
||||
uint maxlines = Clamp(65536 / (w * pixelformat / 8), 16, 128); // number of lines per iteration
|
||||
|
||||
uint8 *buff = MallocT<uint8>(maxlines * w * pixelformat / 8); // buffer which is rendered to
|
||||
uint8 *line = AllocaM(uint8, bytewidth); // one line, stored to file
|
||||
uint8_t *buff = MallocT<uint8_t>(maxlines * w * pixelformat / 8); // buffer which is rendered to
|
||||
uint8_t *line = AllocaM(uint8_t, bytewidth); // one line, stored to file
|
||||
memset(line, 0, bytewidth);
|
||||
|
||||
/* Start at the bottom, since bitmaps are stored bottom up */
|
||||
@@ -326,7 +326,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
|
||||
text[0].text_length = strlen(_openttd_revision);
|
||||
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
|
||||
const uint32 text_buf_length = 65536;
|
||||
const uint32_t text_buf_length = 65536;
|
||||
char * const text_buf = MallocT<char>(text_buf_length);
|
||||
auto guard = scope_guard([=]() {
|
||||
free(text_buf);
|
||||
@@ -399,7 +399,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
|
||||
maxlines = Clamp(65536 / w, 16, 128);
|
||||
|
||||
/* now generate the bitmap bits */
|
||||
void *buff = CallocT<uint8>(static_cast<size_t>(w) * maxlines * bpp); // by default generate 128 lines at a time.
|
||||
void *buff = CallocT<uint8_t>(static_cast<size_t>(w) * maxlines * bpp); // by default generate 128 lines at a time.
|
||||
|
||||
y = 0;
|
||||
do {
|
||||
@@ -436,16 +436,16 @@ struct PcxHeader {
|
||||
byte version;
|
||||
byte rle;
|
||||
byte bpp;
|
||||
uint32 unused;
|
||||
uint16 xmax, ymax;
|
||||
uint16 hdpi, vdpi;
|
||||
uint32_t unused;
|
||||
uint16_t xmax, ymax;
|
||||
uint16_t hdpi, vdpi;
|
||||
byte pal_small[16 * 3];
|
||||
byte reserved;
|
||||
byte planes;
|
||||
uint16 pitch;
|
||||
uint16 cpal;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint16_t pitch;
|
||||
uint16_t cpal;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
byte filler[54];
|
||||
};
|
||||
static_assert(sizeof(PcxHeader) == 128);
|
||||
@@ -506,7 +506,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
|
||||
maxlines = Clamp(65536 / w, 16, 128);
|
||||
|
||||
/* now generate the bitmap bits */
|
||||
uint8 *buff = CallocT<uint8>(static_cast<size_t>(w) * maxlines); // by default generate 128 lines at a time.
|
||||
uint8_t *buff = CallocT<uint8_t>(static_cast<size_t>(w) * maxlines); // by default generate 128 lines at a time.
|
||||
|
||||
y = 0;
|
||||
do {
|
||||
@@ -520,14 +520,14 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
|
||||
|
||||
/* write them to pcx */
|
||||
for (i = 0; i != n; i++) {
|
||||
const uint8 *bufp = buff + i * w;
|
||||
const uint8_t *bufp = buff + i * w;
|
||||
byte runchar = bufp[0];
|
||||
uint runcount = 1;
|
||||
uint j;
|
||||
|
||||
/* for each pixel... */
|
||||
for (j = 1; j < w; j++) {
|
||||
uint8 ch = bufp[j];
|
||||
uint8_t ch = bufp[j];
|
||||
|
||||
if (ch != runchar || runcount >= 0x3f) {
|
||||
if (runcount > 1 || (runchar & 0xC0) == 0xC0) {
|
||||
@@ -758,7 +758,7 @@ static bool MakeSmallScreenshot(bool crashlog)
|
||||
* @param height the height of the screenshot, or 0 for current viewport height (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD).
|
||||
* @param[out] vp Result viewport
|
||||
*/
|
||||
void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32 width, uint32 height)
|
||||
void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32_t width, uint32_t height)
|
||||
{
|
||||
switch(t) {
|
||||
case SC_VIEWPORT:
|
||||
@@ -847,7 +847,7 @@ void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32 width, uint3
|
||||
* @param height the height of the screenshot of, or 0 for current viewport height.
|
||||
* @return true on success
|
||||
*/
|
||||
static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32 width = 0, uint32 height = 0)
|
||||
static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32_t width = 0, uint32_t height = 0)
|
||||
{
|
||||
Viewport vp;
|
||||
SetupScreenshotViewport(t, &vp, width, height);
|
||||
@@ -970,7 +970,7 @@ static void ShowScreenshotResultMessage(ScreenshotType t, bool ret)
|
||||
* @param height the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM).
|
||||
* @return true iff the screenshot was made successfully
|
||||
*/
|
||||
static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
|
||||
static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32_t width, uint32_t height)
|
||||
{
|
||||
if (t == SC_VIEWPORT) {
|
||||
/* First draw the dirty parts of the screen and only then change the name
|
||||
@@ -1042,7 +1042,7 @@ static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32 width,
|
||||
* @return true iff the screenshot was successfully made.
|
||||
* @see MakeScreenshotWithConfirm
|
||||
*/
|
||||
bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
|
||||
bool MakeScreenshot(ScreenshotType t, std::string name, uint32_t width, uint32_t height)
|
||||
{
|
||||
if (t == SC_CRASHLOG) {
|
||||
/* Video buffer might or might not be locked. */
|
||||
@@ -1271,7 +1271,7 @@ static byte GetIndustryValue(TileIndex tile)
|
||||
template <typename T>
|
||||
void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n, T colorCallback)
|
||||
{
|
||||
uint32 *ubuf = (uint32 *)buf;
|
||||
uint32_t *ubuf = (uint32_t *)buf;
|
||||
uint num = (pitch * n);
|
||||
for (uint i = 0; i < num; i++) {
|
||||
uint row = y + (int)(i / pitch);
|
||||
@@ -1280,7 +1280,7 @@ void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n
|
||||
TileIndex tile = TileXY(col, row);
|
||||
byte val = colorCallback(tile);
|
||||
|
||||
uint32 colour_buf = 0;
|
||||
uint32_t colour_buf = 0;
|
||||
colour_buf = (_cur_palette.palette[val].b << 0);
|
||||
colour_buf |= (_cur_palette.palette[val].g << 8);
|
||||
colour_buf |= (_cur_palette.palette[val].r << 16);
|
||||
|
Reference in New Issue
Block a user