本文整理汇总了C++中common::MemoryReadStream::readUint16BE方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryReadStream::readUint16BE方法的具体用法?C++ MemoryReadStream::readUint16BE怎么用?C++ MemoryReadStream::readUint16BE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::MemoryReadStream
的用法示例。
在下文中一共展示了MemoryReadStream::readUint16BE方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadChunked
void PictureResource::loadChunked(byte *source, int size) {
// Loads a "chunked" picture as used in Manhole EGA
Common::MemoryReadStream *sourceS = new Common::MemoryReadStream(source, size);
byte cmdFlags = 0, pixelFlags = 0, maskFlags = 0;
uint16 cmdOffs = 0, pixelOffs = 0, maskOffs = 0;
uint16 lineSize = 0, width = 0, height = 0;
sourceS->skip(36); // skip the "Flex" header
_hasPalette = false;
while (!sourceS->eos()) {
uint32 chunkType = sourceS->readUint32BE();
uint32 chunkSize = sourceS->readUint32BE();
if (sourceS->eos())
break;
debug(0, "chunkType = %08X; chunkSize = %d", chunkType, chunkSize);
if (chunkType == MKTAG('R','e','c','t')) {
debug(0, "Rect");
sourceS->skip(4);
height = sourceS->readUint16BE();
width = sourceS->readUint16BE();
debug(0, "width = %d; height = %d", width, height);
} else if (chunkType == MKTAG('f','M','a','p')) {
debug(0, "fMap");
lineSize = sourceS->readUint16BE();
sourceS->skip(11);
cmdFlags = sourceS->readByte();
cmdOffs = sourceS->pos();
sourceS->skip(chunkSize - 14);
debug(0, "lineSize = %d; cmdFlags = %d; cmdOffs = %04X", lineSize, cmdFlags, cmdOffs);
} else if (chunkType == MKTAG('f','L','C','o')) {
debug(0, "fLCo");
sourceS->skip(9);
pixelFlags = sourceS->readByte();
pixelOffs = sourceS->pos();
sourceS->skip(chunkSize - 10);
debug(0, "pixelFlags = %d; pixelOffs = %04X", pixelFlags, pixelOffs);
} else if (chunkType == MKTAG('f','P','i','x')) {
debug(0, "fPix");
sourceS->skip(9);
maskFlags = sourceS->readByte();
maskOffs = sourceS->pos();
sourceS->skip(chunkSize - 10);
debug(0, "maskFlags = %d; maskOffs = %04X", maskFlags, maskOffs);
} else if (chunkType == MKTAG('f','G','C','o')) {
debug(0, "fGCo");
_hasPalette = true;
_paletteColorCount = chunkSize / 3;
_picturePalette = new byte[_paletteColorCount * 3];
sourceS->read(_picturePalette, _paletteColorCount * 3);
} else {
error("PictureResource::loadChunked() Invalid chunk %08X at %08X", chunkType, sourceS->pos());
}
}
if (!cmdOffs || !pixelOffs /*|| !maskOffs*/ || !lineSize || !width || !height) {
error("PictureResource::loadChunked() Error parsing the picture data, one or more chunks/parameters are missing");
}
_picture = new Graphics::Surface();
_picture->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
decompressImage(source, *_picture, cmdOffs, pixelOffs, maskOffs, lineSize, cmdFlags, pixelFlags, maskFlags);
delete sourceS;
}