diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-28 13:06:20 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-10-12 13:00:43 +0200 |
commit | 98d65f2ff4eb86c052311e798a50ecbd635351a7 (patch) | |
tree | 1379b8ec645bf28a58375794941f45b0644a5d15 /src/gui/doc/snippets | |
parent | 418389c3ed925b2da3538d808ceeb53727978a8c (diff) |
Add an example to the documentation of QImage::scanLine()
I couldn't find any examples in Qt's documentation of this when I was
trying to use it in a project.
Pick-to: 5.15 5.12
Change-Id: Ic7b7b71f219b2c1012829980866940b9a77bd11f
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Diffstat (limited to 'src/gui/doc/snippets')
-rw-r--r-- | src/gui/doc/snippets/code/src_gui_image_qimage.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/doc/snippets/code/src_gui_image_qimage.cpp b/src/gui/doc/snippets/code/src_gui_image_qimage.cpp index b36d12018a..cbc2aaae33 100644 --- a/src/gui/doc/snippets/code/src_gui_image_qimage.cpp +++ b/src/gui/doc/snippets/code/src_gui_image_qimage.cpp @@ -99,6 +99,17 @@ static const char * const start_xpm[] = { }; //! [2] + +//! [scanLine] +for (int y = 0; y < image.height(); ++y) { + QRgb *line = reinterpret_cast<QRgb*>(image.scanLine(y)); + for (int x = 0; x < image.width(); ++x) { + QRgb &rgb = line[x]; + rgb = qRgba(qRed(rgb), qGreen(0), qBlue(rgb), qAlpha(rgb)); + } +} +//! [scanLine] + Q_UNUSED(start_xpm); } // wrapper1 } // src_gui_image_qimage |