Answer the question
In order to leave comments, you need to log in
How to convert an image to binary with a custom color table so that the quality of the result does not suffer?
Hello. There is this code:
QApplication a(argc, argv);
//Адрес ресурса: :/<prefix>/<alias>
const QString file_name = ":/ferrari.jpeg";
QImage mono_img(file_name);
QVector<QRgb> color_table(2);
color_table[0] = QColor(Qt::white).rgb();
color_table[1] = QColor(Qt::red).rgb();
mono_img = mono_img.convertToFormat(QImage::Format_Mono, color_table);
QLabel label;
label.setPixmap(QPixmap::fromImage(mono_img));
label.show();
return a.exec();
mono_img.convertToFormat(QImage::Format_Mono);
Tell me how you can fix this.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question