Save picture in bmp format



  • Hello,

    I want to save a picture from my camera in a bmp format.
    I use a QImageEncoderSettings class to do it but I cannot save in bmp format, I read the docs about this class but I still dont success to use correctly the "setCodec" to have the bmp format.

    Thanks for your help.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Please show the code you use to save your images.



  •  auto filename = QFileDialog::getSaveFileName(this, tr("Save Image"), ".", tr("Image (*.bmp)"));
        if (filename.isEmpty())
            return;
        mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile);
        QImageEncoderSettings imageSettings;
        imageSettings.setCodec("bmp");
        imageSettings.setResolution(1024, 1280);
        mCameraImageCapture->setEncodingSettings(imageSettings);
        mCamera->setCaptureMode(QCamera::CaptureStillImage);
        mCamera->start();
        mCamera->searchAndLock();
        mCameraImageCapture->capture(filename);
        mCamera->unlock();
    

    The image still save on default(jpg) format with this code.


  • Moderators

    @descom_g Shouldn't it be

    imageSettings.setCodec("image/bmp");
    

    ?



  • I have already tried it and that still save in jpg.


  • Qt Champions 2016

    @descom_g
    hi
    Try to list the codec available to be sure

    foreach(const QString &codecName, imagecapture->supportedImageCodecs()) {
    qDebug() << ...


Log in to reply