[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include <QtGui>
|
---|
| 43 |
|
---|
| 44 | void myProcessing(const QString &)
|
---|
| 45 | {
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | int main()
|
---|
| 49 | {
|
---|
| 50 | QWidget myWidget;
|
---|
| 51 | {
|
---|
| 52 | // RECORD
|
---|
| 53 | //! [0]
|
---|
| 54 | QPicture picture;
|
---|
| 55 | QPainter painter;
|
---|
| 56 | painter.begin(&picture); // paint in picture
|
---|
| 57 | painter.drawEllipse(10,20, 80,70); // draw an ellipse
|
---|
| 58 | painter.end(); // painting done
|
---|
| 59 | picture.save("drawing.pic"); // save picture
|
---|
| 60 | //! [0]
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | {
|
---|
| 64 | // REPLAY
|
---|
| 65 | //! [1]
|
---|
| 66 | QPicture picture;
|
---|
| 67 | picture.load("drawing.pic"); // load picture
|
---|
| 68 | QPainter painter;
|
---|
[561] | 69 | painter.begin(&myImage); // paint in myImage
|
---|
[2] | 70 | painter.drawPicture(0, 0, picture); // draw the picture at (0,0)
|
---|
| 71 | painter.end(); // painting done
|
---|
| 72 | //! [1]
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | QPicture myPicture;
|
---|
| 76 | {
|
---|
| 77 | // FORMATS
|
---|
| 78 | //! [2]
|
---|
| 79 | QStringList list = QPicture::inputFormatList();
|
---|
| 80 | foreach (QString string, list)
|
---|
| 81 | myProcessing(string);
|
---|
| 82 | //! [2]
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | {
|
---|
| 86 | // OUTPUT
|
---|
| 87 | //! [3]
|
---|
| 88 | QStringList list = QPicture::outputFormatList();
|
---|
| 89 | foreach (QString string, list)
|
---|
| 90 | myProcessing(string);
|
---|
| 91 | //! [3]
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | {
|
---|
| 95 | // PIC READ
|
---|
| 96 | //! [4]
|
---|
| 97 | QPictureIO iio;
|
---|
| 98 | QPixmap pixmap;
|
---|
| 99 | iio.setFileName("vegeburger.pic");
|
---|
| 100 | if (iio.read()) { // OK
|
---|
| 101 | QPicture picture = iio.picture();
|
---|
| 102 | QPainter painter(&pixmap);
|
---|
| 103 | painter.drawPicture(0, 0, picture);
|
---|
| 104 | }
|
---|
| 105 | //! [4]
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | {
|
---|
| 109 | QPixmap pixmap;
|
---|
| 110 | // PIC WRITE
|
---|
| 111 | //! [5]
|
---|
| 112 | QPictureIO iio;
|
---|
| 113 | QPicture picture;
|
---|
| 114 | QPainter painter(&picture);
|
---|
| 115 | painter.drawPixmap(0, 0, pixmap);
|
---|
| 116 | iio.setPicture(picture);
|
---|
| 117 | iio.setFileName("vegeburger.pic");
|
---|
| 118 | iio.setFormat("PIC");
|
---|
| 119 | if (iio.write())
|
---|
| 120 | return true; // returned true if written successfully
|
---|
| 121 | //! [5]
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | // SVG READ
|
---|
| 127 | //! [6]
|
---|
| 128 | void readSVG(QPictureIO *picture)
|
---|
| 129 | {
|
---|
| 130 | // read the picture using the picture->ioDevice()
|
---|
| 131 | }
|
---|
| 132 | //! [6]
|
---|
| 133 |
|
---|
| 134 | // SVG WRITE
|
---|
| 135 | //! [7]
|
---|
| 136 | void writeSVG(QPictureIO *picture)
|
---|
| 137 | {
|
---|
| 138 | // write the picture using the picture->ioDevice()
|
---|
| 139 | }
|
---|
| 140 | //! [7]
|
---|
| 141 |
|
---|
| 142 | // USE SVG
|
---|
| 143 | void foo() {
|
---|
| 144 |
|
---|
| 145 | //! [8]
|
---|
| 146 | // add the SVG picture handler
|
---|
| 147 | // ...
|
---|
| 148 | //! [8]
|
---|
| 149 | QPictureIO::defineIOHandler("SVG", 0, 0, readSVG, writeSVG);
|
---|
| 150 | // ...
|
---|
| 151 |
|
---|
| 152 | }
|
---|