QImage img(data_image, Nc, Nl, Nc, QImage::Format_Indexed8); // Создание таблицы цветов. QVector<QRgb> color_table; for(int i = 0; i < 256; ++i) { color_table.append(qRgb(i,i,i)); } img.setColorTable(color_table); QImage optimal_img = img.convertToFormat(QImage::Format_Mono); delete data_image; p.drawText(font_X,font_Y,setable_text); QGraphicsScene* scene = new QGraphicsScene(this); scene->setSceneRect(0,0,28400,28400); QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); QGraphicsPixmapItem *item1 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); QGraphicsPixmapItem *item2 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); QGraphicsPixmapItem *item3 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); QGraphicsPixmapItem *item4 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); // на этот и следующий не хватает памяти QGraphicsPixmapItem *item5 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); QGraphicsPixmapItem *item6 = new QGraphicsPixmapItem(QPixmap::fromImage(optimal_img)); scene->addItem(item); scene->addItem(item1); scene->addItem(item2); scene->addItem(item3); scene->addItem(item4); scene->addItem(item5); //scene->addItem(item6); item1->setPos(7100, 0); item2->setPos(0, 7100); item3->setPos(7100, 7100); item4->setPos(14200, 7100); item5->setPos(14200, 14200); item6->setPos(14200, 28400); ui->graphicsView->setScene(scene);
I create a scene and place on it images with the size 7100х7100
format QImage::Format_Mono
. When you try to create more than 5 objects of type QGraphicsPixmapItem
images, a warning is issued that the RAM has QImage: out of memory, returning null image
: QImage: out of memory, returning null image
. It is really over, but I don’t really understand why QGraphicsPixmapItem
objects take up so much space, because:
QImage::Format_Mono The image is stored using 1-bit per pixel.
Or am I misunderstanding something? And how, then, should I place at least 20-24 images on the stage? Sample image: