QTextImage
 All Classes Functions Pages
qtextimage.h
1 /*
2  * Copyright (c) 2015 Narwhal Software s.r.l.
3  * www.narwhal.it
4  * This software is licensed under an MIT-style license.
5  * See the LICENCE file for details.
6  */
7 
8 #ifndef QTEXTIMAGE_H
9 #define QTEXTIMAGE_H
10 
11 #include <QPainter>
12 #include <QPen>
13 #include <QSharedDataPointer>
14 #include <functional>
15 
16 class QTextImageData;
28 {
29 public:
33  QTextImage();
34  QTextImage(const QTextImage &);
35  QTextImage &operator=(const QTextImage &);
36  ~QTextImage();
37 
43  static QTextImage parse(const QByteArray &text);
49  static QTextImage parse(const QString &text);
55  static QTextImage parse(const QStringList &text);
59  bool isValid() const;
66  QImage render(int scale, const QPen &strokePen, const QBrush &fillBrush = QBrush()) const;
106  QImage render(int scale, std::function<void(char, QPainter &)> lineConfig) const;
107 private:
108  QSharedDataPointer<QTextImageData> data;
109 };
110 
111 
112 inline QTextImage QTextImage::parse(const QString &text) {
113  return parse(text.toLatin1());
114 }
115 
116 inline QTextImage QTextImage::parse(const QStringList &text) {
117  return parse(text.join('\n').toLatin1());
118 }
119 
120 #endif // QTEXTIMAGE_H
QTextImage()
Constructs a null image.
Definition: qtextimage.cpp:67
QImage render(int scale, const QPen &strokePen, const QBrush &fillBrush=QBrush()) const
Render the image on a QImage.
Definition: qtextimage.cpp:150
An ASCII-encoded image.
Definition: qtextimage.h:27
static QTextImage parse(const QByteArray &text)
Parse a QTextImage from a byte array.
Definition: qtextimage.cpp:86
bool isValid() const
Whether this image was parsed from a correct ASCIImage string.
Definition: qtextimage.cpp:146