1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/artisan/gviewport/RenderedImage.cpp
10 #include <QPaintDevice>
12 #include <QMutexLocker>
14 #include "artisan/gviewport/RenderedImage.h"
15 #include "artisan/gviewport/CoordinateMapper.h"
17 #include "util/MessageSystem.h"
22 RenderedImage::RenderedImage(const Rect
&dataRange
, const Rect
&pixelSize
)
23 : m_dataRange(dataRange
), m_pixelSize(pixelSize
) {
25 m_image
= QImage(m_pixelSize
.width(), m_pixelSize
.height(), QImage::Format_ARGB32
);
27 //m_image.fill(qRgb(qrand()%256, qrand()%256, qrand()%256));
28 m_image
.fill(qRgb(255, 255, 255));
30 m_painter
= new QPainter();
33 RenderedImage::~RenderedImage() {
37 void RenderedImage::merge(RenderedImage
&other
) {
38 CoordinateMapper
mapper(*this);
39 Rect local
= mapper
.dataToPixel(other
.dataRange());
42 m_painter
->drawImage(local
.toQRect(), other
.m_image
);
47 void RenderedImage::startPainting() {
49 m_painter
->begin(&m_image
);
52 void RenderedImage::stopPainting() {
57 void RenderedImage::paintOnto(QPaintDevice
*device
) {
58 QPainter
painter(device
);
59 painter
.drawImage(QRect(0, 0, device
->width(), device
->height()), m_image
, m_image
.rect());
62 RenderedImage
&RenderedImage::operator=(const RenderedImage
&other
) {
63 m_dataRange
= other
.m_dataRange
;
64 m_pixelSize
= other
.m_pixelSize
;
65 m_image
= other
.m_image
;
69 } // namespace GViewport
70 } // namespace Artisan