summaryrefslogtreecommitdiff
path: root/liveview
diff options
context:
space:
mode:
Diffstat (limited to 'liveview')
-rw-r--r--liveview/liveview.cpp10
-rw-r--r--liveview/liveviewpaintengine.cpp18
2 files changed, 19 insertions, 9 deletions
diff --git a/liveview/liveview.cpp b/liveview/liveview.cpp
index c36f944..58bfb83 100644
--- a/liveview/liveview.cpp
+++ b/liveview/liveview.cpp
@@ -54,9 +54,9 @@ int LiveView::metric(PaintDeviceMetric metric) const
case PdmHeightMM:
return 24;
case PdmNumColors:
- return 65536;
+ return 256;
case PdmDepth:
- return 16;
+ return 8;
case PdmDpiX:
case PdmPhysicalDpiX:
return 136;
@@ -167,7 +167,8 @@ QImage* LiveView::image()
void LiveView::renderImage(int x, int y, const QImage &image)
{
- QByteArray data = encodeImage(image);
+ qDebug() << "Rendering image at" << x << 'x' << y << "of size" << image.size();
+ QByteArray data = encodeImage(image.copy(0,0,64,64));
if (!data.isEmpty()) {
displayBitmap(x, y, data);
}
@@ -226,7 +227,7 @@ QByteArray LiveView::encodeImage(const QImage& image) const
{
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
- if (image.save(&buffer, "PNG")) {
+ if (image.save(&buffer, "PNG", 0)) {
return buffer.buffer();
} else {
qWarning() << "Failed to encode image";
@@ -286,6 +287,7 @@ void LiveView::displayBitmap(unsigned char x, unsigned char y, const QByteArray
data[1] = y;
data[2] = 1; // TODO Figure out what this is. Maybe format?
data.append(image);
+ qDebug() << "Trying to send" << image.size() << "bytes";
send(Message(DisplayBitmap, data));
}
diff --git a/liveview/liveviewpaintengine.cpp b/liveview/liveviewpaintengine.cpp
index 9f7ffec..2370477 100644
--- a/liveview/liveviewpaintengine.cpp
+++ b/liveview/liveviewpaintengine.cpp
@@ -21,9 +21,17 @@ bool LiveViewPaintEngine::end()
bool ret = WatchPaintEngine::end();
if (ret) {
QRect rect = _damaged.boundingRect();
- if (!rect.isEmpty()) {
- QImage sub_image = _watch->image()->copy(rect);
- _watch->renderImage(rect.x(), rect.y(), sub_image);
+
+ const int tile_size = 64;
+ // Have to make tiles
+ for (int x = rect.left(); x < rect.right(); x += tile_size) {
+ for (int y = rect.top(); y < rect.bottom(); y += tile_size) {
+ QRect tile(x, y,
+ qMin(x + tile_size, rect.right()),
+ qMin(y + tile_size, rect.bottom()));
+ QImage sub_image = _watch->image()->copy(tile);
+ _watch->renderImage(tile.x(), tile.y(), sub_image);
+ }
}
}
return ret;
@@ -35,7 +43,7 @@ void LiveViewPaintEngine::drawRects(const QRectF *rects, int rectCount)
for (i = 0; i < rectCount; i++) {
const QRectF& r = rects[i];
if (_hasBrush && fillsEntireImage(r.toRect()) && _isBrushBlack) {
- //_watch->clear();
+ _watch->clear();
_damaged = QRegion();
continue;
}
@@ -58,7 +66,7 @@ void LiveViewPaintEngine::drawRects(const QRect *rects, int rectCount)
for (i = 0; i < rectCount; i++) {
const QRect& r = rects[i];
if (_hasBrush && fillsEntireImage(r) && _isBrushBlack) {
- //_watch->clear();
+ _watch->clear();
_damaged = QRegion();
continue;
}