LITTLEBLACKDOG.COM Forum Index LITTLEBLACKDOG.COM

 
LWD LWD   FAQ FAQ   Memberlist Memberlist   Usergroups Usergroups   Active Topics Active Topics   Register Register  
  Profile Profile   Log in to check your private messages Log in to check your private messages   Log in Log in  
  Who is Online Who is Online   Image Gallery Image Gallery   Chat Chat   Search Search  
  LWDGear       LBDGear  

View next topic
View previous topic
Post new topic     Reply to topic   LITTLEBLACKDOG.COM Forum Index » Code Warriors
Author Message
hohlecow
Tail-Wagger
Tail-Wagger


Joined: 17 May 2002
Posts: 2151
Location: hungary for turkey and chile

Post Posted: Mon Mar 31, 2003 6:46 pm   Post subject: image selection in Qt Reply with quote Back to top  

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)
View user's profile Send private message Send e-mail Visit poster's website AIM Address
brotherhobbes
Butt Sniffer
Butt Sniffer


Joined: 06 May 2002
Posts: 1579

Post Posted: Mon Mar 31, 2003 6:48 pm   Post subject: Reply with quote Back to top  

what is Qt? QuickTime is the only thing that comes to mind with those initials...
View user's profile Send private message Send e-mail
Lycander
Lead Dog
Lead Dog


Joined: 24 May 2002
Age: 25
Posts: 12198
Location: The Constitution State

Post Posted: Mon Mar 31, 2003 8:33 pm   Post subject: Reply with quote Back to top  

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
View user's profile Send private message
Lycander
Lead Dog
Lead Dog


Joined: 24 May 2002
Age: 25
Posts: 12198
Location: The Constitution State

Post Posted: Mon Mar 31, 2003 8:34 pm   Post subject: Reply with quote Back to top  

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
View user's profile Send private message
brotherhobbes
Butt Sniffer
Butt Sniffer


Joined: 06 May 2002
Posts: 1579

Post Posted: Tue Apr 01, 2003 3:34 am   Post subject: Reply with quote Back to top  

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 !
View user's profile Send private message Send e-mail
hohlecow
Tail-Wagger
Tail-Wagger


Joined: 17 May 2002
Posts: 2151
Location: hungary for turkey and chile

Post Posted: Tue Apr 01, 2003 12:13 pm   Post subject: Reply with quote Back to top  

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)
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Lycander
Lead Dog
Lead Dog


Joined: 24 May 2002
Age: 25
Posts: 12198
Location: The Constitution State

Post Posted: Tue Apr 01, 2003 12:40 pm   Post subject: Reply with quote Back to top  

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
View user's profile Send private message
hohlecow
Tail-Wagger
Tail-Wagger


Joined: 17 May 2002
Posts: 2151
Location: hungary for turkey and chile

Post Posted: Tue Apr 01, 2003 6:48 pm   Post subject: Reply with quote Back to top  

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)
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Lycander
Lead Dog
Lead Dog


Joined: 24 May 2002
Age: 25
Posts: 12198
Location: The Constitution State

Post Posted: Tue Apr 01, 2003 7:15 pm   Post subject: Reply with quote Back to top  

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
View user's profile Send private message
hohlecow
Tail-Wagger
Tail-Wagger


Joined: 17 May 2002
Posts: 2151
Location: hungary for turkey and chile

Post Posted: Tue Apr 01, 2003 9:22 pm   Post subject: Reply with quote Back to top  

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)
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic     Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours

Help us keep advertisements off this site. Donate today!