this is actually outside of the scope of Qt.
You should use a graphics processing library (like OpenCV - i don't know if it offers such functionality) to do such stuff. Or you need to implement an appropriate algorithmn yourself which uses the Qt API to access the pixel data.
QPainter can draw a QImage. So you can for example create a new Widget, subclass for QLabel for example if you want and reimplement paintEvent. Like this you work all the time with your QImage without creating another one.
And better you can only update the region that changed, no need to refresh everything. I did not try it but it should work.
I don't know of any but it should be quite straightforward to implement. Basically you map coordinates from one space to another based on a parametric transformation (a matrix) and then interpolate where the pixels are closer/farther from one another.
Hi @Lisbetti and Welcome,
AFAIK you will need some C++ API's as well for cropping the image. Once you grab the image using grapToImage call a C++ function and pass this image to it for further processing. Once you receive it on C++ side you have QImage::copy function to copy the desired part. This function too returns a QImage which you can send it to QML again for displaying.
Okay, so the idea here is to utilize the Item element's grabToImage method to save everything inside the element to a file. Placing the Image inside the Item, and calling the method provides the feature I was looking for. Thanks, @p3c0!
EDIT: I hadn't realized the grabToImage method is an inherited method in Image. The use of a wrapping Item is unnecessary in this case. I should also note that this method does not save the actual image, but a lower resolution copy, as quoted from the documentation: "This function will render the item to an offscreen surface and copy that surface from the GPU's memory into the CPU's memory, which can be quite costly." Is there a better way of saving the full resolution image to a file without having to request it from it's source a second time? This sort of brings me back to my original question.
I checked if a new image was returned by saving each image data to a file before it gets returned and the image seems to be correct.
I will try to replace the graphicsview/scene by a QLabel, perhaps this will work.
Thanks for advice. I removed clip, but unfortunately it did not help. Further testing shows that as long as image fits to 2048x2048 size there is no loss in image quality. After some searching, I am guessing that this might be caused by Android texture size limitation.
There's no guessing, Qt will load your image with the corresponding plugin which uses the usual libraries to manipulate the images (libpng, libjpeg etc.). Then IIRC there might be a conversion to a format suited for display e.g. ARGB32.
The next version of QuickAndroid will come with a Image Picker using native code. You may use it directly or just check learn how its handle image picking. In fact, it is a bit troublesome to do it in Android. There has several way of passing image data. (e.g clip data, content url , file url). It depends on the photo application.