src/ChildWidget.cpp
/*
 * Copy defined boxes to new image file
 */
Copy defined boxes to new image file
Copy defined boxes to new image file
bool ChildWidget::createStringImage(const QString& fileName,
                                    const QString& qData) {
  if (DMESS > 10) qDebug() << Q_FUNC_INFO;
  QImage image = gItem2qImage();
  QImage result = image;
  result.fill(Qt::white);
  QPainter painter(&result);
  QStringList rowOfData = qData.split("\n");
  for (int x = 0; x < rowOfData.size(); x++) {
    QStringList rowData = rowOfData.at(x).split(" ");
    if (rowData.size() < 4)
            continue;  
    int x0 = rowData[1].toInt();
    int y0 = imageHeight - rowData[2].toInt();
    int w = rowData[3].toInt() - x0;
    int h = rowData[4].toInt() - rowData[2].toInt() ;
    QImage srcImage = image.copy(x0, y0 - h, w, h);
    painter.drawImage(QPoint(x0, y0 - h), srcImage);
  }
  painter.end();
  result.save(fileName, 0);
  return true;
}
bool ChildWidget :: createStringImage ( const QString & fileName , const QString & qData ) { if ( DMESS > 10 ) qDebug ( ) << Q_FUNC_INFO ; QImage image = gItem2qImage ( ) ; QImage result = image ; result . fill ( Qt :: white ) ; QPainter painter ( & result ) ; QStringList rowOfData = qData . split ( " \n " ) ; for ( int x = 0 ; x < rowOfData . size ( ) ; x ++ ) { QStringList rowData = rowOfData . at ( x ) . split ( " " ) ; if ( rowData . size ( ) < 4 ) continue ; int x0 = rowData [ 1 ] . toInt ( ) ; int y0 = imageHeight - rowData [ 2 ] . toInt ( ) ; int w = rowData [ 3 ] . toInt ( ) - x0 ; int h = rowData [ 4 ] . toInt ( ) - rowData [ 2 ] . toInt ( ) ; QImage srcImage = image . copy ( x0 , y0 - h , w , h ) ; painter . drawImage ( QPoint ( x0 , y0 - h ) , srcImage ) ; } painter . end ( ) ; result . save ( fileName , 0 ) ; return true ; }
Copy defined boxes to new image file
Copy defined boxes to new image file
// skip rows without enough items