Results 1 to 10 of 10

Thread: Picasa crop selection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Picasa crop selection

    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/SGD.../s400/crop.JPG

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Picasa crop selection

    You can try this-
    In drawForeGround() draw the black rect. While using rubberband note the selectedRect.
    In drawForeGround() ,
    Qt Code:
    1. if(!selectedRect.contains(p))
    2. apply black mask;
    To copy to clipboard, switch view to plain text mode 

    Hope u get the idea

  3. #3
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Picasa crop selection

    Do I need to override QGraphicsView::drawForeGround.

    I tried:

    Qt Code:
    1. QPainter p(this);
    2. p.setOpacity(0.5);
    3. setBackgroundBrush(Qt::red)
    4. drawForeGround(p,rect);
    To copy to clipboard, switch view to plain text mode 
    but this fills all view with red color.
    Last edited by jpn; 28th June 2008 at 22:07. Reason: missing [code] tags

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Picasa crop selection

    Do I need to override QGraphicsView::drawForeGround.
    Yes, you should override it

  5. #5
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Picasa crop selection

    Yes, I override drawForeGround(), now everything is working except some refreshing problem. Somehow the scene is not getting refreshed..

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Picasa crop selection

    I am invalidating scene in mouse move event, but scene is not showing the updated crop rectangle.

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Picasa crop selection

    How about scene->update() ??

  8. #8
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Picasa crop selection

    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-p...drawForeground

  9. #9
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Picasa crop selection

    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.

  10. #10
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Picasa crop selection

    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-intere.../msg00305.html
    2. http://www.qtcentre.org/forum/search...earchid=362676

    Thanx Buddy for replying..

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.