本文整理汇总了C++中Tileset::setTransparentColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::setTransparentColor方法的具体用法?C++ Tileset::setTransparentColor怎么用?C++ Tileset::setTransparentColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tileset
的用法示例。
在下文中一共展示了Tileset::setTransparentColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tr
Tileset *VariantToMapConverter::toTileset(const QVariant &variant)
{
const QVariantMap variantMap = variant.toMap();
const int firstGid = variantMap["firstgid"].toInt();
const QString name = variantMap["name"].toString();
const int tileWidth = variantMap["tilewidth"].toInt();
const int tileHeight = variantMap["tileheight"].toInt();
const int spacing = variantMap["spacing"].toInt();
const int margin = variantMap["margin"].toInt();
const QVariantMap tileOffset = variantMap["tileoffset"].toMap();
const int tileOffsetX = tileOffset["x"].toInt();
const int tileOffsetY = tileOffset["y"].toInt();
if (tileWidth <= 0 || tileHeight <= 0 || firstGid == 0) {
mError = tr("Invalid tileset parameters for tileset '%1'").arg(name);
return 0;
}
Tileset *tileset = new Tileset(name,
tileWidth, tileHeight,
spacing, margin);
tileset->setTileOffset(QPoint(tileOffsetX, tileOffsetY));
const QString trans = variantMap["transparentcolor"].toString();
if (!trans.isEmpty())
#if QT_VERSION >= 0x040700
if (QColor::isValidColor(trans))
#endif
tileset->setTransparentColor(QColor(trans));
QString imageSource = variantMap["image"].toString();
if (QDir::isRelativePath(imageSource))
imageSource = mMapDir.path() + QLatin1Char('/') + imageSource;
if (!tileset->loadFromImage(QImage(imageSource), imageSource)) {
mError = tr("Error loading tileset image:\n'%1'").arg(imageSource);
delete tileset;
return 0;
}
tileset->setProperties(toProperties(variantMap["properties"]));
QVariantMap propertiesVariantMap = variantMap["tileproperties"].toMap();
QVariantMap::const_iterator it = propertiesVariantMap.constBegin();
for (; it != propertiesVariantMap.constEnd(); ++it) {
const int tileIndex = it.key().toInt();
const QVariant propertiesVar = it.value();
if (tileIndex >= 0 && tileIndex < tileset->tileCount()) {
const Properties properties = toProperties(propertiesVar);
tileset->tileAt(tileIndex)->setProperties(properties);
}
}
mGidMapper.insert(firstGid, tileset);
return tileset;
}