I have a QML based app which shall provide basic image editing. I have implemented cropping, and now I would like to add the effects provided by QtGraphicalEffects
. I have added the effects to the QML, and added corresponding sliders, so I can add the effects to my image, which works well.
However, my question is, how I would be able to save those effects back to the image file? The problem is, that I am scaling down the image to fit the screen dimensions, therefore, saving directly from the QML / javascript would result in a shrinked image.
For the cropping part I have solved this by doing the cropping in C++, and re-opening the original image unscaled, and applying the cropping to the original image.
Could I do something similar in QML? E.g. when a save button is pressed, render the original image again in original size (off-screen, so its not visible), apply the effect, then save it? Is this possible?
You should be able to use an unscaled Image
that has Item::visible: false
, render all of the effects, and then use Item::grabToImage
on the resulting rendering to save the result.
You can use Image::implicitWidth
and Image::implicitHeight
to get the native height and width of the original Image
(before scaling).