1
我想在我的OpenGL應用程序上運行幾個單元測試。這導致我在過去幾個問題(OpenGL draw difference between 2 computers),但現在我知道我能做什麼,不能做什麼。奇怪的QImage比較結果
這裏有一個小測試,我寫了檢查渲染:
QImage display(grabFrameBuffer());
QImage wanted(PATH_TO_RESSOURCES + "/file_010.bmp");
int Qimage_width = display.width();
int Qimage_height = display.height();
for(int i = 1; i < Qimage_width; i++) {
for(int j = 1; j < Qimage_height; j++) {
if(QColor(display.pixel(i, j)).name() != QColor(wanted.pixel(i, j)).name()) {
qDebug() << "different pixel detected" << i << j;
}
}
}
QVERIFY(wanted == display);
的QVERIFY()失敗,但消息"different pixel detected" << i << j
從未顯示。 如果我用Photoshop比較文件(請參閱photo.stackexchange),我找不到任何不同的像素。我有點迷路。
編輯:我正在使用Qt 5.2,如果手動更改file_010.bmp上的一個像素,將顯示錯誤消息"different pixel detected" << i << j
。
你確定比較name()屬性是否恰當? –
@MartinDelille name()返回顏色十六進制代碼(即:##00ff00)如果代碼不同,像素不一樣。 –
嘗試比較顏色組分而不是:QColor :: red(),QColor :: blue()和QColor :: green() –