void pListView::setImage(unsigned selection, unsigned position, const nall::image& image) { QTreeWidgetItem* item = qtListView->topLevelItem(selection); if(item) { if(image.empty() == 0) item->setIcon(position, CreateIcon(image)); if(image.empty() == 1) item->setIcon(position, QIcon()); } }
void pListView::setImage(unsigned row, unsigned column, const nall::image& image) { QTreeWidgetItem* item = qtListView->topLevelItem(row); if(item) { if(image.empty() == 0) item->setIcon(column, CreateIcon(image)); if(image.empty() == 1) item->setIcon(column, QIcon()); } }
static QIcon CreateIcon(const nall::image& image, bool scale = false) { if(image.empty()) return QIcon(); nall::image qtBuffer = image; qtBuffer.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0); if(scale) qtBuffer.scale(16, 16, Interpolation::Linear); QImage qtImage(qtBuffer.data, qtBuffer.width, qtBuffer.height, QImage::Format_ARGB32); return QIcon(QPixmap::fromImage(qtImage)); }