PDA

View Full Version : Get Pixel Values



amitpatel22
14th June 2011, 06:15
Hi..

I have been facing problem with getting pixel values..

Suppose I have entered a text in editbox and this text are drawn on QPainter(DC).Now i want to get pixel values of that text(Co-ordinates) so i can draw that text with moveTo and lineTo with another QPainter object.

Waiting for quick reply..

Thanks..

almboa
14th June 2011, 07:01
Quick reply:

Draw on a QImage and use:
QRgb pixel ( const QPoint & position ) const
QRgb pixel ( int x, int y ) const

amitpatel22
14th June 2011, 07:22
Thanks for quick reply..

Actually i want position of pixels drawn on QPainter in other terms each and every point of text drawn..

Suppose i have drawn text "abc" from some starting point(0,0) on QPainter then i want co-ordinates of each and every points.

Best regards..
Amit

Santosh Reddy
14th June 2011, 07:41
Your post not clear
Use the text in the editbox and use QPainter to draw text at required location, save the location if wish to. What is that you are look for?

Added after 12 minutes:

You need to use QPainterPath, and then use bonding rectangle of the path, get all the sub paths in it, and prepare a list of pointer which are in the intersection of both the bonding rectangle and the sub paths.

Why do you need all the points on the text drawn? There should be a simpler way by avoid this.

amitpatel22
14th June 2011, 09:09
thanks Santosh...

But i could not understand what u say..will u please elaborate so i can understand easily..

Niamita
14th June 2011, 11:16
Are you want to x and y cordinates of text drawn? If yes than you can use any of the mouseEvent to get cordinates.

amitpatel22
14th June 2011, 12:05
I know i can get x and y coordinates from mouseEvent but i want all the coordinates of that text that are drawn on the QPaint so i can use that in another place to draw the same text.

Santosh Reddy
15th June 2011, 04:33
You can use QPainterPath to get the all the region in the path, try reading QPainterPath, look at how to get sub-paths of the text drawn