cvNamedWindow(wndname, 1 );
cvZero( image );
cvShowImage(wndname,image);
+ cvWaitKey(DELAY);
rng = cvRNG((unsigned)-1);
pt[0] = &(ptt[0]);
cvLine( image, pt1, pt2, random_color(&rng), cvRandInt(&rng)%10, line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 0; i< NUMBER; i++)
cvRectangle( image,pt1, pt2, random_color(&rng), cvRandInt(&rng)%10-1, line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 0; i< NUMBER; i++)
cvEllipse( image, pt1, sz, angle, angle - 100, angle + 200,
random_color(&rng), cvRandInt(&rng)%10-1, line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 0; i< NUMBER; i++)
cvPolyLine( image, pt, arr, 2, 1, random_color(&rng), cvRandInt(&rng)%10, line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 0; i< NUMBER; i++)
cvFillPoly( image, pt, arr, 2, random_color(&rng), line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 0; i< NUMBER; i++)
cvCircle( image, pt1, cvRandInt(&rng)%300, random_color(&rng),
cvRandInt(&rng)%10-1, line_type, 0 );
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
for (i = 1; i< NUMBER; i++)
cvPutText( image, "Testing text rendering!", pt1, &font, random_color(&rng));
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
cvInitFont( &font, CV_FONT_HERSHEY_COMPLEX, 3, 3, 0.0, 5, line_type );
cvSubS( image2, cvScalarAll(i), image, 0 );
cvPutText( image, "OpenCV forever!", pt1, &font, CV_RGB(255,i,i));
cvShowImage(wndname,image);
- cvWaitKey(DELAY);
+ if(cvWaitKey(DELAY) >= 0) return 0;
}
// Wait for a key stroke; the same function arranges events processing
static void icvUpdateWindowSize( const CvWindow* window )
{
- int width = 0, height = 240; /* init \88 al taille de base de l'image*/
+ int width = 0, height = 240; /* init à al taille de base de l'image*/
Rect globalBounds;
GetWindowBounds(window->window, kWindowContentRgn, &globalBounds);
ly = ly * window->imageHeight / (content.bottom - content.top - window->trackbarheight);
}
- if (lx>0 && ly >0){ /* a remettre dans les coordonn\8ees locale */
+ if (lx>0 && ly >0){ /* a remettre dans les coordonnées locale */
window->on_mouse (event, lx, ly, flags, window->on_mouse_param);
return noErr;
}
// wait at least for one event (to allow mouse, etc. processing), exit if maxWait milliseconds passed (nullEvent)
UInt32 start = TickCount();
+ int iters=0;
do
{
// remaining time until maxWait is over
UInt32 wait = EventTimeToTicks (maxWait / 1000.0) - (TickCount() - start);
- if (wait < 0)
- wait = 0;
-
+ if ((int)wait <= 0)
+ {
+ if( maxWait > 0 && iters > 0 )
+ break;
+ wait = 1;
+ }
+ iters++;
WaitNextEvent (everyEvent, &theEvent, maxWait > 0 ? wait : kDurationForever, NULL);
}
while (lastKey == NO_KEY && theEvent.what != nullEvent);