How to convert QPixMap to QPainterPath and vice-versa?

时间:2019-04-23 15:17:46

标签: c++ qt

  • I am trying to implement a pattern recognition algorithm.
  • I have set up a QWidget with a QPixMap on which the user can draw the pattern with his/her mouse.
  • Assuming the user draws a '3', the program should save all the points (x and y coordinates) in that drawing into an xml file so that the file can be loaded and the shape be recognized.
  • I know there is a (de)serialization operator built in QDataStream for QPainterPath but how would I convert the drawing into a QPainterPath?

1 个答案:

答案 0 :(得分:0)

像您这样的声音正在寻找某种启发式技术来对像素数据进行矢量化处理。 Qt中没有内置这样的东西。我建议研究向量化。

我最好的建议是,如果您还正在编写绘图工具,则在用户绘制路径时跟踪其路径并将其保存为QPicture,这样就永远不会以像素形式出现。