本文整理汇总了C++中ImageLoader::init方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLoader::init方法的具体用法?C++ ImageLoader::init怎么用?C++ ImageLoader::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLoader
的用法示例。
在下文中一共展示了ImageLoader::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFrame
void CDefFile::loadFrame(size_t frame, size_t group, ImageLoader &loader) const
{
std::map<size_t, std::vector <size_t> >::const_iterator it;
it = offset.find(group);
assert (it != offset.end());
const ui8 * FDef = data+it->second[frame];
const SSpriteDef sd = * reinterpret_cast<const SSpriteDef *>(FDef);
SSpriteDef sprite;
sprite.format = read_le_u32(&sd.format);
sprite.fullWidth = read_le_u32(&sd.fullWidth);
sprite.fullHeight = read_le_u32(&sd.fullHeight);
sprite.width = read_le_u32(&sd.width);
sprite.height = read_le_u32(&sd.height);
sprite.leftMargin = read_le_u32(&sd.leftMargin);
sprite.topMargin = read_le_u32(&sd.topMargin);
ui32 currentOffset = sizeof(SSpriteDef);
ui32 BaseOffset = sizeof(SSpriteDef);
loader.init(Point(sprite.width, sprite.height),
Point(sprite.leftMargin, sprite.topMargin),
Point(sprite.fullWidth, sprite.fullHeight), palette);
switch (sprite.format)
{
case 0:
{
//pixel data is not compressed, copy data to surface
for (ui32 i=0; i<sprite.height; i++)
{
loader.Load(sprite.width, FDef[currentOffset]);
currentOffset += sprite.width;
loader.EndLine();
}
break;
}
case 1:
{
//for each line we have offset of pixel data
const ui32 * RWEntriesLoc = reinterpret_cast<const ui32 *>(FDef+currentOffset);
currentOffset += sizeof(ui32) * sprite.height;
for (ui32 i=0; i<sprite.height; i++)
{
//get position of the line
currentOffset=BaseOffset + read_le_u32(RWEntriesLoc + i);
ui32 TotalRowLength = 0;
while (TotalRowLength<sprite.width)
{
ui8 type=FDef[currentOffset++];
ui32 length=FDef[currentOffset++] + 1;
if (type==0xFF)//Raw data
{
loader.Load(length, FDef + currentOffset);
currentOffset+=length;
}
else// RLE
{
loader.Load(length, type);
}
TotalRowLength += length;
}
loader.EndLine();
}
break;
}
case 2:
{
currentOffset = BaseOffset + read_le_u16(FDef + BaseOffset);
for (ui32 i=0; i<sprite.height; i++)
{
ui32 TotalRowLength=0;
while (TotalRowLength<sprite.width)
{
ui8 SegmentType=FDef[currentOffset++];
ui8 code = SegmentType / 32;
ui8 length = (SegmentType & 31) + 1;
if (code==7)//Raw data
{
loader.Load(length, FDef[currentOffset]);
currentOffset += length;
}
else//RLE
{
loader.Load(length, code);
}
TotalRowLength+=length;
}
loader.EndLine();
}
break;
//.........这里部分代码省略.........