void ResidentTab::onAddNewEntry() { ResidentLine* newLine = new ResidentLine(mStartTimeEdit->toPlainText(), mEndTimeEdit->toPlainText(), this); connect(newLine, SIGNAL(removeResidentLine(ResidentLine*)), this, SLOT(onRemoveResidentLine(ResidentLine*))); connect(newLine, SIGNAL(wrongStartDateFormat()), this, SLOT(onWrongDateFormat())); mLinesLayout->addWidget(newLine); recalculateResult(); mStartTimeEdit->clear(); mEndTimeEdit->clear(); }
int ImageComposer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: chooseSource(); break; case 1: chooseDestination(); break; case 2: recalculateResult(); break; default: ; } _id -= 3; } return _id; }
//! [11] void ImageComposer::loadImage(const QString &fileName, QImage *image, QToolButton *button) { image->load(fileName); QImage fixedImage(resultSize, QImage::Format_ARGB32_Premultiplied); QPainter painter(&fixedImage); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(fixedImage.rect(), Qt::transparent); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.drawImage(imagePos(*image), *image); painter.end(); button->setIcon(QPixmap::fromImage(fixedImage)); *image = fixedImage; recalculateResult(); }
void ResidentTab::onRemoveResidentLine(ResidentLine *line) { mLinesLayout->removeWidget(line); line->deleteLater(); recalculateResult(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); FileRoot = "C:\\Data\\Images\\En\\"; ascii_counter = 65; ascii_counter1 = 97; ascii_counter2=48; desImg= QImage(FileRoot + "SavedImage"); desImg = desImg.scaled(20,20); desImg.save(FileRoot + "SavedImage.bmp"); GenerateImages(); QPixmap genPix; for(int i = ascii_counter; i<91; i++) { sourceImg= QImage(FileRoot + "img_" +QString::number(i)+".bmp"); resImg = QImage(20, 20, QImage::Format_ARGB32_Premultiplied); genPix = recalculateResult(); genPix.save(FileRoot+"resImg\\"+QString::number(i)+".bmp"); } for(int i = ascii_counter1; i<123;i++) { sourceImg= QImage(FileRoot + "img_" +QString::number(i)+".bmp"); resImg = QImage(20, 20, QImage::Format_ARGB32_Premultiplied); genPix = recalculateResult(); genPix.save(FileRoot+"resImg\\"+QString::number(i)+".bmp"); } for(int i = ascii_counter2; i<58;i++) { sourceImg= QImage(FileRoot + "img_" +QString::number(i)+".bmp"); resImg = QImage(20, 20, QImage::Format_ARGB32_Premultiplied); genPix = recalculateResult(); genPix.save(FileRoot+"resImg\\"+QString::number(i)+".bmp"); } QImage countImg; int lowest_white=20*20; int highest_black=0; int index; int index_b; for(int i = ascii_counter; i<91; i++) { countImg = QImage(FileRoot + "resImg\\" +QString::number(i)+".bmp"); int white=0; int black=0; for (int j=0; j<countImg.width(); j++) { for (int k=0; k<countImg.height(); k++) { QRgb getRgb = countImg.pixel(j,k); if (qRed(getRgb)>=200 && qGreen(getRgb)>=200 && qBlue(getRgb)>=200) { white++; } if (qRed(getRgb)<=20 && qGreen(getRgb)<=20 && qBlue(getRgb)<=20) { black++; } } } if (white<=lowest_white) { lowest_white = white; index = i; } if (black>=highest_black) { highest_black = black; index_b = i; } } for(int i = ascii_counter1; i<123;i++) { countImg = QImage(FileRoot + "resImg\\" +QString::number(i)+".bmp"); int white=0; int black=0; for (int j=0; j<countImg.width(); j++) { for (int k=0; k<countImg.height(); k++) { QRgb getRgb = countImg.pixel(j,k); int a = qRed(getRgb); if (qRed(getRgb)>=200 && qGreen(getRgb)>=200 && qBlue(getRgb)>=200) { white++; } if (qRed(getRgb)<=20 && qGreen(getRgb)<=20 && qBlue(getRgb)<=20) { black++; } } } if (white<=lowest_white) { lowest_white = white; index = i; } if (black>=highest_black) { highest_black = black; index_b = i; } } for(int i = ascii_counter2; i<58;i++) { countImg = QImage(FileRoot + "resImg\\" +QString::number(i)+".bmp"); //qdebug()<<"FILE"<<QString::number(i); int white=0; int black=0; for (int j=0; j<countImg.width(); j++) { for (int k=0; k<countImg.height(); k++) { QRgb getRgb = countImg.pixel(j,k); //qdebug()<<"RED"<<qRed(getRgb)<< // "GREEN"<<qGreen(getRgb)<< // "BLUE"<<qBlue(getRgb); if (qRed(getRgb)>=200 && qGreen(getRgb)>=200 && qBlue(getRgb)>=200) { white++; } if (qRed(getRgb)<=20 && qGreen(getRgb)<=20 && qBlue(getRgb)<=20) { black++; } } } if (white<=lowest_white) { lowest_white = white; index = i; } if (black>=highest_black) { highest_black = black; index_b = i; } } qDebug()<<"WHITE"<<index<<QString(QChar(index))<<lowest_white; qDebug()<<"BLACK"<<index_b<<QString(QChar(index_b))<<highest_black; }