Images in loops


#1

Hello,

I am new with Juces and hope you can give me some guidance.

I have actually two problems.

  1. I would like to display images (more or less a video)
  2. How can I change images by time

To 1: What is the proper component to display an image? I found classes such as Images & Graphics to store and modify images but I am not able to put them on the Front Window (with exception as background).

To 2: I am using a webcam, which provides me a new image each time I call the aquire-function. Juce is “event driven”. How can I call the acquire function in a kind of loop without pressing a juce component?

Thanks,
sag


#2

Sounds like you need to get familiar with the Timer class.

And for displaying an image, any component will do - you can just draw it in your paint() routine. The juce demo is full of examples of images being drawn, have a look in there.


#3

Hello Jules,

thank you for your advise.

So, I can use the paint-method as a kind of main loop?

Regards,
sag


#4

I don’t really understand what you mean. There’s no such thing as a “main loop” in event-driven programming.


#5

Hello Jules,

thank you for your answer. I am used to program micrcontrollers. There you have both, a main function and events. So I thought also here it is possible to have both.

I checked out the Multitimer, which are really simple to use. But I have a Problem when I exit the program.

I used the Jucer to construct some buttons, etc. I added a class, lets call it MY_TIMER which is dervied from MultiTimer. The program runs well as long I do not use the timer. The timer also works properly, but if I exit the program after I called a method of a certain object of MY_TIMER I get a crash, exception or access violation.

Do I need to consider sth when I use timers?

Regards,
sag


#6

Sounds like you’re kind of new to high-level programming… No, there are no special considerations with timers, but if something crashes, you obviously need to use your debugger and find out why! I’d presume that when you say you’re “exiting”, then you’re probably calling a low-level function rather than letting the event loop terminate gracefully - see the JUCEApplication class for more info about how to quit properly.