本文整理汇总了C++中common::WriteStream::writeUint32BE方法的典型用法代码示例。如果您正苦于以下问题:C++ WriteStream::writeUint32BE方法的具体用法?C++ WriteStream::writeUint32BE怎么用?C++ WriteStream::writeUint32BE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::WriteStream
的用法示例。
在下文中一共展示了WriteStream::writeUint32BE方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool SaveHeader::write(Common::WriteStream &stream) const {
stream.writeUint32BE(kID1);
stream.writeUint32BE(kID2);
stream.writeUint32BE(_type);
stream.writeUint32LE(_version);
stream.writeUint32LE(_size);
return flushStream(stream);
}
示例2: exportWAVImpl
void MainWindow::exportWAVImpl(Sound::AudioStream *sound, Common::WriteStream &wav) {
assert(sound);
const uint16 channels = sound->getChannels();
const uint32 rate = sound->getRate();
std::deque<SoundBuffer> buffers;
uint64 length = getSoundLength(sound);
if (length != Sound::RewindableAudioStream::kInvalidLength)
buffers.resize((length / (SoundBuffer::kBufferSize / channels)) + 1);
uint32 samples = 0;
std::deque<SoundBuffer>::iterator buffer = buffers.begin();
while (!sound->endOfStream()) {
if (buffer == buffers.end()) {
buffers.push_back(SoundBuffer());
buffer = --buffers.end();
}
buffer->samples = sound->readBuffer(buffer->buffer, SoundBuffer::kBufferSize);
if (buffer->samples > 0)
samples += buffer->samples;
++buffer;
}
samples /= channels;
const uint32 dataSize = samples * channels * 2;
const uint32 byteRate = rate * channels * 2;
const uint16 blockAlign = channels * 2;
wav.writeUint32BE(MKTAG('R', 'I', 'F', 'F'));
wav.writeUint32LE(36 + dataSize);
wav.writeUint32BE(MKTAG('W', 'A', 'V', 'E'));
wav.writeUint32BE(MKTAG('f', 'm', 't', ' '));
wav.writeUint32LE(16);
wav.writeUint16LE(1);
wav.writeUint16LE(channels);
wav.writeUint32LE(rate);
wav.writeUint32LE(byteRate);
wav.writeUint16LE(blockAlign);
wav.writeUint16LE(16);
wav.writeUint32BE(MKTAG('d', 'a', 't', 'a'));
wav.writeUint32LE(dataSize);
for (std::deque<SoundBuffer>::const_iterator b = buffers.begin(); b != buffers.end(); ++b)
for (int i = 0; i < b->samples; i++)
wav.writeUint16LE(b->buffer[i]);
}
示例3: saveThumbnail
bool saveThumbnail(Common::WriteStream &out, const Graphics::Surface &thumb) {
if (thumb.format.bytesPerPixel != 2) {
warning("trying to save thumbnail with bpp different than 2");
return false;
}
ThumbnailHeader header;
header.type = MKTAG('T','H','M','B');
header.size = ThumbnailHeaderSize + thumb.w*thumb.h*thumb.format.bytesPerPixel;
header.version = THMB_VERSION;
header.width = thumb.w;
header.height = thumb.h;
header.bpp = thumb.format.bytesPerPixel;
out.writeUint32BE(header.type);
out.writeUint32BE(header.size);
out.writeByte(header.version);
out.writeUint16BE(header.width);
out.writeUint16BE(header.height);
out.writeByte(header.bpp);
// TODO: for later this shouldn't be casted to uint16...
uint16 *pixels = (uint16 *)thumb.pixels;
for (uint16 p = 0; p < thumb.w*thumb.h; ++p, ++pixels)
out.writeUint16BE(*pixels);
return true;
}
示例4: if
Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const {
if (shouldQuit())
return 0;
Common::WriteStream *out = 0;
if (!(out = _saveFileMan->openForSaving(filename))) {
warning("Can't create file '%s', game not saved", filename);
return 0;
}
// Savegame version
out->writeUint32BE(MKTAG('W', 'W', 'S', 'V'));
out->writeByte(_flags.gameID);
out->writeUint32BE(CURRENT_SAVE_VERSION);
out->write(saveName, strlen(saveName) + 1);
if (_flags.isTalkie)
out->writeUint32BE(GF_TALKIE);
else if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
out->writeUint32BE(GF_FMTOWNS);
else
out->writeUint32BE(GF_FLOPPY);
if (out->err()) {
warning("Can't write file '%s'. (Disk full?)", filename);
delete out;
return 0;
}
Graphics::Surface *genThumbnail = 0;
if (!thumbnail)
thumbnail = genThumbnail = generateSaveThumbnail();
if (thumbnail)
Graphics::saveThumbnail(*out, *thumbnail);
else
Graphics::saveThumbnail(*out);
if (genThumbnail) {
genThumbnail->free();
delete genThumbnail;
}
return out;
}