I am new in C++. How can I convert a TIF file into a BMP file in C++98?
Here is my "newForm.h".Here is private slots for loading tiff and coverting the image.
#ifndef _NEWFORM_H
#define _NEWFORM_H
#include <QMainWindow>
#include <QFileDialog>
#include <QDebug>
#include "ui_newForm.h"
QT_BEGIN_NAMESPACE
namespace Ui { class newForm; }
QT_END_NAMESPACE
class newForm : public QDialog {
Q_OBJECT
public:
newForm();
virtual ~newForm();
private slots:
void on_load_tiff_PushButton_clicked();
void on_bmp_PushButton_convert();
private:
QString mResourceDir;
Ui::newForm widget;
};
#endif /* _NEWFORM_H */
Here is my "main.cpp" in which i show the "newForm".
#include <QApplication>
#include "newForm.h"
int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QApplication app(argc, argv);
newForm a;
a.show();
// create and show your widgets here
return app.exec();
}
Here is "newForm.cpp".Here is on_load_tiff_PushButton_clicked which load tiff image.I want to convert tiff image into bitmap image using on_bitmap_PushButton_convert .how i can do that
#include "newForm.h"
#include <QMainWindow>
#include <QFileDialog>
#include <QDebug>
newForm::newForm() {
widget.setupUi(this);
mResourceDir = "/root/NetBeansProjects/TIF_TO_BMP/file.tiff";
connect(widget.pushButton, SIGNAL(clicked()), this, SLOT(on_load_tiff_PushButton_clicked()));
connect(widget.pushButton_2, SIGNAL(clicked()), this, SLOT(on_bitmap_PushButton_convert()));
}
QString filename ;
void newForm::on_load_tiff_PushButton_clicked()
{
filename = QFileDialog::getOpenFileName(this,tr("Load Image"),mResourceDir,tr("Images (*.jpg *.tiff)"));
if (filename.isEmpty()){
return;
}
QPixmap p(filename);
if (! widget.graphicsView->scene()){
qDebug() << "No Scene!";
QGraphicsScene *scene = new QGraphicsScene(this);
widget.graphicsView->setScene(scene);
}
widget.graphicsView->scene()->addPixmap(p);
}
void newForm::on_bitmap_PushButton_convert()
{
if (widget.graphicsView->scene()) {
QPixmap p(filename);
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
p.save(&buffer, "BMP"); // writes pixmap into bytes in PNG format
// widget.graphicsView->scene()->clear();
}
}
newForm::~newForm() {
}
Here is image of the "newForm.ui"
I want this make "bmp" image on this directory /root/NetBeansProjects/TIF_TO_BMP/file.tiff in centos6.8 which is not made on clicking the Convert_To_BMP button that calls on_bitmap_PushButton_convert().

You could use stb which is a header-only library.
https://github.com/nothings/stb/blob/master/tests/image_write_test.c