QtConcurrent scaling image



  • Hello everyone. Help make out what the problem is.
    He took an example of Image Scaling working:
    @QImage scale (const QString & imageFileName)
    {
         QImage image (imageFileName);
         return image.scaled (QSize (imageSize, imageSize), Qt :: IgnoreAspectRatio, Qt :: SmoothTransformation);
    }

    void Images :: open ()
    {
    ...
         QStringList files = QFileDialog :: getOpenFileNames (this, tr ("Select Images"),
                                 QStandardPaths :: writableLocation (QStandardPaths :: PicturesLocation),
                                 "*. jpg *. png");

    ...
         imageScaling-> setFuture (QtConcurrent :: mapped (files, scale));
    ...
    }@

    But if you do so. falls with error

    @QImage scale (const QString & imageFileName)
    {
         QImage image (imageFileName);
         return image.scaled (QSize (imageSize, imageSize), Qt :: IgnoreAspectRatio, Qt :: SmoothTransformation);
    }

    void Images :: open ()
    {
    ...
         QStringList files;
         files.append (QString ("path to file"));
         files.append (QString ("path to file2"));
         files.append (QString ("etc"));

    ...
         imageScaling-> setFuture (QtConcurrent :: mapped (files, scale));
    ...
    }@

    if you add in QStringList path to a single file, it works too



  • bq. But if you do so. falls with error

    What kind of error?



  • can't figure out what the problem is, can you give us some more details. i have "image scaling sample codes":http://www.rasteredge.com/how-to/csharp-imaging/scale-image/ found for you on the google, you may take a lookt, hope it is helpful for you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.