PDA

View Full Version : Cropping an image with qt



akshaysulakhe
12th August 2013, 22:16
Hello friends, I am loading some images from a folder. What i want to do is check the dimensions of the image, which i am able to do now, and then if the size exceeds my label size i would like to crop the image. But the cropping should be done by user so the person can select the desired area to be cropped and save the image with same name. I thought this code might be common on internet, but i couldnt find any good ones. If anyone can give me a headstart for this that would be really helpful. Thank you for your time.

wysota
12th August 2013, 22:17
Is your problem with cropping itself or with marking the area for cropping?

akshaysulakhe
13th August 2013, 12:12
Hello wyosta :- Its with giving a seperate window where the initial image is loaded and the area is marked using mouse. Sorry for the late reply.

wysota
13th August 2013, 13:21
You should know how to open a new window and load the image into it. As for marking the area, reimplement mousePressEvent(), mouseMoveEvent() and mouseRelease() event to let the user mark two points (one using mouse press, the other using mouse move and release) and reimplement paintEvent() to draw the rubber band between those two points. Alternatively use QRubberBand class with those mouse events.

akshaysulakhe
13th August 2013, 13:42
Thanks, that helped to atleast understand what to do.