PDA

View Full Version : How to copy selected ellipse area from image



adamsakli
24th September 2009, 12:04
Hi guys
I'm developing a program for image prosessing. I want to copy selected ellipse area on image. How can i do this. I developed a program which draw an ellipse on image when mouse move.
The problem i want to copy this area. How can i copy? QImage has a copy function but this is for rectangle not ellipse. How can i copy ellipse area. I put image what i did.

^NyAw^
24th September 2009, 12:13
Hi,

You can't really create an elliptic image because it's only possible to save rectangle images.
You can use QImage QImage::copy(const QRect& rectangle = QRect()) const with the bounding rectangle of the ellipse. Then in the obtained image you can paint the outside pixels with black color. It's only an idea.

adamsakli
24th September 2009, 12:29
Thanks for reply ^NyAw^.
But image prossesing program like GIMP, Adobe photoshop do this. I can select ellipse area and can copy this area from image and paste anywhere i want. I want to do like on GIMP and Photosshop.

^NyAw^
24th September 2009, 12:44
Hi,

I think that QGraphicsView can help you.

scascio
24th September 2009, 14:57
Going further in the direction of copying rectangles, you can then set a mask to your image, by drawing in a QBitmap an ellipse of the same size.

aamer4yu
24th September 2009, 19:54
I think you can try this -
copy the rectangle from the image which bounds the ellipse. Then traverse the rect and set the pixels transparent which are not in ellipse.
This might not be very efficient but you can optimise or look for some fast algo for determining points inside a ellipse. HINT : you can check the border areas,,, ellipse will cover most of the inner area.