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>
13 #include "artisan/gviewport/RenderedImage.h"
14 #include "artisan/gviewport/CoordinateMapper.h"
16 #include "util/MessageSystem.h"
21 RenderedImage::RenderedImage(const Rect
&dataRange
, const Rect
&pixelSize
)
22 : m_dataRange(dataRange
), m_pixelSize(pixelSize
) {
24 m_image
= QImage(m_pixelSize
.width(), m_pixelSize
.height(), QImage::Format_ARGB32
);
26 m_image
.fill(qRgb(qrand()%256, qrand()%256, qrand()%256));
28 m_painter
= new QPainter();
31 RenderedImage::~RenderedImage() {
35 void RenderedImage::merge(RenderedImage
&other
) {
36 CoordinateMapper
mapper(*this);
37 Rect local
= mapper
.dataToPixel(other
.dataRange());
40 m_painter
->drawImage(local
.toQRect(), other
.m_image
);
45 void RenderedImage::startPainting() {
46 m_painter
->begin(&m_image
);
49 void RenderedImage::stopPainting() {
53 void RenderedImage::paintOnto(QPaintDevice
*device
) {
54 QPainter
painter(device
);
55 painter
.drawImage(QRect(0, 0, device
->width(), device
->height()), m_image
, m_image
.rect());
58 RenderedImage
&RenderedImage::operator=(const RenderedImage
&other
) {
59 m_dataRange
= other
.m_dataRange
;
60 m_pixelSize
= other
.m_pixelSize
;
61 m_image
= other
.m_image
;
65 } // namespace GViewport
66 } // namespace Artisan