| Author |
Message |
hohlecow
Tail-Wagger


Joined: 17 May 2002 Posts: 2151
Location: hungary for turkey and chile
|
Posted:
Mon Mar 31, 2003 6:46 pm Post subject: image selection in Qt |
|
well, no one responded to my last Qt post, so this may be a shot in the dark.
i'm making an image displaying and manipulation framework for my digital image processing class. our current assigment requires you to do histogram equalization on an image or part of the image.
the equalization part is easy. what i don't know how to do is create a selection box with Qt. I would like dotted selection box like Photoshop, Gimp, Paint Shop Pro, Paint, or prety much any image viewer/manipulator offers, but i don't know quit how to do it.
I am currently using a QImage object to display images, but this can be changed if it will make selections easier (as long as its still a fast Qt object.
Any suggestions are appreciated, as always. |
_________________ give as much as you can, and take nothing
sometimes i think if zombies were attacking us, liberals would be fighting for thier rights, "they eat brains for fuel, it's part of who they are" or "we can't descriminate against them, that's just the way they were reanimated."
trying it again: POTD (picture of the day)
|
|
|
|
|
brotherhobbes
Butt Sniffer

Joined: 06 May 2002 Posts: 1579
|
Posted:
Mon Mar 31, 2003 6:48 pm Post subject: |
|
what is Qt? QuickTime is the only thing that comes to mind with those initials... |
|
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Mar 31, 2003 8:33 pm Post subject: |
|
First of all, forgive me cause this is coming from a Windows programmer. I dabbled in Qt a little bit but that was years ago and I never got very far.
Ok, first thing you want to do is get an idea of how to handle mouse events, like mouse clicks, moves/drags. When the user mouse clicks on the canvas, start a drawing routine that does the actual drawing of the selection marquee. You'll also need to create a brush before hand. To make it nice, it should be an animated brush for the "marquee" effect - it looks like the dots are moving back and forth. But any way you do it, that's the brush you'd use to draw the selection box. A bright pink solid line would work too, I've seen that before.
So you capture the point at which the mouse was click down. And every time your application gets the "mouse move" message, redraw the selection box using the original point (where the mouse was first clicked) to the current coordinates of the mouse cursor.
Mouse clicked down: (X1, Y1) upper left corner
Mouse moved to new point: (X2, Y2) lower right corner
The other 2 coordinates would be:
X2, Y1 (upper right corner)
X1, Y2 (lower left corner) |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Mon Mar 31, 2003 8:34 pm Post subject: |
|
brotherhobbes wrote:what is Qt? QuickTime is the only thing that comes to mind with those initials...
Qt is a multi platform Windowing API developed by Trolltech and is the basis of KDE. |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
brotherhobbes
Butt Sniffer

Joined: 06 May 2002 Posts: 1579
|
Posted:
Tue Apr 01, 2003 3:34 am Post subject: |
|
Lycander wrote:brotherhobbes wrote:what is Qt? QuickTime is the only thing that comes to mind with those initials...
Qt is a multi platform Windowing API developed by Trolltech and is the basis of KDE.
! thanks for the info ! |
|
|
|
|
|
|
hohlecow
Tail-Wagger


Joined: 17 May 2002 Posts: 2151
Location: hungary for turkey and chile
|
Posted:
Tue Apr 01, 2003 12:13 pm Post subject: |
|
i was thinking about writing the marquee code myself, and i already have a bunch of classes written from previous programs that would make it easier, but i figured Qt would have something built in.
plus i don't know how fast drawing on top of an image is going to be. I'll probably end up using a QPixmap object, which is remarkably slow.
ah well, thanks for the help. |
_________________ give as much as you can, and take nothing
sometimes i think if zombies were attacking us, liberals would be fighting for thier rights, "they eat brains for fuel, it's part of who they are" or "we can't descriminate against them, that's just the way they were reanimated."
trying it again: POTD (picture of the day)
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Apr 01, 2003 12:40 pm Post subject: |
|
Double buffer it or use a transparent pane if one exists. The transparent pane would be an overlay over the canvas that can be drawn on and that is where you'll draw your marquee, that way the image data never gets affected. If you feel like doing some multi-threaded programming, you can use a second thread to do the marquee drawing which sould offer better response time. |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
hohlecow
Tail-Wagger


Joined: 17 May 2002 Posts: 2151
Location: hungary for turkey and chile
|
Posted:
Tue Apr 01, 2003 6:48 pm Post subject: |
|
i figured it out. it was insanely easy. 15-20 lines of code. the selection box doesn't have the animated marching ants effect, but its still a nice dashed line.
here's a screenshot of what i've got so far:
so much more work to do... |
_________________ give as much as you can, and take nothing
sometimes i think if zombies were attacking us, liberals would be fighting for thier rights, "they eat brains for fuel, it's part of who they are" or "we can't descriminate against them, that's just the way they were reanimated."
trying it again: POTD (picture of the day)
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Apr 01, 2003 7:15 pm Post subject: |
|
Way to go! Now who's the chick in the pic? |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
hohlecow
Tail-Wagger


Joined: 17 May 2002 Posts: 2151
Location: hungary for turkey and chile
|
Posted:
Tue Apr 01, 2003 9:22 pm Post subject: |
|
haha! i wish i knew! i found the pic while looking for some ralph steadman illustrations for a paper for my visual arts class last semester. that should give you a pretty good lead on finding that picture. |
_________________ give as much as you can, and take nothing
sometimes i think if zombies were attacking us, liberals would be fighting for thier rights, "they eat brains for fuel, it's part of who they are" or "we can't descriminate against them, that's just the way they were reanimated."
trying it again: POTD (picture of the day)
|
|
|
|
|
|
|