PDA

View Full Version : Select Region from image



yazwas
5th July 2009, 13:30
Hello All,

This is my first post in this forum :)

I've just started writing an application for image manipuliation, I would like to have some basic functionality, like zoom in/out, rotate left/right, and select a region from the image, and being able to save this new selected region to a new instance of QImage for example

The zoom in/out, and rotate are easily implemented, but I have a problem with the region selection, I would like to have 2 options, either select a recangle region, or the ability for the user to select irregular shape (much as MS paint)

I actually dont know how to do either at this moment, and I would like to know if anyone can help me with this issue

any comments are most welcomed, and thanks very much for your time reading this post :)

Lykurg
5th July 2009, 13:42
For a rectangular selection you can use the rubber band selection mode of the graphics scene. For an irregular shape just draw a item over all other things in your scene, add some handlers that the user can modify the shape and then use the shape of that item to extract the new image.

Gargolissimus
6th July 2009, 12:00
I wrote an application which needs rectangular regions for processing. I used
"QImage::copy ( const QRect & rectangle = QRect() ) const" for further processing.

Garg

yazwas
15th July 2009, 17:03
Thank you guys for the response,

I was away, and just came back, and this is why I'm late in my response

Gargolissimus: Thank you very much, I use this, and it works,

Lykurg: can you show me a sample code for the irregular selection

Thanks alot

Lykurg
15th July 2009, 17:41
Lykurg: can you show me a sample code for the irregular selection

I have no short code, but have e.g a look at the book "Foundations of Qt® Development" of Johan Thelin, he has a good example for that in his book.