本文整理汇总了C++中common::DumpFile::writeUint16LE方法的典型用法代码示例。如果您正苦于以下问题:C++ DumpFile::writeUint16LE方法的具体用法?C++ DumpFile::writeUint16LE怎么用?C++ DumpFile::writeUint16LE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::DumpFile
的用法示例。
在下文中一共展示了DumpFile::writeUint16LE方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeBMP
static bool writeBMP(const Common::UString &filename, const byte *data,
int width, int height) {
if ((width <= 0) || (height <= 0) || !data)
return false;
Common::DumpFile file;
if (!file.open(filename))
return false;
// The pitch of the output has to be divisible by 4, so
// we output zeroes to make the pitch that far.
int extraDataSize = width & 3;
int imageSize = height * (width + extraDataSize) * 3;
// Main bitmap header
file.writeByte('B');
file.writeByte('M');
file.writeUint32LE(14 + 40 + imageSize); // Size
file.writeUint32LE(0); // reserved
file.writeUint32LE(14 + 40); // Image offset after both headers
// v3 header
file.writeUint32LE(40);
file.writeUint32LE(width);
file.writeUint32LE(height);
file.writeUint16LE(1);
file.writeUint16LE(24);
file.writeUint32LE(0);
file.writeUint32LE(imageSize);
file.writeUint32LE(72);
file.writeUint32LE(72);
file.writeUint32LE(0);
file.writeUint32LE(0);
if (extraDataSize != 0) {
// Dump, making sure the pitch is correct
while (height--) {
file.write(data, width * 3);
// Ensure we're on a 4-byte boundary
for (int i = 0; i < extraDataSize; i++)
file.writeByte(0);
data += width * 3;
}
} else {
// Dump directly (can do all at once here because the data
// is already good for BMP output)
file.write(data, width * height * 3);
}
if (!file.flush() || file.err())
return false;
file.close();
return true;
}
示例2: cmdDumpImage
bool Console::cmdDumpImage(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Use %s <TGA/TGZ name> to dump a Z-Vision TGA/TGZ image into a regular BMP image\n", argv[0]);
return true;
}
Common::String fileName = argv[1];
if (!fileName.hasSuffix(".tga")) {
debugPrintf("%s is not an image file", argv[1]);
}
Common::File f;
if (!_engine->getSearchManager()->openFile(f, argv[1])) {
warning("File not found: %s", argv[1]);
return true;
}
Graphics::Surface surface;
_engine->getRenderManager()->readImageToSurface(argv[1], surface, false);
// Open file
Common::DumpFile out;
fileName.setChar('b', fileName.size() - 3);
fileName.setChar('m', fileName.size() - 2);
fileName.setChar('p', fileName.size() - 1);
out.open(fileName);
// Write BMP header
out.writeByte('B');
out.writeByte('M');
out.writeUint32LE(surface.h * surface.pitch + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(surface.w);
out.writeUint32LE(surface.h);
out.writeUint16LE(1);
out.writeUint16LE(16);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
// Write pixel data to BMP
out.write(surface.getPixels(), surface.pitch * surface.h);
out.flush();
out.close();
surface.free();
return true;
}
示例3: saveScreenshot
void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const {
const uint width = _outputScreenWidth;
const uint height = _outputScreenHeight;
// A line of a BMP image must have a size divisible by 4.
// We calculate the padding bytes needed here.
// Since we use a 3 byte per pixel mode, we can use width % 4 here, since
// it is equal to 4 - (width * 3) % 4. (4 - (width * Bpp) % 4, is the
// usual way of computing the padding bytes required).
const uint linePaddingSize = width % 4;
const uint lineSize = width * 3 + linePaddingSize;
// Allocate memory for screenshot
uint8 *pixels = new uint8[lineSize * height];
// Get pixel data from OpenGL buffer
GLCALL(glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels));
// BMP stores as BGR. Since we can't assume that GL_BGR is supported we
// will swap the components from the RGB we read to BGR on our own.
for (uint y = height; y-- > 0;) {
uint8 *line = pixels + y * lineSize;
for (uint x = width; x > 0; --x, line += 3) {
SWAP(line[0], line[2]);
}
}
// Open file
Common::DumpFile out;
out.open(filename);
// Write BMP header
out.writeByte('B');
out.writeByte('M');
out.writeUint32LE(height * lineSize + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(width);
out.writeUint32LE(height);
out.writeUint16LE(1);
out.writeUint16LE(24);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
// Write pixel data to BMP
out.write(pixels, lineSize * height);
// Free allocated memory
delete[] pixels;
}
示例4: cmdRawToWav
bool Console::cmdRawToWav(int argc, const char **argv) {
if (argc != 3) {
debugPrintf("Use %s <rawFilePath> <wavFileName> to dump a .RAW file to .WAV\n", argv[0]);
return true;
}
Common::File file;
if (!_engine->getSearchManager()->openFile(file, argv[1])) {
warning("File not found: %s", argv[1]);
return true;
}
Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine);
Common::DumpFile output;
output.open(argv[2]);
output.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
output.writeUint32LE(file.size() * 2 + 36);
output.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
output.writeUint32BE(MKTAG('f', 'm', 't', ' '));
output.writeUint32LE(16);
output.writeUint16LE(1);
uint16 numChannels;
if (audioStream->isStereo()) {
numChannels = 2;
output.writeUint16LE(2);
} else {
numChannels = 1;
output.writeUint16LE(1);
}
output.writeUint32LE(audioStream->getRate());
output.writeUint32LE(audioStream->getRate() * numChannels * 2);
output.writeUint16LE(numChannels * 2);
output.writeUint16LE(16);
output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
output.writeUint32LE(file.size() * 2);
int16 *buffer = new int16[file.size()];
audioStream->readBuffer(buffer, file.size());
#ifndef SCUMM_LITTLE_ENDIAN
for (int i = 0; i < file.size(); ++i)
buffer[i] = TO_LE_16(buffer[i]);
#endif
output.write(buffer, file.size() * 2);
delete[] buffer;
return true;
}
示例5: convertRawToWav
void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile) {
Common::File file;
if (!file.open(inputFile))
return;
Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine);
Common::DumpFile output;
output.open(outputFile);
output.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
output.writeUint32LE(file.size() * 2 + 36);
output.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
output.writeUint32BE(MKTAG('f', 'm', 't', ' '));
output.writeUint32LE(16);
output.writeUint16LE(1);
uint16 numChannels;
if (audioStream->isStereo()) {
numChannels = 2;
output.writeUint16LE(2);
} else {
numChannels = 1;
output.writeUint16LE(1);
}
output.writeUint32LE(audioStream->getRate());
output.writeUint32LE(audioStream->getRate() * numChannels * 2);
output.writeUint16LE(numChannels * 2);
output.writeUint16LE(16);
output.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
output.writeUint32LE(file.size() * 2);
int16 *buffer = new int16[file.size()];
audioStream->readBuffer(buffer, file.size());
output.write(buffer, file.size() * 2);
delete[] buffer;
}
示例6: getGLPixelFormat
//.........这里部分代码省略.........
if (hardwareFormat.bytesPerPixel == 2) {
uint16 *palette = (uint16 *)_cursor->getPalette() + _cursorKeyColor;
*palette &= ~aMask;
} else if (hardwareFormat.bytesPerPixel == 4) {
uint32 *palette = (uint32 *)_cursor->getPalette() + _cursorKeyColor;
*palette &= ~aMask;
} else {
warning("OpenGLGraphicsManager::updateCursorPalette: Unsupported pixel depth %d", hardwareFormat.bytesPerPixel);
}
}
void OpenGLGraphicsManager::recalculateCursorScaling() {
if (!_cursor || !_gameScreen) {
return;
}
// By default we use the unscaled versions.
_cursorHotspotXScaled = _cursorHotspotX;
_cursorHotspotYScaled = _cursorHotspotY;
_cursorWidthScaled = _cursor->getWidth();
_cursorHeightScaled = _cursor->getHeight();
// In case scaling is actually enabled we will scale the cursor according
// to the game screen.
if (!_cursorDontScale) {
const frac_t screenScaleFactorX = intToFrac(_displayWidth) / _gameScreen->getWidth();
const frac_t screenScaleFactorY = intToFrac(_displayHeight) / _gameScreen->getHeight();
_cursorHotspotXScaled = fracToInt(_cursorHotspotXScaled * screenScaleFactorX);
_cursorWidthScaled = fracToInt(_cursorWidthScaled * screenScaleFactorX);
_cursorHotspotYScaled = fracToInt(_cursorHotspotYScaled * screenScaleFactorY);
_cursorHeightScaled = fracToInt(_cursorHeightScaled * screenScaleFactorY);
}
}
#ifdef USE_OSD
const Graphics::Font *OpenGLGraphicsManager::getFontOSD() {
return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
}
#endif
void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const {
const uint width = _outputScreenWidth;
const uint height = _outputScreenHeight;
// A line of a BMP image must have a size divisible by 4.
// We calculate the padding bytes needed here.
// Since we use a 3 byte per pixel mode, we can use width % 4 here, since
// it is equal to 4 - (width * 3) % 4. (4 - (width * Bpp) % 4, is the
// usual way of computing the padding bytes required).
const uint linePaddingSize = width % 4;
const uint lineSize = width * 3 + linePaddingSize;
// Allocate memory for screenshot
uint8 *pixels = new uint8[lineSize * height];
// Get pixel data from OpenGL buffer
GLCALL(glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels));
// BMP stores as BGR. Since we can't assume that GL_BGR is supported we
// will swap the components from the RGB we read to BGR on our own.
for (uint y = height; y-- > 0;) {
uint8 *line = pixels + y * lineSize;
for (uint x = width; x > 0; --x, line += 3) {
SWAP(line[0], line[2]);
}
}
// Open file
Common::DumpFile out;
out.open(filename);
// Write BMP header
out.writeByte('B');
out.writeByte('M');
out.writeUint32LE(height * lineSize + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(width);
out.writeUint32LE(height);
out.writeUint16LE(1);
out.writeUint16LE(24);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
// Write pixel data to BMP
out.write(pixels, lineSize * height);
// Free allocated memory
delete[] pixels;
}
} // End of namespace OpenGL
示例7: getGLPixelFormat
//.........这里部分代码省略.........
}
if (_cursorPaletteEnabled) {
_cursor->setPalette(0, 256, _cursorPalette);
} else {
_cursor->setPalette(0, 256, _gamePalette);
}
_cursor->setColorKey(_cursorKeyColor);
}
void OpenGLGraphicsManager::recalculateCursorScaling() {
if (!_cursor || !_gameScreen) {
return;
}
// By default we use the unscaled versions.
_cursorHotspotXScaled = _cursorHotspotX;
_cursorHotspotYScaled = _cursorHotspotY;
_cursorWidthScaled = _cursor->getWidth();
_cursorHeightScaled = _cursor->getHeight();
// In case scaling is actually enabled we will scale the cursor according
// to the game screen.
if (!_cursorDontScale) {
const frac_t screenScaleFactorX = intToFrac(_displayWidth) / _gameScreen->getWidth();
const frac_t screenScaleFactorY = intToFrac(_displayHeight) / _gameScreen->getHeight();
_cursorHotspotXScaled = fracToInt(_cursorHotspotXScaled * screenScaleFactorX);
_cursorWidthScaled = fracToInt(_cursorWidthScaled * screenScaleFactorX);
_cursorHotspotYScaled = fracToInt(_cursorHotspotYScaled * screenScaleFactorY);
_cursorHeightScaled = fracToInt(_cursorHeightScaled * screenScaleFactorY);
}
}
#ifdef USE_OSD
const Graphics::Font *OpenGLGraphicsManager::getFontOSD() {
return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
}
#endif
void OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const {
const uint width = _outputScreenWidth;
const uint height = _outputScreenHeight;
// A line of a BMP image must have a size divisible by 4.
// We calculate the padding bytes needed here.
// Since we use a 3 byte per pixel mode, we can use width % 4 here, since
// it is equal to 4 - (width * 3) % 4. (4 - (width * Bpp) % 4, is the
// usual way of computing the padding bytes required).
const uint linePaddingSize = width % 4;
const uint lineSize = width * 3 + linePaddingSize;
// Allocate memory for screenshot
uint8 *pixels = new uint8[lineSize * height];
// Get pixel data from OpenGL buffer
GL_CALL(glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels));
// BMP stores as BGR. Since we can't assume that GL_BGR is supported we
// will swap the components from the RGB we read to BGR on our own.
for (uint y = height; y-- > 0;) {
uint8 *line = pixels + y * lineSize;
for (uint x = width; x > 0; --x, line += 3) {
SWAP(line[0], line[2]);
}
}
// Open file
Common::DumpFile out;
out.open(filename);
// Write BMP header
out.writeByte('B');
out.writeByte('M');
out.writeUint32LE(height * lineSize + 54);
out.writeUint32LE(0);
out.writeUint32LE(54);
out.writeUint32LE(40);
out.writeUint32LE(width);
out.writeUint32LE(height);
out.writeUint16LE(1);
out.writeUint16LE(24);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
out.writeUint32LE(0);
// Write pixel data to BMP
out.write(pixels, lineSize * height);
// Free allocated memory
delete[] pixels;
}
} // End of namespace OpenGL