hakermania
18th April 2011, 15:21
I use this code in order to capture the color of a pixel, compare it with a HTML value and do an action if the comparisono is successful
while(1){
sleep(3000);
QPixmap *a = new QPixmap;
*a = QPixmap::grabWindow(QApplication::desktop()->winId());
QImage *img = new QImage;
*img = a->toImage();
QRgb b = img->pixel(796,554);
QColor *c = new QColor;
c->setRgb(b);
qDebug() << c->name();
delete a;
delete c;
if(c->name() == "#968d82"){
system("canberra-gtk-play -f ~/Documents/Alert.wav");
}
Every time it goes through the loop the program takes almost 4MB of memory usage :rolleyes::confused::rolleyes:
It's probaly because it grubs the whole desktop picture every time it runs...
I tried to free some by deleting 'a' and 'c' but it didn't work. Any suggestion?
while(1){
sleep(3000);
QPixmap *a = new QPixmap;
*a = QPixmap::grabWindow(QApplication::desktop()->winId());
QImage *img = new QImage;
*img = a->toImage();
QRgb b = img->pixel(796,554);
QColor *c = new QColor;
c->setRgb(b);
qDebug() << c->name();
delete a;
delete c;
if(c->name() == "#968d82"){
system("canberra-gtk-play -f ~/Documents/Alert.wav");
}
Every time it goes through the loop the program takes almost 4MB of memory usage :rolleyes::confused::rolleyes:
It's probaly because it grubs the whole desktop picture every time it runs...
I tried to free some by deleting 'a' and 'c' but it didn't work. Any suggestion?