QImage::Format_Mono
의 QImage
을 만들었습니다. 이미지를 QGraphicsView
에 QGraphicsScene
을 통해 표시하려고하면보기가 변경되지 않습니다. QImage
은 QPixmap::fromImage()
기능을 통해 생성 된 QPixmap
을 사용하여 장면에로드됩니다. 또한 저장 기능을 사용하여 PNG/JPG/BMP로 QPixmap
을 저장하려고했지만 아무 소용이 없었습니다.QImage :: Format_mono to .png 및 QGraphicsScene
QGraphicsView *view = new QGraphicsView();
QGraphicsScene *scene = new QGraphicsScene();
view.setScene(scene);
QImage img(size,QImage::Format_Mono);
QVector<QRgb> v;
v.append(Qt::color0); // I have tried using black and white
v.append(Qt::color1); // instead of color0 and 1 as well.
img.setColorTable(v);
// Do some stuff to populate the image using img.setPixel(c,r,bw)
// where bw is an index either 0 or 1 and c and r are within bounds
QPixmap p = QPixmap::fromImage(img);
p.save("mono.png");
scene->addPixmap(p);
// Code to display the view
을 내가 대신 QImage::Format_RGB888
의 이미지를 확인하고 PNG /보기가 적절하게 표시 검은 색 또는 흰색 중 하나와 픽셀을 채울 경우 다음과 같이 기본 코드 구조입니다.
QGraphicsView
에 QImage
을 표시하도록 코드를 업데이트하려면 어떻게해야합니까?
그런데'view.setScene (scene);은 코드에있는 것이 아니라 오타에 불과합니다. – Boris