#include "qgraphicspixmapoptimizeditem.h"#include <QStyle>#include <QPainter>#include <QStyleOptionGraphicsItem>#include <QImage>#include <QDebug>QGraphicsPixmapOptimizedItem::QGraphicsPixmapOptimizedItem() : QGraphicsPixmapItem(){ currImage = 0;}void QGraphicsPixmapOptimizedItem::setPixmap(const QPixmap &pixmap){ QGraphicsPixmapItem::setPixmap(pixmap); if (currImage) delete currImage; currImage = new QImage(pixmap.toImage());}void QGraphicsPixmapOptimizedItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ Q_UNUSED(widget); painter->setRenderHint(QPainter::SmoothPixmapTransform, (transformationMode() == Qt::SmoothTransformation)); QRectF exposed = option->exposedRect.adjusted(-1, -1, 1, 1); exposed &= QRectF(offset().x(), offset().y(), currImage->width(), currImage->height()); painter->drawImage(exposed, *currImage, exposed.translated(-offset()));}
ViewImageWidget::ViewImageWidget(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::ViewImageWidget){ m_ui->setupUi(this); graphicsScene = new QGraphicsScene(); m_ui->imageView->setScene(graphicsScene); m_ui->imageView->setDragMode(QGraphicsView::ScrollHandDrag); pixmapItem = new QGraphicsPixmapOptimizedItem(); pixmapItem->setShapeMode(QGraphicsPixmapItem::BoundingRectShape); pixmapItem->setCacheMode(QGraphicsPixmapItem::DeviceCoordinateCache); pixmapItem->setTransformationMode(Qt::SmoothTransformation); graphicsScene->addItem(pixmapItem);// ...}
void ViewImageWidget::updateImage(){// ... ((QGraphicsPixmapOptimizedItem *)pixmapItem)->setPixmap(QPixmap(currImagePath)); if (pixmapItem && (pixmapItem->pixmap().width() > m_ui->imageView->width() || pixmapItem->pixmap().height() > m_ui->imageView->height())) m_ui->imageView->fitInView(pixmapItem, Qt::KeepAspectRatio);}
$ cat callgrind.out.5060.tar.bz2.part_aa.txt callgrind.out.5060.tar.bz2.part_ab.txt > callgrind.out.5060.tar.bz2 && tar -jxvf callgrind.out.5060.tar.bz2bzip2: Data integrity error when decompressing. Input file = (stdin), output file = (stdout)It is possible that the compressed file(s) have become corrupted.You can use the -tvv option to test integrity of such files.You can use the `bzip2recover' program to attempt to recoverdata from undamaged sections of corrupted files.tar: Child returned status 2tar: Exiting with failure status due to previous errors