mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
parent
acb40bc738
commit
8ad448a23c
4 changed files with 24 additions and 25 deletions
|
|
@ -422,7 +422,7 @@ PictureLoader::~PictureLoader()
|
|||
worker->deleteLater();
|
||||
}
|
||||
|
||||
void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
|
||||
void PictureLoader::getCardBackPixmap(QPixmap &pixmap, QSize size)
|
||||
{
|
||||
QString backCacheKey = "_trice_card_back_" + QString::number(size.width()) + QString::number(size.height());
|
||||
if(!QPixmapCache::find(backCacheKey, &pixmap))
|
||||
|
|
@ -435,29 +435,26 @@ void PictureLoader::internalGetCardBackPixmap(QPixmap &pixmap, QSize size)
|
|||
|
||||
void PictureLoader::getPixmap(QPixmap &pixmap, CardInfo *card, QSize size)
|
||||
{
|
||||
if(card)
|
||||
{
|
||||
// search for an exact size copy of the picure in cache
|
||||
QString key = card->getPixmapCacheKey();
|
||||
QString sizekey = key + QLatin1Char('_') + QString::number(size.width()) + QString::number(size.height());
|
||||
if(QPixmapCache::find(sizekey, &pixmap))
|
||||
return;
|
||||
if(card == nullptr)
|
||||
return;
|
||||
|
||||
// load the image and create a copy of the correct size
|
||||
QPixmap bigPixmap;
|
||||
if(QPixmapCache::find(key, &bigPixmap))
|
||||
{
|
||||
pixmap = bigPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QPixmapCache::insert(sizekey, pixmap);
|
||||
return;
|
||||
}
|
||||
// search for an exact size copy of the picure in cache
|
||||
QString key = card->getPixmapCacheKey();
|
||||
QString sizekey = key + QLatin1Char('_') + QString::number(size.width()) + QString::number(size.height());
|
||||
if(QPixmapCache::find(sizekey, &pixmap))
|
||||
return;
|
||||
|
||||
// add the card to the load queue
|
||||
getInstance().worker->enqueueImageLoad(card);
|
||||
} else {
|
||||
// requesting the image for a null card is a shortcut to get the card background image
|
||||
internalGetCardBackPixmap(pixmap, size);
|
||||
// load the image and create a copy of the correct size
|
||||
QPixmap bigPixmap;
|
||||
if(QPixmapCache::find(key, &bigPixmap))
|
||||
{
|
||||
pixmap = bigPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QPixmapCache::insert(sizekey, pixmap);
|
||||
return;
|
||||
}
|
||||
|
||||
// add the card to the load queue
|
||||
getInstance().worker->enqueueImageLoad(card);
|
||||
}
|
||||
|
||||
void PictureLoader::imageLoaded(CardInfo *card, const QImage &image)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue