• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

krfb

  • sources
  • kde-4.14
  • kdenetwork
  • krfb
  • framebuffers
  • qt
qtframebuffer.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 */
9 
10 #include "qtframebuffer.h"
11 #include "qtframebuffer.moc"
12 
13 #include <QTimer>
14 #include <QRegion>
15 #include <QPixmap>
16 #include <QBitmap>
17 
18 
19 const int UPDATE_TIME = 500;
20 
21 QtFrameBuffer::QtFrameBuffer(WId id, QObject *parent)
22  : FrameBuffer(id, parent)
23 {
24  fbImage = QPixmap::grabWindow(win).toImage();
25  fb = new char[fbImage.numBytes()];
26  t = new QTimer(this);
27  connect(t, SIGNAL(timeout()), SLOT(updateFrameBuffer()));
28 }
29 
30 
31 QtFrameBuffer::~QtFrameBuffer()
32 {
33  delete [] fb;
34  fb = 0;
35 }
36 
37 int QtFrameBuffer::depth()
38 {
39  return fbImage.depth();
40 }
41 
42 int QtFrameBuffer::height()
43 {
44  return fbImage.height();
45 }
46 
47 int QtFrameBuffer::width()
48 {
49  return fbImage.width();
50 }
51 
52 void QtFrameBuffer::getServerFormat(rfbPixelFormat &format)
53 {
54  format.bitsPerPixel = 32;
55  format.depth = 32;
56  format.trueColour = true;
57 
58  format.bigEndian = false;
59  format.redShift = 16;
60  format.greenShift = 8;
61  format.blueShift = 0;
62  format.redMax = 0xff;
63  format.greenMax = 0xff;
64  format.blueMax = 0xff;
65 }
66 
67 void QtFrameBuffer::updateFrameBuffer()
68 {
69  QImage img = QPixmap::grabWindow(win).toImage();
70  QSize imgSize = img.size();
71 
72 
73  // verify what part of the image need to be marked as changed
74  // fbImage is the previous version of the image,
75  // img is the current one
76 
77 #if 0 // This is actually slower than updating the whole desktop...
78 
79  QImage map(imgSize, QImage::Format_Mono);
80  map.fill(0);
81 
82  for (int x = 0; x < imgSize.width(); x++) {
83  for (int y = 0; y < imgSize.height(); y++) {
84  if (img.pixel(x, y) != fbImage.pixel(x, y)) {
85  map.setPixel(x, y, 1);
86  }
87  }
88  }
89 
90  QRegion r(QBitmap::fromImage(map));
91  tiles = tiles + r.rects();
92 
93 #else
94  tiles.append(img.rect());
95 #endif
96 
97  memcpy(fb, (const char *)img.bits(), img.numBytes());
98  fbImage = img;
99 
100 }
101 
102 int QtFrameBuffer::paddedWidth()
103 {
104  return fbImage.width() * 4;
105 }
106 
107 void QtFrameBuffer::startMonitor()
108 {
109  t->start(UPDATE_TIME);
110 }
111 
112 void QtFrameBuffer::stopMonitor()
113 {
114  t->stop();
115 }
116 
QtFrameBuffer::paddedWidth
virtual int paddedWidth()
Definition: qtframebuffer.cpp:102
qtframebuffer.h
QtFrameBuffer::QtFrameBuffer
QtFrameBuffer(WId id, QObject *parent=0)
Definition: qtframebuffer.cpp:21
QSize::width
int width() const
FrameBuffer
Definition: framebuffer.h:27
QtFrameBuffer::height
virtual int height()
Definition: qtframebuffer.cpp:42
QtFrameBuffer::depth
virtual int depth()
Definition: qtframebuffer.cpp:37
UPDATE_TIME
const int UPDATE_TIME
Definition: qtframebuffer.cpp:19
QBitmap::fromImage
QBitmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
QImage::depth
int depth() const
QImage::setPixel
void setPixel(int x, int y, uint index_or_rgb)
QtFrameBuffer::~QtFrameBuffer
~QtFrameBuffer()
Definition: qtframebuffer.cpp:31
QPixmap::grabWindow
QPixmap grabWindow(WId window, int x, int y, int width, int height)
rfbPixelFormat
Definition: rfbproto.h:148
QImage::pixel
QRgb pixel(int x, int y) const
rfbPixelFormat::blueMax
uint16_t blueMax
Definition: rfbproto.h:173
QList::append
void append(const T &value)
rfbPixelFormat::redMax
uint16_t redMax
Definition: rfbproto.h:167
rfbPixelFormat::greenMax
uint16_t greenMax
Definition: rfbproto.h:171
QTimer
QtFrameBuffer::stopMonitor
virtual void stopMonitor()
Definition: qtframebuffer.cpp:112
QImage::fill
void fill(uint pixelValue)
QObject
QImage::width
int width() const
rfbPixelFormat::trueColour
uint8_t trueColour
Definition: rfbproto.h:160
QImage::rect
QRect rect() const
FrameBuffer::tiles
QList< QRect > tiles
Definition: framebuffer.h:50
QSize
QTimer::stop
void stop()
QImage::numBytes
int numBytes() const
QImage
rfbPixelFormat::bigEndian
uint8_t bigEndian
Definition: rfbproto.h:154
QtFrameBuffer::updateFrameBuffer
void updateFrameBuffer()
Definition: qtframebuffer.cpp:67
QtFrameBuffer::startMonitor
virtual void startMonitor()
Definition: qtframebuffer.cpp:107
rfbPixelFormat::bitsPerPixel
uint8_t bitsPerPixel
Definition: rfbproto.h:150
FrameBuffer::win
WId win
Definition: framebuffer.h:48
rfbPixelFormat::blueShift
uint8_t blueShift
Definition: rfbproto.h:189
QRegion::rects
QVector< QRect > rects() const
QSize::height
int height() const
QImage::size
QSize size() const
QImage::bits
uchar * bits()
QTimer::start
void start(int msec)
FrameBuffer::fb
char * fb
Definition: framebuffer.h:49
QImage::height
int height() const
rfbPixelFormat::depth
uint8_t depth
Definition: rfbproto.h:152
QPixmap::toImage
QImage toImage() const
QtFrameBuffer::getServerFormat
virtual void getServerFormat(rfbPixelFormat &format)
Definition: qtframebuffer.cpp:52
rfbPixelFormat::redShift
uint8_t redShift
Definition: rfbproto.h:175
rfbPixelFormat::greenShift
uint8_t greenShift
Definition: rfbproto.h:187
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QtFrameBuffer::width
virtual int width()
Definition: qtframebuffer.cpp:47
QRegion
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krfb

Skip menu "krfb"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal