PDA

View Full Version : Picasa crop selection



yogeshgokul
24th June 2008, 13:38
I need to implement the crop functionality same as picasa have. When you double click any image in picasa library, an ImageEditor opens. In that image editor, there is functionality of images croping. So I just want to provide crop selection area in same fashion, picasa doing. Like when we select a image area for crop, all image goes dark, and selection rectangle remains glowing.. I inherited QGraphicsView and using QRubberBand for selection rectangle.
Can somebody tell me how I can achieve that. I am attaching screen shots of picasa stuff.

this is image url
http://lh4.ggpht.com/yogeshgokul/SGDqkbSWL_I/AAAAAAAAADE/YSQbVdxX3kY/s400/crop.JPG

aamer4yu
24th June 2008, 13:59
You can try this-
In drawForeGround() draw the black rect. While using rubberband note the selectedRect.
In drawForeGround() ,

if(!selectedRect.contains(p))
apply black mask;

Hope u get the idea :)

yogeshgokul
24th June 2008, 14:09
Do I need to override QGraphicsView::drawForeGround.

I tried:


QPainter p(this);
p.setOpacity(0.5);
setBackgroundBrush(Qt::red)
drawForeGround(p,rect);
but this fills all view with red color.

aamer4yu
24th June 2008, 15:12
Do I need to override QGraphicsView::drawForeGround.

Yes, you should override it :)

yogeshgokul
25th June 2008, 07:10
Yes, I override drawForeGround(), now everything is working except some refreshing problem. Somehow the scene is not getting refreshed..

yogeshgokul
25th June 2008, 07:34
I am invalidating scene in mouse move event, but scene is not showing the updated crop rectangle.

aamer4yu
25th June 2008, 09:23
How about scene->update() ??

yogeshgokul
25th June 2008, 10:52
I called it in mouse move event. But not updating fast.. I need a fast update. Somebody else also faced this prob.. But he is saying using FullViewportUpdate solved his problem. I tried that too. But not updating:(


http://www.qtcentre.org/forum/f-qt-programming-2/t-drawforeground-update-trouble-11470.html/?highlight=drawForeground

aamer4yu
25th June 2008, 13:38
How are you showing the pic ??

You can try to do the opposite thing...
firstly draw black layer over the pic. In rubberband movement, change the pixel of the rubberband area with the pixels from image..... I guess this will be faster as u are updating fewer pixels. :)

yogeshgokul
25th June 2008, 14:42
I tried everything but this view is not updating. Have you checked that, many more guys facing same problem.

Just search this forum with "drawForeground". And go through the results. You will come to know that this is a problem with foreGround updation.

You can also check here.
1. http://lists.trolltech.com/qt-interest/2007-03/msg00305.html
2. http://www.qtcentre.org/forum/search.php?searchid=362676

Thanx Buddy for replying..