本文整理汇总了C++中BinaryInput::readUInt16方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryInput::readUInt16方法的具体用法?C++ BinaryInput::readUInt16怎么用?C++ BinaryInput::readUInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryInput
的用法示例。
在下文中一共展示了BinaryInput::readUInt16方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugAssertM
GFont::GFont(const String& filename, BinaryInput& b) {
int ver = b.readInt32();
debugAssertM(ver == 1 || ver == 2, "Can't read font files other than version 1");
(void)ver;
if (ver == 1) {
charsetSize = 128;
} else {
charsetSize = b.readInt32();
}
// Read the widths
subWidth.resize(charsetSize);
for (int c = 0; c < charsetSize; ++c) {
subWidth[c] = b.readUInt16();
}
baseline = b.readUInt16();
int texWidth = b.readUInt16();
charWidth = texWidth / 16;
charHeight = texWidth / 16;
// The input may not be a power of 2
int width = ceilPow2(charWidth * 16);
int height = ceilPow2(charHeight * (charsetSize / 16));
// Create a texture
const uint8* ptr = ((uint8*)b.getCArray()) + b.getPosition();
debugAssertM((b.getLength() - b.getPosition()) >= width * height,
"File does not contain enough data for this size texture");
Texture::Preprocess preprocess;
preprocess.computeMinMaxMean = false;
const bool generateMipMaps = true;
m_texture =
Texture::fromMemory
( filename,
ptr,
ImageFormat::R8(),
width,
height,
1,
1,
ImageFormat::R8(),
Texture::DIM_2D,
generateMipMaps,
preprocess);
m_textureMatrix[0] = 1.0f / m_texture->width();
m_textureMatrix[1] = 0;
m_textureMatrix[2] = 0;
m_textureMatrix[3] = 0;
m_textureMatrix[4] = 0;
m_textureMatrix[5] = 1.0f / m_texture->height();
m_textureMatrix[6] = 0;
m_textureMatrix[7] = 0;
m_textureMatrix[8] = 0;
m_textureMatrix[9] = 0;
m_textureMatrix[10] = 1;
m_textureMatrix[11] = 0;
m_textureMatrix[12] = 0;
m_textureMatrix[13] = 0;
m_textureMatrix[14] = 0;
m_textureMatrix[15] = 1;
m_name = filename;
}
示例2: decodeBMP
void GImage::decodeBMP(
BinaryInput& input) {
// The BMP decoding uses these flags.
static const uint16 PICTURE_NONE = 0x0000;
static const uint16 PICTURE_BITMAP = 0x1000;
// Compression Flags
static const uint16 PICTURE_UNCOMPRESSED = 0x0100;
static const uint16 PICTURE_MONOCHROME = 0x0001;
static const uint16 PICTURE_4BIT = 0x0002;
static const uint16 PICTURE_8BIT = 0x0004;
static const uint16 PICTURE_16BIT = 0x0008;
static const uint16 PICTURE_24BIT = 0x0010;
static const uint16 PICTURE_32BIT = 0x0020;
(void)PICTURE_16BIT;
(void)PICTURE_32BIT;
// This is a simple BMP loader that can handle uncompressed BMP files.
// Verify this is a BMP file by looking for the BM tag.
input.reset();
std::string tag = input.readString(2);
if (tag != "BM") {
throw Error("Not a BMP file", input.getFilename());
}
m_channels = 3;
// Skip to the BITMAPINFOHEADER's width and height
input.skip(16);
m_width = input.readUInt32();
m_height = input.readUInt32();
// Skip to the bit count and compression type
input.skip(2);
uint16 bitCount = input.readUInt16();
uint32 compressionType = input.readUInt32();
uint8 red;
uint8 green;
uint8 blue;
uint8 blank;
// Only uncompressed bitmaps are supported by this code
if ((int32)compressionType != BI_RGB) {
throw Error("BMP images must be uncompressed", input.getFilename());
}
uint8* palette = NULL;
// Create the palette if needed
if (bitCount <= 8) {
// Skip to the palette color count in the header
input.skip(12);
int numColors = input.readUInt32();
palette = (uint8*)System::malloc(numColors * 3);
debugAssert(palette);
// Skip past the end of the header to the palette info
input.skip(4);
int c;
for (c = 0; c < numColors * 3; c += 3) {
// Palette information in bitmaps is stored in BGR_ format.
// That means it's blue-green-red-blank, for each entry.
blue = input.readUInt8();
green = input.readUInt8();
red = input.readUInt8();
blank = input.readUInt8();
palette[c] = red;
palette[c + 1] = green;
palette[c + 2] = blue;
}
}
int hStart = 0;
int hEnd = 0;
int hDir = 0;
if (m_height < 0) {
m_height = -m_height;
hStart = 0;
hEnd = m_height;
hDir = 1;
} else {
//height = height;
hStart = m_height - 1;
hEnd = -1;
hDir = -1;
}
m_byte = (uint8*)m_memMan->alloc(m_width * m_height * 3);
debugAssert(m_byte);
//.........这里部分代码省略.........