示例#1
0
int main(int argc, char** argv)
{
	Image screen_image;

	ScreenImage Screen;
	Screen.Init();

	ScreenArea ScreenArea;
	char esc;


	int* cood=ScreenArea.TakeArea();

	Rect Corte(cood[0],cood[1],cood[2],cood[3]);
  	while(esc!='s')
  	{		
  		
  		//pega imagem da tela
  		screen_image.SetData(Screen.ScreenShot(),"Tela",WINDOW_NORMAL);

  		//screen_image.ScaleImg(1.0f);
  		Mat result=screen_image.img(Corte);
    	imshow("Result",result);
    	namedWindow("Result",WINDOW_NORMAL); 
    	esc=screen_image.Show();


    	//O buffer do screen_image precisa ser limpo após tratamento com a imagem
    	Screen.Flush();    	
 	}
  return 0;
}
void ZonePlacementPage::distributeAreas(AreaDistributor *distributor) {

    cleanupGrabAreas();
    for(size_t i = 0; i < distributor->areaCount(); i++) {
        ScreenArea *sf = distributor->next();
        qDebug() << sf->hScanStart() << sf->vScanStart();

        QRect s = QApplication::desktop()->screenGeometry(_screenId);
        QRect r(s.left() + sf->hScanStart() * (float)s.width(),
                s.top()  + sf->vScanStart() * (float)s.height(),
                (sf->hScanEnd() - sf->hScanStart()) * (float)s.width(),
                (sf->vScanEnd() - sf->vScanStart()) * (float)s.height());
        addGrabArea(i, r);

        delete sf;
    }
    resetNewAreaRect();
}
void ZonePlacementPage::distributeAreas(AreaDistributor *distributor, bool invertIds, int idOffset) {

    cleanupGrabAreas();
    for(int i = 0; i < distributor->areaCount(); i++) {
        ScreenArea *sf = distributor->next();
        qDebug() << sf->hScanStart() << sf->vScanStart();

        QRect s = QApplication::desktop()->screenGeometry(_screenId);
        QRect r(sf->hScanStart(),
                sf->vScanStart(),
                (sf->hScanEnd() - sf->hScanStart()),
                (sf->vScanEnd() - sf->vScanStart()));
		int id = ((invertIds ? distributor->areaCount() - (i + 1) : i) + idOffset) % distributor->areaCount();
		id = (id + distributor->areaCount()) % distributor->areaCount();
		addGrabArea(id, r);

        delete sf;
    }
    resetNewAreaRect();
}
ScreenArea * AndromedaDistributor::next() {
    const double thikness = 0.15;
    double x, y;

    if (_dx == 0 && _dy == 0) {
        _dx = 1;
        _width = 1.0 / areaCountOnTopEdge();
        _height = thikness;
        x = 1.0 - areaCountOnBottomEdge() * _width / 2;
        y = 1.0 - _height;
    } else if (_dx > 0 && cmp(_currentArea->hScanEnd(), 1.0, 0.01) >= 0 ) {
        cleanCurrentArea();
        _dx = 0;
        _dy = -1;
        _width = thikness;
        _height = 1.0f / areaCountOnSideEdge();
        x = 1.0f - _width;
        y = 1.0f - _height;
    } else if (_dy < 0 && cmp(_currentArea->vScanStart(), 0.0, .01) <= 0) {
        cleanCurrentArea();
        _dx = -1;
        _dy = 0;
        _width = 1.0 / areaCountOnTopEdge();
        _height = thikness;
        x = 1.0 - _width;
        y = 0.0;
    } else if (_dx < 0 && cmp(_currentArea->hScanStart(), 0.0, .01) <= 0) {
        cleanCurrentArea();
        _dx = 0;
        _dy = 1;
        _width = thikness;
        _height = 1.0 / areaCountOnSideEdge();
        x = 0.0;
        y = 0.0;
    } else if (_dy > 0 && cmp(_currentArea->vScanEnd(), 1.0, .01) >= 0) {
        cleanCurrentArea();
        _dx = 1;
        _dy = 0;
        _width = 1.0 / areaCountOnTopEdge();
        _height = thikness;
        x = 0.0;
        y = 1.0 - _height;
    }

    ScreenArea *result = NULL;
    if (!_currentArea) {
        result = new ScreenArea( x, x + _width, y, y + _height);
    } else {
        ScreenArea *cf = _currentArea;
        double dx = _width * (double)_dx;
        double dy = _height * (double)_dy;

        result = new ScreenArea(within1(cf->hScanStart() + dx), within1(cf->hScanEnd() + dx),
                                    within1(cf->vScanStart() + dy), within1(cf->vScanEnd() + dy));
        cleanCurrentArea();
    }

    _currentArea = result;
    return new ScreenArea(*_currentArea);

}