A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQImage</id>
		<title>C++/Qt/QImage - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FQt%2FQImage"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QImage&amp;action=history"/>
		<updated>2026-04-18T22:14:09Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QImage&amp;diff=1282&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QImage&amp;diff=1282&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QImage&amp;diff=1283&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Qt/QImage&amp;diff=1283&amp;oldid=prev"/>
				<updated>2010-05-25T10:25:24Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Check image format and scan line==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the documentation of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int x, y;&lt;br /&gt;
    {&lt;br /&gt;
        QImage image;&lt;br /&gt;
        if (image.format() == QImage::Format_MonoLSB)&lt;br /&gt;
            image.scanLine(y)[x &amp;gt;&amp;gt; 3] |= 1 &amp;lt;&amp;lt; (x &amp;amp; 7);&lt;br /&gt;
        else&lt;br /&gt;
            image.scanLine(y)[x &amp;gt;&amp;gt; 3] |= 1 &amp;lt;&amp;lt; (7 - (x &amp;amp; 7));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Image composer==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the examples of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#ifndef IMAGECOMPOSER_H&lt;br /&gt;
#define IMAGECOMPOSER_H&lt;br /&gt;
#include &amp;lt;QPainter&amp;gt;&lt;br /&gt;
#include &amp;lt;QWidget&amp;gt;&lt;br /&gt;
QT_BEGIN_NAMESPACE&lt;br /&gt;
class QComboBox;&lt;br /&gt;
class QLabel;&lt;br /&gt;
class QToolButton;&lt;br /&gt;
QT_END_NAMESPACE&lt;br /&gt;
&lt;br /&gt;
class ImageComposer : public QWidget&lt;br /&gt;
{&lt;br /&gt;
    Q_OBJECT&lt;br /&gt;
public:&lt;br /&gt;
    ImageComposer();&lt;br /&gt;
private slots:&lt;br /&gt;
    void chooseSource();&lt;br /&gt;
    void chooseDestination();&lt;br /&gt;
    void recalculateResult();&lt;br /&gt;
&lt;br /&gt;
private:&lt;br /&gt;
    void addOp(QPainter::CompositionMode mode, const QString &amp;amp;name);&lt;br /&gt;
    void chooseImage(const QString &amp;amp;title, QImage *image, QToolButton *button);&lt;br /&gt;
    void loadImage(const QString &amp;amp;fileName, QImage *image, QToolButton *button);&lt;br /&gt;
    QPainter::CompositionMode currentMode() const;&lt;br /&gt;
    QPoint imagePos(const QImage &amp;amp;image) const;&lt;br /&gt;
    QToolButton *sourceButton;&lt;br /&gt;
    QToolButton *destinationButton;&lt;br /&gt;
    QComboBox *operatorComboBox;&lt;br /&gt;
    QLabel *equalLabel;&lt;br /&gt;
    QLabel *resultLabel;&lt;br /&gt;
    QImage sourceImage;&lt;br /&gt;
    QImage destinationImage;&lt;br /&gt;
    QImage resultImage;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;quot;imagecomposer.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
static const QSize resultSize(200, 200);&lt;br /&gt;
&lt;br /&gt;
ImageComposer::ImageComposer()&lt;br /&gt;
{&lt;br /&gt;
    sourceButton = new QToolButton;&lt;br /&gt;
    sourceButton-&amp;gt;setIconSize(resultSize);&lt;br /&gt;
    operatorComboBox = new QComboBox;&lt;br /&gt;
    addOp(QPainter::CompositionMode_SourceOver, tr(&amp;quot;SourceOver&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_DestinationOver, tr(&amp;quot;DestinationOver&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Clear, tr(&amp;quot;Clear&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Source, tr(&amp;quot;Source&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Destination, tr(&amp;quot;Destination&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_SourceIn, tr(&amp;quot;SourceIn&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_DestinationIn, tr(&amp;quot;DestinationIn&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_SourceOut, tr(&amp;quot;SourceOut&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_DestinationOut, tr(&amp;quot;DestinationOut&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_SourceAtop, tr(&amp;quot;SourceAtop&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_DestinationAtop, tr(&amp;quot;DestinationAtop&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Xor, tr(&amp;quot;Xor&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Plus, tr(&amp;quot;Plus&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Multiply, tr(&amp;quot;Multiply&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Screen, tr(&amp;quot;Screen&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Overlay, tr(&amp;quot;Overlay&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Darken, tr(&amp;quot;Darken&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Lighten, tr(&amp;quot;Lighten&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_ColorDodge, tr(&amp;quot;ColorDodge&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_ColorBurn, tr(&amp;quot;ColorBurn&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_HardLight, tr(&amp;quot;HardLight&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_SoftLight, tr(&amp;quot;SoftLight&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Difference, tr(&amp;quot;Difference&amp;quot;));&lt;br /&gt;
    addOp(QPainter::CompositionMode_Exclusion, tr(&amp;quot;Exclusion&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    destinationButton = new QToolButton;&lt;br /&gt;
    destinationButton-&amp;gt;setIconSize(resultSize);&lt;br /&gt;
    equalLabel = new QLabel(tr(&amp;quot;=&amp;quot;));&lt;br /&gt;
    resultLabel = new QLabel;&lt;br /&gt;
    resultLabel-&amp;gt;setMinimumWidth(resultSize.width());&lt;br /&gt;
&lt;br /&gt;
    connect(sourceButton, SIGNAL(clicked()), this, SLOT(chooseSource()));&lt;br /&gt;
    connect(operatorComboBox, SIGNAL(activated(int)),&lt;br /&gt;
            this, SLOT(recalculateResult()));&lt;br /&gt;
    connect(destinationButton, SIGNAL(clicked()),&lt;br /&gt;
            this, SLOT(chooseDestination()));&lt;br /&gt;
&lt;br /&gt;
    QGridLayout *mainLayout = new QGridLayout;&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(sourceButton, 0, 0, 3, 1);&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(operatorComboBox, 1, 1);&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(destinationButton, 0, 2, 3, 1);&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(equalLabel, 1, 3);&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(resultLabel, 0, 4, 3, 1);&lt;br /&gt;
    mainLayout-&amp;gt;setSizeConstraint(QLayout::SetFixedSize);&lt;br /&gt;
    setLayout(mainLayout);&lt;br /&gt;
&lt;br /&gt;
    resultImage = QImage(resultSize, QImage::Format_ARGB32_Premultiplied);&lt;br /&gt;
    loadImage(&amp;quot;:/images/butterfly.png&amp;quot;, &amp;amp;sourceImage, sourceButton);&lt;br /&gt;
    loadImage(&amp;quot;:/images/checker.png&amp;quot;, &amp;amp;destinationImage, destinationButton);&lt;br /&gt;
    setWindowTitle(tr(&amp;quot;Image Composition&amp;quot;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::chooseSource()&lt;br /&gt;
{&lt;br /&gt;
    chooseImage(tr(&amp;quot;Choose Source Image&amp;quot;), &amp;amp;sourceImage, sourceButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::chooseDestination()&lt;br /&gt;
{&lt;br /&gt;
    chooseImage(tr(&amp;quot;Choose Destination Image&amp;quot;), &amp;amp;destinationImage,&lt;br /&gt;
                destinationButton);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::recalculateResult()&lt;br /&gt;
{&lt;br /&gt;
    QPainter::CompositionMode mode = currentMode();&lt;br /&gt;
    QPainter painter(&amp;amp;resultImage);&lt;br /&gt;
    painter.setCompositionMode(QPainter::CompositionMode_Source);&lt;br /&gt;
    painter.fillRect(resultImage.rect(), Qt::transparent);&lt;br /&gt;
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);&lt;br /&gt;
    painter.drawImage(0, 0, destinationImage);&lt;br /&gt;
    painter.setCompositionMode(mode);&lt;br /&gt;
    painter.drawImage(0, 0, sourceImage);&lt;br /&gt;
    painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);&lt;br /&gt;
    painter.fillRect(resultImage.rect(), Qt::white);&lt;br /&gt;
    painter.end();&lt;br /&gt;
    resultLabel-&amp;gt;setPixmap(QPixmap::fromImage(resultImage));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::addOp(QPainter::CompositionMode mode, const QString &amp;amp;name)&lt;br /&gt;
{&lt;br /&gt;
    operatorComboBox-&amp;gt;addItem(name, mode);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::chooseImage(const QString &amp;amp;title, QImage *image,&lt;br /&gt;
                                QToolButton *button)&lt;br /&gt;
{&lt;br /&gt;
    QString fileName = QFileDialog::getOpenFileName(this, title);&lt;br /&gt;
    if (!fileName.isEmpty())&lt;br /&gt;
        loadImage(fileName, image, button);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void ImageComposer::loadImage(const QString &amp;amp;fileName, QImage *image,&lt;br /&gt;
                              QToolButton *button)&lt;br /&gt;
{&lt;br /&gt;
    image-&amp;gt;load(fileName);&lt;br /&gt;
    QImage fixedImage(resultSize, QImage::Format_ARGB32_Premultiplied);&lt;br /&gt;
    QPainter painter(&amp;amp;fixedImage);&lt;br /&gt;
    painter.setCompositionMode(QPainter::CompositionMode_Source);&lt;br /&gt;
    painter.fillRect(fixedImage.rect(), Qt::transparent);&lt;br /&gt;
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);&lt;br /&gt;
    painter.drawImage(imagePos(*image), *image);&lt;br /&gt;
    painter.end();&lt;br /&gt;
    button-&amp;gt;setIcon(QPixmap::fromImage(fixedImage));&lt;br /&gt;
    *image = fixedImage;&lt;br /&gt;
    recalculateResult();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QPainter::CompositionMode ImageComposer::currentMode() const&lt;br /&gt;
{&lt;br /&gt;
    return (QPainter::CompositionMode)&lt;br /&gt;
           operatorComboBox-&amp;gt;itemData(operatorComboBox-&amp;gt;currentIndex()).toInt();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QPoint ImageComposer::imagePos(const QImage &amp;amp;image) const&lt;br /&gt;
{&lt;br /&gt;
    return QPoint((resultSize.width() - image.width()) / 2,&lt;br /&gt;
                  (resultSize.height() - image.height()) / 2);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QApplication&amp;gt;&lt;br /&gt;
#include &amp;quot;imagecomposer.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    Q_INIT_RESOURCE(imagecomposition);&lt;br /&gt;
    QApplication app(argc, argv);&lt;br /&gt;
    ImageComposer composer;&lt;br /&gt;
    composer.show();&lt;br /&gt;
    return app.exec();&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set entry 19 in the color table to yellow==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the documentation of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int x, y;&lt;br /&gt;
    {&lt;br /&gt;
        // 8-BIT ACCESS&lt;br /&gt;
        QImage image;&lt;br /&gt;
        // set entry 19 in the color table to yellow&lt;br /&gt;
        image.setColor(19, qRgb(255, 255, 0));&lt;br /&gt;
        // set 8 bit pixel at (x,y) to value yellow (in color table)&lt;br /&gt;
        image.scanLine(y)[x] = 19;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sets 32 bit pixel at (x,y) to yellow==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the documentation of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int x, y;&lt;br /&gt;
    {&lt;br /&gt;
        // 32-BIT&lt;br /&gt;
        QImage image;&lt;br /&gt;
        // sets 32 bit pixel at (x,y) to yellow.&lt;br /&gt;
        uint *ptr = reinterpret_cast&amp;lt;uint *&amp;gt;(image.scanLine(y)) + x;&lt;br /&gt;
        *ptr = qRgb(255, 255, 0);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==svg text object==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the examples of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#ifndef SVGTEXTOBJECT_H&lt;br /&gt;
#define SVGTEXTOBJECT_H&lt;br /&gt;
#include &amp;lt;QTextObjectInterface&amp;gt;&lt;br /&gt;
QT_BEGIN_NAMESPACE&lt;br /&gt;
class QTextDocument;&lt;br /&gt;
class QTextFormat;&lt;br /&gt;
class QPainter;&lt;br /&gt;
class QRectF;&lt;br /&gt;
class QSizeF;&lt;br /&gt;
QT_END_NAMESPACE&lt;br /&gt;
 &lt;br /&gt;
class SvgTextObject : public QObject, public QTextObjectInterface&lt;br /&gt;
{&lt;br /&gt;
    Q_OBJECT&lt;br /&gt;
    Q_INTERFACES(QTextObjectInterface)&lt;br /&gt;
&lt;br /&gt;
public:        &lt;br /&gt;
    QSizeF intrinsicSize(QTextDocument *doc, int posInDocument,&lt;br /&gt;
                         const QTextFormat &amp;amp;format);&lt;br /&gt;
    void drawObject(QPainter *painter, const QRectF &amp;amp;rect, QTextDocument *doc,&lt;br /&gt;
                    int posInDocument, const QTextFormat &amp;amp;format);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;lt;QtSvg&amp;gt;&lt;br /&gt;
#include &amp;quot;svgtextobject.h&amp;quot;&lt;br /&gt;
#include &amp;quot;window.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
QSizeF SvgTextObject::intrinsicSize(QTextDocument *doc, int posInDocument,&lt;br /&gt;
                                    const QTextFormat &amp;amp;format)&lt;br /&gt;
{&lt;br /&gt;
    QImage bufferedImage = qVariantValue&amp;lt;QImage&amp;gt;(format.property(Window::SvgData));&lt;br /&gt;
    QSize size = bufferedImage.size();&lt;br /&gt;
    &lt;br /&gt;
    if (size.height() &amp;gt; 25)&lt;br /&gt;
        size *= 25.0 / (double) size.height();&lt;br /&gt;
    return QSizeF(size);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void SvgTextObject::drawObject(QPainter *painter, const QRectF &amp;amp;rect,&lt;br /&gt;
                               QTextDocument *doc, int posInDocument,&lt;br /&gt;
                               const QTextFormat &amp;amp;format)&lt;br /&gt;
{&lt;br /&gt;
    QImage bufferedImage = qVariantValue&amp;lt;QImage&amp;gt;(format.property(Window::SvgData));&lt;br /&gt;
    painter-&amp;gt;drawImage(rect, bufferedImage);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifndef WINDOW_H&lt;br /&gt;
#define WINDOW_H&lt;br /&gt;
#include &amp;lt;QWidget&amp;gt;&lt;br /&gt;
#include &amp;lt;QTextFormat&amp;gt;&lt;br /&gt;
QT_BEGIN_NAMESPACE&lt;br /&gt;
class QTextEdit;&lt;br /&gt;
class QLineEdit;&lt;br /&gt;
class QPushButton;&lt;br /&gt;
class QLabel;&lt;br /&gt;
QT_END_NAMESPACE&lt;br /&gt;
&lt;br /&gt;
class Window : public QWidget&lt;br /&gt;
{&lt;br /&gt;
    Q_OBJECT&lt;br /&gt;
public:&lt;br /&gt;
    enum { SvgTextFormat = QTextFormat::UserObject + 1 };&lt;br /&gt;
    enum SvgProperties { SvgData = 1 };&lt;br /&gt;
    Window();&lt;br /&gt;
private slots:&lt;br /&gt;
    void insertTextObject();&lt;br /&gt;
private:&lt;br /&gt;
    void setupTextObject();&lt;br /&gt;
    void setupGui();&lt;br /&gt;
private:&lt;br /&gt;
    QTextEdit *textEdit;&lt;br /&gt;
    QLabel *fileNameLabel;&lt;br /&gt;
    QLineEdit *fileNameLineEdit;&lt;br /&gt;
    QPushButton *insertTextObjectButton;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;lt;QtSvg&amp;gt;&lt;br /&gt;
#include &amp;quot;window.h&amp;quot;&lt;br /&gt;
#include &amp;quot;svgtextobject.h&amp;quot;&lt;br /&gt;
Window::Window()&lt;br /&gt;
{&lt;br /&gt;
    setupGui();&lt;br /&gt;
    setupTextObject();&lt;br /&gt;
    setWindowTitle(&amp;quot;Text Object Example&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Window::insertTextObject()&lt;br /&gt;
{&lt;br /&gt;
    QString fileName = fileNameLineEdit-&amp;gt;text();&lt;br /&gt;
    QFile file(fileName);&lt;br /&gt;
    if (!file.open(QIODevice::ReadOnly)) {&lt;br /&gt;
        QMessageBox::warning(this, tr(&amp;quot;Error Opening File&amp;quot;),&lt;br /&gt;
                             tr(&amp;quot;Could not open &amp;quot;%1&amp;quot;&amp;quot;).arg(fileName));&lt;br /&gt;
    }&lt;br /&gt;
    QByteArray svgData = file.readAll();&lt;br /&gt;
&lt;br /&gt;
    QTextCharFormat svgCharFormat;&lt;br /&gt;
    svgCharFormat.setObjectType(SvgTextFormat);&lt;br /&gt;
    QSvgRenderer renderer(svgData);&lt;br /&gt;
    QImage svgBufferImage(renderer.defaultSize(), QImage::Format_ARGB32);&lt;br /&gt;
    QPainter painter(&amp;amp;svgBufferImage);&lt;br /&gt;
    renderer.render(&amp;amp;painter, svgBufferImage.rect());&lt;br /&gt;
    svgCharFormat.setProperty(SvgData, svgBufferImage);&lt;br /&gt;
    QTextCursor cursor = textEdit-&amp;gt;textCursor();&lt;br /&gt;
    cursor.insertText(QString(QChar::ObjectReplacementCharacter), svgCharFormat);&lt;br /&gt;
    textEdit-&amp;gt;setTextCursor(cursor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Window::setupTextObject()&lt;br /&gt;
{&lt;br /&gt;
    QObject *svgInterface = new SvgTextObject;&lt;br /&gt;
    textEdit-&amp;gt;document()-&amp;gt;documentLayout()-&amp;gt;registerHandler(SvgTextFormat, svgInterface);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Window::setupGui()&lt;br /&gt;
{&lt;br /&gt;
    fileNameLabel = new QLabel(tr(&amp;quot;Svg File Name:&amp;quot;));&lt;br /&gt;
    fileNameLineEdit = new QLineEdit;&lt;br /&gt;
    insertTextObjectButton = new QPushButton(tr(&amp;quot;Insert Image&amp;quot;));&lt;br /&gt;
    fileNameLineEdit-&amp;gt;setText(&amp;quot;./files/heart.svg&amp;quot;);&lt;br /&gt;
    connect(insertTextObjectButton, SIGNAL(clicked()),&lt;br /&gt;
            this, SLOT(insertTextObject()));&lt;br /&gt;
    QHBoxLayout *bottomLayout = new QHBoxLayout;&lt;br /&gt;
    bottomLayout-&amp;gt;addWidget(fileNameLabel);&lt;br /&gt;
    bottomLayout-&amp;gt;addWidget(fileNameLineEdit);&lt;br /&gt;
    bottomLayout-&amp;gt;addWidget(insertTextObjectButton);&lt;br /&gt;
    textEdit = new QTextEdit;&lt;br /&gt;
    QVBoxLayout *mainLayout = new QVBoxLayout;&lt;br /&gt;
    mainLayout-&amp;gt;addWidget(textEdit);&lt;br /&gt;
    mainLayout-&amp;gt;addLayout(bottomLayout);&lt;br /&gt;
    setLayout(mainLayout);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
#include &amp;quot;window.h&amp;quot;&lt;br /&gt;
int main(int argv, char **args)&lt;br /&gt;
{&lt;br /&gt;
    QApplication app(argv, args);&lt;br /&gt;
    Window window;&lt;br /&gt;
    window.show();&lt;br /&gt;
    return app.exec();&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Writes image into ba in PNG format==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;  &lt;br /&gt;
/****************************************************************************&lt;br /&gt;
**&lt;br /&gt;
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).&lt;br /&gt;
** All rights reserved.&lt;br /&gt;
** Contact: Nokia Corporation (qt-info@nokia.com)&lt;br /&gt;
**&lt;br /&gt;
** This file is part of the documentation of the Qt Toolkit.&lt;br /&gt;
**&lt;br /&gt;
** $QT_BEGIN_LICENSE:LGPL$&lt;br /&gt;
** Commercial Usage&lt;br /&gt;
** Licensees holding valid Qt Commercial licenses may use this file in&lt;br /&gt;
** accordance with the Qt Commercial License Agreement provided with the&lt;br /&gt;
** Software or, alternatively, in accordance with the terms contained in&lt;br /&gt;
** a written agreement between you and Nokia.&lt;br /&gt;
**&lt;br /&gt;
** GNU Lesser General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU Lesser&lt;br /&gt;
** General Public License version 2.1 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.LGPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU Lesser General Public License version 2.1 requirements&lt;br /&gt;
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.&lt;br /&gt;
**&lt;br /&gt;
** In addition, as a special exception, Nokia gives you certain additional&lt;br /&gt;
** rights.  These rights are described in the Nokia Qt LGPL Exception&lt;br /&gt;
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.&lt;br /&gt;
**&lt;br /&gt;
** GNU General Public License Usage&lt;br /&gt;
** Alternatively, this file may be used under the terms of the GNU&lt;br /&gt;
** General Public License version 3.0 as published by the Free Software&lt;br /&gt;
** Foundation and appearing in the file LICENSE.GPL included in the&lt;br /&gt;
** packaging of this file.  Please review the following information to&lt;br /&gt;
** ensure the GNU General Public License version 3.0 requirements will be&lt;br /&gt;
** met: http://www.gnu.org/copyleft/gpl.html.&lt;br /&gt;
**&lt;br /&gt;
** If you have questions regarding the use of this file, please contact&lt;br /&gt;
** Nokia at qt-info@nokia.com.&lt;br /&gt;
** $QT_END_LICENSE$&lt;br /&gt;
**&lt;br /&gt;
****************************************************************************/&lt;br /&gt;
#include &amp;lt;QtGui&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int x, y;&lt;br /&gt;
    {&lt;br /&gt;
        QImage image;&lt;br /&gt;
        QByteArray ba;&lt;br /&gt;
        QBuffer buffer(&amp;amp;ba);&lt;br /&gt;
        buffer.open(QIODevice::WriteOnly);&lt;br /&gt;
        image.save(&amp;amp;buffer, &amp;quot;PNG&amp;quot;); // writes image into ba in PNG format&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>