i using qt developing simple drawing application.
i have qimage , filled trasparent.
qimage *m_markerimg = new qimage(400,320, qimage::format_argb32_premultiplied); m_markerimg -> fill( qt::transparent );
i have created custom graphics scene inheriting qgraphicsscene & drawing line on image in mousemove event of graphics scene as:
qpointf plotpoint = mouseevent->scenepos(); m_painter.drawline(m_initpoint,plotpoint); m_initpoint=plotpoint;
where m_initpoint being assigned in mouse press event. working fine , able draw lines on image. want store pixels covered line @ runtime i.e. during line draw. although can store points on drawing i.e. m_initpoint & plotpoint in case of penwidth set more 1 , single line pixel while need whole of pixels covered width of line.
how can that?
you need to:
- convert line path,
- stroke path using
qpainterpathstroker
(see this example), - get stroked path polygon,
- scan (iterate) pixels of polygon - see this question complete example.
Comments
Post a Comment