qmlfrontend/hwengine.cpp
changeset 14394 4409344db447
parent 14393 b6824a53d4b1
child 15919 d52f5d8e75e6
equal deleted inserted replaced
14393:b6824a53d4b1 14394:4409344db447
     1 #include "hwengine.h"
     1 #include "hwengine.h"
     2 
     2 
     3 #include <QDebug>
     3 #include <QDebug>
     4 #include <QImage>
     4 #include <QImage>
     5 #include <QLibrary>
       
     6 #include <QQmlEngine>
       
     7 #include <QUuid>
     5 #include <QUuid>
     8 
     6 
     9 #include "engine_instance.h"
     7 #include "engine_instance.h"
    10 #include "engine_interface.h"
     8 #include "engine_interface.h"
    11 #include "game_view.h"
     9 #include "game_view.h"
    25   if (!engine.isValid())  // TODO: error notification
    23   if (!engine.isValid())  // TODO: error notification
    26     return;
    24     return;
    27 
    25 
    28   engine.sendConfig(m_gameConfig);
    26   engine.sendConfig(m_gameConfig);
    29 
    27 
    30   Engine::PreviewInfo preview = engine.generatePreview();
    28   QImage previewImage = engine.generatePreview();
    31 
       
    32   QVector<QRgb> colorTable;
       
    33   colorTable.resize(256);
       
    34   for (int i = 0; i < 256; ++i) colorTable[i] = qRgba(255, 255, 0, i);
       
    35 
       
    36   QImage previewImage(preview.land, static_cast<int>(preview.width),
       
    37                       static_cast<int>(preview.height),
       
    38                       QImage::Format_Indexed8);
       
    39   previewImage.setColorTable(colorTable);
       
    40   previewImage.detach();
       
    41 
    29 
    42   if (m_previewAcceptor) m_previewAcceptor->setImage(previewImage);
    30   if (m_previewAcceptor) m_previewAcceptor->setImage(previewImage);
    43 
    31 
    44   emit previewImageChanged();
    32   emit previewImageChanged();
    45   // m_runQueue->queue(m_gameConfig);
    33   // m_runQueue->queue(m_gameConfig);