How to correct the Image?
-
hey
i am getting your problem completely but related your issue i found something here.
https://www.kdab.com/qt-on-android-how-to-convert-qt-images-to-android-images-and-vice-versa/http://stackoverflow.com/questions/31137830/display-image-from-raw-bitmap-file-to-bmp-file
-
@Rohith
The forum's image upload is broken, please use an external site (e.g. postimage.org). -
Here is the Link of Image Please Go through It
-
I want to send the image to the printer for printing
here is code
QImage img("1.jpg"); QImage img1 = img.scaled(QSize(384,500), Qt::IgnoreAspectRatio); QBitmap *prnbmp1 = new QBitmap(QBitmap::fromImage((const QImage)img1,Qt::MonoOnly)); prnbmp1->save("finalimage.bmp","BMP",-1); QImage img2("finalimage.bmp" ); img2.save("finalimage.bmp"); QFile file1("finalimage.bmp"); qDebug()<<"size of img in bytes"<<file1.size();
after converting to Bmp i am sending to printer by converting the BMP to HEX
here is the Link for Original Image
https://s10.postimg.org/lj1v7ddy1/image.jpg
Thanks in advance
-
form http://doc.qt.io/qt-5/qimage.html
Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. Finally, the QPicture class is a paint device that records and replays QPainter commands.
QImage img("1.jpg"); QImage img1 = img.scaled(QSize(384,500), Qt::IgnoreAspectRatio); img1.convertToFormat(QImage::Format_Mono); //Converts to black and white but original image is already B/W so I'm not sure it's necessary img1.save("finalimage.bmp","BMP");
-
You don't need all this. Just write the image to the file with the appropriate format. E.g:
QImage img = QImage("1.jpg").scaled(QSize(384,500), Qt::IgnoreAspectRatio); if (!img.save("finalimage.bmp", "BMP")) ; //< Couldn't save the image, handle the error
Look here for the supported formats.
Kind regards.