54 int width,
int height) {
56 if ((width <= 0) || (height <= 0) || !data)
60 if (!file.
open(filename))
65 int extraDataSize = width & 3;
66 int imageSize = height * (width + extraDataSize) * 3;
88 if (extraDataSize != 0) {
91 file.
write(data, width * 3);
94 for (
int i = 0; i < extraDataSize; i++)
102 file.
write(data, width * height * 3);
119 glGetIntegerv(GL_VIEWPORT, m_viewport);
121 if ((m_viewport[2] <= 0) || (m_viewport[3] <= 0))
126 glReadPixels(0, 0, m_viewport[2], m_viewport[3], GL_BGR, GL_UNSIGNED_BYTE, screen.
get());
127 const bool success =
writeBMP(filename, screen.
get(), m_viewport[2], m_viewport[3]);
134 warning(
"Failed to take screenshot");
bool takeScreenshot()
Saves a screenshot to a file.
size_t write(const void *dataPtr, size_t dataSize)
Write data into the stream.
A class holding an UTF-8 string.
A date/time object, storing a specific point in time.
UString formatDateTimeISO(uint32 sep=0, uint32 sepDate=0, uint32 sepTime=0) const
Return a string representation of the date and time in ISO 8601 format.
static bool writeBMP(const Common::UString &filename, const byte *data, int width, int height)
bool constructFilename(Common::UString &filename)
A simple scoped smart pointer template.
Utility functions for manipulating date and time.
Threading system helpers.
const char * c_str() const
Return the (utf8 encoded) string data.
static UString getUserDataFile(UString file)
Return a path suitable for writing into.
bool open(const UString &fileName)
Try to open the file with the given fileName.
static bool isRegularFile(const UString &p)
Does specified path exist and is it a regular file?
void writeUint16LE(uint16 value)
void writeByte(byte value)
void warning(const char *s,...)
void flush()
Commit any buffered data to the underlying channel or storage medium; unbuffered streams can use the ...
PointerType get() const
Returns the plain pointer value.
void close()
Close the file, if open.
void enforceMainThread()
Throws an Exception if called from a non-main thread.
Coordinated Universal Time (UTC).
void status(const char *s,...)
Implementing the stream writing interfaces for files.
A simple streaming file writing class.
void writeUint32LE(uint32 value)
Utility class for manipulating file paths.