mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-27 13:14:49 +01:00
Code cleanup
This commit is contained in:
parent
aeed3e3848
commit
1d4640c85c
@ -95,6 +95,25 @@ bool Sprites::load(const QString &jsonFile, const QString &imageFile)
|
|||||||
|
|
||||||
QImage Sprites::sprite(const Sprite &sprite, const QColor &color, qreal scale)
|
QImage Sprites::sprite(const Sprite &sprite, const QColor &color, qreal scale)
|
||||||
{
|
{
|
||||||
|
_lock.lock();
|
||||||
|
if (_init <= 0) {
|
||||||
|
if (_init < 0) {
|
||||||
|
_lock.unlock();
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
_img = QImage(_imageFile);
|
||||||
|
if (_img.isNull()) {
|
||||||
|
qWarning() << _imageFile << ": invalid sprite atlas image";
|
||||||
|
_init = -1;
|
||||||
|
_lock.unlock();
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
_init = 1;
|
||||||
|
}
|
||||||
|
_lock.unlock();
|
||||||
|
|
||||||
if (!_img.rect().contains(sprite.rect()))
|
if (!_img.rect().contains(sprite.rect()))
|
||||||
return QImage();
|
return QImage();
|
||||||
|
|
||||||
@ -118,25 +137,6 @@ QImage Sprites::icon(const QString &name, const QColor &color, qreal size)
|
|||||||
if (name.isNull())
|
if (name.isNull())
|
||||||
return QImage();
|
return QImage();
|
||||||
|
|
||||||
_lock.lock();
|
|
||||||
if (_init <= 0) {
|
|
||||||
if (_init < 0) {
|
|
||||||
_lock.unlock();
|
|
||||||
return QImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
_img = QImage(_imageFile);
|
|
||||||
if (_img.isNull()) {
|
|
||||||
qWarning() << _imageFile << ": invalid sprite atlas image";
|
|
||||||
_init = -1;
|
|
||||||
_lock.unlock();
|
|
||||||
return QImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
_init = 1;
|
|
||||||
}
|
|
||||||
_lock.unlock();
|
|
||||||
|
|
||||||
QMap<QString, Sprite>::const_iterator it = _sprites.constFind(name);
|
QMap<QString, Sprite>::const_iterator it = _sprites.constFind(name);
|
||||||
if (it == _sprites.constEnd())
|
if (it == _sprites.constEnd())
|
||||||
return QImage();
|
return QImage();
|
||||||
|
Loading…
Reference in New Issue
Block a user