Generating code128 barcode
-
wrote on 17 Jun 2024, 11:09 last edited by
the above image was my expected output but creating code 128 barcode by using this reference https://github.com/promixis/Code128, i got the below image as my output
-
And what's the relation to Qt here? You should ask the developer how to use the library if you have issues with it.
-
wrote on 17 Jun 2024, 11:26 last edited by
I want to generate the bar code through QT c++. but i have no idea to generate bar code as the above expected image
-
And what did you try? What issues did you face? Provide some code - we won't write code for you.
-
I want to generate the bar code through QT c++. but i have no idea to generate bar code as the above expected image
wrote on 17 Jun 2024, 11:42 last edited by Pl45m4@Thananjeyan said in Generating code128 barcode:
i have no idea to generate bar code as the above expected image
If you look at the wiki page linked in your mentioned GitHub repo above (this one here), you can see that the produced Code128 does not look like your "expected image".
Qt still has nothing to do with it (that the output of this library is not what you expect).
And there is nothing as "Qt" C++... it's just C++. If it works in any C++ program, you can integrate it together with a Qt GUI. -
wrote on 17 Jun 2024, 12:12 last edited by Thananjeyan
code_text ```m_Scene.update(); ui->graphicsView_2->update(); ui->graphicsView_2->setScene(&m_Scene); m_Barcode = new Code128Item(); m_Barcode->setHighDPI(true); m_Barcode->setWidth(200); m_Barcode->setHeight(70); m_Barcode->setPos(0,0); m_Barcode->update(); m_Scene.addItem(m_Barcode); m_Scene.update(); m_Barcode->update(); m_Barcode->setText("B6560"); m_Barcode->update(); ui->graphicsView_2->setScene(&m_Scene); ui->graphicsView_2->update(); ui->graphicsView_2->setFixedSize(m_Scene.sceneRect().width(),m_Scene.sceneRect().height()); ui->graphicsView_2->update(); ui->graphicsView_2->setScene(&m_Scene); ui->graphicsView_2->fitInView(0,0,m_Scene.sceneRect().width(),m_Scene.sceneRect().height(), Qt::IgnoreAspectRatio); ui->graphicsView_2->update(); QImage pixMap(1900,1024,QImage::Format_ARGB32_Premultiplied); pixMap.fill(Qt::transparent); QPainter p(&pixMap); m_Scene.render(&p); p.end(); pixMap.save("D:/Barcode/img1.png"); QThread::msleep(1000); Imagepath="D:/Barcode/img1.png"; code_text
this is the program i used to get the above output now i just want to reduce width of the barcode and barcode stripes``` -
code_text ```m_Scene.update(); ui->graphicsView_2->update(); ui->graphicsView_2->setScene(&m_Scene); m_Barcode = new Code128Item(); m_Barcode->setHighDPI(true); m_Barcode->setWidth(200); m_Barcode->setHeight(70); m_Barcode->setPos(0,0); m_Barcode->update(); m_Scene.addItem(m_Barcode); m_Scene.update(); m_Barcode->update(); m_Barcode->setText("B6560"); m_Barcode->update(); ui->graphicsView_2->setScene(&m_Scene); ui->graphicsView_2->update(); ui->graphicsView_2->setFixedSize(m_Scene.sceneRect().width(),m_Scene.sceneRect().height()); ui->graphicsView_2->update(); ui->graphicsView_2->setScene(&m_Scene); ui->graphicsView_2->fitInView(0,0,m_Scene.sceneRect().width(),m_Scene.sceneRect().height(), Qt::IgnoreAspectRatio); ui->graphicsView_2->update(); QImage pixMap(1900,1024,QImage::Format_ARGB32_Premultiplied); pixMap.fill(Qt::transparent); QPainter p(&pixMap); m_Scene.render(&p); p.end(); pixMap.save("D:/Barcode/img1.png"); QThread::msleep(1000); Imagepath="D:/Barcode/img1.png"; code_text
this is the program i used to get the above output now i just want to reduce width of the barcode and barcode stripes```wrote on 17 Jun 2024, 12:27 last edited by Pl45m4@Thananjeyan said in Generating code128 barcode:
now i just want to reduce width of the barcode and barcode stripes
You can resize the whole image with Qt... but I don't see how you want to "reduce barcode stripes"?!
The output image is generated by this Code128 lib, right?! Check if there are any options to do so.QThread::msleep(1000);
What is this doing there?!
Edit:
@Thananjeyan your "slim" barcode from the photo above could be Code128 barcode without the checksum.
I don't know if you can make your library print the "data" only, without adding any checkum and how you can read it later...
1/7